KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2006 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;
12
13 import org.eclipse.jface.action.IAction;
14 import org.eclipse.jface.viewers.ISelection;
15 import org.eclipse.pde.internal.ui.PDEPlugin;
16 import org.eclipse.search.ui.NewSearchUI;
17 import org.eclipse.swt.widgets.Shell;
18 import org.eclipse.ui.IWorkbenchWindow;
19 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
20
21 public class OpenPluginSearchPageAction implements
22         IWorkbenchWindowActionDelegate {
23     
24     private static final String JavaDoc PLUGIN_SEARCH_PAGE_ID = "org.eclipse.pde.internal.ui.search.SearchPage"; //$NON-NLS-1$
25
private IWorkbenchWindow fWindow;
26
27     public void dispose() {
28         fWindow = null;
29     }
30
31     public void init(IWorkbenchWindow window) {
32         fWindow = window;
33     }
34
35     public void run(IAction action) {
36         if (fWindow == null || fWindow.getActivePage() == null) {
37             beep();
38             return;
39         }
40         NewSearchUI.openSearchDialog(fWindow, PLUGIN_SEARCH_PAGE_ID);
41     }
42
43     public void selectionChanged(IAction action, ISelection selection) {
44         // do nothing since the action isn't selection dependent.
45
}
46     
47     protected void beep() {
48         Shell shell= PDEPlugin.getActiveWorkbenchShell();
49         if (shell != null && shell.getDisplay() != null)
50             shell.getDisplay().beep();
51     }
52
53 }
54
Popular Tags