< prev index next >
src/java.desktop/share/classes/javax/swing/undo/CompoundEdit.java
Print this page
*** 33,49 ****
* @author Ray Ryan
*/
@SuppressWarnings("serial") // Same-version serialization only
public class CompoundEdit extends AbstractUndoableEdit {
/**
! * True if this edit has never received <code>end</code>.
*/
boolean inProgress;
/**
! * The collection of <code>UndoableEdit</code>s
! * undone/redone en masse by this <code>CompoundEdit</code>.
*/
protected Vector<UndoableEdit> edits;
/**
* Constructs a {@code CompoundEdit}.
--- 33,49 ----
* @author Ray Ryan
*/
@SuppressWarnings("serial") // Same-version serialization only
public class CompoundEdit extends AbstractUndoableEdit {
/**
! * True if this edit has never received {@code end}.
*/
boolean inProgress;
/**
! * The collection of {@code UndoableEdit}s
! * undone/redone en masse by this {@code CompoundEdit}.
*/
protected Vector<UndoableEdit> edits;
/**
* Constructs a {@code CompoundEdit}.
*** 53,64 ****
inProgress = true;
edits = new Vector<UndoableEdit>();
}
/**
! * Sends <code>undo</code> to all contained
! * <code>UndoableEdits</code> in the reverse of
* the order in which they were added.
*/
public void undo() throws CannotUndoException {
super.undo();
int i = edits.size();
--- 53,64 ----
inProgress = true;
edits = new Vector<UndoableEdit>();
}
/**
! * Sends {@code undo} to all contained
! * {@code UndoableEdits} in the reverse of
* the order in which they were added.
*/
public void undo() throws CannotUndoException {
super.undo();
int i = edits.size();
*** 67,78 ****
e.undo();
}
}
/**
! * Sends <code>redo</code> to all contained
! * <code>UndoableEdit</code>s in the order in
* which they were added.
*/
public void redo() throws CannotRedoException {
super.redo();
Enumeration<UndoableEdit> cursor = edits.elements();
--- 67,78 ----
e.undo();
}
}
/**
! * Sends {@code redo} to all contained
! * {@code UndoableEdit}s in the order in
* which they were added.
*/
public void redo() throws CannotRedoException {
super.redo();
Enumeration<UndoableEdit> cursor = edits.elements();
*** 80,92 ****
cursor.nextElement().redo();
}
}
/**
! * Returns the last <code>UndoableEdit</code> in
! * <code>edits</code>, or <code>null</code>
! * if <code>edits</code> is empty.
*
* @return the last {@code UndoableEdit} in {@code edits},
* or {@code null} if {@code edits} is empty.
*/
protected UndoableEdit lastEdit() {
--- 80,92 ----
cursor.nextElement().redo();
}
}
/**
! * Returns the last {@code UndoableEdit} in
! * {@code edits}, or {@code null}
! * if {@code edits} is empty.
*
* @return the last {@code UndoableEdit} in {@code edits},
* or {@code null} if {@code edits} is empty.
*/
protected UndoableEdit lastEdit() {
*** 96,106 ****
else
return null;
}
/**
! * Sends <code>die</code> to each subedit,
* in the reverse of the order that they were added.
*/
public void die() {
int size = edits.size();
for (int i = size-1; i >= 0; i--)
--- 96,106 ----
else
return null;
}
/**
! * Sends {@code die} to each subedit,
* in the reverse of the order that they were added.
*/
public void die() {
int size = edits.size();
for (int i = size-1; i >= 0; i--)
*** 112,133 ****
}
super.die();
}
/**
! * If this edit is <code>inProgress</code>,
! * accepts <code>anEdit</code> and returns true.
*
! * <p>The last edit added to this <code>CompoundEdit</code>
! * is given a chance to <code>addEdit(anEdit)</code>.
! * If it refuses (returns false), <code>anEdit</code> is
! * given a chance to <code>replaceEdit</code> the last edit.
! * If <code>anEdit</code> returns false here,
! * it is added to <code>edits</code>.
*
* @param anEdit the edit to be added
! * @return true if the edit is <code>inProgress</code>;
* otherwise returns false
*/
public boolean addEdit(UndoableEdit anEdit) {
if (!inProgress) {
return false;
--- 112,133 ----
}
super.die();
}
/**
! * If this edit is {@code inProgress},
! * accepts {@code anEdit} and returns true.
*
! * <p>The last edit added to this {@code CompoundEdit}
! * is given a chance to {@code addEdit(anEdit)}.
! * If it refuses (returns false), {@code anEdit} is
! * given a chance to {@code replaceEdit} the last edit.
! * If {@code anEdit} returns false here,
! * it is added to {@code edits}.
*
* @param anEdit the edit to be added
! * @return true if the edit is {@code inProgress};
* otherwise returns false
*/
public boolean addEdit(UndoableEdit anEdit) {
if (!inProgress) {
return false;
*** 152,182 ****
return true;
}
}
/**
! * Sets <code>inProgress</code> to false.
*
* @see #canUndo
* @see #canRedo
*/
public void end() {
inProgress = false;
}
/**
! * Returns false if <code>isInProgress</code> or if super
* returns false.
*
* @see #isInProgress
*/
public boolean canUndo() {
return !isInProgress() && super.canUndo();
}
/**
! * Returns false if <code>isInProgress</code> or if super
* returns false.
*
* @see #isInProgress
*/
public boolean canRedo() {
--- 152,182 ----
return true;
}
}
/**
! * Sets {@code inProgress} to false.
*
* @see #canUndo
* @see #canRedo
*/
public void end() {
inProgress = false;
}
/**
! * Returns false if {@code isInProgress} or if super
* returns false.
*
* @see #isInProgress
*/
public boolean canUndo() {
return !isInProgress() && super.canUndo();
}
/**
! * Returns false if {@code isInProgress} or if super
* returns false.
*
* @see #isInProgress
*/
public boolean canRedo() {
*** 194,205 ****
public boolean isInProgress() {
return inProgress;
}
/**
! * Returns true if any of the <code>UndoableEdit</code>s
! * in <code>edits</code> do.
* Returns false if they all return false.
*/
public boolean isSignificant() {
Enumeration<UndoableEdit> cursor = edits.elements();
while (cursor.hasMoreElements()) {
--- 194,205 ----
public boolean isInProgress() {
return inProgress;
}
/**
! * Returns true if any of the {@code UndoableEdit}s
! * in {@code edits} do.
* Returns false if they all return false.
*/
public boolean isSignificant() {
Enumeration<UndoableEdit> cursor = edits.elements();
while (cursor.hasMoreElements()) {
*** 209,221 ****
}
return false;
}
/**
! * Returns <code>getPresentationName</code> from the
! * last <code>UndoableEdit</code> added to
! * <code>edits</code>. If <code>edits</code> is empty,
* calls super.
*/
public String getPresentationName() {
UndoableEdit last = lastEdit();
if (last != null) {
--- 209,221 ----
}
return false;
}
/**
! * Returns {@code getPresentationName} from the
! * last {@code UndoableEdit} added to
! * {@code edits}. If {@code edits} is empty,
* calls super.
*/
public String getPresentationName() {
UndoableEdit last = lastEdit();
if (last != null) {
*** 224,237 ****
return super.getPresentationName();
}
}
/**
! * Returns <code>getUndoPresentationName</code>
! * from the last <code>UndoableEdit</code>
! * added to <code>edits</code>.
! * If <code>edits</code> is empty, calls super.
*/
public String getUndoPresentationName() {
UndoableEdit last = lastEdit();
if (last != null) {
return last.getUndoPresentationName();
--- 224,237 ----
return super.getPresentationName();
}
}
/**
! * Returns {@code getUndoPresentationName}
! * from the last {@code UndoableEdit}
! * added to {@code edits}.
! * If {@code edits} is empty, calls super.
*/
public String getUndoPresentationName() {
UndoableEdit last = lastEdit();
if (last != null) {
return last.getUndoPresentationName();
*** 239,252 ****
return super.getUndoPresentationName();
}
}
/**
! * Returns <code>getRedoPresentationName</code>
! * from the last <code>UndoableEdit</code>
! * added to <code>edits</code>.
! * If <code>edits</code> is empty, calls super.
*/
public String getRedoPresentationName() {
UndoableEdit last = lastEdit();
if (last != null) {
return last.getRedoPresentationName();
--- 239,252 ----
return super.getUndoPresentationName();
}
}
/**
! * Returns {@code getRedoPresentationName}
! * from the last {@code UndoableEdit}
! * added to {@code edits}.
! * If {@code edits} is empty, calls super.
*/
public String getRedoPresentationName() {
UndoableEdit last = lastEdit();
if (last != null) {
return last.getRedoPresentationName();
< prev index next >