Package org.eclipse.draw2d
Class Clickable
java.lang.Object
org.eclipse.draw2d.Figure
org.eclipse.draw2d.Clickable
- All Implemented Interfaces:
- IFigure
A Clickable responds to mouse clicks in some way (determined by a
 ClickBehavior) and fires action events. No visual appearance of feedback is
 offered. Depends on a model holder and an event handler which understands the
 model and updates the model accordingly. 
ButtonModel is used by
 default. Any figure can be set as contents to a Clickable.
 Clickable->EventHandler->Model->ModelObserver->Listeners of actions.- 
Nested Class SummaryNested classes/interfaces inherited from class org.eclipse.draw2d.FigureFigure.FigureIterator, Figure.IdentitySearch, Figure.ReverseFigureChildrenIteratorNested classes/interfaces inherited from interface org.eclipse.draw2d.IFigureIFigure.NoInsets
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intAn action is performed every time the mouse is released.protected static intThe highest reserved flag used by this classstatic final intFiring starts as soon as the mouse is pressed on this Clickable, and keeps firing at prefixed intervals until the mouse is released.static final intStyle constant that defines a push button.static final intStyle constant that defines a toggle button.Fields inherited from class org.eclipse.draw2d.FigurebgColor, border, bounds, fgColor, flags, font, maxSize, minSize, NO_MANAGER, prefSize, toolTipFields inherited from interface org.eclipse.draw2d.IFigureMAX_DIMENSION, MIN_DIMENSION, NO_INSETS
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddActionListener(ActionListener listener) Adds the given listener to the list of action listeners of this Figure.voidaddChangeListener(ChangeListener listener) Adds the given listener to the list of state change listeners of this figure.protected ButtonModelReturns a newly created ButtonModel as the default model to be used by this Clickable based on the button style.protected org.eclipse.draw2d.ClickableEventHandlerReturns a newly created event handler for this Clickable and its model.protected org.eclipse.draw2d.Clickable.ModelObserverReturns a newly created model observer which listens to the model, and fires any action or state changes.voiddoClick()Fires an action performed event.protected voidCalled when there has been an action performed by this Clickable, which is determined by the model.protected voidfireStateChanged(ChangeEvent modelChange) Called when there has been a change of state in the model of this clickable.getModel()Returns the behavior model used by this Clickable.protected voidhookEventHandler(org.eclipse.draw2d.ClickableEventHandler handler) Adds the given ClickableEventHandler to this clickable.protected voidinit()Initializes this Clickable by setting a default model and adding a clickable event handler for that model.booleanReturnstrueif rollover feedback is enabled.booleanReturnstrueif this Clickable is in a selected state.booleanisStyle(int style) Returnstrueif this Clickable's style is the same as the passed style.protected voidpaintBorder(Graphics graphics) If this Clickable has focus, this method paints a focus rectangle.protected voidpaintClientArea(Graphics graphics) Paints the area of this figure excluded by the borders.voidremoveActionListener(ActionListener listener) Removes the given listener from the list of ActionListener's of this Clickable.voidremoveChangeListener(ChangeListener listener) Removes the given listener from the list of ChangeListener's of this clickable.protected voidsetContents(IFigure contents) Sets the Figure which is the contents of this Clickable.voidsetEnabled(boolean value) Sets this IFigure to be enabled.voidsetEventHandler(org.eclipse.draw2d.ClickableEventHandler h) Sets the event handler which interacts with the model to determine the behavior of this Clickable.voidsetFiringMethod(int type) Determines how this clickable is to fire notifications to its listeners.voidsetModel(ButtonModel model) Sets the model to be used by this clickable for its state and behavior determination.voidsetRolloverEnabled(boolean value) Enables or disables rollover feedback of this figure.voidsetSelected(boolean value) Sets the selected state of this Clickable.voidsetStyle(int style) Sets this Clickable's style to the passed value, eitherSTYLE_BUTTONorSTYLE_TOGGLE.protected voidunhookEventHandler(org.eclipse.draw2d.ClickableEventHandler handler) Removes the given ClickableEventHandler containing listeners from this Clickable.Methods inherited from class org.eclipse.draw2d.Figureadd, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getBounds, getChildren, getChildrenRevIterable, getClientArea, getClientArea, getClippingStrategy, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getListenersIterable, 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, handleMouseWheelScrolled, hasFocus, internalGetEventDispatcher, intersects, invalidate, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isMouseEventTarget, isOpaque, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, layout, optimizeClip, paint, paintChildren, paintFigure, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setBounds, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setClippingStrategy, setConstraint, setCursor, setFlag, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, useLocalCoordinates, validate
- 
Field Details- 
MAX_FLAGprotected static int MAX_FLAGThe highest reserved flag used by this class
- 
STYLE_BUTTONpublic static final int STYLE_BUTTONStyle constant that defines a push button. The button will be pressed when the mouse is pressed on top of it. The button will be released when the mouse is released or is move off of the button.
- 
STYLE_TOGGLEpublic static final int STYLE_TOGGLEStyle constant that defines a toggle button. The button will toggle between 2 states when the mouse is clicked on the button.
- 
DEFAULT_FIRINGpublic static final int DEFAULT_FIRINGAn action is performed every time the mouse is released.- See Also:
 
- 
REPEAT_FIRINGpublic static final int REPEAT_FIRINGFiring starts as soon as the mouse is pressed on this Clickable, and keeps firing at prefixed intervals until the mouse is released.- See Also:
 
 
- 
- 
Constructor Details- 
Clickablepublic Clickable()Constructs a Clickable with no contents.
- 
ClickableConstructs a Clickable whose contents are provided as input. The content figure occupies the entire region of the Clickable.- Parameters:
- contents- The content figure
 
- 
ClickableConstructs a Clickable whose contents are provided as input. The content figure occupies the entire region of the Clickable. Sets the style to the given style (eitherSTYLE_BUTTONorSTYLE_TOGGLE).- Parameters:
- contents- The content figure
- style- The button style
 
 
- 
- 
Method Details- 
addActionListenerAdds the given listener to the list of action listeners of this Figure. Listener is called whenever an action is performed.- Parameters:
- listener- The ActionListener to be added
- Since:
- 2.0
 
- 
addChangeListenerAdds the given listener to the list of state change listeners of this figure. A ChangeListener is informed if there is any state change in the model requiring action by the listener.- Parameters:
- listener- The ChangeListener to be added
- Since:
- 2.0
 
- 
createDefaultModelReturns a newly created ButtonModel as the default model to be used by this Clickable based on the button style.- Returns:
- The model to be used by default
- Since:
- 2.0
 
- 
createEventHandlerprotected org.eclipse.draw2d.ClickableEventHandler createEventHandler()Returns a newly created event handler for this Clickable and its model.- Returns:
- The event handler
- Since:
- 2.0
 
- 
createModelObserverprotected org.eclipse.draw2d.Clickable.ModelObserver createModelObserver()Returns a newly created model observer which listens to the model, and fires any action or state changes. A ModelObserver holds both an action listener and a state change listener.- Returns:
- The newly created model observer
- Since:
- 2.0
 
- 
doClickpublic void doClick()Fires an action performed event.- Since:
- 2.0
 
- 
fireActionPerformedprotected void fireActionPerformed()Called when there has been an action performed by this Clickable, which is determined by the model. Notifies all ActionListener type listeners of an action performed.- Since:
- 2.0
 
- 
fireStateChangedCalled when there has been a change of state in the model of this clickable. Notifies all ChangeListener type listeners of the state change.- Parameters:
- modelChange- The ChangeEvent
- Since:
- 2.0
 
- 
getModelReturns the behavior model used by this Clickable.- Returns:
- The model used by this Clickable
- Since:
- 2.0
 
- 
hookEventHandlerprotected void hookEventHandler(org.eclipse.draw2d.ClickableEventHandler handler) Adds the given ClickableEventHandler to this clickable. A ClickableEventHandler should be a MouseListener, MouseMotionListener, ChangeListener, KeyListener, and FocusListener.- Parameters:
- handler- The new event handler
- Since:
- 2.0
 
- 
initprotected void init()Initializes this Clickable by setting a default model and adding a clickable event handler for that model.- Since:
- 2.0
 
- 
isRolloverEnabledpublic boolean isRolloverEnabled()Returnstrueif rollover feedback is enabled.- Returns:
- truerollover feedback is enabled
- Since:
- 2.0
 
- 
isSelectedpublic boolean isSelected()Returnstrueif this Clickable is in a selected state. The model is the one which holds all this state based information.- Returns:
- trueif this Clickable is in a selected state
- Since:
- 2.0
 
- 
isStylepublic boolean isStyle(int style) Returnstrueif this Clickable's style is the same as the passed style.- Parameters:
- style- The style to be checked
- Returns:
- trueif this Clickable's style is the same as the passed style
- Since:
- 2.0
 
- 
paintBorderIf this Clickable has focus, this method paints a focus rectangle.- Overrides:
- paintBorderin class- Figure
- Parameters:
- graphics- Graphics handle for painting
- See Also:
 
- 
paintClientAreaPaints 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:
- paintClientAreain class- Figure
- Parameters:
- graphics- Graphics handle for painting
- Since:
- 2.0
 
- 
removeActionListenerRemoves the given listener from the list of ActionListener's of this Clickable.- Parameters:
- listener- Listener to be removed from this figure
- Since:
- 2.0
 
- 
removeChangeListenerRemoves the given listener from the list of ChangeListener's of this clickable.- Parameters:
- listener- Listener to be removed from this figure
- Since:
- 2.0
 
- 
setContentsSets the Figure which is the contents of this Clickable. This Figure occupies the entire clickable region.- Parameters:
- contents- Contents of the clickable
- Since:
- 2.0
 
- 
setEnabledpublic void setEnabled(boolean value) Description copied from interface:IFigureSets this IFigure to be enabled.- Specified by:
- setEnabledin interface- IFigure
- Overrides:
- setEnabledin class- Figure
- Parameters:
- value-- trueif this IFigure should be enabled
- See Also:
 
- 
setEventHandlerpublic void setEventHandler(org.eclipse.draw2d.ClickableEventHandler h) Sets the event handler which interacts with the model to determine the behavior of this Clickable.- Parameters:
- h- Event handler for this clickable
- Since:
- 2.0
 
- 
setFiringMethodpublic void setFiringMethod(int type) Determines how this clickable is to fire notifications to its listeners. In the default firing method (DEFAULT_FIRING), an action is performed every time the mouse is released. In the repeat firing method (REPEAT_FIRING), firing starts as soon as it is pressed on this clickable, and keeps firing at prefixed intervals until the mouse is released.- Parameters:
- type- Type of firing
- Since:
- 2.0
 
- 
setModelSets the model to be used by this clickable for its state and behavior determination. This clickable removes any observers from the previous model before adding new ones to the new model.- Parameters:
- model- The new model of this Clickable
- Since:
- 2.0
 
- 
setRolloverEnabledpublic void setRolloverEnabled(boolean value) Enables or disables rollover feedback of this figure. Generally used in conjunction with the model to determine if feedback is to be shown.- Parameters:
- value- The rollover state to be set
- Since:
- 2.0
 
- 
setSelectedpublic void setSelected(boolean value) Sets the selected state of this Clickable. Since the model is responsible for all state based information, it is informed of the state change. Extending classes can choose selection information, if they do not represent any selection.- Parameters:
- value- New selected state of this clickable.
- Since:
- 2.0
- See Also:
 
- 
setStylepublic void setStyle(int style) Sets this Clickable's style to the passed value, eitherSTYLE_BUTTONorSTYLE_TOGGLE.- Parameters:
- style- The button style
- Since:
- 2.0
 
- 
unhookEventHandlerprotected void unhookEventHandler(org.eclipse.draw2d.ClickableEventHandler handler) Removes the given ClickableEventHandler containing listeners from this Clickable.- Parameters:
- handler- The event handler to be removed
- Since:
- 2.0
 
 
-