public class Clickable extends Figure
ButtonModel
is used by
default. Any figure can be set as contents to a Clickable.
Clickable->EventHandler->Model->ModelObserver->Listeners of actions.Figure.FigureIterator, Figure.IdentitySearch
IFigure.NoInsets
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_FIRING
An action is performed every time the mouse is released.
|
protected static int |
MAX_FLAG
The highest reserved flag used by this class
|
static int |
REPEAT_FIRING
Firing starts as soon as the mouse is pressed on this Clickable, and
keeps firing at prefixed intervals until the mouse is released.
|
static int |
STYLE_BUTTON
Style constant that defines a push button.
|
static int |
STYLE_TOGGLE
Style constant that defines a toggle button.
|
bgColor, border, bounds, fgColor, flags, font, maxSize, minSize, NO_MANAGER, prefSize, toolTip
MAX_DIMENSION, MIN_DIMENSION, NO_INSETS
Constructor and Description |
---|
Clickable()
Constructs a Clickable with no contents.
|
Clickable(IFigure contents)
Constructs a Clickable whose contents are provided as input.
|
Clickable(IFigure contents,
int style)
Constructs a Clickable whose contents are provided as input.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener listener)
Adds the given listener to the list of action listeners of this Figure.
|
void |
addChangeListener(ChangeListener listener)
Adds the given listener to the list of state change listeners of this
figure.
|
protected ButtonModel |
createDefaultModel()
Returns a newly created ButtonModel as the default model to be used by
this Clickable based on the button style.
|
protected org.eclipse.draw2d.ClickableEventHandler |
createEventHandler()
Returns a newly created event handler for this Clickable and its model.
|
protected org.eclipse.draw2d.Clickable.ModelObserver |
createModelObserver()
Returns a newly created model observer which listens to the model, and
fires any action or state changes.
|
void |
doClick()
Fires an action performed event.
|
protected void |
fireActionPerformed()
Called when there has been an action performed by this Clickable, which
is determined by the model.
|
protected void |
fireStateChanged(ChangeEvent modelChange)
Called when there has been a change of state in the model of this
clickable.
|
ButtonModel |
getModel()
Returns the behavior model used by this Clickable.
|
protected void |
hookEventHandler(org.eclipse.draw2d.ClickableEventHandler handler)
Adds the given ClickableEventHandler to this clickable.
|
protected void |
init()
Initializes this Clickable by setting a default model and adding a
clickable event handler for that model.
|
boolean |
isRolloverEnabled()
Returns
true if rollover feedback is enabled. |
boolean |
isSelected()
Returns
true if this Clickable is in a selected state. |
boolean |
isStyle(int style)
Returns
true if this Clickable's style is the same as the
passed style. |
protected void |
paintBorder(Graphics graphics)
If this Clickable has focus, this method paints a focus rectangle.
|
protected void |
paintClientArea(Graphics graphics)
Paints the area of this figure excluded by the borders.
|
void |
removeActionListener(ActionListener listener)
Removes the given listener from the list of ActionListener's of this
Clickable.
|
void |
removeChangeListener(ChangeListener listener)
Removes the given listener from the list of ChangeListener's of this
clickable.
|
protected void |
setContents(IFigure contents)
Sets the Figure which is the contents of this Clickable.
|
void |
setEnabled(boolean value)
Sets this IFigure to be enabled.
|
void |
setEventHandler(org.eclipse.draw2d.ClickableEventHandler h)
Sets the event handler which interacts with the model to determine the
behavior of this Clickable.
|
void |
setFiringMethod(int type)
Determines how this clickable is to fire notifications to its listeners.
|
void |
setModel(ButtonModel model)
Sets the model to be used by this clickable for its state and behavior
determination.
|
void |
setRolloverEnabled(boolean value)
Enables or disables rollover feedback of this figure.
|
void |
setSelected(boolean value)
Sets the selected state of this Clickable.
|
void |
setStyle(int style)
Sets this Clickable's style to the passed value, either
STYLE_BUTTON or STYLE_TOGGLE . |
protected void |
unhookEventHandler(org.eclipse.draw2d.ClickableEventHandler handler)
Removes the given ClickableEventHandler containing listeners from this
Clickable.
|
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, isOpaque, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, layout, paint, paintChildren, paintFigure, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, 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
protected static int MAX_FLAG
public static final int STYLE_BUTTON
public static final int STYLE_TOGGLE
public static final int DEFAULT_FIRING
public static final int REPEAT_FIRING
public Clickable()
public Clickable(IFigure contents)
contents
- The content figurepublic Clickable(IFigure contents, int style)
STYLE_BUTTON
or STYLE_TOGGLE
).contents
- The content figurestyle
- The button stylepublic void addActionListener(ActionListener listener)
listener
- The ActionListener to be addedpublic void addChangeListener(ChangeListener listener)
listener
- The ChangeListener to be addedprotected ButtonModel createDefaultModel()
protected org.eclipse.draw2d.ClickableEventHandler createEventHandler()
protected org.eclipse.draw2d.Clickable.ModelObserver createModelObserver()
public void doClick()
protected void fireActionPerformed()
protected void fireStateChanged(ChangeEvent modelChange)
modelChange
- The ChangeEventpublic ButtonModel getModel()
protected void hookEventHandler(org.eclipse.draw2d.ClickableEventHandler handler)
handler
- The new event handlerprotected void init()
public boolean isRolloverEnabled()
true
if rollover feedback is enabled.true
rollover feedback is enabledpublic boolean isSelected()
true
if this Clickable is in a selected state. The
model is the one which holds all this state based information.true
if this Clickable is in a selected statepublic boolean isStyle(int style)
true
if this Clickable's style is the same as the
passed style.style
- The style to be checkedtrue
if this Clickable's style is the same as the
passed styleprotected void paintBorder(Graphics graphics)
paintBorder
in class Figure
graphics
- Graphics handle for paintingBorder.paint(IFigure, Graphics, Insets)
protected void paintClientArea(Graphics graphics)
paintClientArea
in class Figure
graphics
- Graphics handle for paintingpublic void removeActionListener(ActionListener listener)
listener
- Listener to be removed from this figurepublic void removeChangeListener(ChangeListener listener)
listener
- Listener to be removed from this figureprotected void setContents(IFigure contents)
contents
- Contents of the clickablepublic void setEnabled(boolean value)
IFigure
setEnabled
in interface IFigure
setEnabled
in class Figure
value
- true
if this IFigure should be enabledIFigure.setEnabled(boolean)
public void setEventHandler(org.eclipse.draw2d.ClickableEventHandler h)
h
- Event handler for this clickablepublic void setFiringMethod(int type)
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.type
- Type of firingpublic void setModel(ButtonModel model)
model
- The new model of this Clickablepublic void setRolloverEnabled(boolean value)
value
- The rollover state to be setpublic void setSelected(boolean value)
value
- New selected state of this clickable.isSelected()
public void setStyle(int style)
STYLE_BUTTON
or STYLE_TOGGLE
.style
- The button styleprotected void unhookEventHandler(org.eclipse.draw2d.ClickableEventHandler handler)
handler
- The event handler to be removedCopyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.