1 11 package org.eclipse.ui.internal.actions; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.swt.custom.BusyIndicator; 15 import org.eclipse.ui.IWorkbenchPreferenceConstants; 16 import org.eclipse.ui.IWorkbenchWindow; 17 import org.eclipse.ui.PlatformUI; 18 import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; 19 import org.eclipse.ui.internal.IWorkbenchGraphicConstants; 20 import org.eclipse.ui.internal.IWorkbenchHelpContextIds; 21 import org.eclipse.ui.internal.WorkbenchImages; 22 import org.eclipse.ui.internal.WorkbenchMessages; 23 import org.eclipse.ui.internal.util.PrefUtil; 24 25 30 public class HelpSearchAction extends Action implements IWorkbenchAction { 31 35 private IWorkbenchWindow workbenchWindow; 36 37 40 public HelpSearchAction() { 41 this(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); 42 } 43 44 49 public HelpSearchAction(IWorkbenchWindow window) { 50 if (window == null) { 51 throw new IllegalArgumentException (); 52 } 53 this.workbenchWindow = window; 54 setActionDefinitionId("org.eclipse.ui.help.helpSearch"); 56 String overrideText = PrefUtil.getAPIPreferenceStore().getString( 58 IWorkbenchPreferenceConstants.HELP_SEARCH_ACTION_TEXT); 59 if ("".equals(overrideText)) { setText(WorkbenchMessages.HelpSearchAction_text); 61 setToolTipText(WorkbenchMessages.HelpSearchAction_toolTip); 62 } else { 63 setText(overrideText); 64 setToolTipText(Action.removeMnemonics(overrideText)); 65 } 66 setImageDescriptor(WorkbenchImages 67 .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_HELP_SEARCH)); 68 window.getWorkbench().getHelpSystem().setHelp(this, 69 IWorkbenchHelpContextIds.HELP_SEARCH_ACTION); 70 } 71 72 75 public void run() { 76 if (workbenchWindow == null) { 77 return; 79 } 80 BusyIndicator.showWhile(null, new Runnable () { 82 public void run() { 83 workbenchWindow.getWorkbench().getHelpSystem().displaySearch(); 84 } 85 }); 86 } 87 88 91 public void dispose() { 92 workbenchWindow = null; 93 } 94 95 } 96 | Popular Tags |