1 |
/* AbstractTableModel.java -- |
/* AbstractTableModel.java -- |
2 |
Copyright (C) 2002 Free Software Foundation, Inc. |
Copyright (C) 2002, 2003 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
44 |
* AbstractUndoableEdit |
* AbstractUndoableEdit |
45 |
* @author Andrew Selkirk |
* @author Andrew Selkirk |
46 |
*/ |
*/ |
47 |
public class AbstractUndoableEdit extends Object |
public class AbstractUndoableEdit implements UndoableEdit, Serializable |
|
implements UndoableEdit, Serializable |
|
48 |
{ |
{ |
49 |
static final long serialVersionUID = 580150227676302096L; |
static final long serialVersionUID = 580150227676302096L; |
50 |
|
|
51 |
//------------------------------------------------------------- |
//------------------------------------------------------------- |
52 |
// Constants -------------------------------------------------- |
// Constants -------------------------------------------------- |
53 |
//------------------------------------------------------------- |
//------------------------------------------------------------- |
54 |
|
|
55 |
/** |
/** |
56 |
* String returned by getRedoPresentationName() |
* String returned by getRedoPresentationName() |
57 |
*/ |
*/ |
58 |
protected static String RedoName = "Redo"; |
protected static String RedoName = "Redo"; |
59 |
|
|
60 |
/** |
/** |
61 |
* String returned by getUndoPresentationName() |
* String returned by getUndoPresentationName() |
62 |
*/ |
*/ |
63 |
protected static String UndoName = "Undo"; |
protected static String UndoName = "Undo"; |
64 |
|
|
65 |
|
|
66 |
//------------------------------------------------------------- |
//------------------------------------------------------------- |
67 |
// Variables -------------------------------------------------- |
// Variables -------------------------------------------------- |
68 |
//------------------------------------------------------------- |
//------------------------------------------------------------- |
69 |
|
|
70 |
/** |
/** |
71 |
* TODO |
* TODO |
72 |
*/ |
*/ |
73 |
private boolean hasBeenDone = false; |
private boolean hasBeenDone = false; |
74 |
|
|
75 |
/** |
/** |
76 |
* The edit is alive |
* The edit is alive |
77 |
*/ |
*/ |
78 |
private boolean alive = true; |
private boolean alive = true; |
79 |
|
|
80 |
|
|
81 |
//------------------------------------------------------------- |
//------------------------------------------------------------- |
82 |
// Initialization --------------------------------------------- |
// Initialization --------------------------------------------- |
83 |
//------------------------------------------------------------- |
//------------------------------------------------------------- |
84 |
|
|
85 |
/** |
/** |
86 |
* Create new AbstractUndoableEdit |
* Create new AbstractUndoableEdit |
87 |
*/ |
*/ |
88 |
public AbstractUndoableEdit() { |
public AbstractUndoableEdit() |
89 |
} // AbstractUndoableEdit() |
{ |
90 |
|
} // AbstractUndoableEdit() |
91 |
|
|
92 |
//------------------------------------------------------------- |
|
93 |
// Interface: UndoableEdit ------------------------------------ |
//------------------------------------------------------------- |
94 |
//------------------------------------------------------------- |
// Interface: UndoableEdit ------------------------------------ |
95 |
|
//------------------------------------------------------------- |
96 |
/** |
|
97 |
* addEdit |
/** |
98 |
* @param anEdit TODO |
* addEdit |
99 |
* @returns TODO |
* @param anEdit TODO |
100 |
*/ |
* @returns TODO |
101 |
public boolean addEdit(UndoableEdit anEdit) { |
*/ |
102 |
return false; |
public boolean addEdit(UndoableEdit anEdit) |
103 |
} // addEdit() |
{ |
104 |
|
return false; |
105 |
/** |
} // addEdit() |
106 |
* canRedo() |
|
107 |
* @returns true if redoable, false otherwise |
/** |
108 |
*/ |
* canRedo() |
109 |
public boolean canRedo() { |
* @returns true if redoable, false otherwise |
110 |
if (alive == true && hasBeenDone == false) { |
*/ |
111 |
return true; |
public boolean canRedo() |
112 |
} // if |
{ |
113 |
return false; |
if (alive == true && hasBeenDone == false) |
114 |
} // canRedo() |
return true; |
115 |
|
return false; |
116 |
/** |
} // canRedo() |
117 |
* canUndo() |
|
118 |
* @returns true if undoable, false otherwise |
/** |
119 |
*/ |
* canUndo() |
120 |
public boolean canUndo() { |
* @returns true if undoable, false otherwise |
121 |
if (alive == true && hasBeenDone == true) { |
*/ |
122 |
return true; |
public boolean canUndo() |
123 |
} // if |
{ |
124 |
return false; |
if (alive == true && hasBeenDone == true) |
125 |
} // canUndo() |
return true; |
126 |
|
return false; |
127 |
/** |
} // canUndo() |
128 |
* die |
|
129 |
*/ |
/** |
130 |
public void die() { |
* die |
131 |
alive = false; |
*/ |
132 |
} // die() |
public void die() |
133 |
|
{ |
134 |
/** |
alive = false; |
135 |
* getPresentation |
} // die() |
136 |
* @returns TODO |
|
137 |
*/ |
/** |
138 |
public String getPresentationName() { |
* getPresentation |
139 |
return ""; |
* @returns TODO |
140 |
} // getPresentationName() |
*/ |
141 |
|
public String getPresentationName() |
142 |
/** |
{ |
143 |
* getRedoPresentationName |
return ""; |
144 |
* @returns TODO |
} // getPresentationName() |
145 |
*/ |
|
146 |
public String getRedoPresentationName() { |
/** |
147 |
if (getPresentationName().equals("") == true) { |
* getRedoPresentationName |
148 |
return RedoName; |
* @returns TODO |
149 |
} else { |
*/ |
150 |
return RedoName + " " + getPresentationName(); |
public String getRedoPresentationName() |
151 |
} |
{ |
152 |
} // getRedoPresentationName() |
if (getPresentationName().equals("")) |
153 |
|
return RedoName; |
154 |
/** |
return RedoName + " " + getPresentationName(); |
155 |
* getUndoPresentationName |
} // getRedoPresentationName() |
156 |
* @returns TODO |
|
157 |
*/ |
/** |
158 |
public String getUndoPresentationName() { |
* getUndoPresentationName |
159 |
if (getPresentationName().equals("") == true) { |
* @returns TODO |
160 |
return UndoName; |
*/ |
161 |
} else { |
public String getUndoPresentationName() |
162 |
return UndoName + " " + getPresentationName(); |
{ |
163 |
} |
if (getPresentationName().equals("")) |
164 |
} // getUndoPresentationName() |
return UndoName; |
165 |
|
return UndoName + " " + getPresentationName(); |
166 |
/** |
} // getUndoPresentationName() |
167 |
* isSignificant |
|
168 |
* @returns true |
/** |
169 |
*/ |
* isSignificant |
170 |
public boolean isSignificant() { |
* @returns true |
171 |
return true; |
*/ |
172 |
} // isSignificant() |
public boolean isSignificant() |
173 |
|
{ |
174 |
/** |
return true; |
175 |
* redo |
} // isSignificant() |
176 |
* @throws CannotRedoException TODO |
|
177 |
*/ |
/** |
178 |
public void redo() throws CannotRedoException { |
* redo |
179 |
if (canRedo() == false) { |
* @throws CannotRedoException TODO |
180 |
throw new CannotRedoException(); |
*/ |
181 |
} |
public void redo() throws CannotRedoException |
182 |
hasBeenDone = true; |
{ |
183 |
} // redo() |
if (! canRedo()) |
184 |
|
throw new CannotRedoException(); |
185 |
/** |
hasBeenDone = true; |
186 |
* replaceEdit |
} // redo() |
187 |
* @param anEdit TODO |
|
188 |
* @returns TODO |
/** |
189 |
*/ |
* replaceEdit |
190 |
public boolean replaceEdit(UndoableEdit anEdit) { |
* @param anEdit TODO |
191 |
return false; |
* @returns TODO |
192 |
} // replaceEdit() |
*/ |
193 |
|
public boolean replaceEdit(UndoableEdit anEdit) |
194 |
/** |
{ |
195 |
* String representation |
return false; |
196 |
* @returns String representation |
} // replaceEdit() |
197 |
*/ |
|
198 |
public String toString() { |
/** |
199 |
return null; // TODO |
* String representation |
200 |
} // toString() |
* @returns String representation |
201 |
|
*/ |
202 |
/** |
public String toString() |
203 |
* undo |
{ |
204 |
* @throws CannotUndoException TODO |
return null; // TODO |
205 |
*/ |
} // toString() |
206 |
public void undo() throws CannotUndoException { |
|
207 |
if (canUndo() == false) { |
/** |
208 |
throw new CannotUndoException(); |
* undo |
209 |
} |
* @throws CannotUndoException TODO |
210 |
hasBeenDone = false; |
*/ |
211 |
} // undo() |
public void undo() throws CannotUndoException |
212 |
|
{ |
213 |
|
if (! canUndo()) |
214 |
|
throw new CannotUndoException(); |
215 |
|
hasBeenDone = false; |
216 |
|
} // undo() |
217 |
} // AbstractUndoableEdit |
} // AbstractUndoableEdit |