01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.ui.search;
11:
12: import org.eclipse.jdt.internal.ui.JavaPlugin;
13: import org.eclipse.jface.action.IAction;
14: import org.eclipse.jface.viewers.ISelection;
15: import org.eclipse.search.ui.NewSearchUI;
16: import org.eclipse.swt.widgets.Shell;
17: import org.eclipse.ui.IWorkbenchWindow;
18: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
19:
20: /**
21: * Opens the Search Dialog and brings the Java search page to front
22: */
23: public class OpenJavaSearchPageAction implements
24: IWorkbenchWindowActionDelegate {
25:
26: private static final String 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
41: .logErrorMessage("Could not open the search dialog - for some reason the window handle was null"); //$NON-NLS-1$
42: return;
43: }
44: NewSearchUI.openSearchDialog(fWindow, JAVA_SEARCH_PAGE_ID);
45: }
46:
47: public void selectionChanged(IAction action, ISelection selection) {
48: // do nothing since the action isn't selection dependent.
49: }
50:
51: public void dispose() {
52: fWindow = null;
53: }
54:
55: protected void beep() {
56: Shell shell = JavaPlugin.getActiveWorkbenchShell();
57: if (shell != null && shell.getDisplay() != null)
58: shell.getDisplay().beep();
59: }
60: }
|