List of usage examples for org.eclipse.jface.action IAction setHelpListener
void setHelpListener(HelpListener listener);
From source file:org.eclipse.ui.internal.help.WorkbenchHelpSystem.java
License:Open Source License
/** * Sets the given help contexts on the given action. * <p>// w ww .j a v a 2 s. c o m * Use this method when the list of help contexts is known in advance. Help * contexts can either supplied as a static list, or calculated with a * context computer (but not both). * </p> * * @param action * the action on which to register the computer * @param contexts * the contexts to use when F1 help is invoked; a mixed-type * array of context ids (type <code>String</code>) and/or help * contexts (type <code>IContext</code>) * @deprecated use setHelp with a single context id parameter */ public void setHelp(IAction action, final Object[] contexts) { for (int i = 0; i < contexts.length; i++) { Assert.isTrue(contexts[i] instanceof String || contexts[i] instanceof IContext); } action.setHelpListener(new HelpListener() { public void helpRequested(HelpEvent event) { if (contexts != null && contexts.length > 0 && getHelpUI() != null) { // determine the context IContext context = null; if (contexts[0] instanceof String) { context = HelpSystem.getContext((String) contexts[0]); } else if (contexts[0] instanceof IContext) { context = (IContext) contexts[0]; } if (context != null) { Point point = computePopUpLocation(event.widget.getDisplay()); displayContext(context, point.x, point.y); } } } }); }
From source file:org.eclipse.ui.internal.help.WorkbenchHelpSystem.java
License:Open Source License
/** * Sets the given help context computer on the given action. * <p>//from ww w. ja va 2 s .com * Use this method when the help contexts cannot be computed in advance. * Help contexts can either supplied as a static list, or calculated with a * context computer (but not both). * </p> * * @param action * the action on which to register the computer * @param computer * the computer to determine the help contexts for the control * when F1 help is invoked * @deprecated context computers are no longer supported, clients should * implement their own help listener */ public void setHelp(IAction action, final IContextComputer computer) { action.setHelpListener(new HelpListener() { public void helpRequested(HelpEvent event) { Object[] helpContexts = computer.computeContexts(event); if (helpContexts != null && helpContexts.length > 0 && getHelpUI() != null) { // determine the context IContext context = null; if (helpContexts[0] instanceof String) { context = HelpSystem.getContext((String) helpContexts[0]); } else if (helpContexts[0] instanceof IContext) { context = (IContext) helpContexts[0]; } if (context != null) { Point point = computePopUpLocation(event.widget.getDisplay()); displayContext(context, point.x, point.y); } } } }); }
From source file:org.eclipse.ui.internal.help.WorkbenchHelpSystem.java
License:Open Source License
public void setHelp(final IAction action, final String contextId) { if (WorkbenchPlugin.DEBUG) setHelpTrace(contextId);// w w w .j a v a 2s . c o m action.setHelpListener(new HelpListener() { public void helpRequested(HelpEvent event) { if (getHelpUI() != null) { IContext context = HelpSystem.getContext(contextId); if (context != null) { Point point = computePopUpLocation(event.widget.getDisplay()); String title = LegacyActionTools.removeMnemonics(action.getText()); displayContext(new ContextWithTitle(context, title), point.x, point.y); } } } }); }