Package org.eclipse.draw2d
Class ButtonModel
java.lang.Object
org.eclipse.draw2d.ButtonModel
- Direct Known Subclasses:
ToggleModel
A model for buttons containing several properties, including enabled,
pressed, selected, rollover enabled and mouseover.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
The name of the action associated with this button.protected static final int
Flag for armed button statestatic final String
Armed propertystatic final int
Action performed events are not fired until the mouse button is released.protected static final int
Flag for enablement button statestatic final String
Enabled propertyprotected org.eclipse.draw2d.ButtonStateTransitionListener
Listens to button state transitions and fires action performed events based on the desired behavior (DEFAULT_FIRING_BEHAVIOR
orREPEAT_FIRING_BEHAVIOR
).protected ButtonGroup
The ButtonGroup this button belongs to (if any).protected static final int
Flag that can be used by subclasses to define more statesprotected static final int
Flag for mouseOver statestatic final String
Mouseover propertyprotected static final int
Flag for pressed button statestatic final String
Pressed propertystatic final int
Action performed events fire repeatedly until the mouse button is released.protected static final int
Flag for rollover enablement button statestatic final String
Rollover Enabled propertyprotected static final int
Flag for selected button statestatic final String
Selected property -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addActionListener
(ActionListener listener) Registers the given listener as an ActionListener.void
addChangeListener
(ChangeListener listener) Registers the given listener as a ChangeListener.void
addStateTransitionListener
(org.eclipse.draw2d.ButtonStateTransitionListener listener) Registers the given listener as a ButtonStateTransitionListener.protected void
Notifies any ActionListeners on this ButtonModel that an action has been performed.protected void
Notifies any listening ButtonStateTransitionListener that the pressed state of this button has been cancelled.protected void
Notifies any listening ButtonStateTransitionListener that this button has been pressed.protected void
Notifies any listening ButtonStateTransitionListener that this button has been released.protected void
Notifies any listening ButtonStateTransitionListeners that this button has resumed activity.protected void
fireStateChanged
(String property) Notifies any listening ChangeListeners that this button's state has changed.protected void
Notifies any listening ButtonStateTransitionListeners that this button has suspended activity.getGroup()
Returns the group to which this model belongs.Returns an object representing user data.protected void
Sets the firing behavior for this button.boolean
isArmed()
Returnstrue
if this button is armed.boolean
Returnstrue
if this button is enabled.boolean
Returnstrue
if the mouse is over this button.boolean
Returnstrue
if this button is pressed.boolean
Returns the selection state of this model.void
removeActionListener
(ActionListener listener) Removes the given ActionListener.void
removeChangeListener
(ChangeListener listener) Removes the given ChangeListener.void
removeStateTransitionListener
(org.eclipse.draw2d.ButtonStateTransitionListener listener) Removes the given ButtonStateTransitionListener.void
setArmed
(boolean value) Sets this button to be armed.void
setEnabled
(boolean value) Sets this button to be enabled.void
setFiringBehavior
(int type) Sets the firing behavior for this button.void
setGroup
(ButtonGroup bg) Sets the ButtonGroup to which this model belongs to.void
setMouseOver
(boolean value) Sets the mouseover property of this button.void
setPressed
(boolean value) Sets the pressed property of this button.void
setSelected
(boolean value) Sets this button to be selected.void
setUserData
(Object data) Sets user data.
-
Field Details
-
ENABLED_PROPERTY
Enabled property- See Also:
-
PRESSED_PROPERTY
Pressed property- See Also:
-
SELECTED_PROPERTY
Selected property- See Also:
-
ROLLOVER_ENABLED_PROPERTY
Rollover Enabled property- See Also:
-
MOUSEOVER_PROPERTY
Mouseover property- See Also:
-
ARMED_PROPERTY
Armed property- See Also:
-
ARMED_FLAG
protected static final int ARMED_FLAGFlag for armed button state- See Also:
-
PRESSED_FLAG
protected static final int PRESSED_FLAGFlag for pressed button state- See Also:
-
MOUSEOVER_FLAG
protected static final int MOUSEOVER_FLAGFlag for mouseOver state- See Also:
-
SELECTED_FLAG
protected static final int SELECTED_FLAGFlag for selected button state- See Also:
-
ENABLED_FLAG
protected static final int ENABLED_FLAGFlag for enablement button state- See Also:
-
ROLLOVER_ENABLED_FLAG
protected static final int ROLLOVER_ENABLED_FLAGFlag for rollover enablement button state- See Also:
-
MAX_FLAG
protected static final int MAX_FLAGFlag that can be used by subclasses to define more states- See Also:
-
DEFAULT_FIRING_BEHAVIOR
public static final int DEFAULT_FIRING_BEHAVIORAction performed events are not fired until the mouse button is released.- See Also:
-
REPEAT_FIRING_BEHAVIOR
public static final int REPEAT_FIRING_BEHAVIORAction performed events fire repeatedly until the mouse button is released.- See Also:
-
actionName
The name of the action associated with this button. -
group
The ButtonGroup this button belongs to (if any). -
firingBehavior
protected org.eclipse.draw2d.ButtonStateTransitionListener firingBehaviorListens to button state transitions and fires action performed events based on the desired behavior (DEFAULT_FIRING_BEHAVIOR
orREPEAT_FIRING_BEHAVIOR
).
-
-
Constructor Details
-
ButtonModel
public ButtonModel()
-
-
Method Details
-
addActionListener
Registers the given listener as an ActionListener.- Parameters:
listener
- The ActionListener to add- Since:
- 2.0
-
addChangeListener
Registers the given listener as a ChangeListener.- Parameters:
listener
- The ChangeListener to add- Since:
- 2.0
-
addStateTransitionListener
public void addStateTransitionListener(org.eclipse.draw2d.ButtonStateTransitionListener listener) Registers the given listener as a ButtonStateTransitionListener.- Parameters:
listener
- The ButtonStateTransitionListener to add- Since:
- 2.0
-
fireActionPerformed
protected void fireActionPerformed()Notifies any ActionListeners on this ButtonModel that an action has been performed.- Since:
- 2.0
-
fireCanceled
protected void fireCanceled()Notifies any listening ButtonStateTransitionListener that the pressed state of this button has been cancelled.- Since:
- 2.0
-
firePressed
protected void firePressed()Notifies any listening ButtonStateTransitionListener that this button has been pressed.- Since:
- 2.0
-
fireReleased
protected void fireReleased()Notifies any listening ButtonStateTransitionListener that this button has been released.- Since:
- 2.0
-
fireResume
protected void fireResume()Notifies any listening ButtonStateTransitionListeners that this button has resumed activity.- Since:
- 2.0
-
fireStateChanged
Notifies any listening ChangeListeners that this button's state has changed.- Parameters:
property
- The name of the property that changed- Since:
- 2.0
-
fireSuspend
protected void fireSuspend()Notifies any listening ButtonStateTransitionListeners that this button has suspended activity.- Since:
- 2.0
-
getGroup
Returns the group to which this model belongs.- Returns:
- The ButtonGroup to which this model belongs
- Since:
- 2.0
-
getUserData
Returns an object representing user data.- Returns:
- User data
- Since:
- 2.0
-
installFiringBehavior
protected void installFiringBehavior()Sets the firing behavior for this button.- Since:
- 2.0
-
isArmed
public boolean isArmed()Returnstrue
if this button is armed. If a button is armed, it will fire an ActionPerformed when released.- Returns:
true
if this button is armed- Since:
- 2.0
-
isEnabled
public boolean isEnabled()Returnstrue
if this button is enabled.- Returns:
true
if this button is enabled- Since:
- 2.0
-
isMouseOver
public boolean isMouseOver()Returnstrue
if the mouse is over this button.- Returns:
true
if the mouse is over this button- Since:
- 2.0
-
isPressed
public boolean isPressed()Returnstrue
if this button is pressed.- Returns:
true
if this button is pressed- Since:
- 2.0
-
isSelected
public boolean isSelected()Returns the selection state of this model. If this model belongs to any group, the group is queried for selection state, else the flags are used.- Returns:
true
if this button is selected- Since:
- 2.0
-
removeActionListener
Removes the given ActionListener.- Parameters:
listener
- The ActionListener to remove- Since:
- 2.0
-
removeChangeListener
Removes the given ChangeListener.- Parameters:
listener
- The ChangeListener to remove- Since:
- 2.0
-
removeStateTransitionListener
public void removeStateTransitionListener(org.eclipse.draw2d.ButtonStateTransitionListener listener) Removes the given ButtonStateTransitionListener.- Parameters:
listener
- The ButtonStateTransitionListener to remove- Since:
- 2.0
-
setArmed
public void setArmed(boolean value) Sets this button to be armed. If a button is armed, it will fire an ActionPerformed when released.- Parameters:
value
- The armed state- Since:
- 2.0
-
setEnabled
public void setEnabled(boolean value) Sets this button to be enabled.- Parameters:
value
- The enabled state- Since:
- 2.0
-
setFiringBehavior
public void setFiringBehavior(int type) Sets the firing behavior for this button.DEFAULT_FIRING_BEHAVIOR
is the default behavior, where action performed events are not fired until the mouse button is released.REPEAT_FIRING_BEHAVIOR
causes action performed events to fire repeatedly until the mouse button is released.- Parameters:
type
- The firing behavior type- Since:
- 2.0
-
setGroup
Sets the ButtonGroup to which this model belongs to. Adds this model as a listener to the group.- Parameters:
bg
- The group to which this model belongs.- Since:
- 2.0
-
setMouseOver
public void setMouseOver(boolean value) Sets the mouseover property of this button.- Parameters:
value
- The value the mouseover property will be set to- Since:
- 2.0
-
setPressed
public void setPressed(boolean value) Sets the pressed property of this button.- Parameters:
value
- The value the pressed property will be set to- Since:
- 2.0
-
setSelected
public void setSelected(boolean value) Sets this button to be selected.- Parameters:
value
- The value the selected property will be set to- Since:
- 2.0
-
setUserData
Sets user data.- Parameters:
data
- The user data- Since:
- 2.0
-