KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > search > OpenJavaSearchPageAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdt.internal.ui.search;
12
13 import org.eclipse.jdt.internal.ui.JavaPlugin;
14 import org.eclipse.jface.action.IAction;
15 import org.eclipse.jface.viewers.ISelection;
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 /**
22  * Opens the Search Dialog and brings the Java search page to front
23  */

24 public class OpenJavaSearchPageAction implements IWorkbenchWindowActionDelegate {
25
26     private static final String JavaDoc JAVA_SEARCH_PAGE_ID= "org.eclipse.jdt.ui.JavaSearchPage"; //$NON-NLS-1$
27

28     private IWorkbenchWindow fWindow;
29
30     public OpenJavaSearchPageAction() {
31     }
32
33     public void init(IWorkbenchWindow window) {
34         fWindow= window;
35     }
36
37     public void run(IAction action) {
38         if (fWindow == null || fWindow.getActivePage() == null) {
39             beep();
40             JavaPlugin.logErrorMessage("Could not open the search dialog - for some reason the window handle was null"); //$NON-NLS-1$
41
return;
42         }
43         NewSearchUI.openSearchDialog(fWindow, JAVA_SEARCH_PAGE_ID);
44     }
45
46     public void selectionChanged(IAction action, ISelection selection) {
47         // do nothing since the action isn't selection dependent.
48
}
49
50     public void dispose() {
51         fWindow= null;
52     }
53
54     protected void beep() {
55         Shell shell= JavaPlugin.getActiveWorkbenchShell();
56         if (shell != null && shell.getDisplay() != null)
57             shell.getDisplay().beep();
58     }
59 }
60
Popular Tags