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 SummaryFieldsModifier and TypeFieldDescriptionprotected StringThe name of the action associated with this button.protected static final intFlag for armed button statestatic final StringArmed propertystatic final intAction performed events are not fired until the mouse button is released.protected static final intFlag for enablement button statestatic final StringEnabled propertyprotected org.eclipse.draw2d.ButtonStateTransitionListenerListens to button state transitions and fires action performed events based on the desired behavior (DEFAULT_FIRING_BEHAVIORorREPEAT_FIRING_BEHAVIOR).protected ButtonGroupThe ButtonGroup this button belongs to (if any).protected static final intFlag that can be used by subclasses to define more statesprotected static final intFlag for mouseOver statestatic final StringMouseover propertyprotected static final intFlag for pressed button statestatic final StringPressed propertystatic final intAction performed events fire repeatedly until the mouse button is released.protected static final intFlag for rollover enablement button statestatic final StringRollover Enabled propertyprotected static final intFlag for selected button statestatic final StringSelected property
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddActionListener(ActionListener listener) Registers the given listener as an ActionListener.voidaddChangeListener(ChangeListener listener) Registers the given listener as a ChangeListener.voidaddStateTransitionListener(org.eclipse.draw2d.ButtonStateTransitionListener listener) Registers the given listener as a ButtonStateTransitionListener.protected voidNotifies any ActionListeners on this ButtonModel that an action has been performed.protected voidNotifies any listening ButtonStateTransitionListener that the pressed state of this button has been cancelled.protected voidNotifies any listening ButtonStateTransitionListener that this button has been pressed.protected voidNotifies any listening ButtonStateTransitionListener that this button has been released.protected voidNotifies any listening ButtonStateTransitionListeners that this button has resumed activity.protected voidfireStateChanged(String property) Notifies any listening ChangeListeners that this button's state has changed.protected voidNotifies 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 voidSets the firing behavior for this button.booleanisArmed()Returnstrueif this button is armed.booleanReturnstrueif this button is enabled.booleanReturnstrueif the mouse is over this button.booleanReturnstrueif this button is pressed.booleanReturns the selection state of this model.voidremoveActionListener(ActionListener listener) Removes the given ActionListener.voidremoveChangeListener(ChangeListener listener) Removes the given ChangeListener.voidremoveStateTransitionListener(org.eclipse.draw2d.ButtonStateTransitionListener listener) Removes the given ButtonStateTransitionListener.voidsetArmed(boolean value) Sets this button to be armed.voidsetEnabled(boolean value) Sets this button to be enabled.voidsetFiringBehavior(int type) Sets the firing behavior for this button.voidsetGroup(ButtonGroup bg) Sets the ButtonGroup to which this model belongs to.voidsetMouseOver(boolean value) Sets the mouseover property of this button.voidsetPressed(boolean value) Sets the pressed property of this button.voidsetSelected(boolean value) Sets this button to be selected.voidsetUserData(Object data) Sets user data.
- 
Field Details- 
ENABLED_PROPERTYEnabled property- See Also:
 
- 
PRESSED_PROPERTYPressed property- See Also:
 
- 
SELECTED_PROPERTYSelected property- See Also:
 
- 
ROLLOVER_ENABLED_PROPERTYRollover Enabled property- See Also:
 
- 
MOUSEOVER_PROPERTYMouseover property- See Also:
 
- 
ARMED_PROPERTYArmed property- See Also:
 
- 
ARMED_FLAGprotected static final int ARMED_FLAGFlag for armed button state- See Also:
 
- 
PRESSED_FLAGprotected static final int PRESSED_FLAGFlag for pressed button state- See Also:
 
- 
MOUSEOVER_FLAGprotected static final int MOUSEOVER_FLAGFlag for mouseOver state- See Also:
 
- 
SELECTED_FLAGprotected static final int SELECTED_FLAGFlag for selected button state- See Also:
 
- 
ENABLED_FLAGprotected static final int ENABLED_FLAGFlag for enablement button state- See Also:
 
- 
ROLLOVER_ENABLED_FLAGprotected static final int ROLLOVER_ENABLED_FLAGFlag for rollover enablement button state- See Also:
 
- 
MAX_FLAGprotected static final int MAX_FLAGFlag that can be used by subclasses to define more states- See Also:
 
- 
DEFAULT_FIRING_BEHAVIORpublic static final int DEFAULT_FIRING_BEHAVIORAction performed events are not fired until the mouse button is released.- See Also:
 
- 
REPEAT_FIRING_BEHAVIORpublic static final int REPEAT_FIRING_BEHAVIORAction performed events fire repeatedly until the mouse button is released.- See Also:
 
- 
actionNameThe name of the action associated with this button.
- 
groupThe ButtonGroup this button belongs to (if any).
- 
firingBehaviorprotected org.eclipse.draw2d.ButtonStateTransitionListener firingBehaviorListens to button state transitions and fires action performed events based on the desired behavior (DEFAULT_FIRING_BEHAVIORorREPEAT_FIRING_BEHAVIOR).
 
- 
- 
Constructor Details- 
ButtonModelpublic ButtonModel()
 
- 
- 
Method Details- 
addActionListenerRegisters the given listener as an ActionListener.- Parameters:
- listener- The ActionListener to add
- Since:
- 2.0
 
- 
addChangeListenerRegisters the given listener as a ChangeListener.- Parameters:
- listener- The ChangeListener to add
- Since:
- 2.0
 
- 
addStateTransitionListenerpublic void addStateTransitionListener(org.eclipse.draw2d.ButtonStateTransitionListener listener) Registers the given listener as a ButtonStateTransitionListener.- Parameters:
- listener- The ButtonStateTransitionListener to add
- Since:
- 2.0
 
- 
fireActionPerformedprotected void fireActionPerformed()Notifies any ActionListeners on this ButtonModel that an action has been performed.- Since:
- 2.0
 
- 
fireCanceledprotected void fireCanceled()Notifies any listening ButtonStateTransitionListener that the pressed state of this button has been cancelled.- Since:
- 2.0
 
- 
firePressedprotected void firePressed()Notifies any listening ButtonStateTransitionListener that this button has been pressed.- Since:
- 2.0
 
- 
fireReleasedprotected void fireReleased()Notifies any listening ButtonStateTransitionListener that this button has been released.- Since:
- 2.0
 
- 
fireResumeprotected void fireResume()Notifies any listening ButtonStateTransitionListeners that this button has resumed activity.- Since:
- 2.0
 
- 
fireStateChangedNotifies any listening ChangeListeners that this button's state has changed.- Parameters:
- property- The name of the property that changed
- Since:
- 2.0
 
- 
fireSuspendprotected void fireSuspend()Notifies any listening ButtonStateTransitionListeners that this button has suspended activity.- Since:
- 2.0
 
- 
getGroupReturns the group to which this model belongs.- Returns:
- The ButtonGroup to which this model belongs
- Since:
- 2.0
 
- 
getUserDataReturns an object representing user data.- Returns:
- User data
- Since:
- 2.0
 
- 
installFiringBehaviorprotected void installFiringBehavior()Sets the firing behavior for this button.- Since:
- 2.0
 
- 
isArmedpublic boolean isArmed()Returnstrueif this button is armed. If a button is armed, it will fire an ActionPerformed when released.- Returns:
- trueif this button is armed
- Since:
- 2.0
 
- 
isEnabledpublic boolean isEnabled()Returnstrueif this button is enabled.- Returns:
- trueif this button is enabled
- Since:
- 2.0
 
- 
isMouseOverpublic boolean isMouseOver()Returnstrueif the mouse is over this button.- Returns:
- trueif the mouse is over this button
- Since:
- 2.0
 
- 
isPressedpublic boolean isPressed()Returnstrueif this button is pressed.- Returns:
- trueif this button is pressed
- Since:
- 2.0
 
- 
isSelectedpublic 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:
- trueif this button is selected
- Since:
- 2.0
 
- 
removeActionListenerRemoves the given ActionListener.- Parameters:
- listener- The ActionListener to remove
- Since:
- 2.0
 
- 
removeChangeListenerRemoves the given ChangeListener.- Parameters:
- listener- The ChangeListener to remove
- Since:
- 2.0
 
- 
removeStateTransitionListenerpublic void removeStateTransitionListener(org.eclipse.draw2d.ButtonStateTransitionListener listener) Removes the given ButtonStateTransitionListener.- Parameters:
- listener- The ButtonStateTransitionListener to remove
- Since:
- 2.0
 
- 
setArmedpublic 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
 
- 
setEnabledpublic void setEnabled(boolean value) Sets this button to be enabled.- Parameters:
- value- The enabled state
- Since:
- 2.0
 
- 
setFiringBehaviorpublic void setFiringBehavior(int type) Sets the firing behavior for this button.DEFAULT_FIRING_BEHAVIORis the default behavior, where action performed events are not fired until the mouse button is released.REPEAT_FIRING_BEHAVIORcauses action performed events to fire repeatedly until the mouse button is released.- Parameters:
- type- The firing behavior type
- Since:
- 2.0
 
- 
setGroupSets 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
 
- 
setMouseOverpublic 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
 
- 
setPressedpublic 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
 
- 
setSelectedpublic void setSelected(boolean value) Sets this button to be selected.- Parameters:
- value- The value the selected property will be set to
- Since:
- 2.0
 
- 
setUserDataSets user data.- Parameters:
- data- The user data
- Since:
- 2.0
 
 
-