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