10
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2006, 2008 IBM Corporation and others.
|
|
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> - refactoring (bug 153993)
|
|
11 * fix in bug 151295,166500,200337
|
|
12 * Port to the D programming language:
|
|
13 * Frank Benoit <benoit@tionex.de>
|
|
14 *******************************************************************************/
|
|
15
|
|
16 module dwtx.jface.viewers.ColumnViewerEditor;
|
|
17
|
|
18 import dwtx.jface.viewers.CellEditor;
|
|
19 import dwtx.jface.viewers.ICellEditorListener;
|
|
20 import dwtx.jface.viewers.ColumnViewer;
|
|
21 import dwtx.jface.viewers.ColumnViewerEditorActivationStrategy;
|
|
22 import dwtx.jface.viewers.ViewerCell;
|
|
23 import dwtx.jface.viewers.ViewerColumn;
|
|
24 import dwtx.jface.viewers.ColumnViewerEditorActivationEvent;
|
|
25 import dwtx.jface.viewers.ColumnViewerEditorActivationListener;
|
|
26 import dwtx.jface.viewers.ColumnViewerEditorDeactivationEvent;
|
|
27 import dwtx.jface.viewers.ViewerRow;
|
|
28 import dwtx.jface.viewers.DoubleClickEvent;
|
|
29 import dwtx.jface.viewers.OpenEvent;
|
|
30
|
|
31 import dwt.DWT;
|
|
32 import dwt.events.FocusAdapter;
|
|
33 import dwt.events.FocusEvent;
|
|
34 import dwt.events.FocusListener;
|
|
35 import dwt.events.MouseAdapter;
|
|
36 import dwt.events.MouseEvent;
|
|
37 import dwt.events.MouseListener;
|
|
38 import dwt.events.TraverseEvent;
|
|
39 import dwt.events.TraverseListener;
|
|
40 import dwt.widgets.Control;
|
|
41 import dwt.widgets.Display;
|
|
42 import dwt.widgets.Item;
|
|
43 import dwtx.core.runtime.ListenerList;
|
|
44
|
|
45 import dwt.dwthelper.utils;
|
|
46
|
|
47 /**
|
|
48 * This is the base for all editor implementations of Viewers. ColumnViewer
|
|
49 * implementators have to subclass this class and implement the missing methods
|
|
50 *
|
|
51 * @since 3.3
|
|
52 * @see TableViewerEditor
|
|
53 * @see TreeViewerEditor
|
|
54 */
|
|
55 public abstract class ColumnViewerEditor {
|
|
56 private CellEditor cellEditor;
|
|
57
|
|
58 private ICellEditorListener cellEditorListener;
|
|
59
|
|
60 private FocusListener focusListener;
|
|
61
|
|
62 private MouseListener mouseListener;
|
|
63
|
|
64 private ColumnViewer viewer;
|
|
65
|
|
66 private TraverseListener tabeditingListener;
|
|
67
|
|
68 private int activationTime;
|
|
69
|
|
70 private ViewerCell cell;
|
|
71
|
|
72 private ColumnViewerEditorActivationEvent activationEvent;
|
|
73
|
|
74 private ListenerList editorActivationListener;
|
|
75
|
|
76 private ColumnViewerEditorActivationStrategy editorActivationStrategy;
|
|
77
|
|
78 /**
|
|
79 * Tabbing from cell to cell is turned off
|
|
80 */
|
|
81 public static const int DEFAULT = 1;
|
|
82
|
|
83 /**
|
|
84 * Should if the end of the row is reach started from the start/end of the
|
|
85 * row below/above
|
|
86 */
|
|
87 public static const int TABBING_MOVE_TO_ROW_NEIGHBOR = 1 << 1;
|
|
88
|
|
89 /**
|
|
90 * Should if the end of the row is reach started from the beginning in the
|
|
91 * same row
|
|
92 */
|
|
93 public static const int TABBING_CYCLE_IN_ROW = 1 << 2;
|
|
94
|
|
95 /**
|
|
96 * Support tabbing to Cell above/below the current cell
|
|
97 */
|
|
98 public static const int TABBING_VERTICAL = 1 << 3;
|
|
99
|
|
100 /**
|
|
101 * Should tabbing from column to column with in one row be supported
|
|
102 */
|
|
103 public static const int TABBING_HORIZONTAL = 1 << 4;
|
|
104
|
|
105 /**
|
|
106 * Style mask used to enable keyboard activation
|
|
107 */
|
|
108 public static const int KEYBOARD_ACTIVATION = 1 << 5;
|
|
109
|
|
110 private int feature;
|
|
111
|
|
112 /**
|
|
113 * @param viewer
|
|
114 * the viewer this editor is attached to
|
|
115 * @param editorActivationStrategy
|
|
116 * the strategy used to decide about editor activation
|
|
117 * @param feature
|
|
118 * bit mask controlling the editor
|
|
119 * <ul>
|
|
120 * <li>{@link ColumnViewerEditor#DEFAULT}</li>
|
|
121 * <li>{@link ColumnViewerEditor#TABBING_CYCLE_IN_ROW}</li>
|
|
122 * <li>{@link ColumnViewerEditor#TABBING_HORIZONTAL}</li>
|
|
123 * <li>{@link ColumnViewerEditor#TABBING_MOVE_TO_ROW_NEIGHBOR}</li>
|
|
124 * <li>{@link ColumnViewerEditor#TABBING_VERTICAL}</li>
|
|
125 * </ul>
|
|
126 */
|
|
127 protected this(ColumnViewer viewer,
|
|
128 ColumnViewerEditorActivationStrategy editorActivationStrategy,
|
|
129 int feature) {
|
|
130 this.viewer = viewer;
|
|
131 this.editorActivationStrategy = editorActivationStrategy;
|
|
132 if ((feature & KEYBOARD_ACTIVATION) is KEYBOARD_ACTIVATION) {
|
|
133 this.editorActivationStrategy
|
|
134 .setEnableEditorActivationWithKeyboard(true);
|
|
135 }
|
|
136 this.feature = feature;
|
|
137 initCellEditorListener();
|
|
138 }
|
|
139
|
|
140 private void initCellEditorListener() {
|
|
141 cellEditorListener = new class ICellEditorListener {
|
|
142 public void editorValueChanged(bool oldValidState,
|
|
143 bool newValidState) {
|
|
144 // Ignore.
|
|
145 }
|
|
146
|
|
147 public void cancelEditor() {
|
|
148 this.outer.cancelEditing();
|
|
149 }
|
|
150
|
|
151 public void applyEditorValue() {
|
|
152 this.outer.applyEditorValue();
|
|
153 }
|
|
154 };
|
|
155 }
|
|
156
|
|
157 void activateCellEditor() {
|
|
158
|
|
159 ViewerColumn part = viewer.getViewerColumn(cell.getColumnIndex());
|
|
160 Object element = cell.getElement();
|
|
161
|
|
162 if (part !is null && part.getEditingSupport() !is null
|
|
163 && part.getEditingSupport().canEdit_package(element)) {
|
|
164
|
|
165 cellEditor = part.getEditingSupport().getCellEditor_package(element);
|
|
166 if (cellEditor !is null) {
|
|
167 if (editorActivationListener !is null
|
|
168 && !editorActivationListener.isEmpty()) {
|
|
169 Object[] ls = editorActivationListener.getListeners();
|
|
170 for (int i = 0; i < ls.length; i++) {
|
|
171
|
|
172 if (activationEvent.cancel) {
|
|
173 // Avoid leaking
|
|
174 this.cell = null;
|
|
175 return;
|
|
176 }
|
|
177
|
|
178 (cast(ColumnViewerEditorActivationListener) ls[i])
|
|
179 .beforeEditorActivated(activationEvent);
|
|
180 }
|
|
181 }
|
|
182
|
|
183 updateFocusCell(cell, activationEvent);
|
|
184
|
|
185 cellEditor.addListener(cellEditorListener);
|
|
186 part.getEditingSupport().initializeCellEditorValue_package(cellEditor,
|
|
187 cell);
|
|
188
|
|
189 // Tricky flow of control here:
|
|
190 // activate() can trigger callback to cellEditorListener which
|
|
191 // will clear cellEditor
|
|
192 // so must get control first, but must still call activate()
|
|
193 // even if there is no control.
|
|
194 Control control = cellEditor.getControl();
|
|
195 cellEditor.activate(activationEvent);
|
|
196 if (control is null) {
|
|
197 return;
|
|
198 }
|
|
199 setLayoutData(cellEditor.getLayoutData());
|
|
200 setEditor(control, cast(Item) cell.getItem(), cell.getColumnIndex());
|
|
201 cellEditor.setFocus();
|
|
202
|
|
203 if( cellEditor.dependsOnExternalFocusListener() ) {
|
|
204 if (focusListener is null) {
|
|
205 focusListener = new class FocusAdapter {
|
|
206 public void focusLost(FocusEvent e) {
|
|
207 applyEditorValue();
|
|
208 }
|
|
209 };
|
|
210 }
|
|
211 control.addFocusListener(focusListener);
|
|
212 }
|
|
213
|
39
|
214 mouseListener = new class(control) MouseAdapter {
|
10
|
215 Control control_;
|
39
|
216 this(Control a){
|
|
217 control_=a;
|
10
|
218 }
|
|
219 public void mouseDown(MouseEvent e) {
|
|
220 // time wrap?
|
|
221 // check for expiration of doubleClickTime
|
|
222 if (e.time <= activationTime) {
|
|
223 control_.removeMouseListener(mouseListener);
|
|
224 cancelEditing();
|
|
225 handleDoubleClickEvent();
|
|
226 } else if (mouseListener !is null) {
|
|
227 control_.removeMouseListener(mouseListener);
|
|
228 }
|
|
229 }
|
|
230 };
|
|
231 control.addMouseListener(mouseListener);
|
|
232
|
|
233 if (tabeditingListener is null) {
|
|
234 tabeditingListener = new class TraverseListener {
|
|
235
|
|
236 public void keyTraversed(TraverseEvent e) {
|
|
237 if ((feature & DEFAULT) !is DEFAULT) {
|
|
238 processTraverseEvent(cell.getColumnIndex(),
|
|
239 viewer.getViewerRowFromItem_package(cell
|
|
240 .getItem()), e);
|
|
241 }
|
|
242 }
|
|
243 };
|
|
244 }
|
|
245
|
|
246 control.addTraverseListener(tabeditingListener);
|
|
247
|
|
248 if (editorActivationListener !is null
|
|
249 && !editorActivationListener.isEmpty()) {
|
|
250 Object[] ls = editorActivationListener.getListeners();
|
|
251 for (int i = 0; i < ls.length; i++) {
|
|
252 (cast(ColumnViewerEditorActivationListener) ls[i])
|
|
253 .afterEditorActivated(activationEvent);
|
|
254 }
|
|
255 }
|
|
256 }
|
|
257 } else {
|
|
258 // Avoid leaking
|
|
259 this.cell = null;
|
|
260 }
|
|
261 }
|
|
262
|
|
263 /**
|
|
264 * Applies the current value and deactivates the currently active cell
|
|
265 * editor.
|
|
266 */
|
|
267 void applyEditorValue() {
|
|
268 CellEditor c = this.cellEditor;
|
|
269 if (c !is null && this.cell !is null) {
|
|
270 // null out cell editor before calling save
|
|
271 // in case save results in applyEditorValue being re-entered
|
|
272 // see 1GAHI8Z: ITPUI:ALL - How to code event notification when
|
|
273 // using cell editor ?
|
|
274 ColumnViewerEditorDeactivationEvent tmp = new ColumnViewerEditorDeactivationEvent(
|
|
275 cell);
|
|
276 if (editorActivationListener !is null
|
|
277 && !editorActivationListener.isEmpty()) {
|
|
278 Object[] ls = editorActivationListener.getListeners();
|
|
279 for (int i = 0; i < ls.length; i++) {
|
|
280
|
|
281 (cast(ColumnViewerEditorActivationListener) ls[i])
|
|
282 .beforeEditorDeactivated(tmp);
|
|
283 }
|
|
284 }
|
|
285
|
|
286 this.cellEditor = null;
|
|
287 this.activationEvent = null;
|
|
288 Item t = cast(Item) this.cell.getItem();
|
|
289
|
|
290 // don't null out table item -- same item is still selected
|
|
291 if (t !is null && !t.isDisposed()) {
|
|
292 saveEditorValue(c);
|
|
293 }
|
|
294
|
|
295 setEditor(null, null, 0);
|
|
296 c.removeListener(cellEditorListener);
|
|
297 Control control = c.getControl();
|
|
298 if (control !is null) {
|
|
299 if (mouseListener !is null) {
|
|
300 control.removeMouseListener(mouseListener);
|
|
301 // Clear the instance not needed any more
|
|
302 mouseListener = null;
|
|
303 }
|
|
304 if (focusListener !is null) {
|
|
305 control.removeFocusListener(focusListener);
|
|
306 }
|
|
307
|
|
308 if (tabeditingListener !is null) {
|
|
309 control.removeTraverseListener(tabeditingListener);
|
|
310 }
|
|
311 }
|
|
312 c.deactivate();
|
|
313
|
|
314 if (editorActivationListener !is null
|
|
315 && !editorActivationListener.isEmpty()) {
|
|
316 Object[] ls = editorActivationListener.getListeners();
|
|
317 for (int i = 0; i < ls.length; i++) {
|
|
318 (cast(ColumnViewerEditorActivationListener) ls[i])
|
|
319 .afterEditorDeactivated(tmp);
|
|
320 }
|
|
321 }
|
|
322
|
|
323 this.cell = null;
|
|
324 }
|
|
325 }
|
|
326
|
|
327 /**
|
|
328 * Cancel editing
|
|
329 */
|
|
330 void cancelEditing() {
|
|
331 if (cellEditor !is null) {
|
|
332 ColumnViewerEditorDeactivationEvent tmp = new ColumnViewerEditorDeactivationEvent(
|
|
333 cell);
|
|
334 if (editorActivationListener !is null
|
|
335 && !editorActivationListener.isEmpty()) {
|
|
336 Object[] ls = editorActivationListener.getListeners();
|
|
337 for (int i = 0; i < ls.length; i++) {
|
|
338
|
|
339 (cast(ColumnViewerEditorActivationListener) ls[i])
|
|
340 .beforeEditorDeactivated(tmp);
|
|
341 }
|
|
342 }
|
|
343
|
|
344 setEditor(null, null, 0);
|
|
345 cellEditor.removeListener(cellEditorListener);
|
|
346
|
|
347 Control control = cellEditor.getControl();
|
|
348 if (control !is null) {
|
|
349 if (mouseListener !is null) {
|
|
350 control.removeMouseListener(mouseListener);
|
|
351 // Clear the instance not needed any more
|
|
352 mouseListener = null;
|
|
353 }
|
|
354 if (focusListener !is null) {
|
|
355 control.removeFocusListener(focusListener);
|
|
356 }
|
|
357
|
|
358 if (tabeditingListener !is null) {
|
|
359 control.removeTraverseListener(tabeditingListener);
|
|
360 }
|
|
361 }
|
|
362
|
|
363 CellEditor oldEditor = cellEditor;
|
|
364 oldEditor.deactivate();
|
|
365
|
|
366 if (editorActivationListener !is null
|
|
367 && !editorActivationListener.isEmpty()) {
|
|
368 Object[] ls = editorActivationListener.getListeners();
|
|
369 for (int i = 0; i < ls.length; i++) {
|
|
370 (cast(ColumnViewerEditorActivationListener) ls[i])
|
|
371 .afterEditorDeactivated(tmp);
|
|
372 }
|
|
373 }
|
|
374
|
|
375 this.cellEditor = null;
|
|
376 this.activationEvent = null;
|
|
377 this.cell = null;
|
|
378 }
|
|
379 }
|
|
380
|
|
381 /**
|
|
382 * Enable the editor by mouse down
|
|
383 *
|
|
384 * @param event
|
|
385 */
|
|
386 void handleEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
|
|
387 if (editorActivationStrategy.isEditorActivationEvent_package(event)) {
|
|
388 if (cellEditor !is null) {
|
|
389 applyEditorValue();
|
|
390 }
|
|
391
|
|
392 this.cell = cast(ViewerCell) event.getSource();
|
|
393
|
|
394 activationEvent = event;
|
|
395 activationTime = event.time
|
|
396 + Display.getCurrent().getDoubleClickTime();
|
|
397
|
|
398 activateCellEditor();
|
|
399 }
|
|
400 }
|
|
401
|
|
402 private void saveEditorValue(CellEditor cellEditor) {
|
|
403 ViewerColumn part = viewer.getViewerColumn(cell.getColumnIndex());
|
|
404
|
|
405 if (part !is null && part.getEditingSupport() !is null) {
|
|
406 part.getEditingSupport().saveCellEditorValue_package(cellEditor, cell);
|
|
407 }
|
|
408 }
|
|
409
|
|
410 /**
|
|
411 * Return whether there is an active cell editor.
|
|
412 *
|
|
413 * @return <code>true</code> if there is an active cell editor; otherwise
|
|
414 * <code>false</code> is returned.
|
|
415 */
|
|
416 bool isCellEditorActive() {
|
|
417 return cellEditor !is null;
|
|
418 }
|
|
419
|
|
420 void handleDoubleClickEvent() {
|
|
421 viewer.fireDoubleClick_package(new DoubleClickEvent(viewer, viewer
|
|
422 .getSelection()));
|
|
423 viewer.fireOpen_package(new OpenEvent(viewer, viewer.getSelection()));
|
|
424 }
|
|
425
|
|
426 /**
|
|
427 * Adds the given listener, it is to be notified when the cell editor is
|
|
428 * activated or deactivated.
|
|
429 *
|
|
430 * @param listener
|
|
431 * the listener to add
|
|
432 */
|
|
433 public void addEditorActivationListener(
|
|
434 ColumnViewerEditorActivationListener listener) {
|
|
435 if (editorActivationListener is null) {
|
|
436 editorActivationListener = new ListenerList();
|
|
437 }
|
|
438 editorActivationListener.add(listener);
|
|
439 }
|
|
440
|
|
441 /**
|
|
442 * Removes the given listener.
|
|
443 *
|
|
444 * @param listener
|
|
445 * the listener to remove
|
|
446 */
|
|
447 public void removeEditorActivationListener(
|
|
448 ColumnViewerEditorActivationListener listener) {
|
|
449 if (editorActivationListener !is null) {
|
|
450 editorActivationListener.remove(listener);
|
|
451 }
|
|
452 }
|
|
453
|
|
454 /**
|
|
455 * Process the traverse event and opens the next available editor depending
|
|
456 * of the implemented strategy. The default implementation uses the style
|
|
457 * constants
|
|
458 * <ul>
|
|
459 * <li>{@link ColumnViewerEditor#TABBING_MOVE_TO_ROW_NEIGHBOR}</li>
|
|
460 * <li>{@link ColumnViewerEditor#TABBING_CYCLE_IN_ROW}</li>
|
|
461 * <li>{@link ColumnViewerEditor#TABBING_VERTICAL}</li>
|
|
462 * <li>{@link ColumnViewerEditor#TABBING_HORIZONTAL}</li>
|
|
463 * </ul>
|
|
464 *
|
|
465 * <p>
|
|
466 * Subclasses may overwrite to implement their custom logic to edit the next
|
|
467 * cell
|
|
468 * </p>
|
|
469 *
|
|
470 * @param columnIndex
|
|
471 * the index of the current column
|
|
472 * @param row
|
|
473 * the current row - may only be used for the duration of this
|
|
474 * method call
|
|
475 * @param event
|
|
476 * the traverse event
|
|
477 */
|
|
478 protected void processTraverseEvent(int columnIndex, ViewerRow row,
|
|
479 TraverseEvent event) {
|
|
480
|
|
481 ViewerCell cell2edit = null;
|
|
482
|
|
483 if (event.detail is DWT.TRAVERSE_TAB_PREVIOUS) {
|
|
484 event.doit = false;
|
|
485
|
|
486 if ((event.stateMask & DWT.CTRL) is DWT.CTRL
|
|
487 && (feature & TABBING_VERTICAL) is TABBING_VERTICAL) {
|
|
488 cell2edit = searchCellAboveBelow(row, viewer, columnIndex, true);
|
|
489 } else if ((feature & TABBING_HORIZONTAL) is TABBING_HORIZONTAL) {
|
|
490 cell2edit = searchPreviousCell(row, viewer, columnIndex,
|
|
491 columnIndex);
|
|
492 }
|
|
493 } else if (event.detail is DWT.TRAVERSE_TAB_NEXT) {
|
|
494 event.doit = false;
|
|
495
|
|
496 if ((event.stateMask & DWT.CTRL) is DWT.CTRL
|
|
497 && (feature & TABBING_VERTICAL) is TABBING_VERTICAL) {
|
|
498 cell2edit = searchCellAboveBelow(row, viewer, columnIndex,
|
|
499 false);
|
|
500 } else if ((feature & TABBING_HORIZONTAL) is TABBING_HORIZONTAL) {
|
|
501 cell2edit = searchNextCell(row, viewer, columnIndex,
|
|
502 columnIndex);
|
|
503 }
|
|
504 }
|
|
505
|
|
506 if (cell2edit !is null) {
|
|
507
|
|
508 viewer.getControl().setRedraw(false);
|
|
509 ColumnViewerEditorActivationEvent acEvent = new ColumnViewerEditorActivationEvent(
|
|
510 cell2edit, event);
|
|
511 viewer.triggerEditorActivationEvent_package(acEvent);
|
|
512 viewer.getControl().setRedraw(true);
|
|
513 }
|
|
514 }
|
|
515
|
|
516 private ViewerCell searchCellAboveBelow(ViewerRow row, ColumnViewer viewer,
|
|
517 int columnIndex, bool above) {
|
|
518 ViewerCell rv = null;
|
|
519
|
|
520 ViewerRow newRow = null;
|
|
521
|
|
522 if (above) {
|
|
523 newRow = row.getNeighbor(ViewerRow.ABOVE, false);
|
|
524 } else {
|
|
525 newRow = row.getNeighbor(ViewerRow.BELOW, false);
|
|
526 }
|
|
527
|
|
528 if (newRow !is null) {
|
|
529 ViewerColumn column = viewer.getViewerColumn(columnIndex);
|
|
530 if (column !is null
|
|
531 && column.getEditingSupport() !is null
|
|
532 && column.getEditingSupport().canEdit_package(
|
|
533 newRow.getItem().getData())) {
|
|
534 rv = newRow.getCell(columnIndex);
|
|
535 } else {
|
|
536 rv = searchCellAboveBelow(newRow, viewer, columnIndex, above);
|
|
537 }
|
|
538 }
|
|
539
|
|
540 return rv;
|
|
541 }
|
|
542
|
|
543 private ViewerCell searchPreviousCell(ViewerRow row, ColumnViewer viewer,
|
|
544 int columnIndex, int startIndex) {
|
|
545 ViewerCell rv = null;
|
|
546
|
|
547 if (columnIndex - 1 >= 0) {
|
|
548 ViewerColumn column = viewer.getViewerColumn(columnIndex - 1);
|
|
549 if (column !is null
|
|
550 && column.getEditingSupport() !is null
|
|
551 && column.getEditingSupport().canEdit_package(
|
|
552 row.getItem().getData())) {
|
|
553 rv = row.getCell(columnIndex - 1);
|
|
554 } else {
|
|
555 rv = searchPreviousCell(row, viewer, columnIndex - 1,
|
|
556 startIndex);
|
|
557 }
|
|
558 } else {
|
|
559 if ((feature & TABBING_CYCLE_IN_ROW) is TABBING_CYCLE_IN_ROW) {
|
|
560 // Check that we don't get into endless loop
|
|
561 if (columnIndex - 1 !is startIndex) {
|
|
562 // Don't subtract -1 from getColumnCount() we need to
|
|
563 // start in the virtual column
|
|
564 // next to it
|
|
565 rv = searchPreviousCell(row, viewer, row.getColumnCount(),
|
|
566 startIndex);
|
|
567 }
|
|
568 } else if ((feature & TABBING_MOVE_TO_ROW_NEIGHBOR) is TABBING_MOVE_TO_ROW_NEIGHBOR) {
|
|
569 ViewerRow rowAbove = row.getNeighbor(ViewerRow.ABOVE, false);
|
|
570 if (rowAbove !is null) {
|
|
571 rv = searchPreviousCell(rowAbove, viewer, rowAbove
|
|
572 .getColumnCount(), startIndex);
|
|
573 }
|
|
574 }
|
|
575 }
|
|
576
|
|
577 return rv;
|
|
578 }
|
|
579
|
|
580 private ViewerCell searchNextCell(ViewerRow row, ColumnViewer viewer,
|
|
581 int columnIndex, int startIndex) {
|
|
582 ViewerCell rv = null;
|
|
583
|
|
584 if (columnIndex + 1 < row.getColumnCount()) {
|
|
585 ViewerColumn column = viewer.getViewerColumn(columnIndex + 1);
|
|
586 if (column !is null
|
|
587 && column.getEditingSupport() !is null
|
|
588 && column.getEditingSupport().canEdit_package(
|
|
589 row.getItem().getData())) {
|
|
590 rv = row.getCell(columnIndex + 1);
|
|
591 } else {
|
|
592 rv = searchNextCell(row, viewer, columnIndex + 1, startIndex);
|
|
593 }
|
|
594 } else {
|
|
595 if ((feature & TABBING_CYCLE_IN_ROW) is TABBING_CYCLE_IN_ROW) {
|
|
596 // Check that we don't get into endless loop
|
|
597 if (columnIndex + 1 !is startIndex) {
|
|
598 // Start from -1 from the virtual column before the
|
|
599 // first one
|
|
600 rv = searchNextCell(row, viewer, -1, startIndex);
|
|
601 }
|
|
602 } else if ((feature & TABBING_MOVE_TO_ROW_NEIGHBOR) is TABBING_MOVE_TO_ROW_NEIGHBOR) {
|
|
603 ViewerRow rowBelow = row.getNeighbor(ViewerRow.BELOW, false);
|
|
604 if (rowBelow !is null) {
|
|
605 rv = searchNextCell(rowBelow, viewer, -1, startIndex);
|
|
606 }
|
|
607 }
|
|
608 }
|
|
609
|
|
610 return rv;
|
|
611 }
|
|
612
|
|
613 /**
|
|
614 * Position the editor inside the control
|
|
615 *
|
|
616 * @param w
|
|
617 * the editor control
|
|
618 * @param item
|
|
619 * the item (row) in which the editor is drawn in
|
|
620 * @param fColumnNumber
|
|
621 * the column number in which the editor is shown
|
|
622 */
|
|
623 protected abstract void setEditor(Control w, Item item, int fColumnNumber);
|
|
624
|
|
625 /**
|
|
626 * set the layout data for the editor
|
|
627 *
|
|
628 * @param layoutData
|
|
629 * the layout data used when editor is displayed
|
|
630 */
|
|
631 protected abstract void setLayoutData(CellEditor.LayoutData layoutData);
|
|
632
|
|
633 /**
|
|
634 * @param focusCell
|
|
635 * updates the cell with the current input focus
|
|
636 * @param event
|
|
637 * the event requesting to update the focusCell
|
|
638 */
|
|
639 protected abstract void updateFocusCell(ViewerCell focusCell,
|
|
640 ColumnViewerEditorActivationEvent event);
|
|
641
|
|
642 /**
|
|
643 * @return the cell currently holding the focus if no cell has the focus or
|
|
644 * the viewer implementation doesn't support <code>null</code> is
|
|
645 * returned
|
|
646 *
|
|
647 */
|
|
648 public ViewerCell getFocusCell() {
|
|
649 return null;
|
|
650 }
|
|
651
|
|
652 /**
|
|
653 * @return the viewer working for
|
|
654 */
|
|
655 protected ColumnViewer getViewer() {
|
|
656 return viewer;
|
|
657 }
|
|
658 }
|