Index: Eclipse UI/org/eclipse/ui/internal/actions/DynamicHelpAction.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/actions/DynamicHelpAction.java,v retrieving revision 1.1 diff -u -r1.1 DynamicHelpAction.java --- Eclipse UI/org/eclipse/ui/internal/actions/DynamicHelpAction.java 21 Mar 2005 18:37:22 -0000 1.1 +++ Eclipse UI/org/eclipse/ui/internal/actions/DynamicHelpAction.java 5 May 2005 19:36:08 -0000 @@ -10,7 +10,10 @@ *******************************************************************************/ package org.eclipse.ui.internal.actions; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.action.Action; +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.ui.IWorkbenchPreferenceConstants; import org.eclipse.ui.IWorkbenchWindow; @@ -26,66 +29,76 @@ * @since 3.1 */ public class DynamicHelpAction extends Action implements IWorkbenchAction { - /** - * The workbench window; or null if this - * action has been disposed. - */ - private IWorkbenchWindow workbenchWindow; - - /** - * Zero-arg constructor to allow cheat sheets to reuse this action. - */ - public DynamicHelpAction() { - this(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); - } - - /** - * Constructor for use by ActionFactory. - * - * @param window the window - */ - public DynamicHelpAction(IWorkbenchWindow window) { - if (window == null) { - throw new IllegalArgumentException(); - } - this.workbenchWindow = window; - setActionDefinitionId("org.eclipse.ui.help.dynamicHelp"); //$NON-NLS-1$ - - // support for allowing a product to override the text for the action - String overrideText = PrefUtil.getAPIPreferenceStore().getString( - IWorkbenchPreferenceConstants.DYNAMIC_HELP_ACTION_TEXT); - if ("".equals(overrideText)) { //$NON-NLS-1$ - setText(WorkbenchMessages.DynamicHelpAction_text); - setToolTipText(WorkbenchMessages.DynamicHelpAction_toolTip); - } else { - setText(overrideText); - setToolTipText(Action.removeMnemonics(overrideText)); - } - window.getWorkbench().getHelpSystem().setHelp(this, + /** + * The workbench window; or null if this action has been + * disposed. + */ + private IWorkbenchWindow workbenchWindow; + + /** + * Zero-arg constructor to allow cheat sheets to reuse this action. + */ + public DynamicHelpAction() { + this(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); + } + + /** + * Constructor for use by ActionFactory. + * + * @param window + * the window + */ + public DynamicHelpAction(IWorkbenchWindow window) { + if (window == null) { + throw new IllegalArgumentException(); + } + this.workbenchWindow = window; + setActionDefinitionId("org.eclipse.ui.help.dynamicHelp"); //$NON-NLS-1$ + + // support for allowing a product to override the text for the action + String overrideText = PrefUtil.getAPIPreferenceStore().getString( + IWorkbenchPreferenceConstants.DYNAMIC_HELP_ACTION_TEXT); + if ("".equals(overrideText)) { //$NON-NLS-1$ + setText(appendAccelerator(WorkbenchMessages.DynamicHelpAction_text)); + setToolTipText(WorkbenchMessages.DynamicHelpAction_toolTip); + } else { + setText(appendAccelerator(overrideText)); + setToolTipText(Action.removeMnemonics(overrideText)); + } + window.getWorkbench().getHelpSystem().setHelp(this, IWorkbenchHelpContextIds.DYNAMIC_HELP_ACTION); - } + } - /* (non-Javadoc) - * Method declared on IAction. - */ - public void run() { - if (workbenchWindow == null) { - // action has been disposed - return; - } - //This may take a while, so use the busy indicator - BusyIndicator.showWhile(null, new Runnable() { - public void run() { - workbenchWindow.getWorkbench().getHelpSystem().displayDynamicHelp(); - } - }); - } - - /* (non-Javadoc) - * Method declared on ActionFactory.IWorkbenchAction. - */ - public void dispose() { - workbenchWindow = null; - } + private String appendAccelerator(String text) { + // We know that on Windows context help key is F1 + // and cannot be changed by the user. + if (Platform.getWS().equals(Platform.WS_WIN32)) + return text + "\t" + KeyStroke.getInstance(SWT.F1).format(); //$NON-NLS-1$ + return text; + } + + /* + * (non-Javadoc) Method declared on IAction. + */ + public void run() { + if (workbenchWindow == null) { + // action has been disposed + return; + } + // This may take a while, so use the busy indicator + BusyIndicator.showWhile(null, new Runnable() { + public void run() { + workbenchWindow.getWorkbench().getHelpSystem() + .displayDynamicHelp(); + } + }); + } + + /* + * (non-Javadoc) Method declared on ActionFactory.IWorkbenchAction. + */ + public void dispose() { + workbenchWindow = null; + } }