public final class UndoRedo
extends java.lang.Object
Chart FX keeps a list of actions that were performed on the chart by the user. If the user decides the last (or more) actions are no longer desired, the undo
method can be called. After performing an Undo, the redo
method can be called to redo the action.
Besides using the API, the undo/redo can be controlled by the toolbar of the chart.
Constructor and Description |
---|
UndoRedo() |
Modifier and Type | Method and Description |
---|---|
boolean |
beginOperation()
Start a list of actions to be grouped in one operation, for undo/redo purposes.
|
boolean |
cancelOperation()
Cancels a list of actions to be grouped in one operation for undo/redo purposes.
|
void |
clearHistory()
Clears the list of actions done to the chart by the user.
|
boolean |
endOperation(java.lang.String description)
Ends a list of actions to be grouped in one operation, for undo/redo purposes.
|
boolean |
isCanRedo()
Gets a boolean corresponding to whether or not there are any actions to redo.
|
boolean |
isCanUndo()
Gets a boolean corresponding to whether or not there are any actions to undo.
|
boolean |
isEnabled()
Gets or sets a boolean that indicates whether or not undo and redo actions are allowed in the chart.
|
void |
redo()
Redoes the last action undone by the Undo method.
|
void |
resetEnabled()
Set the property Enabled to its default value.
|
void |
setEnabled(boolean value)
Gets or sets a boolean that indicates whether or not undo and redo actions are allowed in the chart.
|
void |
undo()
Undoes the last action performed by the user.
|
public boolean isCanRedo()
if (chart1.getUndoRedo().getCanRedo()); { chart1.getUndoRedo().Redo(); }
public boolean isCanUndo()
if (chart1.getUndoRedo().getCanUndo()); { chart1.getUndoRedo().Undo(); }
public boolean isEnabled()
chart1.getUndoRedo().setEnabled(false);
chart1.getToolBar().removeAt(chart1.getToolBar().FindCommand(CommandId.Undo)); chart1.getToolBar().removeAt(chart1.getToolBar().FindCommand(CommandId.Redo));
resetEnabled
public void setEnabled(boolean value)
chart1.getUndoRedo().setEnabled(false);
chart1.getToolBar().removeAt(chart1.getToolBar().FindCommand(CommandId.Undo)); chart1.getToolBar().removeAt(chart1.getToolBar().FindCommand(CommandId.Redo));
value
- resetEnabled
public boolean beginOperation()
Start a list of actions to be grouped in one operation, for undo/redo purposes.
Modifying the chart through the API cannot be undone using the undo
method or the undo button on the toolbar. To allow the user to undo actions that were executed using the API, you must preceed the actions with this method and end them with the endOperation
method.
Multple actions can be grouped in one operation that can be undone or redone with one call to Undo or redo
methods. This method starts one operation.
endOperation
method needs to be called once all the actions for the operation have been executed.
This method returns a boolean allowing the developer to know whether or not the operation was created. If UndoRedo is not enabled, this method will return false. If this method is called twice before a EndOperation is called, it will return false.
To change the chart to a 3D bar chart, allowing the end user to revert those changes:
chart1.getUndoRedo().BeginOperation(); chart1.setGallery(Gallery.BAR); chart1.getView3D().setEnabled(true); chart1.getUndoRedo().EndOperation(((java.lang.String)null));
public boolean cancelOperation()
This method should be called after BeginOperation is called, if a list of action is no longer desired.
This method returns a boolean. If Redo/Undo is not enabled, the result will be false. If this method is called without first calling BeginOperation, the result will be false.
Canceling the operation.
chart1.getUndoRedo().CancelOperation();
public void clearHistory()
If UndoRedo is Enabled, a list of user actions are kept by the chart. Invoking this method clears the list.
To clear the undo/redo history:
chart1.getUndoRedo().ClearHistory();
public boolean endOperation(java.lang.String description)
Modifying the chart through the API cannot be undone using the undo
method or the undo button on the toolbar. To allow the user to undo actions that were executed using the API, you must preceed the actions with the beginOperation
method and end them with this method.
Multple actions can be grouped in one operation that can be undone or redone with one call to Undo or redo
methods. This method closes one operation.
This method should only be called after calling BeginOperation.
This method returns a boolean. If Redo/Undo is not enabled, the result will be false. If this method is called without first calling BeginOperation, the result will be false.
This method takes a string as a parameter for debug only. Null is the recommended value.
To change the chart to a 3D bar chart, allowing the end user to revert those changes:
chart1.getUndoRedo().BeginOperation(); chart1.setGallery(Gallery.BAR); chart1.getView3D().setEnabled(true); chart1.getUndoRedo().EndOperation(((java.lang.String)null));
description
- For debug only.public void redo()
Redoes the last action undone by the Undo method.
This method is useful when an action was undone by mistake.
The boolean method CanRedo can be checked before invoking this method.
Actions performed through the API cannot be undone by this method by default. To enable this, you must preceed the actions with the beginOperation
method and finish it calling the endOperation
method.
Calling the redo
method only if a redo is possible:
if (chart1.getUndoRedo().getCanRedo()); { chart1.getUndoRedo().Redo(); }
public void resetEnabled()
isEnabled
public void undo()
Undoes the last action performed by the user.
This is a very useful tool to recover the chart's status after performing an action by mistake.
The boolean method CanUndo can be checked before invoking this method.
Actions performed through the API cannot be undone by this method by default. To enable this, you must preceed the actions with the beginOperation
method and finish it calling the endOperation
method.
Calling the undo
method only if an undo is possible:
if (chart1.getUndoRedo().getCanUndo()); { chart1.getUndoRedo().Undo(); }
2014 Software FX, Inc. All Rights Reserved. Chart FX is a registered trademark of Software FX, Inc
All other names are trademarks or registered trademarks of their respective owners.