KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search > internal > ui > OpenFileSearchPageAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.search.internal.ui;
12
13 import org.eclipse.core.runtime.IStatus;
14 import org.eclipse.core.runtime.Status;
15 import org.eclipse.jface.action.IAction;
16 import org.eclipse.jface.viewers.ISelection;
17 import org.eclipse.search.ui.NewSearchUI;
18 import org.eclipse.ui.IWorkbenchWindow;
19 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
20
21 /**
22  * Opens the Search Dialog.
23  */

24 public class OpenFileSearchPageAction implements IWorkbenchWindowActionDelegate {
25
26     private static final String JavaDoc TEXT_SEARCH_PAGE_ID= "org.eclipse.search.internal.ui.text.TextSearchPage"; //$NON-NLS-1$
27

28     private IWorkbenchWindow fWindow;
29
30     public OpenFileSearchPageAction() {
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             SearchPlugin.beep();
40             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, TEXT_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     public static void logErrorMessage(String JavaDoc message) {
55         IStatus status= new Status(IStatus.ERROR, NewSearchUI.PLUGIN_ID, IStatus.ERROR, message, null);
56         SearchPlugin.log(status);
57     }
58 }
59
Popular Tags