1 11 package org.eclipse.pde.internal.ui.search.dependencies; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.jface.dialogs.Dialog; 15 import org.eclipse.jface.dialogs.MessageDialog; 16 import org.eclipse.jface.viewers.IStructuredContentProvider; 17 import org.eclipse.jface.viewers.Viewer; 18 import org.eclipse.pde.core.plugin.IPluginModelBase; 19 import org.eclipse.pde.internal.ui.PDEPlugin; 20 import org.eclipse.pde.internal.ui.PDEUIMessages; 21 import org.eclipse.ui.dialogs.ListDialog; 22 23 public class ShowResultsAction extends Action { 24 25 private IPluginModelBase fModel; 26 Object [] fUnusedImports; 27 private boolean fReadOnly; 28 29 public ShowResultsAction(IPluginModelBase model, Object [] unused, boolean readOnly) { 30 fModel = model; 31 fUnusedImports = unused; 32 fReadOnly = readOnly; 33 } 34 35 38 public void run() { 39 if (fUnusedImports.length == 0) { 40 MessageDialog.openInformation( 41 PDEPlugin.getActiveWorkbenchShell(), 42 PDEUIMessages.UnusedDependencies_title, 43 PDEUIMessages.UnusedDependencies_notFound); 44 } else { 45 Dialog dialog; 46 if (fReadOnly) { 47 dialog = getUnusedDependeciesInfoDialog(); 49 } else { 50 dialog = new UnusedImportsDialog(PDEPlugin 51 .getActiveWorkbenchShell(), fModel, fUnusedImports); 52 dialog.create(); 53 } 54 dialog.getShell().setText( 55 PDEUIMessages.UnusedDependencies_title); 56 dialog.open(); 57 } 58 } 59 60 63 private Dialog getUnusedDependeciesInfoDialog() { 64 ListDialog dialog = new ListDialog(PDEPlugin.getActiveWorkbenchShell()); 65 dialog.setAddCancelButton(false); 66 dialog.setContentProvider(new IStructuredContentProvider() { 67 public Object [] getElements(Object inputElement) { 68 return fUnusedImports; 69 } 70 71 public void dispose() { 72 } 73 74 public void inputChanged(Viewer viewer, Object oldInput, 75 Object newInput) { 76 } 77 }); 78 dialog.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); 79 dialog.setInput(this); 80 dialog.create(); 81 dialog.getTableViewer().setComparator(new UnusedImportsDialog.Comparator()); 82 return dialog; 83 } 84 } 85 86 87 | Popular Tags |