📄 action.java
字号:
return getToolTipText(); } /* * (non-Javadoc) Method declared on IAction. */ public ImageDescriptor getDisabledImageDescriptor() { return disabledImage; } /* * (non-Javadoc) Method declared on IAction. */ public HelpListener getHelpListener() { return helpListener; } /* * (non-Javadoc) Method declared on IAction. */ public ImageDescriptor getHoverImageDescriptor() { return hoverImage; } /* * (non-Javadoc) Method declared on IAction. */ public String getId() { return id; } /* * (non-Javadoc) Method declared on IAction. */ public ImageDescriptor getImageDescriptor() { return image; } /* * (non-Javadoc) Method declared on IAction. */ public IMenuCreator getMenuCreator() { // The default drop down menu value is only used // to mark this action requested style. So do not // return it. For backward compatibility reasons. if (value == VAL_DROP_DOWN_MENU) { return null; } if (value instanceof IMenuCreator) { return (IMenuCreator) value; } return null; } /* * (non-Javadoc) Method declared on IAction. */ public int getStyle() { // Infer the style from the value field. if (value == VAL_PUSH_BTN || value == null) { return AS_PUSH_BUTTON; } if (value == VAL_TOGGLE_BTN_ON || value == VAL_TOGGLE_BTN_OFF) { return AS_CHECK_BOX; } if (value == VAL_RADIO_BTN_ON || value == VAL_RADIO_BTN_OFF) { return AS_RADIO_BUTTON; } if (value instanceof IMenuCreator) { return AS_DROP_DOWN_MENU; } // We should never get to this line... return AS_PUSH_BUTTON; } /* * (non-Javadoc) Method declared on IAction. */ public String getText() { return text; } /* * (non-Javadoc) Method declared on IAction. */ public String getToolTipText() { return toolTipText; } /* * (non-Javadoc) Method declared on IAction. */ public boolean isChecked() { return value == VAL_TOGGLE_BTN_ON || value == VAL_RADIO_BTN_ON; } /* * (non-Javadoc) Method declared on IAction. */ public boolean isEnabled() { return enabled; } /* * (non-Javadoc) Method declared on IAction. */ public boolean isHandled() { return true; } /** * Reports the outcome of the running of this action via the * {@link IAction#RESULT} property. * * @param success * <code>true</code> if the action succeeded and * <code>false</code> if the action failed or was not completed * @see IAction#RESULT * @since 3.0 */ public final void notifyResult(boolean success) { // avoid Boolean.valueOf(boolean) to allow compilation against JCL // Foundation (bug 80059) firePropertyChange(RESULT, null, success ? Boolean.TRUE : Boolean.FALSE); } /** * The default implementation of this <code>IAction</code> method does * nothing. Subclasses should override this method if they do not need * information from the triggering event, or override * <code>runWithEvent(Event)</code> if they do. */ public void run() { // do nothing } /** * The default implementation of this <code>IAction</code> method ignores * the event argument, and simply calls <code>run()</code>. Subclasses * should override this method if they need information from the triggering * event, or override <code>run()</code> if not. * * @param event * the SWT event which triggered this action being run * @since 2.0 */ public void runWithEvent(Event event) { run(); } /* * @see IAction#setAccelerator(int) */ public void setAccelerator(int keycode) { this.accelerator = keycode; } /* * (non-Javadoc) Method declared on IAction. */ public void setActionDefinitionId(String id) { actionDefinitionId = id; } /* * (non-Javadoc) Method declared on IAction. */ public void setChecked(boolean checked) { Object newValue = null; // For backward compatibility, if the style is not // set yet, then convert it to a toggle button. if (value == null || value == VAL_TOGGLE_BTN_ON || value == VAL_TOGGLE_BTN_OFF) { newValue = checked ? VAL_TOGGLE_BTN_ON : VAL_TOGGLE_BTN_OFF; } else if (value == VAL_RADIO_BTN_ON || value == VAL_RADIO_BTN_OFF) { newValue = checked ? VAL_RADIO_BTN_ON : VAL_RADIO_BTN_OFF; } else { // Some other style already, so do nothing. return; } if (newValue != value) { value = newValue; if (checked) { firePropertyChange(CHECKED, Boolean.FALSE, Boolean.TRUE); } else { firePropertyChange(CHECKED, Boolean.TRUE, Boolean.FALSE); } } } /* * (non-Javadoc) Method declared on IAction. */ public void setDescription(String text) { if ((description == null && text != null) || (description != null && text == null) || (description != null && text != null && !text .equals(description))) { String oldDescription = description; description = text; firePropertyChange(DESCRIPTION, oldDescription, description); } } /* * (non-Javadoc) Method declared on IAction. */ public void setDisabledImageDescriptor(ImageDescriptor newImage) { if (disabledImage != newImage) { ImageDescriptor oldImage = disabledImage; disabledImage = newImage; firePropertyChange(IMAGE, oldImage, newImage); } } /* * (non-Javadoc) Method declared on IAction. */ public void setEnabled(boolean enabled) { if (enabled != this.enabled) { Boolean oldVal = this.enabled ? Boolean.TRUE : Boolean.FALSE; Boolean newVal = enabled ? Boolean.TRUE : Boolean.FALSE; this.enabled = enabled; firePropertyChange(ENABLED, oldVal, newVal); } } /* * (non-Javadoc) Method declared on IAction. */ public void setHelpListener(HelpListener listener) { helpListener = listener; } /* * (non-Javadoc) Method declared on IAction. */ public void setHoverImageDescriptor(ImageDescriptor newImage) { if (hoverImage != newImage) { ImageDescriptor oldImage = hoverImage; hoverImage = newImage; firePropertyChange(IMAGE, oldImage, newImage); } } /* * (non-Javadoc) Method declared on IAction. */ public void setId(String id) { this.id = id; } /* * (non-Javadoc) Method declared on IAction. */ public void setImageDescriptor(ImageDescriptor newImage) { if (image != newImage) { ImageDescriptor oldImage = image; image = newImage; firePropertyChange(IMAGE, oldImage, newImage); } } /** * Sets the menu creator for this action. * <p> * Note that if this method is called, it overrides the check status. * </p> * * @param creator * the menu creator, or <code>null</code> if none */ public void setMenuCreator(IMenuCreator creator) { // For backward compatibility, if the style is not // set yet, then convert it to a drop down menu. if (value == null) { value = creator; return; } if (value instanceof IMenuCreator) { value = creator == null ? VAL_DROP_DOWN_MENU : creator; } } /** * Sets the text for this action. * <p> * Fires a property change event for the <code>TEXT</code> property if the * text actually changes as a consequence. * </p> * <p> * The accelerator is identified by the last index of a tab character. If * there are no tab characters, then it is identified by the last index of a * '@' character. If neither, then there is no accelerator text. Note that * if you want to insert a '@' character into the text (but no accelerator, * you can simply insert a '@' or a tab at the end of the text. * </p> * * @param text * the text, or <code>null</code> if none */ public void setText(String text) { String oldText = this.text; int oldAccel = this.accelerator; this.text = text; if (text != null) { String acceleratorText = LegacyActionTools .extractAcceleratorText(text); if (acceleratorText != null) { int newAccelerator = LegacyActionTools .convertLocalizedAccelerator(acceleratorText); // Be sure to not wipe out the accelerator if nothing found if (newAccelerator > 0) { setAccelerator(newAccelerator); } } } if (!(this.accelerator == oldAccel && (oldText == null ? this.text == null : oldText.equals(this.text)))) { firePropertyChange(TEXT, oldText, this.text); } } /** * Sets the tool tip text for this action. * <p> * Fires a property change event for the <code>TOOL_TIP_TEXT</code> * property if the tool tip text actually changes as a consequence. * </p> * * @param toolTipText * the tool tip text, or <code>null</code> if none */ public void setToolTipText(String toolTipText) { String oldToolTipText = this.toolTipText; if (!(oldToolTipText == null ? toolTipText == null : oldToolTipText .equals(toolTipText))) { this.toolTipText = toolTipText; firePropertyChange(TOOL_TIP_TEXT, oldToolTipText, toolTipText); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -