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

/**
 * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Symbian Foundation - initial contribution.
 * Contributors:
 * Description:
 * Overview:
 * Details:
 * Platforms/Drives/Compatibility:
 * Assumptions/Requirement/Pre-requisites:
 * Failures and causes:
 */
package org.symbian.tools.tmw.internal.util;

import java.lang.reflect.InvocationTargetException;
import java.util.Collection;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;

public class DelegateRunnable implements IRunnableWithProgress {
    private final Collection<IRunnableWithProgress> runnables;

    public DelegateRunnable(Collection<IRunnableWithProgress> runnables) {
        this.runnables = runnables;
    }

    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
        monitor.beginTask("Preparing project", runnables.size() * 20);
        for (IRunnableWithProgress runnable : runnables) {
            runnable.run(new SubProgressMonitor(monitor, 20));
        }
        monitor.done();
    }

}