1 11 package org.eclipse.team.internal.ui.actions; 12 13 import java.lang.reflect.InvocationTargetException ; 14 import java.util.Iterator ; 15 16 import org.eclipse.core.resources.IFile; 17 import org.eclipse.core.runtime.IProgressMonitor; 18 import org.eclipse.core.runtime.IStatus; 19 import org.eclipse.core.runtime.Status; 20 import org.eclipse.jface.action.IAction; 21 import org.eclipse.jface.dialogs.ErrorDialog; 22 import org.eclipse.jface.dialogs.ProgressMonitorDialog; 23 import org.eclipse.jface.operation.IRunnableWithProgress; 24 import org.eclipse.jface.viewers.ISelection; 25 import org.eclipse.jface.viewers.IStructuredSelection; 26 import org.eclipse.swt.widgets.Display; 27 import org.eclipse.swt.widgets.Shell; 28 import org.eclipse.team.internal.ui.*; 29 import org.eclipse.ui.IObjectActionDelegate; 30 import org.eclipse.ui.IWorkbenchPart; 31 import org.eclipse.ui.actions.ActionDelegate; 32 33 public class ImportProjectSetAction extends ActionDelegate implements IObjectActionDelegate { 34 35 private IStructuredSelection fSelection; 36 37 public void run(IAction action) { 38 final Shell shell= Display.getDefault().getActiveShell(); 39 try { 40 new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress() { 41 public void run(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 42 Iterator iterator= fSelection.iterator(); 43 while (iterator.hasNext()) { 44 IFile file= (IFile) iterator.next(); 45 ProjectSetImporter.importProjectSet(file.getLocation().toString(), shell, monitor); 46 } 47 } 48 }); 49 } catch (InvocationTargetException exception) { 50 ErrorDialog.openError(shell, null, null, new Status(IStatus.ERROR, TeamUIPlugin.PLUGIN_ID, IStatus.ERROR, TeamUIMessages.ImportProjectSetAction_0, exception.getTargetException())); 51 } catch (InterruptedException exception) { 52 } 53 } 54 55 public void selectionChanged(IAction action, ISelection sel) { 56 if (sel instanceof IStructuredSelection) { 57 fSelection= (IStructuredSelection) sel; 58 } 59 } 60 61 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 62 } 63 64 } 65 | Popular Tags |