Java Reference
In-Depth Information
AbstractUndoableEdit Class
The AbstractUndoableEdit class provides a default implementation for all the methods of the
UndoableEdit interface. Although you might guess from the name that the class is abstract, it
isn't. However, developers tend to work with subclasses of the class, not with a direct instance
of this class.
By default, AbstractUndoableEdit commands are significant (where isSignificant()
returns true ). What significance you place on the significant property setting depends on
your usage of the command. In addition, the class restricts repetition of undoable state changes.
Unless overridden by a subclass, exceptions are thrown if you try to redo something in the
Undoable state or undo something in the Redoable state. The class doesn't support adding or
replacing UndoableEdit operations.
The default presentation names for the undoPresentationName and redoPresentationName
properties are Undo and Redo, respectively. These are found by looking up the UIResource -
related properties shown in Table 21-1. There is no default for the presentationName property.
Subclasses should provide at least a presentation name to provide something more meaningful
than the default settings.
Table 21-1. AbstractUndoableEdit UIResource Elements
Property String
Object Type
AbstractUndoableEdit.undoText
String
AbstractUndoableEdit.redoText
String
Tip By having the Undo and Redo presentation names as UIResource elements, they can be translated
to foreign languages, with their new text available in the same way as other UIResource elements.
CompoundEdit Class
The CompoundEdit class allows you to combine multiple undoable operations into a single
operation. For instance, you may want to combine all the keystrokes for typing a whole word
into a single CompoundEdit command. This would allow you to continuously redo the typing of
a whole word in multiple places. Without combining the separate keystrokes, redoing the last
command would redo only the last single keystroke.
The CompoundEdit class uses a read-only inProgress property to report whether the command
is still being combined. Initially, the property is true . When in progress, additional commands
can be added to the compound command with addEdit(UndoableEdit) . To mark the end of a
set of commands, you call the end() method. Only after you combine all the commands can
they be undone or redone. Figure 21-3 illustrates this.
 
Search WWH ::




Custom Search