Mercurial > projects > dwt-addons
annotate dwtx/jface/viewers/ColumnViewer.d @ 90:7ffeace6c47f
Update 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Jul 2008 23:30:07 +0200 |
parents | 5df4896124c7 |
children |
rev | line source |
---|---|
10 | 1 /******************************************************************************* |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
2 * Copyright (c) 2006, 2008 IBM Corporation and others. |
10 | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation; bug 153993 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
11 * fix in bug 163317, 151295, 167323, 167858, 184346, 187826, 201905 |
10 | 12 * Port to the D programming language: |
13 * Frank Benoit <benoit@tionex.de> | |
14 *******************************************************************************/ | |
15 | |
16 module dwtx.jface.viewers.ColumnViewer; | |
17 | |
18 import dwtx.jface.viewers.StructuredViewer; | |
19 import dwtx.jface.viewers.CellEditor; | |
20 import dwtx.jface.viewers.ICellModifier; | |
21 import dwtx.jface.viewers.ColumnViewerEditor; | |
22 import dwtx.jface.viewers.ViewerCell; | |
23 import dwtx.jface.viewers.ViewerRow; | |
24 import dwtx.jface.viewers.ViewerColumn; | |
25 import dwtx.jface.viewers.CellLabelProvider; | |
26 import dwtx.jface.viewers.IBaseLabelProvider; | |
27 import dwtx.jface.viewers.ColumnViewerEditorActivationEvent; | |
28 import dwtx.jface.viewers.EditingSupport; | |
29 import dwtx.jface.viewers.ITableLabelProvider; | |
30 import dwtx.jface.viewers.ILabelProvider; | |
31 import dwtx.jface.viewers.StructuredSelection; | |
32 import dwt.events.MouseAdapter; | |
33 import dwt.events.MouseEvent; | |
34 import dwt.graphics.Point; | |
35 import dwt.widgets.Control; | |
36 import dwt.widgets.Item; | |
37 import dwt.widgets.Widget; | |
38 import dwtx.core.runtime.Assert; | |
39 import dwtx.core.runtime.IStatus; | |
40 import dwtx.core.runtime.Status; | |
41 import dwtx.jface.internal.InternalPolicy; | |
42 import dwtx.jface.util.Policy; | |
43 | |
44 import dwt.dwthelper.utils; | |
45 | |
46 /** | |
47 * The ColumnViewer is the abstract superclass of viewers that have columns | |
48 * (e.g., AbstractTreeViewer and AbstractTableViewer). Concrete subclasses of | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
49 * {@link ColumnViewer} should implement a matching concrete subclass of {@link |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
50 * ViewerColumn}. |
71 | 51 * |
10 | 52 * <strong> This class is not intended to be subclassed outside of the JFace |
53 * viewers framework.</strong> | |
71 | 54 * |
10 | 55 * @since 3.3 |
71 | 56 * |
10 | 57 */ |
58 public abstract class ColumnViewer : StructuredViewer { | |
59 alias StructuredViewer.getLabelProvider getLabelProvider; | |
14 | 60 alias StructuredViewer.refresh refresh; |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
61 alias StructuredViewer.update update; |
10 | 62 |
63 private CellEditor[] cellEditors; | |
64 | |
65 private ICellModifier cellModifier; | |
66 | |
67 private String[] columnProperties; | |
68 | |
69 /** | |
70 * The cell is a cached viewer cell used for refreshing. | |
71 */ | |
72 private ViewerCell cell; | |
73 | |
74 private ColumnViewerEditor viewerEditor; | |
75 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
76 private bool busy; |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
77 private bool logWhenBusy = true; // initially true, set to false |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
78 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
79 // after logging for the first |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
80 // time |
10 | 81 |
82 /** | |
83 * Create a new instance of the receiver. | |
84 */ | |
85 public this() { | |
86 cell = new ViewerCell(null, 0, null); | |
87 } | |
88 | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
89 protected override void hookControl(Control control) { |
10 | 90 super.hookControl(control); |
91 viewerEditor = createViewerEditor(); | |
92 hookEditingSupport(control); | |
93 } | |
94 | |
95 /** | |
96 * Hook up the editing support. Subclasses may override. | |
71 | 97 * |
10 | 98 * @param control |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
99 * the control you want to hook on |
10 | 100 */ |
101 protected void hookEditingSupport(Control control) { | |
102 // Needed for backwards comp with AbstractTreeViewer and TableTreeViewer | |
103 // who are not hooked this way others may already overwrite and provide | |
104 // their | |
105 // own impl | |
106 if (viewerEditor !is null) { | |
107 control.addMouseListener(new class MouseAdapter { | |
108 public void mouseDown(MouseEvent e) { | |
109 // Workaround for bug 185817 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
110 if (e.count !is 2) { |
10 | 111 handleMouseDown(e); |
112 } | |
113 } | |
114 | |
115 public void mouseDoubleClick(MouseEvent e) { | |
116 handleMouseDown(e); | |
117 } | |
118 }); | |
119 } | |
120 } | |
121 | |
122 /** | |
123 * Creates the viewer editor used for editing cell contents. To be | |
124 * implemented by subclasses. | |
71 | 125 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
126 * @return the editor, or <code>null</code> if this viewer does not support |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
127 * editing cell contents. |
10 | 128 */ |
129 protected abstract ColumnViewerEditor createViewerEditor(); | |
130 | |
131 /** | |
132 * Returns the viewer cell at the given widget-relative coordinates, or | |
133 * <code>null</code> if there is no cell at that location | |
71 | 134 * |
10 | 135 * @param point |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
136 * the widget-relative coordinates |
10 | 137 * @return the cell or <code>null</code> if no cell is found at the given |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
138 * point |
71 | 139 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
140 * @since 3.4 |
10 | 141 */ |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
142 public ViewerCell getCell(Point point) { |
10 | 143 ViewerRow row = getViewerRow(point); |
144 if (row !is null) { | |
145 return row.getCell(point); | |
146 } | |
147 | |
148 return null; | |
149 } | |
150 | |
151 /** | |
152 * Returns the viewer row at the given widget-relative coordinates. | |
71 | 153 * |
10 | 154 * @param point |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
155 * the widget-relative coordinates of the viewer row |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
156 * @return ViewerRow the row or <code>null</code> if no row is found at the |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
157 * given coordinates |
10 | 158 */ |
159 protected ViewerRow getViewerRow(Point point) { | |
160 Item item = getItemAt(point); | |
161 | |
162 if (item !is null) { | |
163 return getViewerRowFromItem(item); | |
164 } | |
165 | |
166 return null; | |
167 } | |
168 package ViewerRow getViewerRow_package(Point point) { | |
169 return getViewerRow(point); | |
170 } | |
171 | |
172 /** | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
173 * Returns a {@link ViewerRow} associated with the given row widget. |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
174 * Implementations may re-use the same instance for different row widgets; |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
175 * callers can only use the viewer row locally and until the next call to |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
176 * this method. |
71 | 177 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
178 * @param item |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
179 * the row widget |
10 | 180 * @return ViewerRow a viewer row object |
181 */ | |
182 protected abstract ViewerRow getViewerRowFromItem(Widget item); | |
183 package ViewerRow getViewerRowFromItem_package(Widget item){ | |
184 return getViewerRowFromItem(item); | |
185 } | |
186 | |
187 /** | |
188 * Returns the column widget at the given column index. | |
71 | 189 * |
10 | 190 * @param columnIndex |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
191 * the column index |
10 | 192 * @return Widget the column widget |
193 */ | |
194 protected abstract Widget getColumnViewerOwner(int columnIndex); | |
195 | |
196 /** | |
197 * Returns the viewer column for the given column index. | |
71 | 198 * |
10 | 199 * @param columnIndex |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
200 * the column index |
10 | 201 * @return the viewer column at the given index, or <code>null</code> if |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
202 * there is none for the given index |
10 | 203 */ |
204 /* package */ViewerColumn getViewerColumn(int columnIndex) { | |
205 | |
206 ViewerColumn viewer; | |
207 Widget columnOwner = getColumnViewerOwner(columnIndex); | |
208 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
209 if (columnOwner is null || columnOwner.isDisposed()) { |
10 | 210 return null; |
211 } | |
212 | |
40
da5ad8eedf5d
debug prints, dwt.dwthelper restructure, ...
Frank Benoit <benoit@tionex.de>
parents:
39
diff
changeset
|
213 viewer = cast(ViewerColumn) columnOwner.getData(ViewerColumn.COLUMN_VIEWER_KEY); |
10 | 214 |
215 if (viewer is null) { | |
216 viewer = createViewerColumn(columnOwner, CellLabelProvider | |
217 .createViewerLabelProvider(this, getLabelProvider())); | |
218 setupEditingSupport(columnIndex, viewer); | |
219 } | |
220 | |
221 if (viewer.getEditingSupport() is null && getCellModifier() !is null) { | |
222 setupEditingSupport(columnIndex, viewer); | |
223 } | |
224 | |
225 return viewer; | |
226 } | |
227 | |
228 /** | |
229 * Sets up editing support for the given column based on the "old" cell | |
230 * editor API. | |
71 | 231 * |
10 | 232 * @param columnIndex |
233 * @param viewer | |
234 */ | |
235 private void setupEditingSupport(int columnIndex, ViewerColumn viewer) { | |
236 if (getCellModifier() !is null) { | |
39 | 237 viewer.setEditingSupport(new class(this,columnIndex) EditingSupport { |
10 | 238 int columnIndex_; |
39 | 239 this(ColumnViewer cv, int ci){ |
10 | 240 super(cv); |
39 | 241 columnIndex_=ci; |
10 | 242 } |
243 /* | |
244 * (non-Javadoc) | |
71 | 245 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
246 * @see |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
247 * dwtx.jface.viewers.EditingSupport#canEdit(java.lang |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
248 * .Object) |
10 | 249 */ |
250 public bool canEdit(Object element) { | |
251 Object[] properties = getColumnProperties(); | |
252 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
253 if (columnIndex_ < properties.length ) { |
10 | 254 return getCellModifier().canModify(element, |
255 (cast(ArrayWrapperString) getColumnProperties()[columnIndex_]).array); | |
256 } | |
257 | |
258 return false; | |
259 } | |
260 | |
261 /* | |
262 * (non-Javadoc) | |
71 | 263 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
264 * @see |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
265 * dwtx.jface.viewers.EditingSupport#getCellEditor(java |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
266 * .lang.Object) |
10 | 267 */ |
268 public CellEditor getCellEditor(Object element) { | |
269 CellEditor[] editors = getCellEditors(); | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
270 if (columnIndex_ < editors.length ) { |
10 | 271 return getCellEditors()[columnIndex_]; |
272 } | |
273 return null; | |
274 } | |
275 | |
276 /* | |
277 * (non-Javadoc) | |
71 | 278 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
279 * @see |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
280 * dwtx.jface.viewers.EditingSupport#getValue(java.lang |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
281 * .Object) |
10 | 282 */ |
283 public Object getValue(Object element) { | |
284 Object[] properties = getColumnProperties(); | |
285 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
286 if (columnIndex_ < properties.length) { |
10 | 287 return getCellModifier().getValue(element, |
288 (cast(ArrayWrapperString) getColumnProperties()[columnIndex_]).array); | |
289 } | |
290 | |
291 return null; | |
292 } | |
293 | |
294 /* | |
295 * (non-Javadoc) | |
71 | 296 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
297 * @see |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
298 * dwtx.jface.viewers.EditingSupport#setValue(java.lang |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
299 * .Object, java.lang.Object) |
10 | 300 */ |
301 public void setValue(Object element, Object value) { | |
302 Object[] properties = getColumnProperties(); | |
303 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
304 if (columnIndex_ < properties.length) { |
10 | 305 getCellModifier().modify(findItem(element), |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
306 (cast(ArrayWrapperString) getColumnProperties()[columnIndex_]).array, |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
307 value); |
10 | 308 } |
309 } | |
310 | |
311 bool isLegacySupport() { | |
312 return true; | |
313 } | |
314 }); | |
315 } | |
316 } | |
317 | |
318 /** | |
319 * Creates a generic viewer column for the given column widget, based on the | |
320 * given label provider. | |
71 | 321 * |
10 | 322 * @param columnOwner |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
323 * the column widget |
10 | 324 * @param labelProvider |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
325 * the label provider to use for the column |
10 | 326 * @return ViewerColumn the viewer column |
327 */ | |
328 private ViewerColumn createViewerColumn(Widget columnOwner, | |
329 CellLabelProvider labelProvider) { | |
330 ViewerColumn column = new class(this, columnOwner) ViewerColumn { | |
331 this( ColumnViewer cv, Widget co ){ | |
332 super(cv,co); | |
333 } | |
334 }; | |
335 column.setLabelProvider(labelProvider, false); | |
336 return column; | |
337 } | |
338 | |
339 /** | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
340 * Update the cached cell object with the given row and column. |
71 | 341 * |
10 | 342 * @param rowItem |
343 * @param column | |
344 * @return ViewerCell | |
345 */ | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
346 /* package */ViewerCell updateCell(ViewerRow rowItem, int column, |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
347 Object element) { |
10 | 348 cell.update(rowItem, column, element); |
349 return cell; | |
350 } | |
351 | |
352 /** | |
353 * Returns the {@link Item} at the given widget-relative coordinates, or | |
354 * <code>null</code> if there is no item at the given coordinates. | |
71 | 355 * |
10 | 356 * @param point |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
357 * the widget-relative coordinates |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
358 * @return the {@link Item} at the coordinates or <code>null</code> if there |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
359 * is no item at the given coordinates |
10 | 360 */ |
361 protected abstract Item getItemAt(Point point); | |
362 | |
363 /* | |
364 * (non-Javadoc) | |
71 | 365 * |
10 | 366 * @see dwtx.jface.viewers.StructuredViewer#getItem(int, int) |
367 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
368 protected override Item getItem(int x, int y) { |
10 | 369 return getItemAt(getControl().toControl(x, y)); |
370 } | |
371 | |
372 /** | |
373 * The column viewer implementation of this <code>Viewer</code> framework | |
374 * method ensures that the given label provider is an instance of | |
375 * <code>ITableLabelProvider</code>, <code>ILabelProvider</code>, or | |
376 * <code>CellLabelProvider</code>. | |
377 * <p> | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
378 * If the label provider is an {@link ITableLabelProvider} , then it |
10 | 379 * provides a separate label text and image for each column. Implementers of |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
380 * <code>ITableLabelProvider</code> may also implement {@link |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
381 * ITableColorProvider} and/or {@link ITableFontProvider} to provide colors |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
382 * and/or fonts. |
10 | 383 * </p> |
384 * <p> | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
385 * If the label provider is an <code>ILabelProvider</code> , then it |
10 | 386 * provides only the label text and image for the first column, and any |
387 * remaining columns are blank. Implementers of <code>ILabelProvider</code> | |
388 * may also implement {@link IColorProvider} and/or {@link IFontProvider} to | |
389 * provide colors and/or fonts. | |
390 * </p> | |
71 | 391 * |
10 | 392 */ |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
393 public override void setLabelProvider(IBaseLabelProvider labelProvider) { |
10 | 394 Assert.isTrue( null !is cast(ITableLabelProvider)labelProvider |
395 || null !is cast(ILabelProvider)labelProvider | |
396 || null !is cast(CellLabelProvider)labelProvider ); | |
397 updateColumnParts(labelProvider);// Reset the label providers in the | |
398 // columns | |
399 super.setLabelProvider(labelProvider); | |
71 | 400 if ( null !is cast(CellLabelProvider)labelProvider ) { |
72
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
401 (cast(CellLabelProvider) labelProvider).initialize_package(this, null); |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
402 } |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
403 } |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
404 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
405 void internalDisposeLabelProvider(IBaseLabelProvider oldProvider) { |
71 | 406 if (null !is cast(CellLabelProvider)oldProvider ) { |
407 (cast(CellLabelProvider) oldProvider).dispose(this, null); | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
408 } else { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
409 super.internalDisposeLabelProvider(oldProvider); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
410 } |
10 | 411 } |
412 | |
413 /** | |
414 * Clear the viewer parts for the columns | |
415 */ | |
416 private void updateColumnParts(IBaseLabelProvider labelProvider) { | |
417 ViewerColumn column; | |
418 int i = 0; | |
419 | |
420 while ((column = getViewerColumn(i++)) !is null) { | |
421 column.setLabelProvider(CellLabelProvider | |
422 .createViewerLabelProvider(this, labelProvider), false); | |
423 } | |
424 } | |
425 | |
426 /** | |
427 * Cancels a currently active cell editor if one is active. All changes | |
428 * already done in the cell editor are lost. | |
71 | 429 * |
10 | 430 * @since 3.1 (in subclasses, added in 3.3 to abstract class) |
431 */ | |
432 public void cancelEditing() { | |
433 if (viewerEditor !is null) { | |
434 viewerEditor.cancelEditing(); | |
435 } | |
436 } | |
437 | |
438 /** | |
439 * Apply the value of the active cell editor if one is active. | |
71 | 440 * |
10 | 441 * @since 3.3 |
442 */ | |
443 protected void applyEditorValue() { | |
444 if (viewerEditor !is null) { | |
445 viewerEditor.applyEditorValue(); | |
446 } | |
447 } | |
448 | |
449 /** | |
450 * Starts editing the given element at the given column index. | |
71 | 451 * |
10 | 452 * @param element |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
453 * the model element |
10 | 454 * @param column |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
455 * the column index |
10 | 456 * @since 3.1 (in subclasses, added in 3.3 to abstract class) |
457 */ | |
458 public void editElement(Object element, int column) { | |
459 if (viewerEditor !is null) { | |
460 try { | |
461 getControl().setRedraw(false); | |
462 // Set the selection at first because in Tree's | |
463 // the element might not be materialized | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
464 setSelection(new StructuredSelection(element), true); |
10 | 465 |
466 Widget item = findItem(element); | |
467 if (item !is null) { | |
468 ViewerRow row = getViewerRowFromItem(item); | |
469 if (row !is null) { | |
470 ViewerCell cell = row.getCell(column); | |
471 if (cell !is null) { | |
472 triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent( | |
473 cell)); | |
474 } | |
475 } | |
476 } | |
477 } finally { | |
478 getControl().setRedraw(true); | |
479 } | |
480 } | |
481 } | |
482 | |
483 /** | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
484 * Return the CellEditors for the receiver, or <code>null</code> if no cell |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
485 * editors are set. |
10 | 486 * <p> |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
487 * Since 3.3, an alternative API is available, see {@link |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
488 * ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible way |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
489 * of editing values in a column viewer. |
10 | 490 * </p> |
71 | 491 * |
492 * | |
10 | 493 * @return CellEditor[] |
494 * @since 3.1 (in subclasses, added in 3.3 to abstract class) | |
495 * @see ViewerColumn#setEditingSupport(EditingSupport) | |
496 * @see EditingSupport | |
497 */ | |
498 public CellEditor[] getCellEditors() { | |
499 return cellEditors; | |
500 } | |
501 | |
502 /** | |
503 * Returns the cell modifier of this viewer, or <code>null</code> if none | |
504 * has been set. | |
71 | 505 * |
10 | 506 * <p> |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
507 * Since 3.3, an alternative API is available, see {@link |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
508 * ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible way |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
509 * of editing values in a column viewer. |
10 | 510 * </p> |
71 | 511 * |
10 | 512 * @return the cell modifier, or <code>null</code> |
513 * @since 3.1 (in subclasses, added in 3.3 to abstract class) | |
514 * @see ViewerColumn#setEditingSupport(EditingSupport) | |
515 * @see EditingSupport | |
516 */ | |
517 public ICellModifier getCellModifier() { | |
518 return cellModifier; | |
519 } | |
520 | |
521 /** | |
522 * Returns the column properties of this table viewer. The properties must | |
523 * correspond with the columns of the table control. They are used to | |
524 * identify the column in a cell modifier. | |
71 | 525 * |
10 | 526 * <p> |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
527 * Since 3.3, an alternative API is available, see {@link |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
528 * ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible way |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
529 * of editing values in a column viewer. |
10 | 530 * </p> |
71 | 531 * |
10 | 532 * @return the list of column properties |
533 * @since 3.1 (in subclasses, added in 3.3 to abstract class) | |
534 * @see ViewerColumn#setEditingSupport(EditingSupport) | |
535 * @see EditingSupport | |
536 */ | |
537 public Object[] getColumnProperties() { | |
538 Object[] res; | |
539 foreach( prop; columnProperties ){ | |
540 res ~= new ArrayWrapperString( prop ); | |
541 } | |
542 return res; | |
543 } | |
544 | |
545 /** | |
546 * Returns whether there is an active cell editor. | |
71 | 547 * |
10 | 548 * <p> |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
549 * Since 3.3, an alternative API is available, see {@link |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
550 * ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible way |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
551 * of editing values in a column viewer. |
10 | 552 * </p> |
71 | 553 * |
10 | 554 * @return <code>true</code> if there is an active cell editor, and |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
555 * <code>false</code> otherwise |
10 | 556 * @since 3.1 (in subclasses, added in 3.3 to abstract class) |
557 * @see ViewerColumn#setEditingSupport(EditingSupport) | |
558 * @see EditingSupport | |
559 */ | |
560 public bool isCellEditorActive() { | |
561 if (viewerEditor !is null) { | |
562 return viewerEditor.isCellEditorActive(); | |
563 } | |
564 return false; | |
565 } | |
566 | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
567 public override void refresh(Object element) { |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
568 if (checkBusy()) |
10 | 569 return; |
570 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
571 if (isCellEditorActive()) { |
10 | 572 cancelEditing(); |
573 } | |
574 | |
575 super.refresh(element); | |
576 } | |
577 | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
578 public override void refresh(Object element, bool updateLabels) { |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
579 if (checkBusy()) |
10 | 580 return; |
581 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
582 if (isCellEditorActive()) { |
10 | 583 cancelEditing(); |
584 } | |
585 | |
586 super.refresh(element, updateLabels); | |
587 } | |
588 | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
589 public override void update(Object element, String[] properties) { |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
590 if (checkBusy()) |
10 | 591 return; |
592 super.update(element, properties); | |
593 } | |
594 | |
595 /** | |
596 * Sets the cell editors of this column viewer. If editing is not supported | |
597 * by this viewer the call simply has no effect. | |
71 | 598 * |
10 | 599 * <p> |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
600 * Since 3.3, an alternative API is available, see {@link |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
601 * ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible way |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
602 * of editing values in a column viewer. |
10 | 603 * </p> |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
604 * <p> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
605 * Users setting up an editable {@link TreeViewer} or {@link TableViewer} with more than 1 column <b>have</b> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
606 * to pass the DWT.FULL_SELECTION style bit |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
607 * </p> |
10 | 608 * @param editors |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
609 * the list of cell editors |
10 | 610 * @since 3.1 (in subclasses, added in 3.3 to abstract class) |
611 * @see ViewerColumn#setEditingSupport(EditingSupport) | |
612 * @see EditingSupport | |
613 */ | |
614 public void setCellEditors(CellEditor[] editors) { | |
615 this.cellEditors = editors; | |
616 } | |
617 | |
618 /** | |
619 * Sets the cell modifier for this column viewer. This method does nothing | |
620 * if editing is not supported by this viewer. | |
71 | 621 * |
10 | 622 * <p> |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
623 * Since 3.3, an alternative API is available, see {@link |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
624 * ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible way |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
625 * of editing values in a column viewer. |
10 | 626 * </p> |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
627 * <p> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
628 * Users setting up an editable {@link TreeViewer} or {@link TableViewer} with more than 1 column <b>have</b> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
629 * to pass the DWT.FULL_SELECTION style bit |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
630 * </p> |
10 | 631 * @param modifier |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
632 * the cell modifier |
10 | 633 * @since 3.1 (in subclasses, added in 3.3 to abstract class) |
634 * @see ViewerColumn#setEditingSupport(EditingSupport) | |
635 * @see EditingSupport | |
636 */ | |
637 public void setCellModifier(ICellModifier modifier) { | |
638 this.cellModifier = modifier; | |
639 } | |
640 | |
641 /** | |
642 * Sets the column properties of this column viewer. The properties must | |
643 * correspond with the columns of the control. They are used to identify the | |
644 * column in a cell modifier. If editing is not supported by this viewer the | |
645 * call simply has no effect. | |
71 | 646 * |
10 | 647 * <p> |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
648 * Since 3.3, an alternative API is available, see {@link |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
649 * ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible way |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
650 * of editing values in a column viewer. |
10 | 651 * </p> |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
652 * <p> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
653 * Users setting up an editable {@link TreeViewer} or {@link TableViewer} with more than 1 column <b>have</b> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
654 * to pass the DWT.FULL_SELECTION style bit |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
655 * </p> |
10 | 656 * @param columnProperties |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
657 * the list of column properties |
10 | 658 * @since 3.1 (in subclasses, added in 3.3 to abstract class) |
659 * @see ViewerColumn#setEditingSupport(EditingSupport) | |
660 * @see EditingSupport | |
661 */ | |
662 public void setColumnProperties(String[] columnProperties) { | |
663 this.columnProperties = columnProperties; | |
664 } | |
665 | |
666 /** | |
667 * Returns the number of columns contained in the receiver. If no columns | |
668 * were created by the programmer, this value is zero, despite the fact that | |
669 * visually, one column of items may be visible. This occurs when the | |
670 * programmer uses the column viewer like a list, adding elements but never | |
671 * creating a column. | |
71 | 672 * |
10 | 673 * @return the number of columns |
71 | 674 * |
10 | 675 * @since 3.3 |
676 */ | |
677 protected abstract int doGetColumnCount(); | |
678 package int doGetColumnCount_package(){ | |
679 return doGetColumnCount(); | |
680 } | |
681 | |
682 /** | |
683 * Returns the label provider associated with the column at the given index | |
684 * or <code>null</code> if no column with this index is known. | |
71 | 685 * |
10 | 686 * @param columnIndex |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
687 * the column index |
10 | 688 * @return the label provider associated with the column or |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
689 * <code>null</code> if no column with this index is known |
71 | 690 * |
10 | 691 * @since 3.3 |
692 */ | |
693 public CellLabelProvider getLabelProvider(int columnIndex) { | |
694 ViewerColumn column = getViewerColumn(columnIndex); | |
695 if (column !is null) { | |
54
a6683645b0d7
Fix ignored labelprovider for TreeViewer (See WrapperViewerLabelProvider.d), removed the debugging prints
Frank Benoit <benoit@tionex.de>
parents:
53
diff
changeset
|
696 auto res = column.getLabelProvider(); |
a6683645b0d7
Fix ignored labelprovider for TreeViewer (See WrapperViewerLabelProvider.d), removed the debugging prints
Frank Benoit <benoit@tionex.de>
parents:
53
diff
changeset
|
697 return res; |
10 | 698 } |
699 return null; | |
700 } | |
701 | |
702 private void handleMouseDown(MouseEvent e) { | |
703 ViewerCell cell = getCell(new Point(e.x, e.y)); | |
704 | |
705 if (cell !is null) { | |
706 triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent( | |
707 cell, e)); | |
708 } | |
709 } | |
710 | |
711 /** | |
712 * Invoking this method fires an editor activation event which tries to | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
713 * enable the editor but before this event is passed to {@link |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
714 * ColumnViewerEditorActivationStrategy} to see if this event should really |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
715 * trigger editor activation |
71 | 716 * |
10 | 717 * @param event |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
718 * the activation event |
10 | 719 */ |
720 protected void triggerEditorActivationEvent( | |
721 ColumnViewerEditorActivationEvent event) { | |
722 viewerEditor.handleEditorActivationEvent(event); | |
723 } | |
724 package void triggerEditorActivationEvent_package( | |
725 ColumnViewerEditorActivationEvent event) { | |
726 triggerEditorActivationEvent(event); | |
727 } | |
728 | |
729 /** | |
730 * @param columnViewerEditor | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
731 * the new column viewer editor |
10 | 732 */ |
733 public void setColumnViewerEditor(ColumnViewerEditor columnViewerEditor) { | |
90 | 734 Assert.isNotNull(columnViewerEditor); |
10 | 735 this.viewerEditor = columnViewerEditor; |
736 } | |
737 | |
738 /** | |
739 * @return the currently attached viewer editor | |
740 */ | |
741 public ColumnViewerEditor getColumnViewerEditor() { | |
742 return viewerEditor; | |
743 } | |
744 | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
745 protected override Object[] getRawChildren(Object parent) { |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
746 bool oldBusy = isBusy(); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
747 setBusy(true); |
10 | 748 try { |
749 return super.getRawChildren(parent); | |
750 } finally { | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
751 setBusy(oldBusy); |
10 | 752 } |
753 } | |
754 | |
755 void clearLegacyEditingSetup() { | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
756 if (!getControl().isDisposed() && getCellEditors() !is null) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
757 int count = doGetColumnCount(); |
10 | 758 |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
759 for (int i = 0; i < count || i is 0; i++) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
760 Widget owner = getColumnViewerOwner(i); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
761 if (owner !is null && !owner.isDisposed()) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
762 ViewerColumn column = cast(ViewerColumn) owner |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
763 .getData(ViewerColumn.COLUMN_VIEWER_KEY); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
764 if (column !is null) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
765 EditingSupport e = column.getEditingSupport(); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
766 // Ensure that only EditingSupports are wiped that are |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
767 // setup |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
768 // for Legacy reasons |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
769 if (e !is null && e.isLegacySupport()) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
770 column.setEditingSupport(null); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
771 } |
10 | 772 } |
773 } | |
774 } | |
775 } | |
776 } | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
777 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
778 /** |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
779 * Checks if this viewer is currently busy, logging a warning and returning |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
780 * <code>true</code> if it is busy. A column viewer is busy when it is |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
781 * processing a refresh, add, remove, insert, replace, setItemCount, |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
782 * expandToLevel, update, setExpandedElements, or similar method that may |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
783 * make calls to client code. Column viewers are not designed to handle |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
784 * reentrant calls while they are busy. The method returns <code>true</code> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
785 * if the viewer is busy. It is recommended that this method be used by |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
786 * subclasses to determine whether the viewer is busy to return early from |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
787 * state-changing methods. |
71 | 788 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
789 * <p> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
790 * This method is not intended to be overridden by subclasses. |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
791 * </p> |
71 | 792 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
793 * @return <code>true</code> if the viewer is busy. |
71 | 794 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
795 * @since 3.4 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
796 */ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
797 protected bool checkBusy() { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
798 if (isBusy()) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
799 if (logWhenBusy) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
800 String message = "Ignored reentrant call while viewer is busy."; //$NON-NLS-1$ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
801 if (!InternalPolicy.DEBUG_LOG_REENTRANT_VIEWER_CALLS) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
802 // stop logging after the first |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
803 logWhenBusy = false; |
72
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
804 message ~= " This is only logged once per viewer instance," ~ //$NON-NLS-1$ |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
805 " but similar calls will still be ignored."; //$NON-NLS-1$ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
806 } |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
807 Policy.getLog().log( |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
808 new Status(IStatus.WARNING, Policy.JFACE, message, |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
809 new RuntimeException())); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
810 } |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
811 return true; |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
812 } |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
813 return false; |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
814 } |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
815 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
816 /** |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
817 * Sets the busy state of this viewer. Subclasses MUST use <code>try</code> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
818 * ...<code>finally</code> as follows to ensure that the busy flag is reset |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
819 * to its original value: |
71 | 820 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
821 * <pre> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
822 * bool oldBusy = isBusy(); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
823 * setBusy(true); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
824 * try { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
825 * // do work |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
826 * } finally { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
827 * setBusy(oldBusy); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
828 * } |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
829 * </pre> |
71 | 830 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
831 * <p> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
832 * This method is not intended to be overridden by subclasses. |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
833 * </p> |
71 | 834 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
835 * @param busy |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
836 * the new value of the busy flag |
71 | 837 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
838 * @since 3.4 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
839 */ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
840 protected void setBusy(bool busy) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
841 this.busy = busy; |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
842 } |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
843 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
844 /** |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
845 * Returns <code>true</code> if this viewer is currently busy processing a |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
846 * refresh, add, remove, insert, replace, setItemCount, expandToLevel, |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
847 * update, setExpandedElements, or similar method that may make calls to |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
848 * client code. Column viewers are not designed to handle reentrant calls |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
849 * while they are busy. It is recommended that clients avoid using this |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
850 * method if they can ensure by other means that they will not make |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
851 * reentrant calls to methods like the ones listed above. See bug 184991 for |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
852 * background discussion. |
71 | 853 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
854 * <p> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
855 * This method is not intended to be overridden by subclasses. |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
856 * </p> |
71 | 857 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
858 * @return Returns whether this viewer is busy. |
71 | 859 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
860 * @since 3.4 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
861 */ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
862 public bool isBusy() { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
863 return busy; |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
54
diff
changeset
|
864 } |
10 | 865 } |