1 11 package org.eclipse.search.internal.ui; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.jface.action.IAction; 15 import org.eclipse.jface.viewers.ISelection; 16 17 import org.eclipse.ui.IWorkbenchWindow; 18 import org.eclipse.ui.IWorkbenchWindowActionDelegate; 19 20 23 public class OpenSearchDialogAction extends Action implements IWorkbenchWindowActionDelegate { 24 25 private IWorkbenchWindow fWindow; 26 private String fPageId; 27 28 public OpenSearchDialogAction() { 29 super(SearchMessages.OpenSearchDialogAction_label); 30 SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_TOOL, SearchPluginImages.IMG_TOOL_SEARCH); 31 setToolTipText(SearchMessages.OpenSearchDialogAction_tooltip); 32 } 33 34 public OpenSearchDialogAction(IWorkbenchWindow window, String pageId) { 35 this(); 36 fPageId= pageId; 37 fWindow= window; 38 } 39 40 public void init(IWorkbenchWindow window) { 41 fWindow= window; 42 } 43 44 public void run(IAction action) { 45 run(); 46 } 47 48 public void run() { 49 if (getWorkbenchWindow().getActivePage() == null) { 50 SearchPlugin.beep(); 51 return; 52 } 53 SearchDialog dialog= new SearchDialog(getWorkbenchWindow(), fPageId); 54 dialog.open(); 55 } 56 57 public void selectionChanged(IAction action, ISelection selection) { 58 } 60 61 private IWorkbenchWindow getWorkbenchWindow() { 62 if (fWindow == null) 63 fWindow= SearchPlugin.getActiveWorkbenchWindow(); 64 return fWindow; 65 } 66 67 public void dispose() { 68 fWindow= null; 69 } 70 } 71 | Popular Tags |