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 HelpContentsAction extends Action implements IWorkbenchAction { 31 35 private IWorkbenchWindow workbenchWindow; 36 37 40 public HelpContentsAction() { 41 this(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); 42 } 43 44 49 public HelpContentsAction(IWorkbenchWindow window) { 50 if (window == null) { 51 throw new IllegalArgumentException (); 52 } 53 this.workbenchWindow = window; 54 setActionDefinitionId("org.eclipse.ui.help.helpContents"); 56 String overrideText = PrefUtil.getAPIPreferenceStore().getString( 58 IWorkbenchPreferenceConstants.HELP_CONTENTS_ACTION_TEXT); 59 if ("".equals(overrideText)) { setText(WorkbenchMessages.HelpContentsAction_text); 61 setToolTipText(WorkbenchMessages.HelpContentsAction_toolTip); 62 } else { 63 setText(overrideText); 64 setToolTipText(Action.removeMnemonics(overrideText)); 65 } 66 setImageDescriptor(WorkbenchImages 67 .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_HELP_CONTENTS)); 68 window.getWorkbench().getHelpSystem().setHelp(this, 69 IWorkbenchHelpContextIds.HELP_CONTENTS_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().displayHelp(); 84 } 85 }); 86 } 87 88 91 public void dispose() { 92 workbenchWindow = null; 93 } 94 95 } 96 | Popular Tags |