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;
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
public void widgetSelected(SelectionEvent e) {
TmfTimestamp ts = extractTimestamp(fTable.getSelection()[0].getText());
- broadcastSignal(new TmfTimeSynchSignal(this, ts));
+ 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() {
-// 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