1
1
/*******************************************************************************
2
2
* Copyright (c) 2010 Ericsson
4
4
* All rights reserved. This program and the accompanying materials are
5
5
* made available under the terms of the Eclipse Public License v1.0 which
6
6
* accompanies this distribution, and is available at
7
7
* http://www.eclipse.org/legal/epl-v10.html
10
10
* Matthew Khouzam - Initial API and implementation
11
* Francois Chouinard - Refactoring, slider support, bug fixing
11
* Francois Chouinard - Refactoring, slider support, bug fixing
12
12
* Patrick Tasse - Improvements and bug fixing
13
13
* Xavier Raynaud - Improvements
14
14
******************************************************************************/
53
53
* TmfVirtualTable allows for the tabular display of arbitrarily large data sets
54
54
* (well, up to Integer.MAX_VALUE or ~2G rows).
56
56
* It is essentially a Composite of Table and Slider, where the number of rows
57
57
* in the table is set to fill the table display area. The slider is rank-based.
59
59
* It differs from Table with the VIRTUAL style flag where an empty entry is
60
60
* created for each virtual row. This does not scale well for very large data sets.
63
63
* H_SCROLL, V_SCROLL, SINGLE, CHECK, FULL_SELECTION, HIDE_SELECTION, NO_SCROLL
64
64
* @author Matthew Khouzam, Francois Chouinard, Patrick Tasse, Xavier Raynaud
65
* @version $Revision: 1.0
65
* @version $Revision: 1.0
67
67
public class TmfVirtualTable extends Composite {
248
254
if (tooltipProvider == null) {
251
String tooltipText = tooltipProvider.getTooltip(i, item.getData());
252
if (tooltipText == null) {
255
tip = new Shell(fTable.getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
256
tip.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
257
FillLayout layout = new FillLayout();
258
layout.marginWidth = 2;
259
tip.setLayout(layout);
260
label = new Label(tip, SWT.WRAP);
261
label.setForeground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
262
label.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
263
label.setData(TOOLTIP_DATA_KEY, item);
264
label.setText(tooltipText);
257
String tooltipText = tooltipProvider.getTooltip(i, item.getData());
258
if (tooltipText == null) {
261
tip = new Shell(fTable.getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
262
tip.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
263
FillLayout layout = new FillLayout();
264
layout.marginWidth = 2;
265
tip.setLayout(layout);
266
label = new Label(tip, SWT.WRAP);
267
label.setForeground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
268
label.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
269
label.setData(TOOLTIP_DATA_KEY, item);
270
label.setText(tooltipText);
266
label.addListener(SWT.MouseExit, labelListener);
267
label.addListener(SWT.MouseDown, labelListener);
268
label.addListener(SWT.MouseWheel, labelListener);
269
Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
270
Point pt = fTable.toDisplay(bounds.x, bounds.y);
271
tip.setBounds(pt.x, pt.y, size.x, size.y);
272
tip.setVisible(true);
272
label.addListener(SWT.MouseExit, labelListener);
273
label.addListener(SWT.MouseDown, labelListener);
274
label.addListener(SWT.MouseWheel, labelListener);
275
Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
276
Point pt = fTable.toDisplay(bounds.x, bounds.y);
277
tip.setBounds(pt.x, pt.y, size.x, size.y);
278
tip.setVisible(true);
422
429
if (fSelectedEventRank < lastEventRank) {
423
430
fSelectedEventRank++;
424
431
selectedRow = fSelectedEventRank - fTableTopEventRank;
425
if (selectedRow >= fFullyVisibleRows) {
432
if (selectedRow == fFullyVisibleRows) {
426
433
fTableTopEventRank++;
427
434
needsRefresh = true;
435
} else if (selectedRow < fFrozenRowCount || selectedRow > fFullyVisibleRows) {
436
fTableTopEventRank = Math.max(0, Math.min(fSelectedEventRank - fFrozenRowCount, lastPageTopEntryRank));
435
445
if (fSelectedEventRank > 0) {
436
446
fSelectedEventRank--;
437
447
selectedRow = fSelectedEventRank - fTableTopEventRank;
438
if (selectedRow < fFrozenRowCount && fTableTopEventRank > 0) {
448
if (selectedRow == fFrozenRowCount - 1 && fTableTopEventRank > 0) {
439
449
fTableTopEventRank--;
440
450
needsRefresh = true;
451
} else if (selectedRow < fFrozenRowCount || selectedRow > fFullyVisibleRows) {
452
fTableTopEventRank = Math.max(0, Math.min(fSelectedEventRank - fFrozenRowCount, lastPageTopEntryRank));
467
480
fSelectedEventRank = lastEventRank;
469
482
selectedRow = fSelectedEventRank - fTableTopEventRank;
470
if (selectedRow > fFullyVisibleRows - 1) {
483
if (selectedRow > fFullyVisibleRows + fFrozenRowCount - 1 && selectedRow < 2 * fFullyVisibleRows) {
471
484
fTableTopEventRank += fFullyVisibleRows;
472
485
if (fTableTopEventRank > lastPageTopEntryRank) {
473
486
fTableTopEventRank = lastPageTopEntryRank;
475
488
needsRefresh = true;
489
} else if (selectedRow < fFrozenRowCount || selectedRow >= 2 * fFullyVisibleRows) {
490
fTableTopEventRank = Math.max(0, Math.min(fSelectedEventRank - fFrozenRowCount, lastPageTopEntryRank));
486
502
fSelectedEventRank = fFrozenRowCount;
488
504
selectedRow = fSelectedEventRank - fTableTopEventRank;
489
if (selectedRow < 0) {
505
if (selectedRow < fFrozenRowCount && selectedRow > -fFullyVisibleRows) {
490
506
fTableTopEventRank -= fFullyVisibleRows;
491
507
if (fTableTopEventRank < 0) {
492
508
fTableTopEventRank = 0;
494
510
needsRefresh = true;
511
} else if (selectedRow <= -fFullyVisibleRows || selectedRow >= fFullyVisibleRows) {
512
fTableTopEventRank = Math.max(0, Math.min(fSelectedEventRank - fFrozenRowCount, lastPageTopEntryRank));
754
775
* Method indexOf. Return the index of a table item
755
776
* @param ti TableItem the table item to search for in the table
756
* @return int the index of the first match. (there should only be one match)
777
* @return int the index of the first match. (there should only be one match)
758
779
public int indexOf(TableItem ti) {
759
780
int index = fTable.indexOf(ti);
760
781
if (index < fFrozenRowCount) {
763
return (index - fFrozenRowCount) + getTopIndex();
784
return (index - fFrozenRowCount) + getTopIndex();
768
788
* Method getColumns.
769
* @return TableColumn[] the table columns
789
* @return TableColumn[] the table columns
771
791
public TableColumn[] getColumns() {
772
792
return fTable.getColumns();