1 | /* AbstractTableModel.java --
|
---|
2 | Copyright (C) 2002 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This file is part of GNU Classpath.
|
---|
5 |
|
---|
6 | GNU Classpath is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | any later version.
|
---|
10 |
|
---|
11 | GNU Classpath is distributed in the hope that it will be useful, but
|
---|
12 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
14 | General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with GNU Classpath; see the file COPYING. If not, write to the
|
---|
18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
---|
19 | 02111-1307 USA.
|
---|
20 |
|
---|
21 | Linking this library statically or dynamically with other modules is
|
---|
22 | making a combined work based on this library. Thus, the terms and
|
---|
23 | conditions of the GNU General Public License cover the whole
|
---|
24 | combination.
|
---|
25 |
|
---|
26 | As a special exception, the copyright holders of this library give you
|
---|
27 | permission to link this library with independent modules to produce an
|
---|
28 | executable, regardless of the license terms of these independent
|
---|
29 | modules, and to copy and distribute the resulting executable under
|
---|
30 | terms of your choice, provided that you also meet, for each linked
|
---|
31 | independent module, the terms and conditions of the license of that
|
---|
32 | module. An independent module is a module which is not derived from
|
---|
33 | or based on this library. If you modify this library, you may extend
|
---|
34 | this exception to your version of the library, but you are not
|
---|
35 | obligated to do so. If you do not wish to do so, delete this
|
---|
36 | exception statement from your version. */
|
---|
37 |
|
---|
38 | package javax.swing.undo;
|
---|
39 |
|
---|
40 | // Imports
|
---|
41 | import java.io.Serializable;
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * AbstractUndoableEdit
|
---|
45 | * @author Andrew Selkirk
|
---|
46 | */
|
---|
47 | public class AbstractUndoableEdit extends Object
|
---|
48 | implements UndoableEdit,
|
---|
49 | Serializable {
|
---|
50 |
|
---|
51 | //-------------------------------------------------------------
|
---|
52 | // Constants --------------------------------------------------
|
---|
53 | //-------------------------------------------------------------
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * String returned by getRedoPresentationName()
|
---|
57 | */
|
---|
58 | protected static String RedoName = "Redo";
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * String returned by getUndoPresentationName()
|
---|
62 | */
|
---|
63 | protected static String UndoName = "Undo";
|
---|
64 |
|
---|
65 |
|
---|
66 | //-------------------------------------------------------------
|
---|
67 | // Variables --------------------------------------------------
|
---|
68 | //-------------------------------------------------------------
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * TODO
|
---|
72 | */
|
---|
73 | private boolean hasBeenDone = false;
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * The edit is alive
|
---|
77 | */
|
---|
78 | private boolean alive = true;
|
---|
79 |
|
---|
80 |
|
---|
81 | //-------------------------------------------------------------
|
---|
82 | // Initialization ---------------------------------------------
|
---|
83 | //-------------------------------------------------------------
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Create new AbstractUndoableEdit
|
---|
87 | */
|
---|
88 | public AbstractUndoableEdit() {
|
---|
89 | } // AbstractUndoableEdit()
|
---|
90 |
|
---|
91 |
|
---|
92 | //-------------------------------------------------------------
|
---|
93 | // Interface: UndoableEdit ------------------------------------
|
---|
94 | //-------------------------------------------------------------
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * addEdit
|
---|
98 | * @param anEdit TODO
|
---|
99 | * @returns TODO
|
---|
100 | */
|
---|
101 | public boolean addEdit(UndoableEdit anEdit) {
|
---|
102 | return false;
|
---|
103 | } // addEdit()
|
---|
104 |
|
---|
105 | /**
|
---|
106 | * canRedo()
|
---|
107 | * @returns true if redoable, false otherwise
|
---|
108 | */
|
---|
109 | public boolean canRedo() {
|
---|
110 | if (alive == true && hasBeenDone == false) {
|
---|
111 | return true;
|
---|
112 | } // if
|
---|
113 | return false;
|
---|
114 | } // canRedo()
|
---|
115 |
|
---|
116 | /**
|
---|
117 | * canUndo()
|
---|
118 | * @returns true if undoable, false otherwise
|
---|
119 | */
|
---|
120 | public boolean canUndo() {
|
---|
121 | if (alive == true && hasBeenDone == true) {
|
---|
122 | return true;
|
---|
123 | } // if
|
---|
124 | return false;
|
---|
125 | } // canUndo()
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * die
|
---|
129 | */
|
---|
130 | public void die() {
|
---|
131 | alive = false;
|
---|
132 | } // die()
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * getPresentation
|
---|
136 | * @returns TODO
|
---|
137 | */
|
---|
138 | public String getPresentationName() {
|
---|
139 | return "";
|
---|
140 | } // getPresentationName()
|
---|
141 |
|
---|
142 | /**
|
---|
143 | * getRedoPresentationName
|
---|
144 | * @returns TODO
|
---|
145 | */
|
---|
146 | public String getRedoPresentationName() {
|
---|
147 | if (getPresentationName().equals("") == true) {
|
---|
148 | return RedoName;
|
---|
149 | } else {
|
---|
150 | return RedoName + " " + getPresentationName();
|
---|
151 | }
|
---|
152 | } // getRedoPresentationName()
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * getUndoPresentationName
|
---|
156 | * @returns TODO
|
---|
157 | */
|
---|
158 | public String getUndoPresentationName() {
|
---|
159 | if (getPresentationName().equals("") == true) {
|
---|
160 | return UndoName;
|
---|
161 | } else {
|
---|
162 | return UndoName + " " + getPresentationName();
|
---|
163 | }
|
---|
164 | } // getUndoPresentationName()
|
---|
165 |
|
---|
166 | /**
|
---|
167 | * isSignificant
|
---|
168 | * @returns true
|
---|
169 | */
|
---|
170 | public boolean isSignificant() {
|
---|
171 | return true;
|
---|
172 | } // isSignificant()
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * redo
|
---|
176 | * @throws CannotRedoException TODO
|
---|
177 | */
|
---|
178 | public void redo() throws CannotRedoException {
|
---|
179 | if (canRedo() == false) {
|
---|
180 | throw new CannotRedoException();
|
---|
181 | }
|
---|
182 | hasBeenDone = true;
|
---|
183 | } // redo()
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * replaceEdit
|
---|
187 | * @param anEdit TODO
|
---|
188 | * @returns TODO
|
---|
189 | */
|
---|
190 | public boolean replaceEdit(UndoableEdit anEdit) {
|
---|
191 | return false;
|
---|
192 | } // replaceEdit()
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * String representation
|
---|
196 | * @returns String representation
|
---|
197 | */
|
---|
198 | public String toString() {
|
---|
199 | return null; // TODO
|
---|
200 | } // toString()
|
---|
201 |
|
---|
202 | /**
|
---|
203 | * undo
|
---|
204 | * @throws CannotUndoException TODO
|
---|
205 | */
|
---|
206 | public void undo() throws CannotUndoException {
|
---|
207 | if (canUndo() == false) {
|
---|
208 | throw new CannotUndoException();
|
---|
209 | }
|
---|
210 | hasBeenDone = false;
|
---|
211 | } // undo()
|
---|
212 |
|
---|
213 |
|
---|
214 | } // AbstractUndoableEdit
|
---|