1 11 package org.eclipse.pde.internal.ui.search.dependencies; 12 13 import java.lang.reflect.InvocationTargetException ; 14 import java.util.Map ; 15 16 import org.eclipse.core.resources.IProject; 17 import org.eclipse.core.resources.WorkspaceJob; 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.IProgressMonitor; 20 import org.eclipse.core.runtime.IStatus; 21 import org.eclipse.core.runtime.Status; 22 import org.eclipse.core.runtime.jobs.Job; 23 import org.eclipse.jface.action.Action; 24 import org.eclipse.jface.dialogs.MessageDialog; 25 import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase; 26 import org.eclipse.pde.internal.ui.PDEPlugin; 27 import org.eclipse.pde.internal.ui.PDEPluginImages; 28 import org.eclipse.pde.internal.ui.PDEUIMessages; 29 import org.eclipse.swt.widgets.Display; 30 import org.eclipse.ui.progress.IProgressConstants; 31 32 public class AddNewDependenciesAction extends Action { 33 34 protected class AddDependenciesOperation extends AddNewDependenciesOperation { 35 public AddDependenciesOperation(IProject project, IBundlePluginModelBase base) { 36 super(project, base); 37 } 38 39 protected void handleNewDependencies(final Map additionalDeps, final boolean useRequireBundle, IProgressMonitor monitor) { 40 if (!additionalDeps.isEmpty()) 41 Display.getDefault().asyncExec(new Runnable () { 42 public void run() { 43 addDependencies(additionalDeps, useRequireBundle); 44 } 45 }); 46 monitor.done(); 47 } 48 } 49 50 private IProject fProject; 51 private IBundlePluginModelBase fBase; 52 53 public AddNewDependenciesAction(IProject project, IBundlePluginModelBase base) { 54 fProject = project; 55 fBase = base; 56 } 57 58 public void run() { 59 Job job = new WorkspaceJob(PDEUIMessages.DependencyManagementSection_jobName) { 60 61 public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { 62 try { 63 AddNewDependenciesOperation op = getOperation(); 64 op.run(monitor); 65 if (!op.foundNewDependencies()) 66 Display.getDefault().asyncExec(new Runnable () { 67 public void run() { 68 MessageDialog.openInformation(PDEPlugin.getActiveWorkbenchShell(), 69 PDEUIMessages.AddNewDependenciesAction_title, 70 PDEUIMessages.AddNewDependenciesAction_notFound); 71 } 72 }); 73 } catch (InvocationTargetException e) { 74 } catch (InterruptedException e) { 75 } finally { 76 monitor.done(); 77 } 78 return new Status(IStatus.OK, PDEPlugin.getPluginId(), IStatus.OK, "", null); } 80 }; 81 job.setUser(true); 82 job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_PSEARCH_OBJ.createImage()); 83 job.schedule(); 84 } 85 86 protected AddNewDependenciesOperation getOperation() { 87 return new AddDependenciesOperation(fProject, fBase); 88 } 89 90 } 91 | Popular Tags |