View | Details | Raw Unified | Return to bug 167858
Collapse All | Expand All

(-)src/org/eclipse/jface/viewers/ColumnViewer.java (-36 / +60 lines)
Lines 49-55 Link Here
49
	private AbstractViewerEditor viewerEditor;
49
	private AbstractViewerEditor viewerEditor;
50
50
51
	private int tabEditingStyle = EditingSupport.TABING_NONE;
51
	private int tabEditingStyle = EditingSupport.TABING_NONE;
52
	
52
53
	/**
53
	/**
54
	 * Create a new instance of the receiver.
54
	 * Create a new instance of the receiver.
55
	 */
55
	 */
Lines 83-91 Link Here
83
	}
83
	}
84
84
85
	/**
85
	/**
86
	 * Creates the viewer editor used for editing cell contents. To be implemented by subclasses.
86
	 * Creates the viewer editor used for editing cell contents. To be
87
	 * implemented by subclasses.
87
	 * 
88
	 * 
88
	 * @return the editor, or <code>null</code> if this viewer does not support editing cell contents.
89
	 * @return the editor, or <code>null</code> if this viewer does not
90
	 *         support editing cell contents.
89
	 */
91
	 */
90
	protected abstract AbstractViewerEditor createViewerEditor();
92
	protected abstract AbstractViewerEditor createViewerEditor();
91
93
Lines 95-101 Link Here
95
	 * 
97
	 * 
96
	 * @param point
98
	 * @param point
97
	 *            the widget-relative coordinates
99
	 *            the widget-relative coordinates
98
	 * @return the cell or <code>null</code> if no cell is found at the given point
100
	 * @return the cell or <code>null</code> if no cell is found at the given
101
	 *         point
99
	 */
102
	 */
100
	ViewerCell getCell(Point point) {
103
	ViewerCell getCell(Point point) {
101
		ViewerRow row = getViewerRow(point);
104
		ViewerRow row = getViewerRow(point);
Lines 127-133 Link Here
127
	/**
130
	/**
128
	 * Returns the viewer row associated with the given row widget.
131
	 * Returns the viewer row associated with the given row widget.
129
	 * 
132
	 * 
130
	 * @param item the row widget
133
	 * @param item
134
	 *            the row widget
131
	 * @return ViewerRow the associated viewer row
135
	 * @return ViewerRow the associated viewer row
132
	 */
136
	 */
133
	protected ViewerRow getViewerRowFromItem(Widget item) {
137
	protected ViewerRow getViewerRowFromItem(Widget item) {
Lines 137-143 Link Here
137
	/**
141
	/**
138
	 * Returns the column widget at the given column index.
142
	 * Returns the column widget at the given column index.
139
	 * 
143
	 * 
140
	 * @param columnIndex the column index
144
	 * @param columnIndex
145
	 *            the column index
141
	 * @return Widget the column widget
146
	 * @return Widget the column widget
142
	 */
147
	 */
143
	protected abstract Widget getColumnViewerOwner(int columnIndex);
148
	protected abstract Widget getColumnViewerOwner(int columnIndex);
Lines 150-156 Link Here
150
	 * @return the viewer column at the given index, or <code>null</code> if
155
	 * @return the viewer column at the given index, or <code>null</code> if
151
	 *         there is none for the given index
156
	 *         there is none for the given index
152
	 */
157
	 */
153
	/* package */ ViewerColumn getViewerColumn(final int columnIndex) {
158
	/* package */ViewerColumn getViewerColumn(final int columnIndex) {
154
159
155
		ViewerColumn viewer;
160
		ViewerColumn viewer;
156
		Widget columnOwner = getColumnViewerOwner(columnIndex);
161
		Widget columnOwner = getColumnViewerOwner(columnIndex);
Lines 176-182 Link Here
176
	}
181
	}
177
182
178
	/**
183
	/**
179
	 * Sets up editing support for the given column based on the "old" cell editor API.
184
	 * Sets up editing support for the given column based on the "old" cell
185
	 * editor API.
180
	 * 
186
	 * 
181
	 * @param columnIndex
187
	 * @param columnIndex
182
	 * @param viewer
188
	 * @param viewer
Lines 229-243 Link Here
229
	}
235
	}
230
236
231
	/**
237
	/**
232
	 * Creates a generic viewer column for the given column widget, based on the given label provider.
238
	 * Creates a generic viewer column for the given column widget, based on the
239
	 * given label provider.
233
	 * 
240
	 * 
234
	 * @param columnOwner the column widget
241
	 * @param columnOwner
235
	 * @param labelProvider the label provider to use for the column
242
	 *            the column widget
243
	 * @param labelProvider
244
	 *            the label provider to use for the column
236
	 * @return ViewerColumn the viewer column
245
	 * @return ViewerColumn the viewer column
237
	 */
246
	 */
238
	private ViewerColumn createViewerColumn(Widget columnOwner,
247
	private ViewerColumn createViewerColumn(Widget columnOwner,
239
			CellLabelProvider labelProvider) {
248
			CellLabelProvider labelProvider) {
240
		ViewerColumn column = new ViewerColumn(this,columnOwner) {};
249
		ViewerColumn column = new ViewerColumn(this, columnOwner) {
250
		};
241
		column.setLabelProvider(labelProvider, false);
251
		column.setLabelProvider(labelProvider, false);
242
		return column;
252
		return column;
243
	}
253
	}
Lines 269-287 Link Here
269
	 * @param column
279
	 * @param column
270
	 * @return ViewerCell
280
	 * @return ViewerCell
271
	 */
281
	 */
272
	/* package */ ViewerCell updateCell(ViewerRow rowItem, int column) {
282
	/* package */ViewerCell updateCell(ViewerRow rowItem, int column) {
273
		cell.update(rowItem, column);
283
		cell.update(rowItem, column);
274
		return cell;
284
		return cell;
275
	}
285
	}
276
286
277
	/**
287
	/**
278
	 * Returns the {@link Item} at the given widget-relative coordinates, or
288
	 * Returns the {@link Item} at the given widget-relative coordinates, or
279
     * <code>null</code> if there is no item at the given coordinates.
289
	 * <code>null</code> if there is no item at the given coordinates.
280
	 * 
290
	 * 
281
	 * @param point
291
	 * @param point
282
	 *            the widget-relative coordinates
292
	 *            the widget-relative coordinates
283
	 * @return the {@link Item} at the coordinates or <code>null</code> if there
293
	 * @return the {@link Item} at the coordinates or <code>null</code> if
284
	 *         is no item at the given coordinates
294
	 *         there is no item at the given coordinates
285
	 */
295
	 */
286
	protected abstract Item getItemAt(Point point);
296
	protected abstract Item getItemAt(Point point);
287
297
Lines 339-345 Link Here
339
349
340
	/**
350
	/**
341
	 * Cancels a currently active cell editor if one is active. All changes
351
	 * Cancels a currently active cell editor if one is active. All changes
342
     * already done in the cell editor are lost.
352
	 * already done in the cell editor are lost.
343
	 * 
353
	 * 
344
	 * @since 3.1 (in subclasses, added in 3.3 to abstract class)
354
	 * @since 3.1 (in subclasses, added in 3.3 to abstract class)
345
	 */
355
	 */
Lines 377-387 Link Here
377
387
378
	/**
388
	/**
379
	 * Return the CellEditors for the receiver, or <code>null</code> if no
389
	 * Return the CellEditors for the receiver, or <code>null</code> if no
380
     * cell editors are set.
390
	 * cell editors are set.
381
	 * <p>
391
	 * <p>
382
	 * Since 3.3, an alternative API is available, see
392
	 * Since 3.3, an alternative API is available, see
383
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible
393
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more
384
	 * way of editing values in a column viewer.
394
	 * flexible way of editing values in a column viewer.
385
	 * </p>
395
	 * </p>
386
	 * 
396
	 * 
387
	 * @return CellEditor[]
397
	 * @return CellEditor[]
Lines 398-409 Link Here
398
408
399
	/**
409
	/**
400
	 * Returns the cell modifier of this viewer, or <code>null</code> if none
410
	 * Returns the cell modifier of this viewer, or <code>null</code> if none
401
     * has been set.
411
	 * has been set.
402
	 * 
412
	 * 
403
	 * <p>
413
	 * <p>
404
	 * Since 3.3, an alternative API is available, see
414
	 * Since 3.3, an alternative API is available, see
405
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible
415
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more
406
	 * way of editing values in a column viewer.
416
	 * flexible way of editing values in a column viewer.
407
	 * </p>
417
	 * </p>
408
	 * 
418
	 * 
409
	 * @return the cell modifier, or <code>null</code>
419
	 * @return the cell modifier, or <code>null</code>
Lines 425-432 Link Here
425
	 * 
435
	 * 
426
	 * <p>
436
	 * <p>
427
	 * Since 3.3, an alternative API is available, see
437
	 * Since 3.3, an alternative API is available, see
428
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible
438
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more
429
	 * way of editing values in a column viewer.
439
	 * flexible way of editing values in a column viewer.
430
	 * </p>
440
	 * </p>
431
	 * 
441
	 * 
432
	 * @return the list of column properties
442
	 * @return the list of column properties
Lines 446-453 Link Here
446
	 * 
456
	 * 
447
	 * <p>
457
	 * <p>
448
	 * Since 3.3, an alternative API is available, see
458
	 * Since 3.3, an alternative API is available, see
449
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible
459
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more
450
	 * way of editing values in a column viewer.
460
	 * flexible way of editing values in a column viewer.
451
	 * </p>
461
	 * </p>
452
	 * 
462
	 * 
453
	 * @return <code>true</code> if there is an active cell editor, and
463
	 * @return <code>true</code> if there is an active cell editor, and
Lines 469-476 Link Here
469
	 * 
479
	 * 
470
	 * <p>
480
	 * <p>
471
	 * Since 3.3, an alternative API is available, see
481
	 * Since 3.3, an alternative API is available, see
472
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible
482
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more
473
	 * way of editing values in a column viewer.
483
	 * flexible way of editing values in a column viewer.
474
	 * </p>
484
	 * </p>
475
	 * 
485
	 * 
476
	 * @param editors
486
	 * @param editors
Lines 486-498 Link Here
486
	}
496
	}
487
497
488
	/**
498
	/**
489
	 * Sets the cell modifier for this column viewer. This method does nothing if editing
499
	 * Sets the cell modifier for this column viewer. This method does nothing
490
	 * is not supported by this viewer.
500
	 * if editing is not supported by this viewer.
491
	 * 
501
	 * 
492
	 * <p>
502
	 * <p>
493
	 * Since 3.3, an alternative API is available, see
503
	 * Since 3.3, an alternative API is available, see
494
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible
504
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more
495
	 * way of editing values in a column viewer.
505
	 * flexible way of editing values in a column viewer.
496
	 * </p>
506
	 * </p>
497
	 * 
507
	 * 
498
	 * @param modifier
508
	 * @param modifier
Lines 515-522 Link Here
515
	 * 
525
	 * 
516
	 * <p>
526
	 * <p>
517
	 * Since 3.3, an alternative API is available, see
527
	 * Since 3.3, an alternative API is available, see
518
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more flexible
528
	 * {@link ViewerColumn#setEditingSupport(EditingSupport)} for a more
519
	 * way of editing values in a column viewer.
529
	 * flexible way of editing values in a column viewer.
520
	 * </p>
530
	 * </p>
521
	 * 
531
	 * 
522
	 * @param columnProperties
532
	 * @param columnProperties
Lines 530-536 Link Here
530
			viewerEditor.setColumnProperties(columnProperties);
540
			viewerEditor.setColumnProperties(columnProperties);
531
		}
541
		}
532
	}
542
	}
533
	
543
534
	/**
544
	/**
535
	 * The tab-editing style used if the default implementation is used
545
	 * The tab-editing style used if the default implementation is used
536
	 * 
546
	 * 
Lines 544-547 Link Here
544
	int getTabEditingStyle() {
554
	int getTabEditingStyle() {
545
		return this.tabEditingStyle;
555
		return this.tabEditingStyle;
546
	}
556
	}
557
558
	/**
559
	 * @param columnIndex
560
	 *            the column index you search the label provider for
561
	 * @return the label provider associated with the column or
562
	 *         <code>null</code> if no column with this index is known
563
	 */
564
	public CellLabelProvider getLabelProvider(int columnIndex) {
565
		ViewerColumn column = getViewerColumn(columnIndex);
566
		if (column != null) {
567
			return column.getLabelProvider();
568
		}
569
		return null;
570
	}
547
}
571
}

Return to bug 167858