From 9ccc6d01230a9d055bc080ba9746c9fee2608125 Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Wed, 28 Jul 2010 18:10:12 +0000 Subject: [PATCH] 2010-07-28 Francois Chouinard Fix for Bug316349 + a bunch of missing @Overrides * src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java: Cleanup * src/org/eclipse/linuxtools/tmf/ui/widgets/ColumnData.java: New file. * src/org/eclipse/linuxtools/tmf/ui/widgets/TmfVirtualTable.java: New file. * META-INF/MANIFEST.MF: Export org.eclipse.linuxtools.tmf.ui.widgets * src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java: Replace Table by TmfVirtualTable --- org.eclipse.linuxtools.lttng.ui/ChangeLog | 4 + .../lttng/ui/views/events/EventsTable.java | 44 +- org.eclipse.linuxtools.tmf.tests/ChangeLog | 3 + .../TmfSyntheticEventProviderStub.java | 1 + org.eclipse.linuxtools.tmf.ui/ChangeLog | 33 ++ .../META-INF/MANIFEST.MF | 3 +- .../tmf/ui/editors/TmfEditorInput.java | 3 +- .../ui/parsers/custom/CustomEventsTable.java | 34 +- .../custom/CustomTxtTraceDefinition.java | 6 +- .../custom/CustomXmlTraceDefinition.java | 2 + .../tmf/ui/viewers/events/TmfEventsTable.java | 97 ++-- .../project/handlers/CloseProjectHandler.java | 1 + .../handlers/DeleteExperimentHandler.java | 1 + .../handlers/DeleteProjectHandler.java | 1 + .../project/handlers/DeleteTraceHandler.java | 1 + .../project/handlers/ImportTraceHandler.java | 1 + .../handlers/NewExperimentHandler.java | 1 + .../project/handlers/NewProjectHandler.java | 1 + .../handlers/OpenExperimentHandler.java | 1 + .../project/handlers/OpenProjectHandler.java | 1 + .../project/handlers/OpenTraceHandler.java | 1 + .../project/handlers/RefreshHandler.java | 1 + .../handlers/RenameExperimentHandler.java | 1 + .../handlers/RenameProjectHandler.java | 1 + .../project/handlers/RenameTraceHandler.java | 1 + .../project/handlers/SelectParserHandler.java | 1 + .../project/handlers/SelectTracesHandler.java | 1 + .../linuxtools/tmf/ui/widgets/ColumnData.java | 26 + .../tmf/ui/widgets/TmfVirtualTable.java | 451 ++++++++++++++++++ .../CustomTxtParserInputWizardPage.java | 17 +- .../CustomTxtParserOutputWizardPage.java | 5 +- .../tmf/ui/wizards/CustomTxtParserWizard.java | 3 +- .../CustomXmlParserInputWizardPage.java | 9 + .../CustomXmlParserOutputWizardPage.java | 3 + .../tmf/ui/wizards/CustomXmlParserWizard.java | 3 +- 35 files changed, 639 insertions(+), 124 deletions(-) create mode 100644 org.eclipse.linuxtools.tmf.tests/ChangeLog create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/ColumnData.java create mode 100644 org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfVirtualTable.java diff --git a/org.eclipse.linuxtools.lttng.ui/ChangeLog b/org.eclipse.linuxtools.lttng.ui/ChangeLog index d4f5a19bfb..b47411d4dd 100644 --- a/org.eclipse.linuxtools.lttng.ui/ChangeLog +++ b/org.eclipse.linuxtools.lttng.ui/ChangeLog @@ -1,3 +1,7 @@ +2010-07-28 Francois Chouinard + + * src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java: Cleanup + 2010-07-14 Francois Chouinard * plugin.xml: Point to the 16x16 LTTng icon for the perspective diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java index c74bb960eb..81dad5e35c 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java @@ -15,12 +15,9 @@ package org.eclipse.linuxtools.lttng.ui.views.events; import org.eclipse.linuxtools.lttng.event.LttngEventContent; import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; +import org.eclipse.linuxtools.tmf.ui.widgets.ColumnData; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; public class EventsTable extends TmfEventsTable { @@ -42,19 +39,6 @@ public class EventsTable extends TmfEventsTable { CONTENT_COLUMN }; - // Column data - static private class ColumnData { - public final String header; - public final int width; - public final int alignment; - - public ColumnData(String h, int w, int a) { - header = h; - width = w; - alignment = a; - } - }; - static private final ColumnData[] COLUMN_DATA = new ColumnData[] { new ColumnData(COLUMN_NAMES[0], 125, SWT.LEFT), new ColumnData(COLUMN_NAMES[1], 100, SWT.LEFT), @@ -68,31 +52,7 @@ public class EventsTable extends TmfEventsTable { // ------------------------------------------------------------------------ public EventsTable(Composite parent, int cacheSize) { - super(parent, cacheSize); - } - - /** - * @param table - * - * FIXME: Add support for column selection - */ - @Override - protected void createColumnHeaders(Table table) { - for (int i = 0; i < COLUMN_DATA.length; i++) { - final TableColumn column = new TableColumn(table, COLUMN_DATA[i].alignment, i); - column.setText(COLUMN_DATA[i].header); - column.setWidth(COLUMN_DATA[i].width); - // TODO: Investigate why the column resizing doesn't work by default - // Anything to do with SWT_VIRTUAL? - column.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - // TODO Auto-generated method stub - } - public void widgetSelected(SelectionEvent e) { - column.pack(); - } - }); - } + super(parent, cacheSize, COLUMN_DATA); } /** diff --git a/org.eclipse.linuxtools.tmf.tests/ChangeLog b/org.eclipse.linuxtools.tmf.tests/ChangeLog new file mode 100644 index 0000000000..ea46def04d --- /dev/null +++ b/org.eclipse.linuxtools.tmf.tests/ChangeLog @@ -0,0 +1,3 @@ +2010-07-28 Francois Chouinard + + * stubs/org/eclipse/linuxtools/tmf/component/TmfSyntheticEventProviderStub.java: Missing @Override \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/component/TmfSyntheticEventProviderStub.java b/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/component/TmfSyntheticEventProviderStub.java index 4e4b6d16eb..6de6d76363 100644 --- a/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/component/TmfSyntheticEventProviderStub.java +++ b/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/component/TmfSyntheticEventProviderStub.java @@ -81,6 +81,7 @@ public class TmfSyntheticEventProviderStub extends TmfEventProvider + + * src/org/eclipse/linuxtools/tmf/ui/widgets/ColumnData.java: New file. + * src/org/eclipse/linuxtools/tmf/ui/widgets/TmfVirtualTable.java: New file. + * META-INF/MANIFEST.MF: Export org.eclipse.linuxtools.tmf.ui.widgets + * src/org/eclipse/linuxtools/tmf/ui/editors/TmfEditorInput.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventsTable.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTraceDefinition.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTraceDefinition.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java: Replace Table by TmfVirtualTable + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/CloseProjectHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteExperimentHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteProjectHandler.java : Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteTraceHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/ImportTraceHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewExperimentHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewProjectHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenExperimentHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenProjectHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenTraceHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RefreshHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameExperimentHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameProjectHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameTraceHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectTracesHandler.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserWizard.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java: Missing @Override + * src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserWizard.java: Missing @Override + 2010-07-20 Francois Chouinard * src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java diff --git a/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF index 3f01a43383..13d57666f3 100644 --- a/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF @@ -22,5 +22,6 @@ Export-Package: org.eclipse.linuxtools.tmf.ui, org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model, org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets, org.eclipse.linuxtools.tmf.ui.views, - org.eclipse.linuxtools.tmf.ui.views.project + org.eclipse.linuxtools.tmf.ui.views.project, + org.eclipse.linuxtools.tmf.ui.widgets Bundle-Localization: plugin diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEditorInput.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEditorInput.java index 0355d6b6a0..3740fae215 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEditorInput.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEditorInput.java @@ -72,7 +72,8 @@ public class TmfEditorInput implements IEditorInput { return fTrace; } - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj instanceof TmfEditorInput) { return fResource.equals(((TmfEditorInput) obj).fResource); } else if (obj instanceof IFileEditorInput) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventsTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventsTable.java index f8d4a7bf71..22e8defce4 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventsTable.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventsTable.java @@ -13,15 +13,16 @@ package org.eclipse.linuxtools.tmf.ui.parsers.custom; import java.text.SimpleDateFormat; +import java.util.LinkedList; +import java.util.List; import java.util.TimeZone; import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn; import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; +import org.eclipse.linuxtools.tmf.ui.widgets.ColumnData; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; public class CustomEventsTable extends TmfEventsTable { @@ -30,7 +31,7 @@ public class CustomEventsTable extends TmfEventsTable { public CustomEventsTable(CustomTraceDefinition definition, Composite parent, int cacheSize) { super(parent, cacheSize); fDefinition = definition; - createColumnHeaders(fTable); + createColumnHeaders(); } public static final String TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; @@ -39,16 +40,27 @@ public class CustomEventsTable extends TmfEventsTable { TIMESTAMP_SIMPLE_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT")); } - @Override - public void createColumnHeaders(final Table table) { - if (fDefinition == null) return; // ignore when called by the super constructor - for (OutputColumn outputColumn : fDefinition.outputs) { - TableColumn column = new TableColumn(table, SWT.LEFT); - column.setText(outputColumn.name); - column.pack(); - } + protected void createColumnHeaders() { + if (fDefinition == null) + return; + List columnData = new LinkedList(); + for (OutputColumn outputColumn : fDefinition.outputs) { + ColumnData column = new ColumnData(outputColumn.name, 0, SWT.LEFT); + columnData.add(column); + } + setColumnHeaders((ColumnData[]) columnData.toArray()); } +// @Override +// public void createColumnHeaders(final Table table) { +// if (fDefinition == null) return; // ignore when called by the super constructor +// for (OutputColumn outputColumn : fDefinition.outputs) { +// TableColumn column = new TableColumn(table, SWT.LEFT); +// column.setText(outputColumn.name); +// column.pack(); +// } +// } + @Override public String[] extractItemFields(TmfEvent event) { if (event instanceof CustomEvent) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTraceDefinition.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTraceDefinition.java index 0e18903021..e9a6d5ee13 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTraceDefinition.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTraceDefinition.java @@ -251,11 +251,13 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { } } - public void save() { + @Override + public void save() { save(CUSTOM_TXT_TRACE_DEFINITIONS_PATH_NAME); } - public void save(String path) { + @Override + public void save(String path) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTraceDefinition.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTraceDefinition.java index fb9f036c26..c6f8b28553 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTraceDefinition.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTraceDefinition.java @@ -167,10 +167,12 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { } } + @Override public void save() { save(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME); } + @Override public void save(String path) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java index edb3b0db73..e6448957d9 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java @@ -9,6 +9,7 @@ * Contributors: * Francois Chouinard - Initial API and implementation * Patrick Tasse - Factored out from events view + * Francois Chouinard - Replaced Table by TmfVirtualTable *******************************************************************************/ package org.eclipse.linuxtools.tmf.ui.viewers.events; @@ -28,6 +29,8 @@ import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal; import org.eclipse.linuxtools.tmf.signal.TmfTraceUpdatedSignal; import org.eclipse.linuxtools.tmf.trace.ITmfTrace; +import org.eclipse.linuxtools.tmf.ui.widgets.ColumnData; +import org.eclipse.linuxtools.tmf.ui.widgets.TmfVirtualTable; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -35,7 +38,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; @@ -50,7 +52,7 @@ public class TmfEventsTable extends TmfComponent { // Table data // ------------------------------------------------------------------------ - protected Table fTable; + protected TmfVirtualTable fTable; protected ITmfTrace fTrace; protected boolean fPackDone = false; @@ -68,19 +70,6 @@ public class TmfEventsTable extends TmfComponent { CONTENT_COLUMN }; - // Column data - static private class ColumnData { - public final String header; - public final int width; - public final int alignment; - - public ColumnData(String h, int w, int a) { - header = h; - width = w; - alignment = a; - } - }; - static private ColumnData[] COLUMN_DATA = new ColumnData[] { new ColumnData(COLUMN_NAMES[0], 100, SWT.LEFT), new ColumnData(COLUMN_NAMES[1], 100, SWT.LEFT), @@ -93,28 +82,30 @@ public class TmfEventsTable extends TmfComponent { // Event cache // ------------------------------------------------------------------------ - private final int fCacheSize; - private TmfEvent[] cache = new TmfEvent[1]; - private int cacheStartIndex = 0; - private int cacheEndIndex = 0; + private final int fCacheSize; + private TmfEvent[] fCache; + private int fCacheStartIndex = 0; + private int fCacheEndIndex = 0; + private boolean fDisposeOnClose; -// private IResourceChangeListener fResourceChangeListener; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ public TmfEventsTable(Composite parent, int cacheSize) { + this(parent, cacheSize, COLUMN_DATA); + } + + public TmfEventsTable(Composite parent, int cacheSize, ColumnData[] columnData) { super("TmfEventsTable"); fCacheSize = cacheSize; - -// fShell = parent.getShell(); + fCache = new TmfEvent[fCacheSize]; // Create a virtual table - // TODO: change SINGLE to MULTI line selection and adjust the selection listener - final int style = SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL; - fTable = new Table(parent, style); + final int style = SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER; + fTable = new TmfVirtualTable(parent, style); // Set the table layout GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); @@ -125,11 +116,10 @@ public class TmfEventsTable extends TmfComponent { fTable.setLinesVisible(true); // Set the columns - createColumnHeaders(fTable); + setColumnHeaders(columnData); // Handle the table item requests fTable.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { TmfTimestamp ts = (TmfTimestamp) fTable.getSelection()[0].getData(); @@ -147,10 +137,10 @@ public class TmfEventsTable extends TmfComponent { final int index = fTable.indexOf(item); // Note: this works because handleEvent() is called once for each row, in sequence - if ((index >= cacheStartIndex ) && (index < cacheEndIndex)) { - int i = index - cacheStartIndex; - item.setText(extractItemFields(cache[i])); - item.setData(new TmfTimestamp(cache[i].getTimestamp())); + if ((index >= fCacheStartIndex) && (index < fCacheEndIndex)) { + int i = index - fCacheStartIndex; + item.setText(extractItemFields(fCache[i])); + item.setData(new TmfTimestamp(fCache[i].getTimestamp())); return; } @@ -159,9 +149,9 @@ public class TmfEventsTable extends TmfComponent { public void handleData() { TmfEvent[] tmpEvent = getData(); if ((tmpEvent != null) && (tmpEvent.length > 0)) { - cache = tmpEvent; - cacheStartIndex = index; - cacheEndIndex = index + tmpEvent.length; + fCache = tmpEvent; + fCacheStartIndex = index; + fCacheEndIndex = index + tmpEvent.length; } } }; @@ -172,10 +162,10 @@ public class TmfEventsTable extends TmfComponent { e.printStackTrace(); } - if (cache[0] != null && cacheStartIndex == index) { - item.setText(extractItemFields(cache[0])); - item.setData(new TmfTimestamp(cache[0].getTimestamp())); - packColumns(fTable); + if (fCache[0] != null && fCacheStartIndex == index) { + item.setText(extractItemFields(fCache[0])); + item.setData(new TmfTimestamp(fCache[0].getTimestamp())); + packColumns(); } } @@ -184,7 +174,8 @@ public class TmfEventsTable extends TmfComponent { fTable.setItemCount(0); } - public void dispose() { + @Override + public void dispose() { fTable.dispose(); if (fTrace != null && fDisposeOnClose) { fTrace.dispose(); @@ -192,7 +183,7 @@ public class TmfEventsTable extends TmfComponent { super.dispose(); } - public Table getTable() { + public TmfVirtualTable getTable() { return fTable; } @@ -201,15 +192,11 @@ public class TmfEventsTable extends TmfComponent { * * FIXME: Add support for column selection */ - protected void createColumnHeaders(Table table) { - for (int i = 0; i < COLUMN_DATA.length; i++) { - TableColumn column = new TableColumn(table, COLUMN_DATA[i].alignment, i); - column.setText(COLUMN_DATA[i].header); - column.setWidth(COLUMN_DATA[i].width); - } + protected void setColumnHeaders(ColumnData[] columnData) { + fTable.setColumnHeaders(columnData); } - protected void packColumns(Table table) { + protected void packColumns() { if (fPackDone) return; for (TableColumn column : fTable.getColumns()) { int headerWidth = column.getWidth(); @@ -261,7 +248,7 @@ public class TmfEventsTable extends TmfComponent { public void run() { //fTable.setSelection(0); fTable.removeAll(); - cacheStartIndex = cacheEndIndex = 0; // Clear the cache + fCacheStartIndex = fCacheEndIndex = 0; // Clear the cache if (!fTable.isDisposed() && fTrace != null) { //int nbEvents = (int) fTrace.getNbEvents(); @@ -270,19 +257,6 @@ public class TmfEventsTable extends TmfComponent { } } }); -// ProgressMonitorDialog dialog = new ProgressMonitorDialog(fShell); -// try { -// dialog.run(false, false, new IRunnableWithProgress() { -// public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { -// monitor.beginTask("Cleaning up, please wait", 0); -// -// -// monitor.done(); -// } -// }); -// } catch (InvocationTargetException e) { -// } catch (InterruptedException e) { -// } } // ------------------------------------------------------------------------ @@ -297,6 +271,7 @@ public class TmfEventsTable extends TmfComponent { public void run() { if (!fTable.isDisposed() && fTrace != null) { fTable.setItemCount((int) fTrace.getNbEvents()); + fTable.refresh(); } } }); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/CloseProjectHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/CloseProjectHandler.java index 427661fb47..e3d728cb1c 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/CloseProjectHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/CloseProjectHandler.java @@ -36,6 +36,7 @@ public class CloseProjectHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteExperimentHandler.java index d40f6126e1..924f38aeca 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteExperimentHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteExperimentHandler.java @@ -39,6 +39,7 @@ public class DeleteExperimentHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteProjectHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteProjectHandler.java index 612ea06ff1..8bbc3653bc 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteProjectHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteProjectHandler.java @@ -39,6 +39,7 @@ public class DeleteProjectHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteTraceHandler.java index 66bbddab97..1fa9598aeb 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteTraceHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/DeleteTraceHandler.java @@ -41,6 +41,7 @@ public class DeleteTraceHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/ImportTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/ImportTraceHandler.java index 303a5ca715..af90aed4bf 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/ImportTraceHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/ImportTraceHandler.java @@ -42,6 +42,7 @@ public class ImportTraceHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewExperimentHandler.java index 592234167d..4d63826067 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewExperimentHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewExperimentHandler.java @@ -42,6 +42,7 @@ public class NewExperimentHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewProjectHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewProjectHandler.java index a3e778cf05..03df7f2fe0 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewProjectHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/NewProjectHandler.java @@ -44,6 +44,7 @@ public class NewProjectHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenExperimentHandler.java index c45c606a34..7de08393e7 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenExperimentHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenExperimentHandler.java @@ -36,6 +36,7 @@ public class OpenExperimentHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenProjectHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenProjectHandler.java index e1a6726050..2e5c8e5723 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenProjectHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenProjectHandler.java @@ -36,6 +36,7 @@ public class OpenProjectHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenTraceHandler.java index 6b7eaf6a02..151cfcb1fa 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenTraceHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/OpenTraceHandler.java @@ -46,6 +46,7 @@ public class OpenTraceHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RefreshHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RefreshHandler.java index 8123f6d865..05d2966caa 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RefreshHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RefreshHandler.java @@ -40,6 +40,7 @@ public class RefreshHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameExperimentHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameExperimentHandler.java index d65dd61c1a..2dcd99f261 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameExperimentHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameExperimentHandler.java @@ -32,6 +32,7 @@ public class RenameExperimentHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { return (fExperiment != null); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameProjectHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameProjectHandler.java index 45fe8abbfc..b7f90cd4bd 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameProjectHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameProjectHandler.java @@ -32,6 +32,7 @@ public class RenameProjectHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameTraceHandler.java index b077b245ff..46728aff08 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameTraceHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/RenameTraceHandler.java @@ -32,6 +32,7 @@ public class RenameTraceHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { return (fTrace != null); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserHandler.java index 2d55dbc171..ad546e2792 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectParserHandler.java @@ -45,6 +45,7 @@ public class SelectParserHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectTracesHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectTracesHandler.java index 054d950205..056f0d69df 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectTracesHandler.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/project/handlers/SelectTracesHandler.java @@ -40,6 +40,7 @@ public class SelectTracesHandler extends AbstractHandler { // Validation // ------------------------------------------------------------------------ + @Override public boolean isEnabled() { // Check if we are closing down diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/ColumnData.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/ColumnData.java new file mode 100644 index 0000000000..6c20fa53ca --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/ColumnData.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2010 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Khouzam - Extracted from TmfEventsView + ******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.widgets; + +public class ColumnData { + public final String header; + public final int width; + public final int alignment; + + public ColumnData(String h, int w, int a) { + header = h; + width = w; + alignment = a; + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfVirtualTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfVirtualTable.java new file mode 100644 index 0000000000..24a5401d36 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/TmfVirtualTable.java @@ -0,0 +1,451 @@ +/******************************************************************************* + * Copyright (c) 2010 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Khouzam - Initial API and implementation + * Francois Chouinard - Refactoring, slider support, bug fixing + ******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.widgets; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseWheelListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Slider; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; + +/** + * TmfVirtualTable + *

+ * TmfVirtualTable allows for the tabular display of arbitrarily large data sets + * (well, up to Integer.MAX_VALUE or ~2G rows). + * + * It is essentially a Composite of Table and Slider, where the number of rows + * in the table is set to fill the table display area. The slider is rank-based. + * + * It differs from Table with the VIRTUAL style flag where an empty entry is + * created for each virtual row. This does not scale well for very large data sets. + */ +public class TmfVirtualTable extends Composite { + + // The table + private Table fTable; + private int fFirstRowOffset = 0; + private int fTableRow = 0; + private int fEffectiveRow = 0; + + private TableItem fSelectedItems[] = null; + private int fTableItemCount = 0; + private int fRowsDisplayed; + private TableItem fTableItems[]; + + // The slider + private Slider fSlider; + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + + /** + * @param parent + * @param style + */ + public TmfVirtualTable(Composite parent, int style) { + super(parent, style | SWT.BORDER & (~SWT.H_SCROLL) & (~SWT.V_SCROLL)); + + // Create the controls + createTable(); + createSlider(); + + // Set the layout + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + gridLayout.horizontalSpacing = 0; + gridLayout.verticalSpacing = 0; + gridLayout.marginWidth = 0; + setLayout(gridLayout); + + GridData tableGridData = new GridData(SWT.FILL, SWT.FILL, true, true); + fTable.setLayoutData(tableGridData); + + GridData sliderGridData = new GridData(SWT.FILL, SWT.FILL, false, true); + fSlider.setLayoutData(sliderGridData); + + // Add the listeners + addMouseWheelListener(new MouseWheelListener() { + public void mouseScrolled(MouseEvent event) { + fFirstRowOffset -= event.count; + int lastFirstRowOffset = fTableItemCount - fRowsDisplayed - 1; + if (fFirstRowOffset > lastFirstRowOffset) { + fFirstRowOffset = lastFirstRowOffset; + } else if (fFirstRowOffset < 0) { + fFirstRowOffset = 0; + } + fSlider.setSelection(fFirstRowOffset); + setSelection(); + } + }); + + addControlListener(new ControlAdapter() { + @Override + public void controlResized(ControlEvent event) { + resize(); + } + }); + + // And display + refresh(); + } + + // ------------------------------------------------------------------------ + // Table handling + // ------------------------------------------------------------------------ + + /** + * Create the table and add listeners + */ + private void createTable() { + + int tableStyle = SWT.NO_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION; + fTable = new Table(this, tableStyle); + + fTable.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + handleTableSelection(); + } + }); + + fTable.addKeyListener(new KeyListener() { + public void keyPressed(KeyEvent event) { + handleTableKeyEvent(event); + } + public void keyReleased(KeyEvent event) { + } + }); + } + + /** + * Update the rows and selected item + */ + private void handleTableSelection() { + fTableRow = fTable.getSelectionIndices()[0]; + fEffectiveRow = fFirstRowOffset + fTableRow; + fSelectedItems = new TableItem[1]; + fSelectedItems[0] = fTable.getSelection()[0]; + } + + /** + * Handle key-based navigation in table. + * + * The key variables are: + * - fFirstRowOffset: the absolute index (in the data set) of the first row displayed + * - fTableRow: the index of the selected event in the table window + * - fEffectiveRow: the absolute index of the selected event (in the data set) + * + * At all times, the following relation should hold true: + * fEffectiveRow = fFirstRowOffset + fTableRow + * + * @param event + */ + private void handleTableKeyEvent(KeyEvent event) { + + boolean needsUpdate = false; + final int lastTableRow = fTableItemCount - 1; + int lastRowDisplayed = ((fTableItemCount < fRowsDisplayed) ? fTableItemCount : fRowsDisplayed) - 1; + + // We are handling things + event.doit = false; + + switch (event.keyCode) { + + case SWT.ARROW_DOWN: { + if (fEffectiveRow < lastTableRow) { + fEffectiveRow++; + if (fTableRow < lastRowDisplayed) { + fTableRow++; + } else if (fTableRow < fEffectiveRow) { + fFirstRowOffset++; + needsUpdate = true; + } + } + break; + } + + case SWT.PAGE_DOWN: { + if (fEffectiveRow < lastTableRow) { + if ((lastTableRow - fEffectiveRow) >= fRowsDisplayed) { + fEffectiveRow += fRowsDisplayed; + fFirstRowOffset += fRowsDisplayed; + } else { + fEffectiveRow = lastTableRow; + fTableRow = lastRowDisplayed; + } + needsUpdate = true; + } + break; + } + + case SWT.END: { + fEffectiveRow = lastTableRow; + fTableRow = lastRowDisplayed; + if (lastTableRow > lastRowDisplayed) { + fFirstRowOffset = fTableItemCount - fRowsDisplayed; + } + needsUpdate = true; + break; + } + + case SWT.ARROW_UP: { + if (fEffectiveRow > 0) { + fEffectiveRow--; + if (fTableRow > 0) { + fTableRow--; + } else { + fFirstRowOffset--; + needsUpdate = true; + } + } + break; + } + + case SWT.PAGE_UP: { + if (fEffectiveRow > 0) { + if (fEffectiveRow > fRowsDisplayed - 1) { + fEffectiveRow -= fRowsDisplayed; + fFirstRowOffset -= fRowsDisplayed; + } else { + fEffectiveRow = 0; + fTableRow = 0; + } + needsUpdate = true; + } + break; + } + + case SWT.HOME: { + fEffectiveRow = 0; + fTableRow = 0; + fFirstRowOffset = 0; + needsUpdate = true; + break; + } + } + + if (needsUpdate) { + for (int i = 0; i < fTableItems.length; i++) { + setDataItem(fTableItems[i]); + } + } + + fTable.setSelection(fTableRow); + fSlider.setSelection(fEffectiveRow); + +// System.out.println("1st: " + fFirstRowOffset + ", TR: " + fTableRow + ", ER: " + fEffectiveRow + +// ", Valid: " + ((fFirstRowOffset >= 0) && (fEffectiveRow == (fFirstRowOffset + fTableRow)))); + } + + private void setDataItem(TableItem item) { + int index = fTable.indexOf(item); + if( index != -1) { + Event event = new Event(); + event.item = item; + event.index = index + fFirstRowOffset; + event.doit = true; + notifyListeners(SWT.SetData, event); + } + } + + // ------------------------------------------------------------------------ + // Slider handling + // ------------------------------------------------------------------------ + + private void createSlider() { + fSlider = new Slider(this, SWT.VERTICAL); + fSlider.setMinimum(0); + fSlider.setMaximum(0); + + fSlider.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + setSelection(); + } + }); + + fSlider.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event event) { + switch (event.detail) { + case SWT.ARROW_DOWN: + case SWT.ARROW_UP: + case SWT.NONE: + case SWT.END: + case SWT.HOME: + case SWT.PAGE_DOWN: + case SWT.PAGE_UP: { + fFirstRowOffset = fSlider.getSelection(); + setSelection(); + break; + } + } + } + }); + } + + // ------------------------------------------------------------------------ + // Simulated Table API + // ------------------------------------------------------------------------ + + public void setHeaderVisible(boolean b) { + fTable.setHeaderVisible(b); + } + + public void setLinesVisible(boolean b) { + fTable.setLinesVisible(b); + } + + public TableItem[] getSelection() { + return fSelectedItems; + } + + public void addSelectionListener(SelectionAdapter sa) { + fTable.addSelectionListener(sa); + } + + public void setItemCount(int nbItems) { + nbItems = Math.max(0, nbItems); + if (nbItems != fTableItemCount) { + fTableItemCount = nbItems; + fSlider.setMaximum(nbItems); + resize(); + } + } + + public int getItemHeight() { + return fTable.getItemHeight(); + } + + public int getTopIndex() { + return fFirstRowOffset; + } + + public void setTopIndex(int i) { + fSlider.setSelection(i); + } + + public int indexOf(TableItem ti) { + return fTable.indexOf(ti) + getTopIndex(); + } + + public TableColumn[] getColumns() { + return fTable.getColumns(); + } + + private void resize() { + + // Compute the numbers of rows that fit the new area + Rectangle clientArea = getClientArea(); + int tableHeight = clientArea.height - fTable.getHeaderHeight(); + int itemHeight = fTable.getItemHeight(); + fRowsDisplayed = tableHeight / itemHeight + 1; // For partial rows + if (fTableItemCount == 0) { + fRowsDisplayed = 0; + } + + // Re-size and re-create the virtual table if needed + int delta = fTable.getItemCount() - fRowsDisplayed; + if (delta != 0) { + fTable.removeAll(); + if (fTableItems != null) { + for (int i = 0; i < fTableItems.length; i++) { + if (fTableItems[i] != null) { + fTableItems[i].dispose(); + } + fTableItems[i] = null; + } + } + fTableItems = new TableItem[fRowsDisplayed]; + for (int i = 0; i < fTableItems.length; i++) { + fTableItems[i] = new TableItem(fTable, i); + } + } + + refresh(); + } + + // ------------------------------------------------------------------------ + // Controls interactions + // ------------------------------------------------------------------------ + + @Override + public boolean setFocus() { + boolean isVisible = isVisible(); + if (isVisible) { + fTable.setFocus(); + } + return isVisible; + } + + public void refresh() { + setSelection(); + } + + public void setColumnHeaders(ColumnData columnData[]) { + for (int i = 0; i < columnData.length; i++) { + TableColumn column = new TableColumn(fTable, columnData[i].alignment, i); + column.setText(columnData[i].header); + if (columnData[i].width > 0) { + column.setWidth(columnData[i].width); + } else { + column.pack(); + } + } + } + + public int removeAll() { + fSlider.setMaximum(0); + fTable.removeAll(); + return 0; + } + + private void setSelection() { + if ((fEffectiveRow >= fFirstRowOffset) && (fEffectiveRow < (fFirstRowOffset + fRowsDisplayed))) { + fTableRow = fEffectiveRow - fFirstRowOffset; + fTable.setSelection(fTableRow); + } else { + fTable.deselect(fTableRow); + } + + for (int i = 0; i < fRowsDisplayed; i++) { + setDataItem(fTableItems[i]); + } + } + + public void setSelection(int i) { + if (fTableItems != null) { + i = Math.min(i, fTableItemCount); + i = Math.max(i, 0); + fSlider.setSelection(i); + setSelection(); + } + } + +} diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java index 5bceafa818..3f0f846b55 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserInputWizardPage.java @@ -166,7 +166,8 @@ public class CustomTxtParserInputWizardPage extends WizardPage { dateFormatHelpButton.setImage(helpImage); dateFormatHelpButton.setToolTipText("Date Format Help"); dateFormatHelpButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { + @Override + public void widgetSelected(SelectionEvent e) { openHelpShell(SIMPLE_DATE_FORMAT_URL); } }); @@ -189,6 +190,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { removeButton.setImage(deleteImage); removeButton.setToolTipText("Remove line"); removeButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { if (treeViewer.getSelection().isEmpty() || selectedLine == null) return; removeLine(); @@ -207,6 +209,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { addNextButton.setImage(addNextImage); addNextButton.setToolTipText("Add next line"); addNextButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { InputLine inputLine = new InputLine(Cardinality.ZERO_OR_MORE, "", null); if (((List) treeViewer.getInput()).size() == 0) { @@ -233,7 +236,8 @@ public class CustomTxtParserInputWizardPage extends WizardPage { addChildButton.setImage(addChildImage); addChildButton.setToolTipText("Add child line"); addChildButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { + @Override + public void widgetSelected(SelectionEvent e) { InputLine inputLine = new InputLine(Cardinality.ZERO_OR_MORE, "", null); if (((List) treeViewer.getInput()).size() == 0) { definition.inputs.add(inputLine); @@ -251,6 +255,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { moveUpButton.setImage(moveUpImage); moveUpButton.setToolTipText("Move up"); moveUpButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { if (treeViewer.getSelection().isEmpty()) return; InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); @@ -273,6 +278,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { moveDownButton.setImage(moveDownImage); moveDownButton.setToolTipText("Move down"); moveDownButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { if (treeViewer.getSelection().isEmpty()) return; InputLine inputLine = (InputLine) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); @@ -356,6 +362,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { highlightAllButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); highlightAllButton.setText("Highlight All"); highlightAllButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { updatePreviews(true); } @@ -366,6 +373,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { legendButton.setToolTipText("Preview Legend"); legendButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); legendButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { openLegend(); } @@ -975,7 +983,8 @@ public class CustomTxtParserInputWizardPage extends WizardPage { regexHelpButton.setImage(helpImage); regexHelpButton.setToolTipText("Regular Expression Help"); regexHelpButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { + @Override + public void widgetSelected(SelectionEvent e) { openHelpShell(PATTERN_URL); } }); @@ -1134,6 +1143,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { addGroupButton.setImage(addImage); addGroupButton.setToolTipText("Add group"); addGroupButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { removeAddGroupButton(); inputs.add(new InputGroup(group, Line.this, inputs.size()+1)); @@ -1266,6 +1276,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage { deleteButton.setImage(deleteImage); deleteButton.setToolTipText("Remove group"); deleteButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { InputGroup.this.line.removeInput(InputGroup.this.inputNumber); validate(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java index 699b58ddc9..8ef7d6c5da 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserOutputWizardPage.java @@ -12,9 +12,9 @@ import org.eclipse.jface.wizard.WizardPage; import org.eclipse.linuxtools.tmf.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomEventsTable; +import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTrace; import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition; -import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.ScrolledComposite; @@ -250,6 +250,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage { enabledButton.setToolTipText("Visible"); enabledButton.setSelection(true); enabledButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { updatePreviewTable(); } @@ -267,6 +268,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage { upButton.setImage(upImage); upButton.setToolTipText("Move Before"); upButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { moveBefore(Output.this); } @@ -277,6 +279,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage { downButton.setImage(downImage); downButton.setToolTipText("Move After"); downButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { moveAfter(Output.this); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserWizard.java index e6ae71f342..cf9c8c6c08 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserWizard.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomTxtParserWizard.java @@ -61,7 +61,8 @@ public class CustomTxtParserWizard extends Wizard implements INewWizard { * Adding the page to the wizard. */ - public void addPages() { + @Override + public void addPages() { inputPage = new CustomTxtParserInputWizardPage(selection, definition); addPage(inputPage); outputPage = new CustomTxtParserOutputWizardPage(this); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java index fea8527660..1fedaf2a71 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserInputWizardPage.java @@ -172,6 +172,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { dateFormatHelpButton.setImage(helpImage); dateFormatHelpButton.setToolTipText("Date Format Help"); dateFormatHelpButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { openHelpShell(SIMPLE_DATE_FORMAT_URL); } @@ -292,6 +293,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { removeButton.setImage(deleteImage); removeButton.setToolTipText("Remove element"); removeButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { if (treeViewer.getSelection().isEmpty() || selectedElement == null) return; removeElement(); @@ -321,6 +323,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { addChildButton.setImage(addChildImage); addChildButton.setToolTipText("Add child element"); addChildButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); if (definition.rootInputElement == null) { @@ -342,6 +345,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { addNextButton.setImage(addNextImage); addNextButton.setToolTipText("Add next element"); addNextButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); if (definition.rootInputElement == null) { @@ -367,6 +371,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { feelingLuckyButton.setImage(addManyImage); feelingLuckyButton.setToolTipText("Feeling lucky"); feelingLuckyButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { InputElement inputElement = null; if (definition.rootInputElement == null) { @@ -391,6 +396,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { moveUpButton.setImage(moveUpImage); moveUpButton.setToolTipText("Move up"); moveUpButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { if (treeViewer.getSelection().isEmpty()) return; InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); @@ -409,6 +415,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { moveDownButton.setImage(moveDownImage); moveDownButton.setToolTipText("Move down"); moveDownButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { if (treeViewer.getSelection().isEmpty()) return; InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement(); @@ -1035,6 +1042,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { addAttributeButton.setImage(addImage); addAttributeButton.setToolTipText("Add attribute"); addAttributeButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { removeAddButton(); String attributeName = getAttributeNameSuggestion(inputElement); @@ -1147,6 +1155,7 @@ public class CustomXmlParserInputWizardPage extends WizardPage { deleteButton.setImage(deleteImage); deleteButton.setToolTipText("Remove attribute"); deleteButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { Attribute.this.element.removeAttribute(Attribute.this.attributeNumber); validate(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java index 5565174db1..502af087e5 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserOutputWizardPage.java @@ -251,6 +251,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage { enabledButton.setToolTipText("Visible"); enabledButton.setSelection(true); enabledButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { updatePreviewTable(); } @@ -268,6 +269,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage { upButton.setImage(upImage); upButton.setToolTipText("Move Before"); upButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { moveBefore(Output.this); } @@ -278,6 +280,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage { downButton.setImage(downImage); downButton.setToolTipText("Move After"); downButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { moveAfter(Output.this); } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserWizard.java index bd74068106..9af0bc7874 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserWizard.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/wizards/CustomXmlParserWizard.java @@ -61,7 +61,8 @@ public class CustomXmlParserWizard extends Wizard implements INewWizard { * Adding the page to the wizard. */ - public void addPages() { + @Override + public void addPages() { inputPage = new CustomXmlParserInputWizardPage(selection, definition); addPage(inputPage); outputPage = new CustomXmlParserOutputWizardPage(this); -- 2.34.1