org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/internal/util/DelegateRunnable.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Tue, 17 Aug 2010 13:40:28 -0700
changeset 466 129c94e78375
permissions -rw-r--r--
Project creation from the templates was implemented
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
466
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
/**
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
 * All rights reserved.
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
 *
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
 * Initial Contributors:
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
 * Symbian Foundation - initial contribution.
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
 * Contributors:
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
 * Description:
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
 * Overview:
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
 * Details:
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
 * Platforms/Drives/Compatibility:
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
 * Assumptions/Requirement/Pre-requisites:
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    17
 * Failures and causes:
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    18
 */
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    19
package org.symbian.tools.tmw.internal.util;
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    20
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    21
import java.lang.reflect.InvocationTargetException;
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    22
import java.util.Collection;
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    23
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    24
import org.eclipse.core.runtime.IProgressMonitor;
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    25
import org.eclipse.core.runtime.SubProgressMonitor;
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    26
import org.eclipse.jface.operation.IRunnableWithProgress;
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    28
public class DelegateRunnable implements IRunnableWithProgress {
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    29
    private final Collection<IRunnableWithProgress> runnables;
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    30
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    31
    public DelegateRunnable(Collection<IRunnableWithProgress> runnables) {
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    32
        this.runnables = runnables;
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    33
    }
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    34
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    35
    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    36
        monitor.beginTask("Preparing project", runnables.size() * 20);
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
        for (IRunnableWithProgress runnable : runnables) {
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
            runnable.run(new SubProgressMonitor(monitor, 20));
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    39
        }
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    40
        monitor.done();
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
    }
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    42
129c94e78375 Project creation from the templates was implemented
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    43
}