1 |
/* AbstractTableModel.java -- |
/* StateEdit.java -- |
2 |
Copyright (C) 2002, 2003 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. |
83 |
|
|
84 |
/** |
/** |
85 |
* Constructor StateEdit |
* Constructor StateEdit |
86 |
* @param value0 TODO |
* @param obj Object to edit |
87 |
*/ |
*/ |
88 |
public StateEdit(StateEditable value0) |
public StateEdit(StateEditable obj) |
89 |
{ |
{ |
90 |
// TODO |
init(obj, null); |
91 |
} |
} |
92 |
|
|
93 |
/** |
/** |
94 |
* Constructor StateEdit |
* Constructor StateEdit |
95 |
* @param value0 TODO |
* @param obj Object to edit |
96 |
* @param value1 TODO |
* @param name Presentation name |
97 |
*/ |
*/ |
98 |
public StateEdit(StateEditable value0, String value1) |
public StateEdit(StateEditable obj, String name) |
99 |
{ |
{ |
100 |
// TODO |
init(obj, name); |
101 |
} |
} |
102 |
|
|
103 |
|
|
106 |
//------------------------------------------------------------- |
//------------------------------------------------------------- |
107 |
|
|
108 |
/** |
/** |
109 |
* init |
* Initialize this object. |
110 |
* @param value0 TODO |
* @param obj Object to edit |
111 |
* @param value1 TODO |
* @param name Presentation name |
112 |
*/ |
*/ |
113 |
protected void init(StateEditable value0, String value1) |
protected void init(StateEditable obj, String name) |
114 |
{ |
{ |
115 |
// TODO |
object = obj; |
116 |
|
undoRedoName = name; |
117 |
|
preState = new Hashtable(); |
118 |
|
postState = new Hashtable(); |
119 |
|
obj.storeState(preState); |
120 |
} |
} |
121 |
|
|
122 |
/** |
/** |
123 |
* end |
* Indicate that all edits are finished, and update this object |
124 |
|
* with final state. |
125 |
*/ |
*/ |
126 |
public void end() |
public void end() |
127 |
{ |
{ |
128 |
// TODO |
object.storeState(postState); |
129 |
|
removeRedundantState(); |
130 |
} |
} |
131 |
|
|
132 |
/** |
/** |
133 |
* undo |
* Undo this edit by applying the initial state to the edited object. |
134 |
*/ |
*/ |
135 |
public void undo() |
public void undo() |
136 |
{ |
{ |
137 |
// TODO |
object.restoreState(preState); |
138 |
} |
} |
139 |
|
|
140 |
/** |
/** |
141 |
* redo |
* Undo this edit by applying the final state to the edited object. |
142 |
*/ |
*/ |
143 |
public void redo() |
public void redo() |
144 |
{ |
{ |
145 |
// TODO |
object.restoreState(postState); |
146 |
} |
} |
147 |
|
|
148 |
/** |
/** |
149 |
* getPresentationName |
* Return the presentation name of this object. |
150 |
* @returns String |
* @returns The name, or null if not set |
151 |
*/ |
*/ |
152 |
public String getPresentationName() |
public String getPresentationName() |
153 |
{ |
{ |
154 |
return null; // TODO |
return undoRedoName; |
155 |
} |
} |
156 |
|
|
157 |
/** |
/** |
159 |
*/ |
*/ |
160 |
protected void removeRedundantState() |
protected void removeRedundantState() |
161 |
{ |
{ |
162 |
// TODO |
Iterator i = preState.keySet().iterator(); |
163 |
|
while (i.hasNext()) |
164 |
|
{ |
165 |
|
Object key = i.next(); |
166 |
|
if (postState.containsKey(key)) |
167 |
|
{ |
168 |
|
if (preState.get(key).equals(postState.get(key))) |
169 |
|
{ |
170 |
|
i.remove(); |
171 |
|
postState.remove(key); |
172 |
|
} |
173 |
|
} |
174 |
|
} |
175 |
} |
} |
176 |
} |
} |