|
Lines 22-856
Link Here
|
| 22 |
import org.eclipse.swt.widgets.Control; |
22 |
import org.eclipse.swt.widgets.Control; |
| 23 |
|
23 |
|
| 24 |
/** |
24 |
/** |
| 25 |
* Abstract base class for cell editors. Implements property change listener handling, |
25 |
* Abstract base class for cell editors. Implements property change listener |
| 26 |
* and SWT window management. |
26 |
* handling, and SWT window management. |
| 27 |
* <p> |
27 |
* <p> |
| 28 |
* Subclasses implement particular kinds of cell editors. This package contains various |
28 |
* Subclasses implement particular kinds of cell editors. This package contains |
| 29 |
* specialized cell editors: |
29 |
* various specialized cell editors: |
| 30 |
* <ul> |
30 |
* <ul> |
| 31 |
* <li><code>TextCellEditor</code> - for simple text strings</li> |
31 |
* <li><code>TextCellEditor</code> - for simple text strings</li> |
| 32 |
* <li><code>ColorCellEditor</code> - for colors</li> |
32 |
* <li><code>ColorCellEditor</code> - for colors</li> |
| 33 |
* <li><code>ComboBoxCellEditor</code> - value selected from drop-down combo box</li> |
33 |
* <li><code>ComboBoxCellEditor</code> - value selected from drop-down combo |
| 34 |
* <li><code>CheckboxCellEditor</code> - boolean valued checkbox</li> |
34 |
* box</li> |
| 35 |
* <li><code>DialogCellEditor</code> - value from arbitrary dialog</li> |
35 |
* <li><code>CheckboxCellEditor</code> - boolean valued checkbox</li> |
|
|
36 |
* <li><code>DialogCellEditor</code> - value from arbitrary dialog</li> |
| 36 |
* </ul> |
37 |
* </ul> |
| 37 |
* </p> |
38 |
* </p> |
| 38 |
*/ |
39 |
*/ |
| 39 |
public abstract class CellEditor { |
40 |
public abstract class CellEditor { |
| 40 |
|
41 |
|
| 41 |
/** |
42 |
/** |
| 42 |
* List of cell editor listeners (element type: <code>ICellEditorListener</code>). |
43 |
* List of cell editor listeners (element type: |
| 43 |
*/ |
44 |
* <code>ICellEditorListener</code>). |
| 44 |
private ListenerList listeners = new ListenerList(); |
45 |
*/ |
| 45 |
|
46 |
private ListenerList listeners = new ListenerList(); |
| 46 |
/** |
47 |
|
| 47 |
* List of cell editor property change listeners |
48 |
/** |
| 48 |
* (element type: <code>IPropertyChangeListener</code>). |
49 |
* List of cell editor property change listeners (element type: |
| 49 |
*/ |
50 |
* <code>IPropertyChangeListener</code>). |
| 50 |
private ListenerList propertyChangeListeners = new ListenerList(); |
51 |
*/ |
| 51 |
|
52 |
private ListenerList propertyChangeListeners = new ListenerList(); |
| 52 |
/** |
53 |
|
| 53 |
* Indicates whether this cell editor's current value is valid. |
54 |
/** |
| 54 |
*/ |
55 |
* Indicates whether this cell editor's current value is valid. |
| 55 |
private boolean valid = false; |
56 |
*/ |
| 56 |
|
57 |
private boolean valid = false; |
| 57 |
/** |
58 |
|
| 58 |
* Optional cell editor validator; <code>null</code> if none. |
59 |
/** |
| 59 |
*/ |
60 |
* Optional cell editor validator; <code>null</code> if none. |
| 60 |
private ICellEditorValidator validator = null; |
61 |
*/ |
| 61 |
|
62 |
private ICellEditorValidator validator = null; |
| 62 |
/** |
63 |
|
| 63 |
* The error message string to display for invalid values; |
64 |
/** |
| 64 |
* <code>null</code> if none (that is, the value is valid). |
65 |
* The error message string to display for invalid values; <code>null</code> |
| 65 |
*/ |
66 |
* if none (that is, the value is valid). |
| 66 |
private String errorMessage = null; |
67 |
*/ |
| 67 |
|
68 |
private String errorMessage = null; |
| 68 |
/** |
69 |
|
| 69 |
* Indicates whether this cell editor has been changed recently. |
70 |
/** |
| 70 |
*/ |
71 |
* Indicates whether this cell editor has been changed recently. |
| 71 |
private boolean dirty = false; |
72 |
*/ |
| 72 |
|
73 |
private boolean dirty = false; |
| 73 |
/** |
74 |
|
| 74 |
* This cell editor's control, or <code>null</code> |
75 |
/** |
| 75 |
* if not created yet. |
76 |
* This cell editor's control, or <code>null</code> if not created yet. |
| 76 |
*/ |
77 |
*/ |
| 77 |
private Control control = null; |
78 |
private Control control = null; |
| 78 |
|
79 |
|
| 79 |
/** |
80 |
/** |
| 80 |
* Default cell editor style |
81 |
* Default cell editor style |
| 81 |
*/ |
82 |
*/ |
| 82 |
private static final int defaultStyle = SWT.NONE; |
83 |
private static final int defaultStyle = SWT.NONE; |
| 83 |
|
84 |
|
| 84 |
/** |
85 |
/** |
| 85 |
* This cell editor's style |
86 |
* This cell editor's style |
| 86 |
*/ |
87 |
*/ |
| 87 |
private int style = defaultStyle; |
88 |
private int style = defaultStyle; |
| 88 |
|
89 |
|
| 89 |
/** |
90 |
/** |
| 90 |
* Struct-like layout data for cell editors, with reasonable defaults |
91 |
* Struct-like layout data for cell editors, with reasonable defaults for |
| 91 |
* for all fields. |
92 |
* all fields. |
| 92 |
*/ |
93 |
*/ |
| 93 |
public static class LayoutData { |
94 |
public static class LayoutData { |
| 94 |
/** |
95 |
/** |
| 95 |
* Horizontal alignment; <code>SWT.LEFT</code> by default. |
96 |
* Horizontal alignment; <code>SWT.LEFT</code> by default. |
| 96 |
*/ |
97 |
*/ |
| 97 |
public int horizontalAlignment = SWT.LEFT; |
98 |
public int horizontalAlignment = SWT.LEFT; |
| 98 |
|
99 |
|
| 99 |
/** |
100 |
/** |
| 100 |
* Indicates control grabs additional space; <code>true</code> by default. |
101 |
* Indicates control grabs additional space; <code>true</code> by |
| 101 |
*/ |
102 |
* default. |
| 102 |
public boolean grabHorizontal = true; |
103 |
*/ |
| 103 |
|
104 |
public boolean grabHorizontal = true; |
| 104 |
/** |
105 |
|
| 105 |
* Minimum width in pixels; <code>50</code> pixels by default. |
106 |
/** |
| 106 |
*/ |
107 |
* Minimum width in pixels; <code>50</code> pixels by default. |
| 107 |
public int minimumWidth = 50; |
108 |
*/ |
| 108 |
} |
109 |
public int minimumWidth = 50; |
| 109 |
|
110 |
} |
| 110 |
/** |
111 |
|
| 111 |
* Property name for the copy action |
112 |
/** |
| 112 |
*/ |
113 |
* Property name for the copy action |
| 113 |
public static final String COPY = "copy"; //$NON-NLS-1$ |
114 |
*/ |
| 114 |
|
115 |
public static final String COPY = "copy"; //$NON-NLS-1$ |
| 115 |
/** |
116 |
|
| 116 |
* Property name for the cut action |
117 |
/** |
| 117 |
*/ |
118 |
* Property name for the cut action |
| 118 |
public static final String CUT = "cut"; //$NON-NLS-1$ |
119 |
*/ |
| 119 |
|
120 |
public static final String CUT = "cut"; //$NON-NLS-1$ |
| 120 |
/** |
121 |
|
| 121 |
* Property name for the delete action |
122 |
/** |
| 122 |
*/ |
123 |
* Property name for the delete action |
| 123 |
public static final String DELETE = "delete"; //$NON-NLS-1$ |
124 |
*/ |
| 124 |
|
125 |
public static final String DELETE = "delete"; //$NON-NLS-1$ |
| 125 |
/** |
126 |
|
| 126 |
* Property name for the find action |
127 |
/** |
| 127 |
*/ |
128 |
* Property name for the find action |
| 128 |
public static final String FIND = "find"; //$NON-NLS-1$ |
129 |
*/ |
| 129 |
|
130 |
public static final String FIND = "find"; //$NON-NLS-1$ |
| 130 |
/** |
131 |
|
| 131 |
* Property name for the paste action |
132 |
/** |
| 132 |
*/ |
133 |
* Property name for the paste action |
| 133 |
public static final String PASTE = "paste"; //$NON-NLS-1$ |
134 |
*/ |
| 134 |
|
135 |
public static final String PASTE = "paste"; //$NON-NLS-1$ |
| 135 |
/** |
136 |
|
| 136 |
* Property name for the redo action |
137 |
/** |
| 137 |
*/ |
138 |
* Property name for the redo action |
| 138 |
public static final String REDO = "redo"; //$NON-NLS-1$ |
139 |
*/ |
| 139 |
|
140 |
public static final String REDO = "redo"; //$NON-NLS-1$ |
| 140 |
/** |
141 |
|
| 141 |
* Property name for the select all action |
142 |
/** |
| 142 |
*/ |
143 |
* Property name for the select all action |
| 143 |
public static final String SELECT_ALL = "selectall"; //$NON-NLS-1$ |
144 |
*/ |
| 144 |
|
145 |
public static final String SELECT_ALL = "selectall"; //$NON-NLS-1$ |
| 145 |
/** |
146 |
|
| 146 |
* Property name for the undo action |
147 |
/** |
| 147 |
*/ |
148 |
* Property name for the undo action |
| 148 |
public static final String UNDO = "undo"; //$NON-NLS-1$ |
149 |
*/ |
| 149 |
|
150 |
public static final String UNDO = "undo"; //$NON-NLS-1$ |
| 150 |
/** |
151 |
|
| 151 |
* Creates a new cell editor with no control |
152 |
/** |
| 152 |
* The cell editor has no cell validator. |
153 |
* Creates a new cell editor with no control The cell editor has no cell |
| 153 |
* @since 2.1 |
154 |
* validator. |
| 154 |
*/ |
155 |
* |
| 155 |
protected CellEditor() { |
156 |
* @since 2.1 |
| 156 |
} |
157 |
*/ |
| 157 |
|
158 |
protected CellEditor() { |
| 158 |
/** |
159 |
} |
| 159 |
* Creates a new cell editor under the given parent control. |
160 |
|
| 160 |
* The cell editor has no cell validator. |
161 |
/** |
| 161 |
* |
162 |
* Creates a new cell editor under the given parent control. The cell editor |
| 162 |
* @param parent the parent control |
163 |
* has no cell validator. |
| 163 |
*/ |
164 |
* |
| 164 |
protected CellEditor(Composite parent) { |
165 |
* @param parent |
| 165 |
this(parent, defaultStyle); |
166 |
* the parent control |
| 166 |
} |
167 |
*/ |
| 167 |
|
168 |
protected CellEditor(Composite parent) { |
| 168 |
/** |
169 |
this(parent, defaultStyle); |
| 169 |
* Creates a new cell editor under the given parent control. |
170 |
} |
| 170 |
* The cell editor has no cell validator. |
171 |
|
| 171 |
* |
172 |
/** |
| 172 |
* @param parent the parent control |
173 |
* Creates a new cell editor under the given parent control. The cell editor |
| 173 |
* @param style the style bits |
174 |
* has no cell validator. |
| 174 |
* @since 2.1 |
175 |
* |
| 175 |
*/ |
176 |
* @param parent |
| 176 |
protected CellEditor(Composite parent, int style) { |
177 |
* the parent control |
| 177 |
this.style = style; |
178 |
* @param style |
| 178 |
create(parent); |
179 |
* the style bits |
| 179 |
} |
180 |
* @since 2.1 |
| 180 |
|
181 |
*/ |
| 181 |
/** |
182 |
protected CellEditor(Composite parent, int style) { |
| 182 |
* Activates this cell editor. |
183 |
this.style = style; |
| 183 |
* <p> |
184 |
create(parent); |
| 184 |
* The default implementation of this framework method |
185 |
} |
| 185 |
* does nothing. Subclasses may reimplement. |
186 |
|
| 186 |
* </p> |
187 |
/** |
| 187 |
*/ |
188 |
* Activates this cell editor. |
| 188 |
public void activate() { |
189 |
* <p> |
| 189 |
} |
190 |
* The default implementation of this framework method does nothing. |
| 190 |
|
191 |
* Subclasses may reimplement. |
| 191 |
/** |
192 |
* </p> |
| 192 |
* Adds a listener to this cell editor. |
193 |
*/ |
| 193 |
* Has no effect if an identical listener is already registered. |
194 |
public void activate() { |
| 194 |
* |
195 |
} |
| 195 |
* @param listener a cell editor listener |
196 |
|
| 196 |
*/ |
197 |
/** |
| 197 |
public void addListener(ICellEditorListener listener) { |
198 |
* Activate the editor but also inform the editor which event triggered its activation. |
| 198 |
listeners.add(listener); |
199 |
* <b>The default implementation simply calls {@link #activate()}</b> |
| 199 |
} |
200 |
* |
| 200 |
|
201 |
* @param activationEvent the editor activation event |
| 201 |
/** |
202 |
*/ |
| 202 |
* Adds a property change listener to this cell editor. |
203 |
public void activate(EditorActivationEvent activationEvent) { |
| 203 |
* Has no effect if an identical property change listener |
204 |
activate(); |
| 204 |
* is already registered. |
205 |
} |
| 205 |
* |
206 |
|
| 206 |
* @param listener a property change listener |
207 |
/** |
| 207 |
*/ |
208 |
* Adds a listener to this cell editor. Has no effect if an identical |
| 208 |
public void addPropertyChangeListener(IPropertyChangeListener listener) { |
209 |
* listener is already registered. |
| 209 |
propertyChangeListeners.add(listener); |
210 |
* |
| 210 |
} |
211 |
* @param listener |
| 211 |
|
212 |
* a cell editor listener |
| 212 |
/** |
213 |
*/ |
| 213 |
* Creates the control for this cell editor under the given parent control. |
214 |
public void addListener(ICellEditorListener listener) { |
| 214 |
* <p> |
215 |
listeners.add(listener); |
| 215 |
* This framework method must be implemented by concrete |
216 |
} |
| 216 |
* subclasses. |
217 |
|
| 217 |
* </p> |
218 |
/** |
| 218 |
* |
219 |
* Adds a property change listener to this cell editor. Has no effect if an |
| 219 |
* @param parent the parent control |
220 |
* identical property change listener is already registered. |
| 220 |
* @return the new control, or <code>null</code> if this cell editor has no control |
221 |
* |
| 221 |
*/ |
222 |
* @param listener |
| 222 |
protected abstract Control createControl(Composite parent); |
223 |
* a property change listener |
| 223 |
|
224 |
*/ |
| 224 |
/** |
225 |
public void addPropertyChangeListener(IPropertyChangeListener listener) { |
| 225 |
* Creates the control for this cell editor under the given parent control. |
226 |
propertyChangeListeners.add(listener); |
| 226 |
* |
227 |
} |
| 227 |
* @param parent the parent control |
228 |
|
| 228 |
* @since 2.1 |
229 |
/** |
| 229 |
*/ |
230 |
* Creates the control for this cell editor under the given parent control. |
| 230 |
public void create(Composite parent) { |
231 |
* <p> |
| 231 |
Assert.isTrue(control == null); |
232 |
* This framework method must be implemented by concrete subclasses. |
| 232 |
control = createControl(parent); |
233 |
* </p> |
| 233 |
// See 1GD5CA6: ITPUI:ALL - TaskView.setSelection does not work |
234 |
* |
| 234 |
// Control is created with getVisible()==true by default. |
235 |
* @param parent |
| 235 |
// This causes composite.setFocus() to work incorrectly. |
236 |
* the parent control |
| 236 |
// The cell editor's control grabs focus instead, even if it is not active. |
237 |
* @return the new control, or <code>null</code> if this cell editor has |
| 237 |
// Make the control invisible here by default. |
238 |
* no control |
| 238 |
deactivate(); |
239 |
*/ |
| 239 |
} |
240 |
protected abstract Control createControl(Composite parent); |
| 240 |
|
241 |
|
| 241 |
/** |
242 |
/** |
| 242 |
* Hides this cell editor's control. Does nothing if this |
243 |
* Creates the control for this cell editor under the given parent control. |
| 243 |
* cell editor is not visible. |
244 |
* |
| 244 |
*/ |
245 |
* @param parent |
| 245 |
public void deactivate() { |
246 |
* the parent control |
| 246 |
if (control != null && !control.isDisposed()) { |
247 |
* @since 2.1 |
|
|
248 |
*/ |
| 249 |
public void create(Composite parent) { |
| 250 |
Assert.isTrue(control == null); |
| 251 |
control = createControl(parent); |
| 252 |
// See 1GD5CA6: ITPUI:ALL - TaskView.setSelection does not work |
| 253 |
// Control is created with getVisible()==true by default. |
| 254 |
// This causes composite.setFocus() to work incorrectly. |
| 255 |
// The cell editor's control grabs focus instead, even if it is not |
| 256 |
// active. |
| 257 |
// Make the control invisible here by default. |
| 258 |
deactivate(); |
| 259 |
} |
| 260 |
|
| 261 |
/** |
| 262 |
* Hides this cell editor's control. Does nothing if this cell editor is not |
| 263 |
* visible. |
| 264 |
*/ |
| 265 |
public void deactivate() { |
| 266 |
if (control != null && !control.isDisposed()) { |
| 247 |
control.setVisible(false); |
267 |
control.setVisible(false); |
| 248 |
} |
268 |
} |
| 249 |
} |
269 |
} |
| 250 |
|
270 |
|
| 251 |
/** |
271 |
/** |
| 252 |
* Disposes of this cell editor and frees any associated SWT resources. |
272 |
* Disposes of this cell editor and frees any associated SWT resources. |
| 253 |
*/ |
273 |
*/ |
| 254 |
public void dispose() { |
274 |
public void dispose() { |
| 255 |
if (control != null && !control.isDisposed()) { |
275 |
if (control != null && !control.isDisposed()) { |
| 256 |
control.dispose(); |
276 |
control.dispose(); |
| 257 |
} |
277 |
} |
| 258 |
control = null; |
278 |
control = null; |
| 259 |
} |
279 |
} |
| 260 |
|
280 |
|
| 261 |
/** |
281 |
/** |
| 262 |
* Returns this cell editor's value. |
282 |
* Returns this cell editor's value. |
| 263 |
* <p> |
283 |
* <p> |
| 264 |
* This framework method must be implemented by concrete subclasses. |
284 |
* This framework method must be implemented by concrete subclasses. |
| 265 |
* </p> |
285 |
* </p> |
| 266 |
* |
286 |
* |
| 267 |
* @return the value of this cell editor |
287 |
* @return the value of this cell editor |
| 268 |
* @see #getValue |
288 |
* @see #getValue |
| 269 |
*/ |
289 |
*/ |
| 270 |
protected abstract Object doGetValue(); |
290 |
protected abstract Object doGetValue(); |
| 271 |
|
291 |
|
| 272 |
/** |
292 |
/** |
| 273 |
* Sets the focus to the cell editor's control. |
293 |
* Sets the focus to the cell editor's control. |
| 274 |
* <p> |
294 |
* <p> |
| 275 |
* This framework method must be implemented by concrete subclasses. |
295 |
* This framework method must be implemented by concrete subclasses. |
| 276 |
* </p> |
296 |
* </p> |
| 277 |
* |
297 |
* |
| 278 |
* @see #setFocus |
298 |
* @see #setFocus |
| 279 |
*/ |
299 |
*/ |
| 280 |
protected abstract void doSetFocus(); |
300 |
protected abstract void doSetFocus(); |
| 281 |
|
301 |
|
| 282 |
/** |
302 |
/** |
| 283 |
* Sets this cell editor's value. |
303 |
* Sets this cell editor's value. |
| 284 |
* <p> |
304 |
* <p> |
| 285 |
* This framework method must be implemented by concrete subclasses. |
305 |
* This framework method must be implemented by concrete subclasses. |
| 286 |
* </p> |
306 |
* </p> |
| 287 |
* |
307 |
* |
| 288 |
* @param value the value of this cell editor |
308 |
* @param value |
| 289 |
* @see #setValue |
309 |
* the value of this cell editor |
| 290 |
*/ |
310 |
* @see #setValue |
| 291 |
protected abstract void doSetValue(Object value); |
311 |
*/ |
| 292 |
|
312 |
protected abstract void doSetValue(Object value); |
| 293 |
/** |
313 |
|
| 294 |
* Notifies all registered cell editor listeners of an apply event. |
314 |
/** |
| 295 |
* Only listeners registered at the time this method is called are notified. |
315 |
* Notifies all registered cell editor listeners of an apply event. Only |
| 296 |
* |
316 |
* listeners registered at the time this method is called are notified. |
| 297 |
* @see ICellEditorListener#applyEditorValue |
317 |
* |
| 298 |
*/ |
318 |
* @see ICellEditorListener#applyEditorValue |
| 299 |
protected void fireApplyEditorValue() { |
319 |
*/ |
| 300 |
Object[] array = listeners.getListeners(); |
320 |
protected void fireApplyEditorValue() { |
| 301 |
for (int i = 0; i < array.length; i++) { |
321 |
Object[] array = listeners.getListeners(); |
| 302 |
final ICellEditorListener l = (ICellEditorListener) array[i]; |
322 |
for (int i = 0; i < array.length; i++) { |
| 303 |
SafeRunnable.run(new SafeRunnable() { |
323 |
final ICellEditorListener l = (ICellEditorListener) array[i]; |
| 304 |
public void run() { |
324 |
SafeRunnable.run(new SafeRunnable() { |
| 305 |
l.applyEditorValue(); |
325 |
public void run() { |
| 306 |
} |
326 |
l.applyEditorValue(); |
| 307 |
}); |
327 |
} |
| 308 |
} |
328 |
}); |
| 309 |
} |
329 |
} |
| 310 |
|
330 |
} |
| 311 |
/** |
331 |
|
| 312 |
* Notifies all registered cell editor listeners that editing has been |
332 |
/** |
| 313 |
* canceled. |
333 |
* Notifies all registered cell editor listeners that editing has been |
| 314 |
* |
334 |
* canceled. |
| 315 |
* @see ICellEditorListener#cancelEditor |
335 |
* |
| 316 |
*/ |
336 |
* @see ICellEditorListener#cancelEditor |
| 317 |
protected void fireCancelEditor() { |
337 |
*/ |
| 318 |
Object[] array = listeners.getListeners(); |
338 |
protected void fireCancelEditor() { |
| 319 |
for (int i = 0; i < array.length; i++) { |
339 |
Object[] array = listeners.getListeners(); |
| 320 |
final ICellEditorListener l = (ICellEditorListener) array[i]; |
340 |
for (int i = 0; i < array.length; i++) { |
| 321 |
SafeRunnable.run(new SafeRunnable() { |
341 |
final ICellEditorListener l = (ICellEditorListener) array[i]; |
| 322 |
public void run() { |
342 |
SafeRunnable.run(new SafeRunnable() { |
| 323 |
l.cancelEditor(); |
343 |
public void run() { |
| 324 |
} |
344 |
l.cancelEditor(); |
| 325 |
}); |
345 |
} |
| 326 |
} |
346 |
}); |
| 327 |
} |
347 |
} |
| 328 |
|
348 |
} |
| 329 |
/** |
349 |
|
| 330 |
* Notifies all registered cell editor listeners of a value change. |
350 |
/** |
| 331 |
* |
351 |
* Notifies all registered cell editor listeners of a value change. |
| 332 |
* @param oldValidState the valid state before the end user changed the value |
352 |
* |
| 333 |
* @param newValidState the current valid state |
353 |
* @param oldValidState |
| 334 |
* @see ICellEditorListener#editorValueChanged |
354 |
* the valid state before the end user changed the value |
| 335 |
*/ |
355 |
* @param newValidState |
| 336 |
protected void fireEditorValueChanged(final boolean oldValidState, |
356 |
* the current valid state |
| 337 |
final boolean newValidState) { |
357 |
* @see ICellEditorListener#editorValueChanged |
| 338 |
Object[] array = listeners.getListeners(); |
358 |
*/ |
| 339 |
for (int i = 0; i < array.length; i++) { |
359 |
protected void fireEditorValueChanged(final boolean oldValidState, |
| 340 |
final ICellEditorListener l = (ICellEditorListener) array[i]; |
360 |
final boolean newValidState) { |
| 341 |
SafeRunnable.run(new SafeRunnable() { |
361 |
Object[] array = listeners.getListeners(); |
| 342 |
public void run() { |
362 |
for (int i = 0; i < array.length; i++) { |
| 343 |
l.editorValueChanged(oldValidState, newValidState); |
363 |
final ICellEditorListener l = (ICellEditorListener) array[i]; |
| 344 |
} |
364 |
SafeRunnable.run(new SafeRunnable() { |
| 345 |
}); |
365 |
public void run() { |
| 346 |
} |
366 |
l.editorValueChanged(oldValidState, newValidState); |
| 347 |
} |
367 |
} |
| 348 |
|
368 |
}); |
| 349 |
/** |
369 |
} |
| 350 |
* Notifies all registered property listeners |
370 |
} |
| 351 |
* of an enablement change. |
371 |
|
| 352 |
* |
372 |
/** |
| 353 |
* @param actionId the id indicating what action's enablement has changed. |
373 |
* Notifies all registered property listeners of an enablement change. |
| 354 |
*/ |
374 |
* |
| 355 |
protected void fireEnablementChanged(final String actionId) { |
375 |
* @param actionId |
| 356 |
Object[] array = propertyChangeListeners.getListeners(); |
376 |
* the id indicating what action's enablement has changed. |
| 357 |
for (int i = 0; i < array.length; i++) { |
377 |
*/ |
| 358 |
final IPropertyChangeListener l = (IPropertyChangeListener) array[i]; |
378 |
protected void fireEnablementChanged(final String actionId) { |
| 359 |
SafeRunnable.run(new SafeRunnable() { |
379 |
Object[] array = propertyChangeListeners.getListeners(); |
| 360 |
public void run() { |
380 |
for (int i = 0; i < array.length; i++) { |
| 361 |
l.propertyChange(new PropertyChangeEvent(this, actionId, |
381 |
final IPropertyChangeListener l = (IPropertyChangeListener) array[i]; |
| 362 |
null, null)); |
382 |
SafeRunnable.run(new SafeRunnable() { |
| 363 |
} |
383 |
public void run() { |
| 364 |
}); |
384 |
l.propertyChange(new PropertyChangeEvent(this, actionId, |
| 365 |
} |
385 |
null, null)); |
| 366 |
} |
386 |
} |
| 367 |
|
387 |
}); |
| 368 |
/** |
388 |
} |
| 369 |
* Sets the style bits for this cell editor. |
389 |
} |
| 370 |
* |
390 |
|
| 371 |
* @param style the SWT style bits for this cell editor |
391 |
/** |
| 372 |
* @since 2.1 |
392 |
* Sets the style bits for this cell editor. |
| 373 |
*/ |
393 |
* |
| 374 |
public void setStyle(int style) { |
394 |
* @param style |
| 375 |
this.style = style; |
395 |
* the SWT style bits for this cell editor |
| 376 |
} |
396 |
* @since 2.1 |
| 377 |
|
397 |
*/ |
| 378 |
/** |
398 |
public void setStyle(int style) { |
| 379 |
* Returns the style bits for this cell editor. |
399 |
this.style = style; |
| 380 |
* |
400 |
} |
| 381 |
* @return the style for this cell editor |
401 |
|
| 382 |
* @since 2.1 |
402 |
/** |
| 383 |
*/ |
403 |
* Returns the style bits for this cell editor. |
| 384 |
public int getStyle() { |
404 |
* |
| 385 |
return style; |
405 |
* @return the style for this cell editor |
| 386 |
} |
406 |
* @since 2.1 |
| 387 |
|
407 |
*/ |
| 388 |
/** |
408 |
public int getStyle() { |
| 389 |
* Returns the control used to implement this cell editor. |
409 |
return style; |
| 390 |
* |
410 |
} |
| 391 |
* @return the control, or <code>null</code> if this cell editor has no control |
411 |
|
| 392 |
*/ |
412 |
/** |
| 393 |
public Control getControl() { |
413 |
* Returns the control used to implement this cell editor. |
| 394 |
return control; |
414 |
* |
| 395 |
} |
415 |
* @return the control, or <code>null</code> if this cell editor has no |
| 396 |
|
416 |
* control |
| 397 |
/** |
417 |
*/ |
| 398 |
* Returns the current error message for this cell editor. |
418 |
public Control getControl() { |
| 399 |
* |
419 |
return control; |
| 400 |
* @return the error message if the cell editor is in an invalid state, |
420 |
} |
| 401 |
* and <code>null</code> if the cell editor is valid |
421 |
|
| 402 |
*/ |
422 |
/** |
| 403 |
public String getErrorMessage() { |
423 |
* Returns the current error message for this cell editor. |
| 404 |
return errorMessage; |
424 |
* |
| 405 |
} |
425 |
* @return the error message if the cell editor is in an invalid state, and |
| 406 |
|
426 |
* <code>null</code> if the cell editor is valid |
| 407 |
/** |
427 |
*/ |
| 408 |
* Returns a layout data object for this cell editor. |
428 |
public String getErrorMessage() { |
| 409 |
* This is called each time the cell editor is activated |
429 |
return errorMessage; |
| 410 |
* and controls the layout of the SWT table editor. |
430 |
} |
| 411 |
* <p> |
431 |
|
| 412 |
* The default implementation of this method sets the |
432 |
/** |
| 413 |
* minimum width to the control's preferred width. |
433 |
* Returns a layout data object for this cell editor. This is called each |
| 414 |
* Subclasses may extend or reimplement. |
434 |
* time the cell editor is activated and controls the layout of the SWT |
| 415 |
* </p> |
435 |
* table editor. |
| 416 |
* |
436 |
* <p> |
| 417 |
* @return the layout data object |
437 |
* The default implementation of this method sets the minimum width to the |
| 418 |
*/ |
438 |
* control's preferred width. Subclasses may extend or reimplement. |
| 419 |
public LayoutData getLayoutData() { |
439 |
* </p> |
| 420 |
LayoutData result = new LayoutData(); |
440 |
* |
| 421 |
Control control = getControl(); |
441 |
* @return the layout data object |
| 422 |
if (control != null) { |
442 |
*/ |
| 423 |
result.minimumWidth = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, |
443 |
public LayoutData getLayoutData() { |
| 424 |
true).x; |
444 |
LayoutData result = new LayoutData(); |
| 425 |
} |
445 |
Control control = getControl(); |
| 426 |
return result; |
446 |
if (control != null) { |
| 427 |
} |
447 |
result.minimumWidth = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, |
| 428 |
|
448 |
true).x; |
| 429 |
/** |
449 |
} |
| 430 |
* Returns the input validator for this cell editor. |
450 |
return result; |
| 431 |
* |
451 |
} |
| 432 |
* @return the input validator, or <code>null</code> if none |
452 |
|
| 433 |
*/ |
453 |
/** |
| 434 |
public ICellEditorValidator getValidator() { |
454 |
* Returns the input validator for this cell editor. |
| 435 |
return validator; |
455 |
* |
| 436 |
} |
456 |
* @return the input validator, or <code>null</code> if none |
| 437 |
|
457 |
*/ |
| 438 |
/** |
458 |
public ICellEditorValidator getValidator() { |
| 439 |
* Returns this cell editor's value provided that it has a valid one. |
459 |
return validator; |
| 440 |
* |
460 |
} |
| 441 |
* @return the value of this cell editor, or <code>null</code> |
461 |
|
| 442 |
* if the cell editor does not contain a valid value |
462 |
/** |
| 443 |
*/ |
463 |
* Returns this cell editor's value provided that it has a valid one. |
| 444 |
public final Object getValue() { |
464 |
* |
| 445 |
if (!valid) { |
465 |
* @return the value of this cell editor, or <code>null</code> if the cell |
|
|
466 |
* editor does not contain a valid value |
| 467 |
*/ |
| 468 |
public final Object getValue() { |
| 469 |
if (!valid) { |
| 446 |
return null; |
470 |
return null; |
| 447 |
} |
471 |
} |
| 448 |
|
472 |
|
| 449 |
return doGetValue(); |
473 |
return doGetValue(); |
| 450 |
} |
474 |
} |
| 451 |
|
475 |
|
| 452 |
/** |
476 |
/** |
| 453 |
* Returns whether this cell editor is activated. |
477 |
* Returns whether this cell editor is activated. |
| 454 |
* |
478 |
* |
| 455 |
* @return <code>true</code> if this cell editor's control is |
479 |
* @return <code>true</code> if this cell editor's control is currently |
| 456 |
* currently activated, and <code>false</code> if not activated |
480 |
* activated, and <code>false</code> if not activated |
| 457 |
*/ |
481 |
*/ |
| 458 |
public boolean isActivated() { |
482 |
public boolean isActivated() { |
| 459 |
// Use the state of the visible style bit (getVisible()) rather than the |
483 |
// Use the state of the visible style bit (getVisible()) rather than the |
| 460 |
// window's actual visibility (isVisible()) to get correct handling when |
484 |
// window's actual visibility (isVisible()) to get correct handling when |
| 461 |
// an ancestor control goes invisible, see bug 85331. |
485 |
// an ancestor control goes invisible, see bug 85331. |
| 462 |
return control != null && control.getVisible(); |
486 |
return control != null && control.getVisible(); |
| 463 |
} |
487 |
} |
| 464 |
|
488 |
|
| 465 |
/** |
489 |
/** |
| 466 |
* Returns <code>true</code> if this cell editor is |
490 |
* Returns <code>true</code> if this cell editor is able to perform the |
| 467 |
* able to perform the copy action. |
491 |
* copy action. |
| 468 |
* <p> |
492 |
* <p> |
| 469 |
* This default implementation always returns |
493 |
* This default implementation always returns <code>false</code>. |
| 470 |
* <code>false</code>. |
494 |
* </p> |
| 471 |
* </p> |
495 |
* <p> |
| 472 |
* <p> |
496 |
* Subclasses may override |
| 473 |
* Subclasses may override |
497 |
* </p> |
| 474 |
* </p> |
498 |
* |
| 475 |
* @return <code>true</code> if copy is possible, |
499 |
* @return <code>true</code> if copy is possible, <code>false</code> |
| 476 |
* <code>false</code> otherwise |
500 |
* otherwise |
| 477 |
*/ |
501 |
*/ |
| 478 |
public boolean isCopyEnabled() { |
502 |
public boolean isCopyEnabled() { |
| 479 |
return false; |
503 |
return false; |
| 480 |
} |
504 |
} |
| 481 |
|
505 |
|
| 482 |
/** |
506 |
/** |
| 483 |
* Returns whether the given value is valid for this cell editor. |
507 |
* Returns whether the given value is valid for this cell editor. This cell |
| 484 |
* This cell editor's validator (if any) makes the actual determination. |
508 |
* editor's validator (if any) makes the actual determination. |
| 485 |
* @param value the value to check for |
509 |
* |
| 486 |
* |
510 |
* @param value |
| 487 |
* @return <code>true</code> if the value is valid, and <code>false</code> |
511 |
* the value to check for |
| 488 |
* if invalid |
512 |
* |
| 489 |
*/ |
513 |
* @return <code>true</code> if the value is valid, and <code>false</code> |
| 490 |
protected boolean isCorrect(Object value) { |
514 |
* if invalid |
| 491 |
errorMessage = null; |
515 |
*/ |
| 492 |
if (validator == null) { |
516 |
protected boolean isCorrect(Object value) { |
|
|
517 |
errorMessage = null; |
| 518 |
if (validator == null) { |
| 493 |
return true; |
519 |
return true; |
| 494 |
} |
520 |
} |
| 495 |
|
521 |
|
| 496 |
errorMessage = validator.isValid(value); |
522 |
errorMessage = validator.isValid(value); |
| 497 |
return (errorMessage == null || errorMessage.equals(""));//$NON-NLS-1$ |
523 |
return (errorMessage == null || errorMessage.equals(""));//$NON-NLS-1$ |
| 498 |
} |
524 |
} |
| 499 |
|
525 |
|
| 500 |
/** |
526 |
/** |
| 501 |
* Returns <code>true</code> if this cell editor is |
527 |
* Returns <code>true</code> if this cell editor is able to perform the |
| 502 |
* able to perform the cut action. |
528 |
* cut action. |
| 503 |
* <p> |
529 |
* <p> |
| 504 |
* This default implementation always returns |
530 |
* This default implementation always returns <code>false</code>. |
| 505 |
* <code>false</code>. |
531 |
* </p> |
| 506 |
* </p> |
532 |
* <p> |
| 507 |
* <p> |
533 |
* Subclasses may override |
| 508 |
* Subclasses may override |
534 |
* </p> |
| 509 |
* </p> |
535 |
* |
| 510 |
* @return <code>true</code> if cut is possible, |
536 |
* @return <code>true</code> if cut is possible, <code>false</code> |
| 511 |
* <code>false</code> otherwise |
537 |
* otherwise |
| 512 |
*/ |
538 |
*/ |
| 513 |
public boolean isCutEnabled() { |
539 |
public boolean isCutEnabled() { |
| 514 |
return false; |
540 |
return false; |
| 515 |
} |
541 |
} |
| 516 |
|
542 |
|
| 517 |
/** |
543 |
/** |
| 518 |
* Returns <code>true</code> if this cell editor is |
544 |
* Returns <code>true</code> if this cell editor is able to perform the |
| 519 |
* able to perform the delete action. |
545 |
* delete action. |
| 520 |
* <p> |
546 |
* <p> |
| 521 |
* This default implementation always returns |
547 |
* This default implementation always returns <code>false</code>. |
| 522 |
* <code>false</code>. |
548 |
* </p> |
| 523 |
* </p> |
549 |
* <p> |
| 524 |
* <p> |
550 |
* Subclasses may override |
| 525 |
* Subclasses may override |
551 |
* </p> |
| 526 |
* </p> |
552 |
* |
| 527 |
* @return <code>true</code> if delete is possible, |
553 |
* @return <code>true</code> if delete is possible, <code>false</code> |
| 528 |
* <code>false</code> otherwise |
554 |
* otherwise |
| 529 |
*/ |
555 |
*/ |
| 530 |
public boolean isDeleteEnabled() { |
556 |
public boolean isDeleteEnabled() { |
| 531 |
return false; |
557 |
return false; |
| 532 |
} |
558 |
} |
| 533 |
|
559 |
|
| 534 |
/** |
560 |
/** |
| 535 |
* Returns whether the value of this cell editor has changed since the |
561 |
* Returns whether the value of this cell editor has changed since the last |
| 536 |
* last call to <code>setValue</code>. |
562 |
* call to <code>setValue</code>. |
| 537 |
* |
563 |
* |
| 538 |
* @return <code>true</code> if the value has changed, and <code>false</code> |
564 |
* @return <code>true</code> if the value has changed, and |
| 539 |
* if unchanged |
565 |
* <code>false</code> if unchanged |
| 540 |
*/ |
566 |
*/ |
| 541 |
public boolean isDirty() { |
567 |
public boolean isDirty() { |
| 542 |
return dirty; |
568 |
return dirty; |
| 543 |
} |
569 |
} |
| 544 |
|
570 |
|
| 545 |
/** |
571 |
/** |
| 546 |
* Marks this cell editor as dirty. |
572 |
* Marks this cell editor as dirty. |
| 547 |
* @since 2.1 |
573 |
* |
| 548 |
*/ |
574 |
* @since 2.1 |
| 549 |
protected void markDirty() { |
575 |
*/ |
| 550 |
dirty = true; |
576 |
protected void markDirty() { |
| 551 |
} |
577 |
dirty = true; |
| 552 |
|
578 |
} |
| 553 |
/** |
579 |
|
| 554 |
* Returns <code>true</code> if this cell editor is |
580 |
/** |
| 555 |
* able to perform the find action. |
581 |
* Returns <code>true</code> if this cell editor is able to perform the |
| 556 |
* <p> |
582 |
* find action. |
| 557 |
* This default implementation always returns |
583 |
* <p> |
| 558 |
* <code>false</code>. |
584 |
* This default implementation always returns <code>false</code>. |
| 559 |
* </p> |
585 |
* </p> |
| 560 |
* <p> |
586 |
* <p> |
| 561 |
* Subclasses may override |
587 |
* Subclasses may override |
| 562 |
* </p> |
588 |
* </p> |
| 563 |
* @return <code>true</code> if find is possible, |
589 |
* |
| 564 |
* <code>false</code> otherwise |
590 |
* @return <code>true</code> if find is possible, <code>false</code> |
| 565 |
*/ |
591 |
* otherwise |
| 566 |
public boolean isFindEnabled() { |
592 |
*/ |
| 567 |
return false; |
593 |
public boolean isFindEnabled() { |
| 568 |
} |
594 |
return false; |
| 569 |
|
595 |
} |
| 570 |
/** |
596 |
|
| 571 |
* Returns <code>true</code> if this cell editor is |
597 |
/** |
| 572 |
* able to perform the paste action. |
598 |
* Returns <code>true</code> if this cell editor is able to perform the |
| 573 |
* <p> |
599 |
* paste action. |
| 574 |
* This default implementation always returns |
600 |
* <p> |
| 575 |
* <code>false</code>. |
601 |
* This default implementation always returns <code>false</code>. |
| 576 |
* </p> |
602 |
* </p> |
| 577 |
* <p> |
603 |
* <p> |
| 578 |
* Subclasses may override |
604 |
* Subclasses may override |
| 579 |
* </p> |
605 |
* </p> |
| 580 |
* @return <code>true</code> if paste is possible, |
606 |
* |
| 581 |
* <code>false</code> otherwise |
607 |
* @return <code>true</code> if paste is possible, <code>false</code> |
| 582 |
*/ |
608 |
* otherwise |
| 583 |
public boolean isPasteEnabled() { |
609 |
*/ |
| 584 |
return false; |
610 |
public boolean isPasteEnabled() { |
| 585 |
} |
611 |
return false; |
| 586 |
|
612 |
} |
| 587 |
/** |
613 |
|
| 588 |
* Returns <code>true</code> if this cell editor is |
614 |
/** |
| 589 |
* able to perform the redo action. |
615 |
* Returns <code>true</code> if this cell editor is able to perform the |
| 590 |
* <p> |
616 |
* redo action. |
| 591 |
* This default implementation always returns |
617 |
* <p> |
| 592 |
* <code>false</code>. |
618 |
* This default implementation always returns <code>false</code>. |
| 593 |
* </p> |
619 |
* </p> |
| 594 |
* <p> |
620 |
* <p> |
| 595 |
* Subclasses may override |
621 |
* Subclasses may override |
| 596 |
* </p> |
622 |
* </p> |
| 597 |
* @return <code>true</code> if redo is possible, |
623 |
* |
| 598 |
* <code>false</code> otherwise |
624 |
* @return <code>true</code> if redo is possible, <code>false</code> |
| 599 |
*/ |
625 |
* otherwise |
| 600 |
public boolean isRedoEnabled() { |
626 |
*/ |
| 601 |
return false; |
627 |
public boolean isRedoEnabled() { |
| 602 |
} |
628 |
return false; |
| 603 |
|
629 |
} |
| 604 |
/** |
630 |
|
| 605 |
* Returns <code>true</code> if this cell editor is |
631 |
/** |
| 606 |
* able to perform the select all action. |
632 |
* Returns <code>true</code> if this cell editor is able to perform the |
| 607 |
* <p> |
633 |
* select all action. |
| 608 |
* This default implementation always returns |
634 |
* <p> |
| 609 |
* <code>false</code>. |
635 |
* This default implementation always returns <code>false</code>. |
| 610 |
* </p> |
636 |
* </p> |
| 611 |
* <p> |
637 |
* <p> |
| 612 |
* Subclasses may override |
638 |
* Subclasses may override |
| 613 |
* </p> |
639 |
* </p> |
| 614 |
* @return <code>true</code> if select all is possible, |
640 |
* |
| 615 |
* <code>false</code> otherwise |
641 |
* @return <code>true</code> if select all is possible, <code>false</code> |
| 616 |
*/ |
642 |
* otherwise |
| 617 |
public boolean isSelectAllEnabled() { |
643 |
*/ |
| 618 |
return false; |
644 |
public boolean isSelectAllEnabled() { |
| 619 |
} |
645 |
return false; |
| 620 |
|
646 |
} |
| 621 |
/** |
647 |
|
| 622 |
* Returns <code>true</code> if this cell editor is |
648 |
/** |
| 623 |
* able to perform the undo action. |
649 |
* Returns <code>true</code> if this cell editor is able to perform the |
| 624 |
* <p> |
650 |
* undo action. |
| 625 |
* This default implementation always returns |
651 |
* <p> |
| 626 |
* <code>false</code>. |
652 |
* This default implementation always returns <code>false</code>. |
| 627 |
* </p> |
653 |
* </p> |
| 628 |
* <p> |
654 |
* <p> |
| 629 |
* Subclasses may override |
655 |
* Subclasses may override |
| 630 |
* </p> |
656 |
* </p> |
| 631 |
* @return <code>true</code> if undo is possible, |
657 |
* |
| 632 |
* <code>false</code> otherwise |
658 |
* @return <code>true</code> if undo is possible, <code>false</code> |
| 633 |
*/ |
659 |
* otherwise |
| 634 |
public boolean isUndoEnabled() { |
660 |
*/ |
| 635 |
return false; |
661 |
public boolean isUndoEnabled() { |
| 636 |
} |
662 |
return false; |
| 637 |
|
663 |
} |
| 638 |
/** |
664 |
|
| 639 |
* Returns whether this cell editor has a valid value. |
665 |
/** |
| 640 |
* The default value is false. |
666 |
* Returns whether this cell editor has a valid value. The default value is |
| 641 |
* |
667 |
* false. |
| 642 |
* @return <code>true</code> if the value is valid, and <code>false</code> |
668 |
* |
| 643 |
* if invalid |
669 |
* @return <code>true</code> if the value is valid, and <code>false</code> |
| 644 |
* |
670 |
* if invalid |
| 645 |
* @see #setValueValid(boolean) |
671 |
* |
| 646 |
*/ |
672 |
* @see #setValueValid(boolean) |
| 647 |
public boolean isValueValid() { |
673 |
*/ |
| 648 |
return valid; |
674 |
public boolean isValueValid() { |
| 649 |
} |
675 |
return valid; |
| 650 |
|
676 |
} |
| 651 |
/** |
677 |
|
| 652 |
* Processes a key release event that occurred in this cell editor. |
678 |
/** |
| 653 |
* <p> |
679 |
* Processes a key release event that occurred in this cell editor. |
| 654 |
* The default implementation of this framework method cancels editing |
680 |
* <p> |
| 655 |
* when the ESC key is pressed. When the RETURN key is pressed the current |
681 |
* The default implementation of this framework method cancels editing when |
| 656 |
* value is applied and the cell editor deactivates. |
682 |
* the ESC key is pressed. When the RETURN key is pressed the current value |
| 657 |
* Subclasses should call this method at appropriate times. |
683 |
* is applied and the cell editor deactivates. Subclasses should call this |
| 658 |
* Subclasses may also extend or reimplement. |
684 |
* method at appropriate times. Subclasses may also extend or reimplement. |
| 659 |
* </p> |
685 |
* </p> |
| 660 |
* |
686 |
* |
| 661 |
* @param keyEvent the key event |
687 |
* @param keyEvent |
| 662 |
*/ |
688 |
* the key event |
| 663 |
protected void keyReleaseOccured(KeyEvent keyEvent) { |
689 |
*/ |
| 664 |
if (keyEvent.character == '\u001b') { // Escape character |
690 |
protected void keyReleaseOccured(KeyEvent keyEvent) { |
| 665 |
fireCancelEditor(); |
691 |
if (keyEvent.character == '\u001b') { // Escape character |
| 666 |
} else if (keyEvent.character == '\r') { // Return key |
692 |
fireCancelEditor(); |
| 667 |
fireApplyEditorValue(); |
693 |
} else if (keyEvent.character == '\r') { // Return key |
| 668 |
deactivate(); |
694 |
fireApplyEditorValue(); |
| 669 |
} |
695 |
deactivate(); |
| 670 |
} |
696 |
} |
| 671 |
|
697 |
} |
| 672 |
/** |
698 |
|
| 673 |
* Processes a focus lost event that occurred in this cell editor. |
699 |
/** |
| 674 |
* <p> |
700 |
* Processes a focus lost event that occurred in this cell editor. |
| 675 |
* The default implementation of this framework method applies the current |
701 |
* <p> |
| 676 |
* value and deactivates the cell editor. |
702 |
* The default implementation of this framework method applies the current |
| 677 |
* Subclasses should call this method at appropriate times. |
703 |
* value and deactivates the cell editor. Subclasses should call this method |
| 678 |
* Subclasses may also extend or reimplement. |
704 |
* at appropriate times. Subclasses may also extend or reimplement. |
| 679 |
* </p> |
705 |
* </p> |
| 680 |
*/ |
706 |
*/ |
| 681 |
protected void focusLost() { |
707 |
protected void focusLost() { |
| 682 |
if (isActivated()) { |
708 |
if (isActivated()) { |
| 683 |
fireApplyEditorValue(); |
709 |
fireApplyEditorValue(); |
| 684 |
deactivate(); |
710 |
deactivate(); |
| 685 |
} |
711 |
} |
| 686 |
} |
712 |
} |
| 687 |
|
713 |
|
| 688 |
/** |
714 |
/** |
| 689 |
* Performs the copy action. |
715 |
* Performs the copy action. This default implementation does nothing. |
| 690 |
* This default implementation does nothing. |
716 |
* <p> |
| 691 |
* <p> |
717 |
* Subclasses may override |
| 692 |
* Subclasses may override |
718 |
* </p> |
| 693 |
* </p> |
719 |
*/ |
| 694 |
*/ |
720 |
public void performCopy() { |
| 695 |
public void performCopy() { |
721 |
} |
| 696 |
} |
722 |
|
| 697 |
|
723 |
/** |
| 698 |
/** |
724 |
* Performs the cut action. This default implementation does nothing. |
| 699 |
* Performs the cut action. |
725 |
* <p> |
| 700 |
* This default implementation does nothing. |
726 |
* Subclasses may override |
| 701 |
* <p> |
727 |
* </p> |
| 702 |
* Subclasses may override |
728 |
*/ |
| 703 |
* </p> |
729 |
public void performCut() { |
| 704 |
*/ |
730 |
} |
| 705 |
public void performCut() { |
731 |
|
| 706 |
} |
732 |
/** |
| 707 |
|
733 |
* Performs the delete action. This default implementation does nothing. |
| 708 |
/** |
734 |
* <p> |
| 709 |
* Performs the delete action. |
735 |
* Subclasses may override |
| 710 |
* This default implementation does nothing. |
736 |
* </p> |
| 711 |
* <p> |
737 |
*/ |
| 712 |
* Subclasses may override |
738 |
public void performDelete() { |
| 713 |
* </p> |
739 |
} |
| 714 |
*/ |
740 |
|
| 715 |
public void performDelete() { |
741 |
/** |
| 716 |
} |
742 |
* Performs the find action. This default implementation does nothing. |
| 717 |
|
743 |
* <p> |
| 718 |
/** |
744 |
* Subclasses may override |
| 719 |
* Performs the find action. |
745 |
* </p> |
| 720 |
* This default implementation does nothing. |
746 |
*/ |
| 721 |
* <p> |
747 |
public void performFind() { |
| 722 |
* Subclasses may override |
748 |
} |
| 723 |
* </p> |
749 |
|
| 724 |
*/ |
750 |
/** |
| 725 |
public void performFind() { |
751 |
* Performs the paste action. This default implementation does nothing. |
| 726 |
} |
752 |
* <p> |
| 727 |
|
753 |
* Subclasses may override |
| 728 |
/** |
754 |
* </p> |
| 729 |
* Performs the paste action. |
755 |
*/ |
| 730 |
* This default implementation does nothing. |
756 |
public void performPaste() { |
| 731 |
* <p> |
757 |
} |
| 732 |
* Subclasses may override |
758 |
|
| 733 |
* </p> |
759 |
/** |
| 734 |
*/ |
760 |
* Performs the redo action. This default implementation does nothing. |
| 735 |
public void performPaste() { |
761 |
* <p> |
| 736 |
} |
762 |
* Subclasses may override |
| 737 |
|
763 |
* </p> |
| 738 |
/** |
764 |
*/ |
| 739 |
* Performs the redo action. |
765 |
public void performRedo() { |
| 740 |
* This default implementation does nothing. |
766 |
} |
| 741 |
* <p> |
767 |
|
| 742 |
* Subclasses may override |
768 |
/** |
| 743 |
* </p> |
769 |
* Performs the select all action. This default implementation does nothing. |
| 744 |
*/ |
770 |
* <p> |
| 745 |
public void performRedo() { |
771 |
* Subclasses may override |
| 746 |
} |
772 |
* </p> |
| 747 |
|
773 |
*/ |
| 748 |
/** |
774 |
public void performSelectAll() { |
| 749 |
* Performs the select all action. |
775 |
} |
| 750 |
* This default implementation does nothing. |
776 |
|
| 751 |
* <p> |
777 |
/** |
| 752 |
* Subclasses may override |
778 |
* Performs the undo action. This default implementation does nothing. |
| 753 |
* </p> |
779 |
* <p> |
| 754 |
*/ |
780 |
* Subclasses may override |
| 755 |
public void performSelectAll() { |
781 |
* </p> |
| 756 |
} |
782 |
*/ |
| 757 |
|
783 |
public void performUndo() { |
| 758 |
/** |
784 |
} |
| 759 |
* Performs the undo action. |
785 |
|
| 760 |
* This default implementation does nothing. |
786 |
/** |
| 761 |
* <p> |
787 |
* Removes the given listener from this cell editor. Has no affect if an |
| 762 |
* Subclasses may override |
788 |
* identical listener is not registered. |
| 763 |
* </p> |
789 |
* |
| 764 |
*/ |
790 |
* @param listener |
| 765 |
public void performUndo() { |
791 |
* a cell editor listener |
| 766 |
} |
792 |
*/ |
| 767 |
|
793 |
public void removeListener(ICellEditorListener listener) { |
| 768 |
/** |
794 |
listeners.remove(listener); |
| 769 |
* Removes the given listener from this cell editor. |
795 |
} |
| 770 |
* Has no affect if an identical listener is not registered. |
796 |
|
| 771 |
* |
797 |
/** |
| 772 |
* @param listener a cell editor listener |
798 |
* Removes the given property change listener from this cell editor. Has no |
| 773 |
*/ |
799 |
* affect if an identical property change listener is not registered. |
| 774 |
public void removeListener(ICellEditorListener listener) { |
800 |
* |
| 775 |
listeners.remove(listener); |
801 |
* @param listener |
| 776 |
} |
802 |
* a property change listener |
| 777 |
|
803 |
*/ |
| 778 |
/** |
804 |
public void removePropertyChangeListener(IPropertyChangeListener listener) { |
| 779 |
* Removes the given property change listener from this cell editor. |
805 |
propertyChangeListeners.remove(listener); |
| 780 |
* Has no affect if an identical property change listener is not |
806 |
} |
| 781 |
* registered. |
807 |
|
| 782 |
* |
808 |
/** |
| 783 |
* @param listener a property change listener |
809 |
* Sets or clears the current error message for this cell editor. |
| 784 |
*/ |
810 |
* <p> |
| 785 |
public void removePropertyChangeListener(IPropertyChangeListener listener) { |
811 |
* No formatting is done here, the message to be set is expected to be fully |
| 786 |
propertyChangeListeners.remove(listener); |
812 |
* formatted before being passed in. |
| 787 |
} |
813 |
* </p> |
| 788 |
|
814 |
* |
| 789 |
/** |
815 |
* @param message |
| 790 |
* Sets or clears the current error message for this cell editor. |
816 |
* the error message, or <code>null</code> to clear |
| 791 |
* <p> |
817 |
*/ |
| 792 |
* No formatting is done here, the message to be set is expected to be fully formatted |
818 |
protected void setErrorMessage(String message) { |
| 793 |
* before being passed in. |
819 |
errorMessage = message; |
| 794 |
* </p> |
820 |
} |
| 795 |
* @param message the error message, or <code>null</code> to clear |
821 |
|
| 796 |
*/ |
822 |
/** |
| 797 |
protected void setErrorMessage(String message) { |
823 |
* Sets the focus to the cell editor's control. |
| 798 |
errorMessage = message; |
824 |
*/ |
| 799 |
} |
825 |
public void setFocus() { |
| 800 |
|
826 |
doSetFocus(); |
| 801 |
/** |
827 |
} |
| 802 |
* Sets the focus to the cell editor's control. |
828 |
|
| 803 |
*/ |
829 |
/** |
| 804 |
public void setFocus() { |
830 |
* Sets the input validator for this cell editor. |
| 805 |
doSetFocus(); |
831 |
* |
| 806 |
} |
832 |
* @param validator |
| 807 |
|
833 |
* the input validator, or <code>null</code> if none |
| 808 |
/** |
834 |
*/ |
| 809 |
* Sets the input validator for this cell editor. |
835 |
public void setValidator(ICellEditorValidator validator) { |
| 810 |
* |
836 |
this.validator = validator; |
| 811 |
* @param validator the input validator, or <code>null</code> if none |
837 |
} |
| 812 |
*/ |
838 |
|
| 813 |
public void setValidator(ICellEditorValidator validator) { |
839 |
/** |
| 814 |
this.validator = validator; |
840 |
* Sets this cell editor's value. |
| 815 |
} |
841 |
* |
| 816 |
|
842 |
* @param value |
| 817 |
/** |
843 |
* the value of this cell editor |
| 818 |
* Sets this cell editor's value. |
844 |
*/ |
| 819 |
* |
845 |
public final void setValue(Object value) { |
| 820 |
* @param value the value of this cell editor |
846 |
valid = isCorrect(value); |
| 821 |
*/ |
847 |
dirty = false; |
| 822 |
public final void setValue(Object value) { |
848 |
doSetValue(value); |
| 823 |
valid = isCorrect(value); |
849 |
} |
| 824 |
dirty = false; |
850 |
|
| 825 |
doSetValue(value); |
851 |
/** |
| 826 |
} |
852 |
* Sets the valid state of this cell editor. The default value is false. |
| 827 |
|
853 |
* Subclasses should call this method on construction. |
| 828 |
/** |
854 |
* |
| 829 |
* Sets the valid state of this cell editor. |
855 |
* @param valid |
| 830 |
* The default value is false. |
856 |
* <code>true</code> if the current valie is valid, and |
| 831 |
* Subclasses should call this method on construction. |
857 |
* <code>false</code> if invalid |
| 832 |
* |
858 |
* |
| 833 |
* @param valid <code>true</code> if the current valie is valid, |
859 |
* @see #isValueValid |
| 834 |
* and <code>false</code> if invalid |
860 |
*/ |
| 835 |
* |
861 |
protected void setValueValid(boolean valid) { |
| 836 |
* @see #isValueValid |
862 |
this.valid = valid; |
| 837 |
*/ |
863 |
} |
| 838 |
protected void setValueValid(boolean valid) { |
864 |
|
| 839 |
this.valid = valid; |
865 |
/** |
| 840 |
} |
866 |
* The value has changed. Updates the valid state flag, marks this cell |
| 841 |
|
867 |
* editor as dirty, and notifies all registered cell editor listeners of a |
| 842 |
/** |
868 |
* value change. |
| 843 |
* The value has changed. |
869 |
* |
| 844 |
* Updates the valid state flag, marks this cell editor as dirty, |
870 |
* @param oldValidState |
| 845 |
* and notifies all registered cell editor listeners of a value change. |
871 |
* the valid state before the end user changed the value |
| 846 |
* |
872 |
* @param newValidState |
| 847 |
* @param oldValidState the valid state before the end user changed the value |
873 |
* the current valid state |
| 848 |
* @param newValidState the current valid state |
874 |
* @see ICellEditorListener#editorValueChanged |
| 849 |
* @see ICellEditorListener#editorValueChanged |
875 |
*/ |
| 850 |
*/ |
876 |
protected void valueChanged(boolean oldValidState, boolean newValidState) { |
| 851 |
protected void valueChanged(boolean oldValidState, boolean newValidState) { |
877 |
valid = newValidState; |
| 852 |
valid = newValidState; |
878 |
dirty = true; |
| 853 |
dirty = true; |
879 |
fireEditorValueChanged(oldValidState, newValidState); |
| 854 |
fireEditorValueChanged(oldValidState, newValidState); |
880 |
} |
| 855 |
} |
|
|
| 856 |
} |
881 |
} |