From d15fd570e2f0370367566b0f0ede1acfce858791 Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Thu, 8 Oct 2009 19:34:10 +0000 Subject: [PATCH] Quick fix for synchronization of the Events View --- .../lttng/ui/views/events/EventsView.java | 26 ++++++++++--- .../lttng/ui/views/project/ProjectView.java | 2 +- .../tmf/ui/views/TmfEventsView.java | 39 +++++++++++-------- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java index 67233027f5..41c21d57af 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java @@ -15,6 +15,8 @@ package org.eclipse.linuxtools.lttng.ui.views.events; import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.ui.views.TmfEventsView; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; @@ -73,17 +75,29 @@ public class EventsView extends TmfEventsView { public EventsView() { } - /** - * @param table - */ - @Override + /** + * @param table + * + * FIXME: Add support for column selection + */ + @Override protected void setColumnHeaders(Table table) { for (int i = 0; i < columnData.length; i++) { - TableColumn column = new TableColumn(table, columnData[i].alignment, i); + final TableColumn column = new TableColumn(table, columnData[i].alignment, i); column.setText(columnData[i].header); column.setWidth(columnData[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(); + } + }); } - } + } /** * @param event diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java index eee2c69dff..e7ff2f8153 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java @@ -45,7 +45,7 @@ import org.eclipse.swt.widgets.Tree; * * TODO: Implement me. Please. * TODO: Put all actions in a context menu - * TODO: Identify LTTng traces and hook doubleClick properly + * TODO: Identify LTTng traces vs. experiments and hook doubleClick properly * TODO: Handle multiple traces */ public class ProjectView extends TmfView { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java index eb60620e75..6767043666 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java @@ -127,7 +127,7 @@ public class TmfEventsView extends TmfView { public void widgetSelected(SelectionEvent e) { TmfTimestamp ts = extractTimestamp(fTable.getSelection()[0].getText()); - broadcastSignal(new TmfTimeSynchSignal(this, ts)); + broadcastSignal(new TmfTimeSynchSignal(fTable, ts)); } }); @@ -269,20 +269,27 @@ public class TmfEventsView extends TmfView { }); } -// @TmfSignalHandler -// public void currentTimeUpdated(TmfTimeSynchSignal signal) { -// if (signal.getSource() != fTable && fExperiment != null) { -// final int index = (int) fExperiment.getIndex(signal.getCurrentTime()); -// // Perform the updates on the UI thread -// fTable.getDisplay().asyncExec(new Runnable() { -// public void run() { -// int pos = (index > fTable.getTopIndex()) ? fTable.getTopIndex() : index; -// fTable.setSelection(pos); -// TmfTimestamp ts = extractTimestamp(fTable.getSelection()[0].getText()); -//// broadcastSignal(new TmfTimeSynchSignal(fTable, ts)); -// } -// }); -// } -// } + @TmfSignalHandler + public void currentTimeUpdated(TmfTimeSynchSignal signal) { + if (signal.getSource() != fTable && fExperiment != null) { + final int index = (int) fExperiment.getIndex(signal.getCurrentTime()); + // Perform the updates on the UI thread + fTable.getDisplay().asyncExec(new Runnable() { + public void run() { + fTable.setSelection(index); + // The timestamp might not correspond to an actual event + // and the selection will point to the next experiment event. + // But we would like to display both the event before and + // after the selected timestamp. + // This works fine by default except when the selected event + // is the top displayed event. The following ensures that we + // always see both events. + if ((index > 0) && (index == fTable.getTopIndex())) { + fTable.setTopIndex(index - 1); + } + } + }); + } + } } \ No newline at end of file -- 2.34.1