Class ComponentEdit
java.lang.Object
com.codename1.util.UndoableEdit
com.codename1.ui.ComponentEdit
An edit made through a component, which brings that component back into view when it is undone or redone.
The history (com.codename1.util.UndoHistory) knows nothing about
components; this wrapper is what ties a step to one. When the step is
replayed and the component is on the form being shown, the component takes
the focus, if it can, and is scrolled into view, so the user sees what
changed. An edit made on another form is still replayed, without switching
forms.
Components that support undo wrap their own edits this way. An application recording its own edits wraps them the same way:
TextField field = new TextField("Draft");
field.setText("Final");
UndoHistory.getGlobal().record(new ComponentEdit(field, new UndoableEdit() {
public void undo() {
field.setText("Draft");
}
public void redo() {
field.setText("Final");
}
}));
-
Constructor Summary
ConstructorsConstructorDescriptionComponentEdit(Component component, UndoableEdit edit) Wraps an edit made through a component. -
Method Summary
Modifier and TypeMethodDescriptionThe component the edit was made in.getEdit()The wrapped edit.getName()A short name for the change, such as "Move" or "Delete", for an "Undo Move" menu item.booleanisAlive()False once what this edit changes can no longer take it, for instance after the component it was made in was given another document.voidredo()Makes the change again, afterundo.protected voidreveal()Brings the component into view when it is on the form being shown: gives it the focus if it can take it and scrolls it into view.voidundo()Takes the change back.
-
Constructor Details
-
ComponentEdit
Wraps an edit made through a component.
Parameters
-
component: the component the edit was made in -
edit: the edit itself
-
-
-
Method Details
-
getComponent
The component the edit was made in. -
getEdit
The wrapped edit. -
undo
public void undo()Description copied from class:UndoableEditTakes the change back.- Specified by:
undoin classUndoableEdit
-
redo
public void redo()Description copied from class:UndoableEditMakes the change again, afterundo.- Specified by:
redoin classUndoableEdit
-
getName
Description copied from class:UndoableEditA short name for the change, such as "Move" or "Delete", for an "Undo Move" menu item. Null by default.- Overrides:
getNamein classUndoableEdit
-
isAlive
public boolean isAlive()Description copied from class:UndoableEditFalse once what this edit changes can no longer take it, for instance after the component it was made in was given another document. A history passes over such an edit and forgets it. True by default.- Overrides:
isAlivein classUndoableEdit
-
reveal
protected void reveal()Brings the component into view when it is on the form being shown: gives it the focus if it can take it and scrolls it into view.
-