KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > search > dependencies > ShowResultsAction


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

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 JavaDoc[] fUnusedImports;
27     private boolean fReadOnly;
28
29     public ShowResultsAction(IPluginModelBase model, Object JavaDoc[] unused, boolean readOnly) {
30         fModel = model;
31         fUnusedImports = unused;
32         fReadOnly = readOnly;
33     }
34     
35     /* (non-Javadoc)
36      * @see org.eclipse.jface.action.Action#run()
37      */

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                 // Launched from Dependencies View, show information dialog
48
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     /**
61      * @return Dialog
62      */

63     private Dialog getUnusedDependeciesInfoDialog() {
64         ListDialog dialog = new ListDialog(PDEPlugin.getActiveWorkbenchShell());
65         dialog.setAddCancelButton(false);
66         dialog.setContentProvider(new IStructuredContentProvider() {
67             public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
68                 return fUnusedImports;
69             }
70
71             public void dispose() {
72             }
73
74             public void inputChanged(Viewer viewer, Object JavaDoc oldInput,
75                     Object JavaDoc 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