KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > search > UnusedDependenciesAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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")); //$NON-NLS-1$
26
}
27
28     public void run() {
29         UnusedDependenciesOperation op = new UnusedDependenciesOperation(model);
30         try {
31             PlatformUI.getWorkbench().getProgressService().busyCursorWhile(op);
32         } catch (Exception JavaDoc e) {
33         }
34
35         IPluginImport[] unused = op.getUnusedDependencies();
36         if (unused.length == 0)
37             MessageDialog.openInformation(
38                 PDEPlugin.getActiveWorkbenchShell(),
39                 PDEPlugin.getResourceString("UnusedDependencies.title"), //$NON-NLS-1$
40
PDEPlugin.getResourceString("UnusedDependencies.notFound")); //$NON-NLS-1$
41
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")); //$NON-NLS-1$
50
dialog.open();
51         } else {
52             String JavaDoc lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
53
StringBuffer JavaDoc buffer =
54                 new StringBuffer JavaDoc(PDEPlugin.getResourceString("UnusedDependencies.found")); //$NON-NLS-1$
55
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"), //$NON-NLS-1$
61
buffer.toString());
62         }
63     }
64
65 }
66
Popular Tags