Lines 11-26
Link Here
|
11 |
|
11 |
|
12 |
package org.eclipse.jface.viewers; |
12 |
package org.eclipse.jface.viewers; |
13 |
|
13 |
|
|
|
14 |
import org.eclipse.jface.viewers.editing.AbstractEditableTreeColumn; |
15 |
import org.eclipse.jface.viewers.editing.IEditableColumn; |
16 |
import org.eclipse.jface.viewers.editing.IEditableMultiColumn; |
17 |
import org.eclipse.jface.viewers.editing.ITabulatorTraversingSupport; |
14 |
import org.eclipse.swt.events.FocusAdapter; |
18 |
import org.eclipse.swt.events.FocusAdapter; |
15 |
import org.eclipse.swt.events.FocusEvent; |
19 |
import org.eclipse.swt.events.FocusEvent; |
16 |
import org.eclipse.swt.events.FocusListener; |
20 |
import org.eclipse.swt.events.FocusListener; |
17 |
import org.eclipse.swt.events.MouseAdapter; |
21 |
import org.eclipse.swt.events.MouseAdapter; |
18 |
import org.eclipse.swt.events.MouseEvent; |
22 |
import org.eclipse.swt.events.MouseEvent; |
19 |
import org.eclipse.swt.events.MouseListener; |
23 |
import org.eclipse.swt.events.MouseListener; |
|
|
24 |
import org.eclipse.swt.events.TraverseListener; |
20 |
import org.eclipse.swt.graphics.Rectangle; |
25 |
import org.eclipse.swt.graphics.Rectangle; |
21 |
import org.eclipse.swt.widgets.Control; |
26 |
import org.eclipse.swt.widgets.Control; |
22 |
import org.eclipse.swt.widgets.Display; |
27 |
import org.eclipse.swt.widgets.Display; |
23 |
import org.eclipse.swt.widgets.Item; |
28 |
import org.eclipse.swt.widgets.Item; |
|
|
29 |
import org.eclipse.swt.widgets.TreeColumn; |
24 |
|
30 |
|
25 |
/** |
31 |
/** |
26 |
* Internal tree viewer implementation. |
32 |
* Internal tree viewer implementation. |
Lines 29-359
Link Here
|
29 |
*/ |
35 |
*/ |
30 |
/* package */abstract class TreeEditorImpl { |
36 |
/* package */abstract class TreeEditorImpl { |
31 |
|
37 |
|
32 |
private CellEditor cellEditor; |
38 |
private CellEditor cellEditor; |
33 |
|
39 |
|
34 |
private CellEditor[] cellEditors; |
40 |
/** |
|
|
41 |
* @deprecated |
42 |
*/ |
43 |
private CellEditor[] cellEditors; |
35 |
|
44 |
|
36 |
private ICellModifier cellModifier; |
45 |
/** |
|
|
46 |
* @deprecated |
47 |
*/ |
48 |
private ICellModifier cellModifier; |
37 |
|
49 |
|
38 |
private String[] columnProperties; |
50 |
/** |
|
|
51 |
* @deprecated |
52 |
*/ |
53 |
private String[] columnProperties; |
39 |
|
54 |
|
40 |
private Item treeItem; |
55 |
private Item treeItem; |
41 |
|
56 |
|
42 |
private int columnNumber; |
57 |
private int columnNumber; |
43 |
|
58 |
|
44 |
private ICellEditorListener cellEditorListener; |
59 |
private ICellEditorListener cellEditorListener; |
45 |
|
60 |
|
46 |
private FocusListener focusListener; |
61 |
private FocusListener focusListener; |
47 |
|
62 |
|
48 |
private MouseListener mouseListener; |
63 |
private MouseListener mouseListener; |
49 |
|
64 |
|
50 |
private int doubleClickExpirationTime; |
65 |
private int doubleClickExpirationTime; |
51 |
|
66 |
|
52 |
private StructuredViewer viewer; |
67 |
private StructuredViewer viewer; |
53 |
|
68 |
|
54 |
TreeEditorImpl(StructuredViewer viewer) { |
69 |
TreeEditorImpl(StructuredViewer viewer) { |
55 |
this.viewer = viewer; |
70 |
this.viewer = viewer; |
56 |
initCellEditorListener(); |
71 |
initCellEditorListener(); |
57 |
} |
72 |
} |
58 |
|
73 |
|
59 |
/** |
74 |
/** |
60 |
* Returns this <code>TreeViewerImpl</code> viewer |
75 |
* Returns this <code>TreeViewerImpl</code> viewer |
61 |
* |
76 |
* |
62 |
* @return the viewer |
77 |
* @return the viewer |
63 |
*/ |
78 |
*/ |
64 |
public StructuredViewer getViewer() { |
79 |
public StructuredViewer getViewer() { |
65 |
return viewer; |
80 |
return viewer; |
66 |
} |
81 |
} |
67 |
|
82 |
|
68 |
private void activateCellEditor() { |
83 |
private void activateCellEditor() { |
69 |
if (cellEditors != null) { |
84 |
CellEditor editor = getEditor(columnNumber); |
70 |
if (cellEditors[columnNumber] != null && cellModifier != null) { |
85 |
|
71 |
Object element = treeItem.getData(); |
86 |
if (editor != null) { |
72 |
String property = columnProperties[columnNumber]; |
87 |
Object element = treeItem.getData(); |
73 |
if (cellModifier.canModify(element, property)) { |
88 |
|
74 |
cellEditor = cellEditors[columnNumber]; |
89 |
cellEditor = editor; |
75 |
//tree.showSelection(); |
90 |
|
76 |
cellEditor.addListener(cellEditorListener); |
91 |
if(viewer instanceof ITabulatorTraversingSupport && ((ITabulatorTraversingSupport) viewer).isTabulatorTraversalEnabled()) { |
77 |
Object value = cellModifier.getValue(element, property); |
92 |
cellEditor.getControl().addTraverseListener(getTabeditingListener()); |
78 |
cellEditor.setValue(value); |
93 |
} |
79 |
// Tricky flow of control here: |
94 |
|
80 |
// activate() can trigger callback to cellEditorListener which will clear cellEditor |
95 |
// tree.showSelection(); |
81 |
// so must get control first, but must still call activate() even if there is no control. |
96 |
cellEditor.addListener(cellEditorListener); |
82 |
final Control control = cellEditor.getControl(); |
97 |
Object value = getModelValue(element, columnNumber); |
83 |
cellEditor.activate(); |
98 |
cellEditor.setValue(value); |
84 |
if (control == null) { |
99 |
// Tricky flow of control here: |
85 |
return; |
100 |
// activate() can trigger callback to cellEditorListener which will |
|
|
101 |
// clear cellEditor |
102 |
// so must get control first, but must still call activate() even if |
103 |
// there is no control. |
104 |
final Control control = cellEditor.getControl(); |
105 |
cellEditor.activate(); |
106 |
if (control == null) { |
107 |
return; |
108 |
} |
109 |
setLayoutData(cellEditor.getLayoutData()); |
110 |
setEditor(control, treeItem, columnNumber); |
111 |
cellEditor.setFocus(); |
112 |
if (focusListener == null) { |
113 |
focusListener = new FocusAdapter() { |
114 |
public void focusLost(FocusEvent e) { |
115 |
applyEditorValue(); |
86 |
} |
116 |
} |
87 |
setLayoutData(cellEditor.getLayoutData()); |
117 |
}; |
88 |
setEditor(control, treeItem, columnNumber); |
118 |
} |
89 |
cellEditor.setFocus(); |
119 |
control.addFocusListener(focusListener); |
90 |
if (focusListener == null) { |
120 |
mouseListener = new MouseAdapter() { |
91 |
focusListener = new FocusAdapter() { |
121 |
public void mouseDown(MouseEvent e) { |
92 |
public void focusLost(FocusEvent e) { |
122 |
// time wrap? |
93 |
applyEditorValue(); |
123 |
// check for expiration of doubleClickTime |
94 |
} |
124 |
if (e.time <= doubleClickExpirationTime) { |
95 |
}; |
125 |
control.removeMouseListener(mouseListener); |
96 |
} |
126 |
cancelEditing(); |
97 |
control.addFocusListener(focusListener); |
127 |
handleDoubleClickEvent(); |
98 |
mouseListener = new MouseAdapter() { |
128 |
} else if (mouseListener != null) { |
99 |
public void mouseDown(MouseEvent e) { |
129 |
control.removeMouseListener(mouseListener); |
100 |
// time wrap? |
130 |
} |
101 |
// check for expiration of doubleClickTime |
131 |
} |
102 |
if (e.time <= doubleClickExpirationTime) { |
132 |
}; |
103 |
control.removeMouseListener(mouseListener); |
133 |
control.addMouseListener(mouseListener); |
104 |
cancelEditing(); |
134 |
} |
105 |
handleDoubleClickEvent(); |
135 |
} |
106 |
} else if (mouseListener != null) { |
|
|
107 |
control.removeMouseListener(mouseListener); |
108 |
} |
109 |
} |
110 |
}; |
111 |
control.addMouseListener(mouseListener); |
112 |
} |
113 |
} |
114 |
} |
115 |
} |
116 |
|
136 |
|
117 |
/** |
137 |
private CellEditor getEditor(int columnNumber) { |
118 |
* Activate a cell editor for the given mouse position. |
138 |
CellEditor editor = null; |
119 |
*/ |
|
|
120 |
private void activateCellEditor(MouseEvent event) { |
121 |
if (treeItem == null || treeItem.isDisposed()) { |
122 |
//item no longer exists |
123 |
return; |
124 |
} |
125 |
int columnToEdit; |
126 |
int columns = getColumnCount(); |
127 |
if (columns == 0) { |
128 |
// If no TreeColumn, Tree acts as if it has a single column |
129 |
// which takes the whole width. |
130 |
columnToEdit = 0; |
131 |
} else { |
132 |
columnToEdit = -1; |
133 |
for (int i = 0; i < columns; i++) { |
134 |
Rectangle bounds = getBounds(treeItem, i); |
135 |
if (bounds.contains(event.x, event.y)) { |
136 |
columnToEdit = i; |
137 |
break; |
138 |
} |
139 |
} |
140 |
if (columnToEdit == -1) { |
141 |
return; |
142 |
} |
143 |
} |
144 |
|
139 |
|
145 |
columnNumber = columnToEdit; |
140 |
// Ensure compatility with old interface |
146 |
activateCellEditor(); |
141 |
if (cellEditors != null) { |
147 |
} |
142 |
if (cellEditors[columnNumber] != null && cellModifier != null) { |
148 |
|
143 |
Object element = treeItem.getData(); |
149 |
/** |
144 |
String property = columnProperties[columnNumber]; |
150 |
* Deactivates the currently active cell editor. |
145 |
|
151 |
*/ |
146 |
if (cellModifier.canModify(element, property)) { |
152 |
public void applyEditorValue() { |
147 |
editor = cellEditors[columnNumber]; |
153 |
CellEditor c = this.cellEditor; |
148 |
} |
154 |
if (c != null) { |
149 |
} |
155 |
// null out cell editor before calling save |
150 |
} else { |
156 |
// in case save results in applyEditorValue being re-entered |
151 |
if (viewer instanceof TreeViewer) { |
157 |
// see 1GAHI8Z: ITPUI:ALL - How to code event notification when using cell editor ? |
152 |
TreeColumn column = ((TreeViewer)viewer).getTree().getColumn(columnNumber); |
158 |
this.cellEditor = null; |
153 |
if( column.getData(IEditableColumn.EDITING_SUPPORT_KEY) != null ) { |
159 |
Item t = this.treeItem; |
154 |
IEditableColumn eColumn = (IEditableColumn)column.getData(IEditableColumn.EDITING_SUPPORT_KEY); |
160 |
// don't null out tree item -- same item is still selected |
155 |
|
161 |
if (t != null && !t.isDisposed()) { |
156 |
Object element = treeItem.getData(); |
162 |
saveEditorValue(c, t); |
157 |
|
163 |
} |
158 |
if( column instanceof IEditableMultiColumn ) { |
164 |
setEditor(null, null, 0); |
159 |
IEditableMultiColumn t = (IEditableMultiColumn)eColumn; |
165 |
c.removeListener(cellEditorListener); |
160 |
|
166 |
Control control = c.getControl(); |
161 |
if( t.canEdit(element, columnNumber) ) { |
167 |
if (control != null) { |
162 |
editor = t.getCellEditor(element, columnNumber); |
168 |
if (mouseListener != null) { |
163 |
} |
169 |
control.removeMouseListener(mouseListener); |
164 |
} else { |
170 |
} |
165 |
if( eColumn.canEdit(element)) { |
171 |
if (focusListener != null) { |
166 |
editor = eColumn.getCellEditor(element); |
172 |
control.removeFocusListener(focusListener); |
167 |
} |
173 |
} |
168 |
} |
|
|
169 |
} |
170 |
} |
171 |
} |
172 |
|
173 |
return editor; |
174 |
} |
175 |
|
176 |
private Object getModelValue(Object element, int columnNumber) { |
177 |
Object value = null; |
178 |
if (cellEditors != null ) { |
179 |
if( cellModifier != null ) { |
180 |
String property = columnProperties[columnNumber]; |
181 |
value = cellModifier.getValue(element, property); |
182 |
} |
183 |
} else { |
184 |
IEditableColumn column = (IEditableColumn)((TableViewer)viewer).getTable().getColumn(columnNumber).getData(IEditableColumn.EDITING_SUPPORT_KEY); |
185 |
|
186 |
if( column instanceof IEditableMultiColumn ) { |
187 |
value = ((IEditableMultiColumn)column).getValue(element,columnNumber); |
188 |
} else { |
189 |
value = column.getValue(element); |
174 |
} |
190 |
} |
175 |
c.deactivate(); |
191 |
} |
176 |
} |
192 |
|
177 |
} |
193 |
return value; |
178 |
|
194 |
} |
179 |
/** |
195 |
|
180 |
* Cancels the active cell editor, without saving the value |
196 |
/** |
181 |
* back to the domain model. |
197 |
* Activate a cell editor for the given mouse position. |
182 |
*/ |
198 |
*/ |
183 |
public void cancelEditing() { |
199 |
private void activateCellEditor(MouseEvent event) { |
184 |
if (cellEditor != null) { |
200 |
if (treeItem == null || treeItem.isDisposed()) { |
185 |
setEditor(null, null, 0); |
201 |
// item no longer exists |
186 |
cellEditor.removeListener(cellEditorListener); |
202 |
return; |
187 |
CellEditor oldEditor = cellEditor; |
203 |
} |
188 |
cellEditor = null; |
204 |
int columnToEdit; |
189 |
oldEditor.deactivate(); |
205 |
int columns = getColumnCount(); |
190 |
} |
206 |
if (columns == 0) { |
191 |
} |
207 |
// If no TreeColumn, Tree acts as if it has a single column |
192 |
|
208 |
// which takes the whole width. |
193 |
/** |
209 |
columnToEdit = 0; |
194 |
* Start editing the given element. |
210 |
} else { |
195 |
* @param element |
211 |
columnToEdit = -1; |
196 |
* @param column |
212 |
for (int i = 0; i < columns; i++) { |
197 |
*/ |
213 |
Rectangle bounds = getBounds(treeItem, i); |
198 |
public void editElement(Object element, int column) { |
214 |
if (bounds.contains(event.x, event.y)) { |
199 |
if (cellEditor != null) { |
215 |
columnToEdit = i; |
|
|
216 |
break; |
217 |
} |
218 |
} |
219 |
if (columnToEdit == -1) { |
220 |
return; |
221 |
} |
222 |
} |
223 |
|
224 |
columnNumber = columnToEdit; |
225 |
activateCellEditor(); |
226 |
} |
227 |
|
228 |
/** |
229 |
* Deactivates the currently active cell editor. |
230 |
*/ |
231 |
public void applyEditorValue() { |
232 |
CellEditor c = this.cellEditor; |
233 |
if (c != null) { |
234 |
if( viewer instanceof ITabulatorTraversingSupport ) { |
235 |
c.getControl().removeTraverseListener(getTabeditingListener()); |
236 |
} |
237 |
|
238 |
// null out cell editor before calling save |
239 |
// in case save results in applyEditorValue being re-entered |
240 |
// see 1GAHI8Z: ITPUI:ALL - How to code event notification when |
241 |
// using cell editor ? |
242 |
this.cellEditor = null; |
243 |
Item t = this.treeItem; |
244 |
// don't null out tree item -- same item is still selected |
245 |
if (t != null && !t.isDisposed()) { |
246 |
saveEditorValue(c, t); |
247 |
} |
248 |
setEditor(null, null, 0); |
249 |
c.removeListener(cellEditorListener); |
250 |
Control control = c.getControl(); |
251 |
if (control != null) { |
252 |
if (mouseListener != null) { |
253 |
control.removeMouseListener(mouseListener); |
254 |
} |
255 |
if (focusListener != null) { |
256 |
control.removeFocusListener(focusListener); |
257 |
} |
258 |
} |
259 |
c.deactivate(); |
260 |
} |
261 |
} |
262 |
|
263 |
/** |
264 |
* Cancels the active cell editor, without saving the value back to the |
265 |
* domain model. |
266 |
*/ |
267 |
public void cancelEditing() { |
268 |
if (cellEditor != null) { |
269 |
|
270 |
if( viewer instanceof ITabulatorTraversingSupport ) { |
271 |
cellEditor.getControl().removeTraverseListener(getTabeditingListener()); |
272 |
} |
273 |
|
274 |
setEditor(null, null, 0); |
275 |
cellEditor.removeListener(cellEditorListener); |
276 |
CellEditor oldEditor = cellEditor; |
277 |
cellEditor = null; |
278 |
oldEditor.deactivate(); |
279 |
} |
280 |
} |
281 |
|
282 |
/** |
283 |
* Start editing the given element. |
284 |
* |
285 |
* @param element |
286 |
* @param column |
287 |
*/ |
288 |
public void editElement(Object element, int column) { |
289 |
if (cellEditor != null) { |
200 |
applyEditorValue(); |
290 |
applyEditorValue(); |
201 |
} |
291 |
} |
202 |
|
292 |
|
203 |
IStructuredSelection structuredSelection; |
293 |
IStructuredSelection structuredSelection; |
204 |
if(element instanceof TreePath) { |
294 |
if (element instanceof TreePath) { |
205 |
structuredSelection = new TreeSelection((TreePath)element, viewer.getComparer()); |
295 |
structuredSelection = new TreeSelection((TreePath) element, viewer |
206 |
} else { |
296 |
.getComparer()); |
207 |
structuredSelection = new StructuredSelection(element); |
297 |
} else { |
208 |
} |
298 |
structuredSelection = new StructuredSelection(element); |
209 |
setSelection(structuredSelection, true); |
299 |
} |
210 |
Item[] selection = getSelection(); |
300 |
setSelection(structuredSelection, true); |
211 |
if (selection.length != 1) { |
301 |
Item[] selection = getSelection(); |
|
|
302 |
if (selection.length != 1) { |
212 |
return; |
303 |
return; |
213 |
} |
304 |
} |
214 |
|
305 |
|
215 |
treeItem = selection[0]; |
306 |
treeItem = selection[0]; |
216 |
|
307 |
|
217 |
// Make sure selection is visible |
308 |
// Make sure selection is visible |
218 |
showSelection(); |
309 |
showSelection(); |
219 |
columnNumber = column; |
310 |
columnNumber = column; |
220 |
activateCellEditor(); |
311 |
activateCellEditor(); |
221 |
|
312 |
|
222 |
} |
313 |
} |
223 |
|
314 |
|
224 |
abstract Rectangle getBounds(Item item, int columnNumber); |
315 |
abstract Rectangle getBounds(Item item, int columnNumber); |
225 |
|
316 |
|
226 |
/** |
317 |
/** |
227 |
* Get the Cell Editors for the receiver. |
318 |
* Get the Cell Editors for the receiver. |
228 |
* @return CellEditor[] |
319 |
* |
229 |
*/ |
320 |
* @return CellEditor[] |
230 |
public CellEditor[] getCellEditors() { |
321 |
* @deprecated please use the new interface {@link AbstractEditableTreeColumn} |
231 |
return cellEditors; |
322 |
*/ |
232 |
} |
323 |
public CellEditor[] getCellEditors() { |
233 |
|
324 |
return cellEditors; |
234 |
/** |
325 |
} |
235 |
* Get the cell modifier for the receiver. |
326 |
|
236 |
* @return ICellModifier |
327 |
/** |
237 |
*/ |
328 |
* Get the cell modifier for the receiver. |
238 |
public ICellModifier getCellModifier() { |
329 |
* |
239 |
return cellModifier; |
330 |
* @return ICellModifier |
240 |
} |
331 |
* @deprecated please use the new interface {@link AbstractEditableTreeColumn} |
241 |
|
332 |
*/ |
242 |
abstract int getColumnCount(); |
333 |
public ICellModifier getCellModifier() { |
243 |
|
334 |
return cellModifier; |
244 |
/** |
335 |
} |
245 |
* Get the column properties for the receiver. |
336 |
|
246 |
* @return Object[] |
337 |
abstract int getColumnCount(); |
247 |
*/ |
338 |
|
248 |
public Object[] getColumnProperties() { |
339 |
/** |
249 |
return columnProperties; |
340 |
* Get the column properties for the receiver. |
250 |
} |
341 |
* |
251 |
|
342 |
* @return Object[] |
252 |
abstract Item[] getSelection(); |
343 |
* @deprecated please use the new interface {@link AbstractEditableTreeColumn} |
253 |
|
344 |
*/ |
254 |
/** |
345 |
public Object[] getColumnProperties() { |
255 |
* Handles the mouse down event; activates the cell editor. |
346 |
return columnProperties; |
256 |
* @param event |
347 |
} |
257 |
*/ |
348 |
|
258 |
public void handleMouseDown(MouseEvent event) { |
349 |
abstract Item[] getSelection(); |
259 |
if (event.button != 1) { |
350 |
|
|
|
351 |
/** |
352 |
* Handles the mouse down event; activates the cell editor. |
353 |
* |
354 |
* @param event |
355 |
* the mouse event that should be handled |
356 |
*/ |
357 |
public void handleMouseDown(MouseEvent event) { |
358 |
if (event.button != 1) { |
260 |
return; |
359 |
return; |
261 |
} |
360 |
} |
262 |
|
361 |
|
263 |
if (cellEditor != null) { |
362 |
if (cellEditor != null) { |
264 |
applyEditorValue(); |
363 |
applyEditorValue(); |
265 |
} |
364 |
} |
266 |
|
365 |
|
267 |
// activate the cell editor immediately. If a second mouseDown |
366 |
// activate the cell editor immediately. If a second mouseDown |
268 |
// is received prior to the expiration of the doubleClick time then |
367 |
// is received prior to the expiration of the doubleClick time then |
269 |
// the cell editor will be deactivated and a doubleClick event will |
368 |
// the cell editor will be deactivated and a doubleClick event will |
270 |
// be processed. |
369 |
// be processed. |
271 |
// |
370 |
// |
272 |
doubleClickExpirationTime = event.time |
371 |
doubleClickExpirationTime = event.time |
273 |
+ Display.getCurrent().getDoubleClickTime(); |
372 |
+ Display.getCurrent().getDoubleClickTime(); |
274 |
|
373 |
|
275 |
Item[] items = getSelection(); |
374 |
Item[] items = getSelection(); |
276 |
// Do not edit if more than one row is selected. |
375 |
// Do not edit if more than one row is selected. |
277 |
if (items.length != 1) { |
376 |
if (items.length != 1) { |
278 |
treeItem = null; |
377 |
treeItem = null; |
279 |
return; |
378 |
return; |
280 |
} |
379 |
} |
281 |
treeItem = items[0]; |
380 |
treeItem = items[0]; |
282 |
activateCellEditor(event); |
381 |
activateCellEditor(event); |
283 |
} |
382 |
} |
284 |
|
383 |
|
285 |
private void initCellEditorListener() { |
384 |
private void initCellEditorListener() { |
286 |
cellEditorListener = new ICellEditorListener() { |
385 |
cellEditorListener = new ICellEditorListener() { |
287 |
public void editorValueChanged(boolean oldValidState, |
386 |
public void editorValueChanged(boolean oldValidState, |
288 |
boolean newValidState) { |
387 |
boolean newValidState) { |
289 |
// Ignore. |
388 |
// Ignore. |
290 |
} |
389 |
} |
291 |
|
390 |
|
292 |
public void cancelEditor() { |
391 |
public void cancelEditor() { |
293 |
TreeEditorImpl.this.cancelEditing(); |
392 |
TreeEditorImpl.this.cancelEditing(); |
294 |
} |
393 |
} |
|
|
394 |
|
395 |
public void applyEditorValue() { |
396 |
TreeEditorImpl.this.applyEditorValue(); |
397 |
} |
398 |
}; |
399 |
} |
295 |
|
400 |
|
296 |
public void applyEditorValue() { |
401 |
/** |
297 |
TreeEditorImpl.this.applyEditorValue(); |
402 |
* Return whether or not there is an active cell editor. |
|
|
403 |
* |
404 |
* @return boolean <code>true</code> if there is an active cell editor; |
405 |
* otherwise <code>false</code> is returned. |
406 |
*/ |
407 |
public boolean isCellEditorActive() { |
408 |
return cellEditor != null; |
409 |
} |
410 |
|
411 |
/** |
412 |
* Saves the value of the currently active cell editor, by delegating to the |
413 |
* cell modifier. |
414 |
*/ |
415 |
private void saveEditorValue(CellEditor cellEditor, Item treeItem) { |
416 |
if( cellEditors != null ) { |
417 |
if (cellModifier != null) { |
418 |
String property = null; |
419 |
if (columnProperties != null |
420 |
&& columnNumber < columnProperties.length) { |
421 |
property = columnProperties[columnNumber]; |
422 |
} |
423 |
cellModifier.modify(treeItem, property, cellEditor.getValue()); |
424 |
} |
425 |
} else { |
426 |
IEditableColumn column = (IEditableColumn)((TreeViewer)viewer).getTree().getColumn(columnNumber).getData(IEditableColumn.EDITING_SUPPORT_KEY); |
427 |
if( column instanceof IEditableMultiColumn ) { |
428 |
((IEditableMultiColumn)column).setValue(treeItem.getData(),cellEditor.getValue(),columnNumber); |
429 |
} else { |
430 |
column.setValue(treeItem.getData(),cellEditor.getValue()); |
298 |
} |
431 |
} |
299 |
}; |
432 |
} |
300 |
} |
433 |
} |
301 |
|
434 |
|
302 |
/** |
435 |
/** |
303 |
* Return whether or not there is an active cell editor. |
436 |
* Set the cell editors for the receiver. |
304 |
* @return boolean <code>true</code> if there is an active cell editor; otherwise |
437 |
* |
305 |
* <code>false</code> is returned. |
438 |
* @param editors |
306 |
*/ |
439 |
* @deprecated please use the new interface {@link AbstractEditableTreeColumn} |
307 |
public boolean isCellEditorActive() { |
440 |
*/ |
308 |
return cellEditor != null; |
441 |
public void setCellEditors(CellEditor[] editors) { |
309 |
} |
442 |
this.cellEditors = editors; |
310 |
|
443 |
} |
311 |
/** |
444 |
|
312 |
* Saves the value of the currently active cell editor, |
445 |
/** |
313 |
* by delegating to the cell modifier. |
446 |
* Set the cell modifier for the receiver. |
314 |
*/ |
447 |
* |
315 |
private void saveEditorValue(CellEditor cellEditor, Item treeItem) { |
448 |
* @param modifier |
316 |
if (cellModifier != null) { |
449 |
* @deprecated please use the new interface {@link AbstractEditableTreeColumn} |
317 |
String property = null; |
450 |
*/ |
318 |
if (columnProperties != null |
451 |
public void setCellModifier(ICellModifier modifier) { |
319 |
&& columnNumber < columnProperties.length) { |
452 |
this.cellModifier = modifier; |
320 |
property = columnProperties[columnNumber]; |
453 |
} |
321 |
} |
454 |
|
322 |
cellModifier.modify(treeItem, property, cellEditor.getValue()); |
455 |
/** |
323 |
} |
456 |
* Set the column properties for the receiver. |
324 |
} |
457 |
* |
325 |
|
458 |
* @param columnProperties |
326 |
/** |
459 |
* @deprecated please use the new interface {@link AbstractEditableTreeColumn} |
327 |
* Set the cell editors for the receiver. |
460 |
*/ |
328 |
* @param editors |
461 |
public void setColumnProperties(String[] columnProperties) { |
329 |
*/ |
462 |
this.columnProperties = columnProperties; |
330 |
public void setCellEditors(CellEditor[] editors) { |
463 |
} |
331 |
this.cellEditors = editors; |
464 |
|
332 |
} |
465 |
abstract void setEditor(Control w, Item item, int fColumnNumber); |
333 |
|
466 |
|
334 |
/** |
467 |
abstract void setLayoutData(CellEditor.LayoutData layoutData); |
335 |
* Set the cell modifier for the receiver. |
|
|
336 |
* @param modifier |
337 |
*/ |
338 |
public void setCellModifier(ICellModifier modifier) { |
339 |
this.cellModifier = modifier; |
340 |
} |
341 |
|
342 |
/** |
343 |
* Set the column properties for the receiver. |
344 |
* @param columnProperties |
345 |
*/ |
346 |
public void setColumnProperties(String[] columnProperties) { |
347 |
this.columnProperties = columnProperties; |
348 |
} |
349 |
|
350 |
abstract void setEditor(Control w, Item item, int fColumnNumber); |
351 |
|
468 |
|
352 |
abstract void setLayoutData(CellEditor.LayoutData layoutData); |
469 |
abstract void setSelection(IStructuredSelection selection, boolean b); |
353 |
|
470 |
|
354 |
abstract void setSelection(IStructuredSelection selection, boolean b); |
471 |
abstract void showSelection(); |
355 |
|
472 |
|
356 |
abstract void showSelection(); |
473 |
abstract void handleDoubleClickEvent(); |
357 |
|
474 |
|
358 |
abstract void handleDoubleClickEvent(); |
475 |
abstract TraverseListener getTabeditingListener(); |
359 |
} |
476 |
} |