jdk/src/share/classes/javax/swing/undo/CompoundEdit.java
author darcy
Sun, 23 Mar 2014 13:49:48 -0700
changeset 23697 e556a715949f
parent 5506 202f599c92aa
child 24495 a5c854a00679
permissions -rw-r--r--
8034169: Fix serial lint warnings in javax.swing Reviewed-by: alanb, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 5506
diff changeset
     2
 * Copyright (c) 1997, 2014, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    public CompoundEdit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        inProgress = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        edits = new Vector<UndoableEdit>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * Sends <code>undo</code> to all contained
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * <code>UndoableEdits</code> in the reverse of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * the order in which they were added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public void undo() throws CannotUndoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        super.undo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        int i = edits.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        while (i-- > 0) {
1843
267cc4de4221 6776095: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
    63
            UndoableEdit e = edits.elementAt(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
            e.undo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Sends <code>redo</code> to all contained
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * <code>UndoableEdit</code>s in the order in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * which they were added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public void redo() throws CannotRedoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        super.redo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        Enumeration cursor = edits.elements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        while (cursor.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            ((UndoableEdit)cursor.nextElement()).redo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Returns the last <code>UndoableEdit</code> in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * <code>edits</code>, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * if <code>edits</code> is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    protected UndoableEdit lastEdit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        int count = edits.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        if (count > 0)
1843
267cc4de4221 6776095: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
    89
            return edits.elementAt(count-1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Sends <code>die</code> to each subedit,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * in the reverse of the order that they were added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public void die() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        int size = edits.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        for (int i = size-1; i >= 0; i--)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        {
1843
267cc4de4221 6776095: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   102
            UndoableEdit e = edits.elementAt(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
//          System.out.println("CompoundEdit(" + i + "): Discarding " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
//                             e.getUndoPresentationName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            e.die();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        super.die();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * If this edit is <code>inProgress</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * accepts <code>anEdit</code> and returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * <p>The last edit added to this <code>CompoundEdit</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * is given a chance to <code>addEdit(anEdit)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * If it refuses (returns false), <code>anEdit</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * given a chance to <code>replaceEdit</code> the last edit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * If <code>anEdit</code> returns false here,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * it is added to <code>edits</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @param anEdit the edit to be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @return true if the edit is <code>inProgress</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *  otherwise returns false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public boolean addEdit(UndoableEdit anEdit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        if (!inProgress) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            UndoableEdit last = lastEdit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            // If this is the first subedit received, just add it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            // Otherwise, give the last one a chance to absorb the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            // one.  If it won't, give the new one a chance to absorb
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            // the last one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            if (last == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                edits.addElement(anEdit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            else if (!last.addEdit(anEdit)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                if (anEdit.replaceEdit(last)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                    edits.removeElementAt(edits.size()-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                }
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * Sets <code>inProgress</code> to false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @see #canUndo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @see #canRedo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public void end() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        inProgress = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * Returns false if <code>isInProgress</code> or if super
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * returns false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @see     #isInProgress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    public boolean canUndo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        return !isInProgress() && super.canUndo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * Returns false if <code>isInProgress</code> or if super
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * returns false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @see     #isInProgress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public boolean canRedo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        return !isInProgress() && super.canRedo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Returns true if this edit is in progress--that is, it has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * received end. This generally means that edits are still being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * added to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @see     #end
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    public boolean isInProgress() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        return inProgress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * Returns true if any of the <code>UndoableEdit</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * in <code>edits</code> do.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Returns false if they all return false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    public boolean  isSignificant() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        Enumeration cursor = edits.elements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        while (cursor.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            if (((UndoableEdit)cursor.nextElement()).isSignificant()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * Returns <code>getPresentationName</code> from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * last <code>UndoableEdit</code> added to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * <code>edits</code>. If <code>edits</code> is empty,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * calls super.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    public String getPresentationName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        UndoableEdit last = lastEdit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if (last != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            return last.getPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            return super.getPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Returns <code>getUndoPresentationName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * from the last <code>UndoableEdit</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * added to <code>edits</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * If <code>edits</code> is empty, calls super.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    public String getUndoPresentationName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        UndoableEdit last = lastEdit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        if (last != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            return last.getUndoPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            return super.getUndoPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * Returns <code>getRedoPresentationName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * from the last <code>UndoableEdit</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * added to <code>edits</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * If <code>edits</code> is empty, calls super.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    public String getRedoPresentationName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        UndoableEdit last = lastEdit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        if (last != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            return last.getRedoPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            return super.getRedoPresentationName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * Returns a string that displays and identifies this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * object's properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @return a String representation of this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public String toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        return super.toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            + " inProgress: " + inProgress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            + " edits: " + edits;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
}