public void helpRequested(HelpEvent e) { try { Object[] selected= null; if (fViewer != null) { ISelection selection= fViewer.getSelection(); if (selection instanceof IStructuredSelection) { selected= ((IStructuredSelection)selection).toArray(); } } else if (fEditor != null) { IJavaElement input= SelectionConverter.getInput(fEditor); if (input != null && ActionUtil.isOnBuildPath(input)) { selected= SelectionConverter.codeResolve(fEditor); } } JavadocHelpContext.displayHelp(fContextId, selected); } catch (CoreException x) { JavaPlugin.log(x); } }
/** * Adds a listener for help requests in this viewer. * Has no effect if an identical listener is already registered. * * @param listener a help listener */ public void addHelpListener(HelpListener listener) { helpListeners.add(listener); if (!helpHooked) { Control control = getControl(); if (control != null && !control.isDisposed()) { if (this.helpListener == null) { this.helpListener = new HelpListener() { public void helpRequested(HelpEvent event) { handleHelpRequest(event); } }; } control.addHelpListener(this.helpListener); helpHooked = true; } } }
/** * Constructs a RetargetAction with the given action id, text and style. * * @param actionID * the retargetable action id * @param text * the action's text, or <code>null</code> if there is no text * @param style * one of <code>AS_PUSH_BUTTON</code>, <code>AS_CHECK_BOX</code>, * <code>AS_DROP_DOWN_MENU</code>, <code>AS_RADIO_BUTTON</code>, * and <code>AS_UNSPECIFIED</code> * @since 3.0 */ public RetargetAction(String actionID, String text, int style) { super(text, style); setId(actionID); setEnabled(false); super.setHelpListener(new HelpListener() { public void helpRequested(HelpEvent e) { HelpListener listener = null; if (handler != null) { // if we have a handler, see if it has a help listener listener = handler.getHelpListener(); if (listener == null) { // use our own help listener listener = localHelpListener; } } if (listener != null) { // pass on the event listener.helpRequested(e); } } }); }
protected void configureShell(Shell newShell) { super.configureShell(newShell); // Register help listener on the shell newShell.addHelpListener(new HelpListener() { public void helpRequested(HelpEvent event) { // call perform help on the current page if (currentPage != null) { currentPage.performHelp(); } } }); }
/** * Open the selected uri if it is not null */ @Override public void helpRequested(HelpEvent e) { if (href != null) { URL url = PlatformUI.getWorkbench().getHelpSystem().resolve(href, false); try { PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(url.toURI().toASCIIString()); } catch (URISyntaxException e1) { e1.printStackTrace(); } } }
@Override public void helpRequested(HelpEvent paramHelpEvent) { new VersionDialog(this.shell).open(); }
/** * Notifies any help listeners that help has been requested. * Only listeners registered at the time this method is called are notified. * * @param event a help event * * @see HelpListener#helpRequested(org.eclipse.swt.events.HelpEvent) */ protected void fireHelpRequested(HelpEvent event) { Object[] listeners = helpListeners.getListeners(); for (int i = 0; i < listeners.length; ++i) { ((HelpListener) listeners[i]).helpRequested(event); } }
/** * Handles a help request from the underlying SWT control. * The default behavior is to fire a help request, * with the event's data modified to hold this viewer. * @param event the event * */ protected void handleHelpRequest(HelpEvent event) { Object oldData = event.data; event.data = this; fireHelpRequested(event); event.data = oldData; }