jdk/src/java.desktop/share/classes/javax/swing/undo/CompoundEdit.java
author darcy
Fri, 03 Apr 2015 10:41:34 -0700
changeset 29894 3e16b51732f5
parent 25859 3317bb8137f4
permissions -rw-r--r--
8076520: Fix missing doclint warnings in javax.swing.{table, tree, undo, plaf.{metal, nimbus, synth}} Reviewed-by: alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
29894
3e16b51732f5 8076520: Fix missing doclint warnings in javax.swing.{table, tree, undo, plaf.{metal, nimbus, synth}}
darcy
parents: 25859
diff changeset
     2
 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1843
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1843
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1843
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1843
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1843
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing.undo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * A concrete subclass of AbstractUndoableEdit, used to assemble little
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * UndoableEdits into great big ones.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * @author Ray Ryan
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 5506
diff changeset
    35
@SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
public class CompoundEdit extends AbstractUndoableEdit {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
     * True if this edit has never received <code>end</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    boolean inProgress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     * The collection of <code>UndoableEdit</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * undone/redone en masse by this <code>CompoundEdit</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    protected Vector<UndoableEdit> edits;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
29894
3e16b51732f5 8076520: Fix missing doclint warnings in javax.swing.{table, tree, undo, plaf.{metal, nimbus, synth}}
darcy
parents: 25859
diff changeset
    48
    /**
3e16b51732f5 8076520: Fix missing doclint warnings in javax.swing.{table, tree, undo, plaf.{metal, nimbus, synth}}
darcy
parents: 25859
diff changeset
    49
     * Constructs a {@code CompoundEdit}.
3e16b51732f5 8076520: Fix missing doclint warnings in javax.swing.{table, tree, undo, plaf.{metal, nimbus, synth}}
darcy
parents: 25859
diff changeset
    50
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    public CompoundEdit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        inProgress = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        edits = new Vector<UndoableEdit>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * Sends <code>undo</code> to all contained
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * <code>UndoableEdits</code> in the reverse of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * the order in which they were added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public void undo() throws CannotUndoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        super.undo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        int i = edits.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        while (i-- > 0) {
1843
267cc4de4221 6776095: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
    66
            UndoableEdit e = edits.elementAt(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            e.undo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Sends <code>redo</code> to all contained
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * <code>UndoableEdit</code>s in the order in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * which they were added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    public void redo() throws CannotRedoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        super.redo();
25568
b906a74c6882 8043550: Fix raw and unchecked lint warnings in javax.swing.*
darcy
parents: 24495
diff changeset
    78
        Enumeration<UndoableEdit> cursor = edits.elements();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        while (cursor.hasMoreElements()) {
25568
b906a74c6882 8043550: Fix raw and unchecked lint warnings in javax.swing.*
darcy
parents: 24495
diff changeset
    80
            cursor.nextElement().redo();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Returns the last <code>UndoableEdit</code> in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * <code>edits</code>, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * if <code>edits</code> is empty.
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 23697
diff changeset
    88
     *
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 23697
diff changeset
    89
     * @return the last {@code UndoableEdit} in {@code edits},
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 23697
diff changeset
    90
     *         or {@code null} if {@code edits} is empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    protected UndoableEdit lastEdit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        int count = edits.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        if (count > 0)
1843
267cc4de4221 6776095: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
    95
            return edits.elementAt(count-1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Sends <code>die</code> to each subedit,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * in the reverse of the order that they were added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public void die() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        int size = edits.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        for (int i = size-1; i >= 0; i--)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        {
1843
267cc4de4221 6776095: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   108
            UndoableEdit e = edits.elementAt(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
//          System.out.println("CompoundEdit(" + i + "): Discarding " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
//                             e.getUndoPresentationName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            e.die();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        super.die();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * If this edit is <code>inProgress</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * accepts <code>anEdit</code> and returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * <p>The last edit added to this <code>CompoundEdit</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * is given a chance to <code>addEdit(anEdit)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * If it refuses (returns false), <code>anEdit</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * given a chance to <code>replaceEdit</code> the last edit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * If <code>anEdit</code> returns false here,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * it is added to <code>edits</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @param anEdit the edit to be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @return true if the edit is <code>inProgress</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *  otherwise returns false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    public boolean addEdit(UndoableEdit anEdit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (!inProgress) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            UndoableEdit last = lastEdit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            // If this is the first subedit received, just add it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            // Otherwise, give the last one a chance to absorb the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            // one.  If it won't, give the new one a chance to absorb
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            // the last one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            if (last == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                edits.addElement(anEdit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            else if (!last.addEdit(anEdit)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                if (anEdit.replaceEdit(last)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                    edits.removeElementAt(edits.size()-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                edits.addElement(anEdit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Sets <code>inProgress</code> to false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @see #canUndo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @see #canRedo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    public void end() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        inProgress = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * Returns false if <code>isInProgress</code> or if super
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * returns false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @see     #isInProgress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public boolean canUndo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return !isInProgress() && super.canUndo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * Returns false if <code>isInProgress</code> or if super
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * returns false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @see     #isInProgress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    public boolean canRedo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        return !isInProgress() && super.canRedo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Returns true if this edit is in progress--that is, it has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * received end. This generally means that edits are still being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * added to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *
24495
a5c854a00679 8042089: Fix doclint warnings from javax.swing.tree and javax.swing.undo packages
yan
parents: 23697
diff changeset
   191
     * @return  whether this edit is in progress
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @see     #end
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public boolean isInProgress() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        return inProgress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * Returns true if any of the <code>UndoableEdit</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * in <code>edits</code> do.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * Returns false if they all return false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public boolean  isSignificant() {
25568
b906a74c6882 8043550: Fix raw and unchecked lint warnings in javax.swing.*
darcy
parents: 24495
diff changeset
   204
        Enumeration<UndoableEdit> cursor = edits.elements();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        while (cursor.hasMoreElements()) {
25568
b906a74c6882 8043550: Fix raw and unchecked lint warnings in javax.swing.*
darcy
parents: 24495
diff changeset
   206
            if (cursor.nextElement().isSignificant()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * Returns <code>getPresentationName</code> from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * last <code>UndoableEdit</code> added to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * <code>edits</code>. If <code>edits</code> is empty,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * calls super.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public String getPresentationName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        UndoableEdit last = lastEdit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        if (last != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            return last.getPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            return super.getPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * Returns <code>getUndoPresentationName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * from the last <code>UndoableEdit</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * added to <code>edits</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * If <code>edits</code> is empty, calls super.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public String getUndoPresentationName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        UndoableEdit last = lastEdit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        if (last != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            return last.getUndoPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            return super.getUndoPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * Returns <code>getRedoPresentationName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * from the last <code>UndoableEdit</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * added to <code>edits</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * If <code>edits</code> is empty, calls super.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    public String getRedoPresentationName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        UndoableEdit last = lastEdit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        if (last != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            return last.getRedoPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            return super.getRedoPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * Returns a string that displays and identifies this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * object's properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @return a String representation of this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    public String toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        return super.toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            + " inProgress: " + inProgress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            + " edits: " + edits;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
}