Quick fix for synchronization of the Events View
authorFrancois Chouinard <fchouinard@gmail.com>
Thu, 8 Oct 2009 19:34:10 +0000 (19:34 +0000)
committerFrancois Chouinard <fchouinard@gmail.com>
Thu, 8 Oct 2009 19:34:10 +0000 (19:34 +0000)
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsView.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java

index 67233027f541a48e673a5f24b91a158a190d3068..41c21d57af2c43e026875b7605c9ea5ac37e0667 100644 (file)
@@ -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
index eee2c69dffc9b91791005051d8d1373cac040a8e..e7ff2f8153aa8d62f0c387026f9e27eb418d162a 100644 (file)
@@ -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 {
index eb60620e75d94892cf729a809095129d0cc9f6a2..6767043666613b745acf4f51cd95f6f705b915b9 100644 (file)
@@ -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
This page took 0.02808 seconds and 5 git commands to generate.