org.eclipse.rse.ui.widgets
Class SystemEditPaneStateMachine
java.lang.Object
org.eclipse.rse.ui.widgets.SystemEditPaneStateMachine
-
public class SystemEditPaneStateMachine
- extends
Object
This class encapsulates the states an edit page (with apply/reset buttons)
can go through and handle managing the state transitions. For example, it manages
the enabled/disabled state of the apply/reset buttons.
There are three modes supported:
- New -> user is creating a "new thing". In this state, the apply button label is
"New", and the reset button is hidden
- Edit -> user is editing an existing thing. The apply and reset buttons have usual labels
- Unset -> overall composite is hidden
In addition to the modes, there are these
states supported
- No changes -> the apply and reset buttons are disabled
- Changes pending -> the apply and reset buttons are enabled
- Changes made -> the apply and reset buttons are disabled
There are constants for these modes and states in
ISystemEditPaneStates
To use this properly, call the following methods at the appropriate times:
-
setNewMode()
-> when users selects to create a new thing.
-
setEditMode()
-> when user selects to edit an existing thing.
-
setUnsetMode()
-> when user selects nothing or something not editable
-
setChangesMade()
-> when user changes anything in the pane!
-
isSaveRequired()
-> if changes are pending, this will prompt the user if they wish to save the
changes or discard the changes. Returns true or false.
-
applyPressed()
-> when user successfully presses apply
-
resetPressed()
-> when user successfully presses reset
Methods inherited from class java.lang.
Object
|
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
|
SystemEditPaneStateMachine
public SystemEditPaneStateMachine(
Composite composite,
Button applyButton,
Button resetButton)
- Constructor for SystemEditPaneStateMachine.
This constructor sets the initial mode to MODE_UNSET.
While this class will handle enabling/disabling the apply/reset buttons,
it is still your job to add listeners and actually do the applying and resetting!
-
Parameters:
-
composite
- - overall composite of the edit pane -
applyButton
- - the Apply pushbutton -
resetButton
- - the Reset pushbutton. Can be null.
setApplyLabelForNewMode
public void setApplyLabelForNewMode(
String label,
String tooltip)
- Set the label and tooltip to use for the apply button in "new" mode.
By default, generic values are used
-
setNewMode
public void setNewMode()
- Set the mode to "New". User has selected "new" and wants to create a new thing.
It is your responsibility to call
isSaveRequired()
first.
It is assumed that after the object is created by pressing Apply, your UI will
select the new object and then call setEditMode
-
setEditMode
public void setEditMode()
- Set the mode to "Edit". User has selected an existing object and wants to changed/edit it
It is your responsibility to call
isSaveRequired()
first.
-
setUnsetMode
public void setUnsetMode()
- Set the mode to "Unset". User has selected nothing or something not editable
It is your responsibility to call
isSaveRequired()
first.
-
setChangesMade
public void setChangesMade()
- User has made changes, such as typing text or selecting a checkbox or radio button.
It is VERY important this be called religiously for every possible change the user can make!
-
isSaveRequired
public boolean isSaveRequired()
- Query if it is ok to switch modes.
If no changes pending, returns false
If changes pending, user is asked to whether to save (true) or discard (false).
-
applyPressed
public void applyPressed()
- User has successfully pressed Apply (that is, no errors found)
-
resetPressed
public void resetPressed()
- User has successfully pressed Reset (that is, no errors found)
-
areChangesPending
public boolean areChangesPending()
- Are any changes pending?
-
getResetButton
public
Button getResetButton()
- Returns the resetButton.
-
-
Returns:
- Button
getApplyButton
public
Button getApplyButton()
- Returns the applyButton.
-
-
Returns:
- Button
getComposite
public
Composite getComposite()
- Returns the composite.
-
-
Returns:
- Composite
getMode
public int getMode()
- Returns the mode.
-
-
Returns:
- int
-
See Also:
-
ISystemEditPaneStates
getState
public int getState()
- Returns the state.
-
-
Returns:
- int
-
See Also:
-
ISystemEditPaneStates
setNewSetByDelete
public void setNewSetByDelete(boolean newSetByDelete)
-
getNewSetByDelete
public boolean getNewSetByDelete()
-
backup
public void backup()
- Backup state method
-
restore
public void restore()
- Restore state method
-
Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.