1 11 package org.eclipse.pde.internal.ui.search; 12 13 import org.eclipse.jface.action.*; 14 import org.eclipse.jface.dialogs.*; 15 import org.eclipse.pde.core.plugin.*; 16 import org.eclipse.pde.internal.ui.*; 17 import org.eclipse.ui.PlatformUI; 18 19 public class UnusedDependenciesAction extends Action { 20 21 private IPluginModelBase model; 22 23 public UnusedDependenciesAction(IPluginModelBase model) { 24 this.model = model; 25 setText(PDEPlugin.getResourceString("UnusedDependencies.action")); } 27 28 public void run() { 29 UnusedDependenciesOperation op = new UnusedDependenciesOperation(model); 30 try { 31 PlatformUI.getWorkbench().getProgressService().busyCursorWhile(op); 32 } catch (Exception e) { 33 } 34 35 IPluginImport[] unused = op.getUnusedDependencies(); 36 if (unused.length == 0) 37 MessageDialog.openInformation( 38 PDEPlugin.getActiveWorkbenchShell(), 39 PDEPlugin.getResourceString("UnusedDependencies.title"), PDEPlugin.getResourceString("UnusedDependencies.notFound")); else if (model.isEditable()) { 42 UnusedImportsDialog dialog = 43 new UnusedImportsDialog( 44 PDEPlugin.getActiveWorkbenchShell(), 45 model, 46 unused); 47 dialog.create(); 48 dialog.getShell().setText( 49 PDEPlugin.getResourceString("UnusedDependencies.title")); dialog.open(); 51 } else { 52 String lineSeparator = System.getProperty("line.separator"); StringBuffer buffer = 54 new StringBuffer (PDEPlugin.getResourceString("UnusedDependencies.found")); for (int i = 0; i < unused.length; i++) { 56 buffer.append(lineSeparator + unused[i].getId()); 57 } 58 MessageDialog.openInformation( 59 PDEPlugin.getActiveWorkbenchShell(), 60 PDEPlugin.getResourceString("UnusedDependencies.title"), buffer.toString()); 62 } 63 } 64 65 } 66 | Popular Tags |