Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class ComponentEdit
- Object
- UndoableEdit
- 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");
}
}));Constructors
public ComponentEdit(Component component, UndoableEdit edit) | Wraps an edit made through a component. |
Methods
public Component getComponent() | The component the edit was made in. |
public UndoableEdit getEdit() | The wrapped edit. |
public void undo() | Takes the change back. |
public void redo() | Makes the change again, after undo. |
public String getName() | A short name for the change, such as “Move” or “Delete”, for an “Undo Move” menu item. |
public boolean isAlive() | False once what this edit changes can no longer take it, for instance after the component it was made in was given another document. |
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. |
Inherited methods
Constructor details
ComponentEdit
public ComponentEdit(Component component, UndoableEdit edit)Wraps an edit made through a component.
Parameters
componentComponent- the component the edit was made in
editUndoableEdit- the edit itself
Method details
getComponent
public Component getComponent()The component the edit was made in.
getEdit
public UndoableEdit getEdit()The wrapped edit.
undo
public void undo()Takes the change back.
redo
public void redo()Makes the change again, after
undo.getName
public String getName()A short name for the change, such as “Move” or “Delete”, for an “Undo
Move” menu item. Null by default.
isAlive
public boolean isAlive()False 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.
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.