public static void addKeyText(final MenuItem mntm, final String text, final Task t) { mntm.setText(text + "\t" + taskKeyMap.get(t)); //$NON-NLS-1$ mntm.addArmListener(new ArmListener() { @Override public void widgetArmed(ArmEvent e) { mntm.setText(text + "\t" + taskKeyMap.get(t)); //$NON-NLS-1$ } }); }
public static void addKeyText(final MenuItem mntm, final String text, final TextTask t) { mntm.setText(text + "\t" + textTaskKeyMap.get(t)); //$NON-NLS-1$ mntm.addArmListener(new ArmListener() { @Override public void widgetArmed(ArmEvent e) { mntm.setText(text + "\t" + textTaskKeyMap.get(t)); //$NON-NLS-1$ } }); }
private void installTooltip(final MenuItem menuItem, final IToolTipTextProvider toolTipTextProvider) { final ArmListener armListener = new ArmListener() { @Override public void widgetArmed(final ArmEvent e) { final boolean wasVisible = toolTip.isVisible(); toolTip.setVisible(false); final String toolTipText = toolTipTextProvider.getToolTipText(); final boolean hasToolTip = toolTipText != null && !toolTipText.isEmpty(); if (wasVisible) { if (hasToolTip) { showToolTip(toolTipText); } } else if (hasToolTip) { lastArmListener = this; final ArmListener thisListener = this; Display.getCurrent().timerExec(400, new Runnable() { @Override public void run() { if (lastArmListener == thisListener) { showToolTip(toolTipText); } } }); } } }; if (toolTip != null) { menuItem.addArmListener(armListener); } }
/** * Adds the listener to the collection of listeners who will be notified * when the arm events are generated for the control, by sending it one of * the messages defined in the <code>ArmListener</code> interface. * * @param listener * the listener which should be notified * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see ArmListener * @see #removeArmListener */ public void addArmListener(ArmListener listener) { checkWidget(); if (listener == null) error(SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener(listener); addListener(SWT.Arm, typedListener); }
/** * Removes the listener from the collection of listeners who will be * notified when the arm events are generated for the control. * * @param listener * the listener which should no longer be notified * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see ArmListener * @see #addArmListener */ public void removeArmListener(ArmListener listener) { checkWidget(); if (listener == null) error(SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook(SWT.Arm, listener); }