Class ActionButtonFigure

java.lang.Object
org.eclipse.draw2d.Figure
org.csstudio.swt.widgets.figures.ActionButtonFigure
All Implemented Interfaces:
ITextFigure, Introspectable, org.eclipse.draw2d.IFigure

public class ActionButtonFigure extends org.eclipse.draw2d.Figure implements Introspectable, ITextFigure
A re-written action button figure which can pass mouse event state to action listener.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     

    Nested classes/interfaces inherited from class org.eclipse.draw2d.Figure

    org.eclipse.draw2d.Figure.FigureIterator, org.eclipse.draw2d.Figure.IdentitySearch

    Nested classes/interfaces inherited from interface org.eclipse.draw2d.IFigure

    org.eclipse.draw2d.IFigure.NoInsets
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Font
    Default label font.
    static final String
     

    Fields inherited from class org.eclipse.draw2d.Figure

    bgColor, border, bounds, fgColor, flags, font, MAX_FLAG, maxSize, minSize, NO_MANAGER, prefSize, toolTip

    Fields inherited from interface org.eclipse.draw2d.IFigure

    MAX_DIMENSION, MIN_DIMENSION, NO_INSETS
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    ActionButtonFigure(boolean runMode)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Registers the given listener as an ActionButtonFigure.ButtonActionListener.
    void
     
    void
    calculateTextPosition(int width, int height)
     
    void
    Dispose the resources on this figure.
    protected void
    Notifies any ActionButtonFigure.ButtonActionListener on this button that an action has been performed.
     
     
     
    int
     
    protected void
    hookEventHandler(org.csstudio.swt.widgets.figures.ActionButtonFigure.ButtonEventHandler handler)
    Adds the given ActionButtonFigure.ButtonEventHandler to this button.
    protected boolean
     
    protected boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    protected void
    paintClientArea(org.eclipse.draw2d.Graphics graphics)
    Paints the area of this figure excluded by the borders.
    void
     
    protected void
    setArmed(boolean armed)
    Set the armed status of the button.
    void
     
    void
    setCursor(Cursor cursor)
     
    void
    setEnabled(boolean value)
     
    void
     
    void
     
    protected void
    setMousePressed(boolean mousePressed)
     
    void
    setRunMode(boolean runMode)
     
    void
    setSelected(boolean selected)
     
    void
    Sets the text for the Button.
    void
    setTextAlignment(int alignment)
    Sets the alignment of the buttons text.
    void
    setToggled(boolean toggled)
     
    void
    setToggleStyle(boolean style)
    Set the style of the Button.

    Methods inherited from class org.eclipse.draw2d.Figure

    add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getClippingStrategy, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getLocalBackgroundColor, getLocalFont, getLocalForegroundColor, getLocation, getMaximumSize, getMinimumSize, getMinimumSize, getParent, getPreferredSize, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, hasFocus, internalGetEventDispatcher, intersects, invalidate, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isMouseEventTarget, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, layout, paint, paintBorder, paintChildren, paintFigure, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBorder, setBounds, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setClippingStrategy, setConstraint, setFlag, setFocusTraversable, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, useLocalCoordinates, validate

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.eclipse.draw2d.IFigure

    add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getClippingStrategy, getCursor, getFont, getForegroundColor, getInsets, getLayoutManager, getLocalBackgroundColor, getLocalForegroundColor, getMaximumSize, getMinimumSize, getMinimumSize, getParent, getPreferredSize, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, hasFocus, internalGetEventDispatcher, intersects, invalidate, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isRequestFocusEnabled, isShowing, isVisible, paint, remove, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBorder, setBounds, setClippingStrategy, setConstraint, setFocusTraversable, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, validate
  • Field Details

    • SWT_KEY_BEFORE_ACTION_RUNNABLE

      public static final String SWT_KEY_BEFORE_ACTION_RUNNABLE
      See Also:
    • FONT

      public static final Font FONT
      Default label font.
  • Constructor Details

    • ActionButtonFigure

      public ActionButtonFigure(boolean runMode)
    • ActionButtonFigure

      public ActionButtonFigure()
  • Method Details

    • addActionListener

      public void addActionListener(ActionButtonFigure.ButtonActionListener listener)
      Registers the given listener as an ActionButtonFigure.ButtonActionListener.
      Parameters:
      listener - The ActionButtonFigure.ButtonActionListener to add
    • dispose

      public void dispose()
      Dispose the resources on this figure.
    • fireActionPerformed

      protected void fireActionPerformed(int i)
      Notifies any ActionButtonFigure.ButtonActionListener on this button that an action has been performed.
    • getImagePath

      public String getImagePath()
    • getTextAlignment

      public int getTextAlignment()
    • hookEventHandler

      protected void hookEventHandler(org.csstudio.swt.widgets.figures.ActionButtonFigure.ButtonEventHandler handler)
      Adds the given ActionButtonFigure.ButtonEventHandler to this button. A ActionButtonFigure.ButtonEventHandler should be a MouseListener, MouseMotionListener, KeyListener, and FocusListener.
    • isArmed

      protected boolean isArmed()
    • isMousePressed

      protected boolean isMousePressed()
    • isOpaque

      public boolean isOpaque()
      Specified by:
      isOpaque in interface org.eclipse.draw2d.IFigure
      Overrides:
      isOpaque in class org.eclipse.draw2d.Figure
    • isRunMode

      public boolean isRunMode()
    • isSelected

      public boolean isSelected()
      Returns:
      true if the button is pushed down. false otherwise.
    • isToggled

      public boolean isToggled()
    • isToggleStyle

      public boolean isToggleStyle()
    • paintClientArea

      protected void paintClientArea(org.eclipse.draw2d.Graphics graphics)
      Paints the area of this figure excluded by the borders. Induces a (1,1) pixel shift in the painting if the mouse is armed, giving it the pressed appearance.
      Overrides:
      paintClientArea in class org.eclipse.draw2d.Figure
    • removeActionListener

      public void removeActionListener(ActionButtonFigure.ButtonActionListener listener)
    • setArmed

      protected void setArmed(boolean armed)
      Set the armed status of the button.
    • setCursor

      public void setCursor(Cursor cursor)
      Specified by:
      setCursor in interface org.eclipse.draw2d.IFigure
      Overrides:
      setCursor in class org.eclipse.draw2d.Figure
    • setEnabled

      public void setEnabled(boolean value)
      Specified by:
      setEnabled in interface org.eclipse.draw2d.IFigure
      Overrides:
      setEnabled in class org.eclipse.draw2d.Figure
    • setFont

      public void setFont(Font f)
      Specified by:
      setFont in interface org.eclipse.draw2d.IFigure
      Overrides:
      setFont in class org.eclipse.draw2d.Figure
    • setImagePath

      public void setImagePath(String path)
    • setMousePressed

      protected void setMousePressed(boolean mousePressed)
    • setRunMode

      public void setRunMode(boolean runMode)
    • setSelected

      public void setSelected(boolean selected)
    • setText

      public void setText(String s)
      Sets the text for the Button.
    • getText

      public String getText()
      Specified by:
      getText in interface ITextFigure
      Returns:
      the label text.
    • setTextAlignment

      public void setTextAlignment(int alignment)
      Sets the alignment of the buttons text. The parameter is a PositionConstants (LEFT, RIGHT, TOP, CENTER, BOTTOM)
    • calculateTextPosition

      public void calculateTextPosition()
    • calculateTextPosition

      public void calculateTextPosition(int width, int height)
    • setToggled

      public void setToggled(boolean toggled)
    • setToggleStyle

      public void setToggleStyle(boolean style)
      Set the style of the Button.
      Parameters:
      style - false = Push, true=Toggle.
    • setBackgroundColor

      public void setBackgroundColor(Color bg)
      Specified by:
      setBackgroundColor in interface org.eclipse.draw2d.IFigure
      Overrides:
      setBackgroundColor in class org.eclipse.draw2d.Figure
    • getBeanInfo

      public BeanInfo getBeanInfo() throws IntrospectionException
      Specified by:
      getBeanInfo in interface Introspectable
      Throws:
      IntrospectionException