Class AbstractDocument.DefaultDocumentEvent
java.lang.Object
javax.swing.undo.AbstractUndoableEdit
javax.swing.undo.CompoundEdit
javax.swing.text.AbstractDocument.DefaultDocumentEvent
- All Implemented Interfaces:
Serializable, DocumentEvent, UndoableEdit
- Enclosing class:
AbstractDocument
Stores document changes as the document is being
modified. Can subsequently be used for change notification
when done with the document modification transaction.
This is used by the AbstractDocument class and its extensions
for broadcasting change information to the document listeners.
-
Nested Class Summary
Nested classes/interfaces declared in interface DocumentEvent
DocumentEvent.ElementChange, DocumentEvent.EventTypeModifier and TypeInterfaceDescriptionstatic interfaceDescribes changes made to a specific element.static final classEnumeration for document event types -
Field Summary
Fields declared in class CompoundEdit
editsModifier and TypeFieldDescriptionprotected Vector<UndoableEdit> The collection ofUndoableEdits undone/redone en masse by thisCompoundEdit.Fields declared in class AbstractUndoableEdit
RedoName, UndoNameModifier and TypeFieldDescriptionprotected static final StringString returned bygetRedoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.protected static final StringString returned bygetUndoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultDocumentEvent(int offs, int len, DocumentEvent.EventType type) Constructs a change record. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddEdit(UndoableEdit anEdit) Adds a document edit.Gets the changes for an element.Gets the document that sourced the change event.intReturns the length of the change.intReturns the offset within the document of the start of the change.Provides a localized, human readable description of this edit suitable for use in, say, a change log.Provides a localized, human readable description of the redoable form of this edit, e.g. for use as a Redo menu item.getType()Returns the type of event.Provides a localized, human readable description of the undoable form of this edit, e.g. for use as an Undo menu item.booleanDefaultDocument events are significant.voidredo()Redoes a change.toString()Returns a string description of the change event.voidundo()Undoes a change.Methods declared in class CompoundEdit
canRedo, canUndo, die, end, isInProgress, lastEditModifier and TypeMethodDescriptionbooleancanRedo()Returns false ifisInProgressor if super returns false.booleancanUndo()Returns false ifisInProgressor if super returns false.voiddie()Sendsdieto each subedit, in the reverse of the order that they were added.voidend()SetsinProgressto false.booleanReturns true if this edit is in progress--that is, it has not received end.protected UndoableEditlastEdit()Returns the lastUndoableEditinedits, ornullifeditsis empty.Methods declared in class AbstractUndoableEdit
replaceEditModifier and TypeMethodDescriptionbooleanreplaceEdit(UndoableEdit anEdit) This default implementation returns false.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
DefaultDocumentEvent
Constructs a change record.- Parameters:
offs- the offset into the document of the change >= 0len- the length of the change >= 0type- the type of event (DocumentEvent.EventType)- Since:
- 1.4
-
-
Method Details
-
toString
Returns a string description of the change event.- Overrides:
toStringin classCompoundEdit- Returns:
- a string
-
addEdit
Adds a document edit. If the number of edits crosses a threshold, this switches on a hashtable lookup for ElementChange implementations since access of these needs to be relatively quick.- Specified by:
addEditin interfaceUndoableEdit- Overrides:
addEditin classCompoundEdit- Parameters:
anEdit- a document edit record- Returns:
- true if the edit was added
- See Also:
-
redo
Redoes a change.- Specified by:
redoin interfaceUndoableEdit- Overrides:
redoin classCompoundEdit- Throws:
CannotRedoException- if the change cannot be redone- See Also:
-
undo
Undoes a change.- Specified by:
undoin interfaceUndoableEdit- Overrides:
undoin classCompoundEdit- Throws:
CannotUndoException- if the change cannot be undone- See Also:
-
isSignificant
public boolean isSignificant()DefaultDocument events are significant. If you wish to aggregate DefaultDocumentEvents to present them as a single edit to the user place them into a CompoundEdit.- Specified by:
isSignificantin interfaceUndoableEdit- Overrides:
isSignificantin classCompoundEdit- Returns:
- whether the event is significant for edit undo purposes
- See Also:
-
getPresentationName
Provides a localized, human readable description of this edit suitable for use in, say, a change log.- Specified by:
getPresentationNamein interfaceUndoableEdit- Overrides:
getPresentationNamein classCompoundEdit- Returns:
- the description
- See Also:
-
getUndoPresentationName
Provides a localized, human readable description of the undoable form of this edit, e.g. for use as an Undo menu item. Typically derived from getDescription();- Specified by:
getUndoPresentationNamein interfaceUndoableEdit- Overrides:
getUndoPresentationNamein classCompoundEdit- Returns:
- the description
- See Also:
-
getRedoPresentationName
Provides a localized, human readable description of the redoable form of this edit, e.g. for use as a Redo menu item. Typically derived from getPresentationName();- Specified by:
getRedoPresentationNamein interfaceUndoableEdit- Overrides:
getRedoPresentationNamein classCompoundEdit- Returns:
- the description
- See Also:
-
getType
Returns the type of event.- Specified by:
getTypein interfaceDocumentEvent- Returns:
- the event type as a DocumentEvent.EventType
- See Also:
-
getOffset
public int getOffset()Returns the offset within the document of the start of the change.- Specified by:
getOffsetin interfaceDocumentEvent- Returns:
- the offset >= 0
- See Also:
-
getLength
public int getLength()Returns the length of the change.- Specified by:
getLengthin interfaceDocumentEvent- Returns:
- the length >= 0
- See Also:
-
getDocument
Gets the document that sourced the change event.- Specified by:
getDocumentin interfaceDocumentEvent- Returns:
- the document
- See Also:
-
getChange
Gets the changes for an element.- Specified by:
getChangein interfaceDocumentEvent- Parameters:
elem- the element- Returns:
- the changes
-