tmf: Deprecate TimeGraphCombo and support columns in TimeGraphViewer
authorPatrick Tasse <patrick.tasse@gmail.com>
Mon, 24 Oct 2016 14:18:13 +0000 (10:18 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Fri, 13 Jan 2017 18:03:38 +0000 (13:03 -0500)
The class TimeGraphCombo is deprecated and AbstractTimeGraphView method
getTimeGraphCombo() is deprecated and returns null.

The TimeGraphViewer supports columns and label provider with new methods
setTimeGraphLabelProvider(), setColumns(String[]), setWeights(int[]) and
getTree(). The tree contains no tree items and is only used to show
column headers and allow for column handling.

If no column names are specified, a single nameless column is used.

If no label provider is specified, the time graph entry's name and the
time graph presentation provider's item image is shown in the first
column.

The TimeGraphViewer is made to extend the Viewer class.

The TimeGraphControl supports auto resize of columns to grow columns at
the item text's preferred width. Auto resize turns off automatically the
first time that a user resizes a column to be narrower than its
preferred width.

The tree expand and collapse controls are changed to be triangle widgets
that are bound in size by the item's height.

The name space split line is made easier to hover with the mouse.
Double-clicking it snaps the name space to the right of the last visible
column text's preferred width. The split line can now be dragged even if
the viewer has no input model.

The TimeGraphControl methods getTree(), getLabelProvider() and
getItemBounds(ITimeGraphEntry) are added to help with UI testing.

Change-Id: I1061371b083499298da4f7c5640929e63ed651db
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/84135
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
18 files changed:
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/controlflow/ControlFlowView.java
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewSortingTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/CriticalPathTest.java
lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/CallStackViewTest.java
tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotTimeGraph.java
tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotTimeGraphEntry.java
tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/TmfAlignTimeAxisTest.java
tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/test/stub/views/TsfTraceAnalysisView.java
tmf/org.eclipse.tracecompass.tmf.ui/.settings/.api_filters
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphCombo.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphViewer.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/ITimeGraphEntry.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java

index c135bef5fc3aca19d0355f855cb784c1e86e5884..1c75b8fd36bf6bebf75bdca2b93e60eaf0643764 100644 (file)
@@ -187,10 +187,10 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView {
     public void createPartControl(Composite parent) {
         super.createPartControl(parent);
         // add "Check active" Button to TimeGraphFilterDialog
-        super.getTimeGraphCombo().addTimeGraphFilterCheckActiveButton(
+        getTimeGraphViewer().getShowFilterDialogAction().getFilterDialog().addTimeGraphFilterCheckActiveButton(
                 new ControlFlowCheckActiveProvider(Messages.ControlFlowView_checkActiveLabel, Messages.ControlFlowView_checkActiveToolTip));
         // add "Uncheck inactive" Button to TimeGraphFilterDialog
-        super.getTimeGraphCombo().addTimeGraphFilterUncheckInactiveButton(
+        getTimeGraphViewer().getShowFilterDialogAction().getFilterDialog().addTimeGraphFilterUncheckInactiveButton(
                 new ControlFlowCheckActiveProvider(Messages.ControlFlowView_uncheckInactiveLabel, Messages.ControlFlowView_uncheckInactiveToolTip));
     }
 
@@ -225,15 +225,15 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView {
             section = settings.addNewSection(getClass().getName());
         }
 
-        IAction hideArrowsAction = getTimeGraphCombo().getTimeGraphViewer().getHideArrowsAction(section);
+        IAction hideArrowsAction = getTimeGraphViewer().getHideArrowsAction(section);
         manager.add(hideArrowsAction);
 
-        IAction followArrowBwdAction = getTimeGraphCombo().getTimeGraphViewer().getFollowArrowBwdAction();
+        IAction followArrowBwdAction = getTimeGraphViewer().getFollowArrowBwdAction();
         followArrowBwdAction.setText(Messages.ControlFlowView_followCPUBwdText);
         followArrowBwdAction.setToolTipText(Messages.ControlFlowView_followCPUBwdText);
         manager.add(followArrowBwdAction);
 
-        IAction followArrowFwdAction = getTimeGraphCombo().getTimeGraphViewer().getFollowArrowFwdAction();
+        IAction followArrowFwdAction = getTimeGraphViewer().getFollowArrowFwdAction();
         followArrowFwdAction.setText(Messages.ControlFlowView_followCPUFwdText);
         followArrowFwdAction.setToolTipText(Messages.ControlFlowView_followCPUFwdText);
         manager.add(followArrowFwdAction);
@@ -952,7 +952,7 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView {
                 if (element instanceof ControlFlowEntry) {
                     ControlFlowEntry entry = (ControlFlowEntry) element;
                     if (entry.getThreadId() == selected) {
-                        getTimeGraphCombo().setSelection(entry);
+                        getTimeGraphViewer().setSelection(entry, true);
                         break;
                     }
                 }
index 51491dfa9262ea9fec436a13a81f16ee9a211ec4..d1b3f17ae171f6cd3ef046155e7813ea59753715 100644 (file)
@@ -40,6 +40,8 @@ import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers.SWTBotTestCondition;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraphEntry;
 import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
 import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils;
@@ -144,13 +146,14 @@ public class ControlFlowViewSortingTest extends KernelTestBase {
         // Create a known state
         applyFilter();
         final SWTBotTree tree = fViewBot.bot().tree();
-        SWTBotTreeItem item = SWTBotUtils.getTreeItem(fBot, tree, TRACE_NAME, SYSTEMD_PROCESS_NAME);
-        item.select();
-
-        testProcessSorting(tree);
-        testTidSorting(tree);
-        testPidSorting(tree);
-        testBirthtimeSorting(tree);
+        final SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(fViewBot.bot());
+        final SWTBotTimeGraphEntry timeGraphEntry = timeGraph.getEntry(TRACE_NAME, SYSTEMD_PROCESS_NAME);
+        timeGraphEntry.select();
+
+        testProcessSorting(tree, timeGraph);
+        testTidSorting(tree, timeGraph);
+        testPidSorting(tree, timeGraph);
+        testBirthtimeSorting(tree, timeGraph);
     }
 
     // ------------------------------------------------------------------------
@@ -186,28 +189,28 @@ public class ControlFlowViewSortingTest extends KernelTestBase {
         UIThreadRunnable.syncExec(treeCheckCounter);
     }
 
-    private static void testProcessSorting(final SWTBotTree tree) {
+    private static void testProcessSorting(final SWTBotTree tree, final SWTBotTimeGraph timeGraph) {
         SWTBotTreeColumn column = tree.header(PROCESS_COLUMN);
         String[] expected = { KTHREAD_PROCESS_NAME, LTTNG_CONSUMER_PROCESS_NAME, SYSTEMD_PROCESS_NAME };
 
         /* Sort direction Up */
-        SWTBotTestCondition condition = getSortCondition(PROCESS_COLUMN, PROCESS_COLUMN_ID, expected, tree, false);
+        SWTBotTestCondition condition = getSortCondition(PROCESS_COLUMN, PROCESS_COLUMN_ID, expected, timeGraph, false);
         clickColumn(tree, column, condition);
 
         /* Sort direction Down */
-        condition = getSortCondition(PROCESS_COLUMN, 0, expected, tree, true);
+        condition = getSortCondition(PROCESS_COLUMN, 0, expected, timeGraph, true);
         clickColumn(tree, column, condition);
     }
 
-    private static void testTidSorting(final SWTBotTree tree) {
+    private static void testTidSorting(final SWTBotTree tree, final SWTBotTimeGraph timeGraph) {
         String[] expected = { SYSTEMD_TID, KTHREAD_TID, LTTNG_CONSUMER_TID };
         SWTBotTreeColumn column = tree.header(TID_COLUMN);
         /* Sort direction Up */
-        SWTBotTestCondition condition = getSortCondition(TID_COLUMN, TID_COLUMN_ID, expected, tree, false);
+        SWTBotTestCondition condition = getSortCondition(TID_COLUMN, TID_COLUMN_ID, expected, timeGraph, false);
         clickColumn(tree, column, condition);
 
         /* Sort direction Down */
-        condition = getSortCondition(TID_COLUMN, TID_COLUMN_ID, expected, tree, true);
+        condition = getSortCondition(TID_COLUMN, TID_COLUMN_ID, expected, timeGraph, true);
         clickColumn(tree, column, condition);
     }
 
@@ -216,20 +219,20 @@ public class ControlFlowViewSortingTest extends KernelTestBase {
      * lttng-consumerd has PTID -1 that is unknown. Currently
      * in CFV PTID is only shown when it's greater than 0.
      */
-    private static void testPidSorting(final SWTBotTree tree) {
+    private static void testPidSorting(final SWTBotTree tree, final SWTBotTimeGraph timeGraph) {
         SWTBotTreeColumn column = tree.header(PTID_COLUMN);
         String[] expected = { LTTNG_CONSUMER_PROCESS_NAME, SYSTEMD_PROCESS_NAME, KTHREAD_PROCESS_NAME };
         /* Sort direction Up */
-        SWTBotTestCondition condition = getSortCondition(PTID_COLUMN, PROCESS_COLUMN_ID, expected, tree, false);
+        SWTBotTestCondition condition = getSortCondition(PTID_COLUMN, PROCESS_COLUMN_ID, expected, timeGraph, false);
         clickColumn(tree, column, condition);
 
         /* Sort direction Down */
         String[] expected2 = { SYSTEMD_PROCESS_NAME, KTHREAD_PROCESS_NAME, LTTNG_CONSUMER_PROCESS_NAME };
-        condition = getSortCondition(PTID_COLUMN, PROCESS_COLUMN_ID, expected2, tree, false);
+        condition = getSortCondition(PTID_COLUMN, PROCESS_COLUMN_ID, expected2, timeGraph, false);
         clickColumn(tree, column, condition);
     }
 
-    private static void testBirthtimeSorting(final SWTBotTree tree) {
+    private static void testBirthtimeSorting(final SWTBotTree tree, final SWTBotTimeGraph timeGraph) {
         SWTBotTreeColumn column = tree.header(BIRTH_COLUMN);
         String[] expected = {
                 Utils.formatTime(LTTNG_CONSUMER_BIRTHTIME, TimeFormat.CALENDAR, Resolution.NANOSEC),
@@ -237,11 +240,11 @@ public class ControlFlowViewSortingTest extends KernelTestBase {
                 Utils.formatTime(KTHREAD_BIRTHTIME, TimeFormat.CALENDAR, Resolution.NANOSEC) };
 
         /* Sort direction Up */
-        SWTBotTestCondition condition = getSortCondition(BIRTH_COLUMN, BIRTH_COLUMN_ID, expected, tree, false);
+        SWTBotTestCondition condition = getSortCondition(BIRTH_COLUMN, BIRTH_COLUMN_ID, expected, timeGraph, false);
         clickColumn(tree, column, condition);
 
         /* Sort direction Down */
-        condition = getSortCondition(BIRTH_COLUMN, BIRTH_COLUMN_ID, expected, tree, true);
+        condition = getSortCondition(BIRTH_COLUMN, BIRTH_COLUMN_ID, expected, timeGraph, true);
         clickColumn(tree, column, condition);
     }
 
@@ -250,20 +253,20 @@ public class ControlFlowViewSortingTest extends KernelTestBase {
         fBot.waitUntil(condition);
     }
 
-    private static SWTBotTestCondition getSortCondition(final String testCase, final int cell, final String[] expected, final SWTBotTree tree, final boolean reverse) {
+    private static SWTBotTestCondition getSortCondition(final String testCase, final int column, final String[] expected, final SWTBotTimeGraph timeGraph, final boolean reverse) {
         return new SWTBotTestCondition() {
             @Override
             public boolean test() throws Exception {
-                SWTBotTreeItem[] items = tree.getTreeItem(TRACE_NAME).getItems();
+                SWTBotTimeGraphEntry[] entries = timeGraph.getEntry(TRACE_NAME).getEntries();
                 if (reverse) {
                     for (int i = expected.length - 1; i > 0; i--) {
-                        if (!expected[i].equals(items[expected.length - (i + 1)].cell(cell))) {
+                        if (!expected[i].equals(entries[expected.length - (i + 1)].getText(column))) {
                             return false;
                         }
                     }
                 } else {
                     for (int i = 0; i < expected.length; i++) {
-                        if (!expected[i].equals(items[i].cell(cell))) {
+                        if (!expected[i].equals(entries[i].getText(column))) {
                             return false;
                         }
                     }
index 14602cbfbac9a0fedadc3f352cbbf765ad8e8e76..0eaadf6920f90207d824292ea5d4dfbbcbf5f941 100644 (file)
@@ -333,7 +333,6 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
         timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
 
         SWTBotView viewBot = getViewBot();
-        final SWTBotTree tree = viewBot.bot().tree();
 
         /* set focus on time graph */
         SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(viewBot.bot());
@@ -352,7 +351,7 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
         viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
         timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID2_TIME2)));
-        fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2"));
+        fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME2));
 
         /* shift-click "Follow CPU Forward" 3 times */
@@ -363,7 +362,7 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
         viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
         timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4));
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID5_TIME1)));
-        fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "5"));
+        fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "5"));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID5_TIME1));
 
         /* shift-click "Follow CPU Backward" 4 times */
@@ -376,7 +375,7 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
         viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
         timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME1));
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID2_TIME1)));
-        fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2"));
+        fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME1));
 
         /* click "Follow CPU Forward" 2 times */
@@ -385,7 +384,7 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
         viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
         timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3));
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID2_TIME3)));
-        fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2"));
+        fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME3));
 
         /* shift-click "Follow CPU Backward" 3 times */
@@ -396,7 +395,7 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
         viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
         timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID1_TIME1));
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID1_TIME1)));
-        fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "1"));
+        fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "1"));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME1));
 
         /* shift-click "Follow CPU Forward" 4 times */
@@ -409,7 +408,7 @@ public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
         viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
         timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME4));
         fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID2_TIME4)));
-        fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2"));
+        fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
         assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME4));
 
         /* click "Follow CPU Backward" 5 times */
index 0d2848a44518dd895432dc1b8610a5df09f98c55..2f7ac98e3b8283b0ab9591b1cd91ee969bcaa8f5 100644 (file)
@@ -76,10 +76,10 @@ public class CriticalPathTest extends KernelTestBase {
      */
     @Test
     public void testFull() {
-        SWTBotTree treeCfv = fViewBotCfv.bot().tree();
+        SWTBotTimeGraph timeGraphCfv = new SWTBotTimeGraph(fViewBotCfv.bot());
         SWTBotTree treeCp = fViewBotCp.bot().tree();
         SWTBotTimeGraph timeGraphCp = new SWTBotTimeGraph(fViewBotCp.bot());
-        assertNotNull(treeCfv.widget);
+        assertNotNull(timeGraphCfv.widget);
         assertNotNull(treeCp.widget);
         SWTBotTreeItem[] allItems = treeCp.getAllItems();
         for (int i = 0; i < allItems.length; i++) {
@@ -88,7 +88,7 @@ public class CriticalPathTest extends KernelTestBase {
 
         ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
         assertNotNull(trace);
-        SWTBotTreeItem entry = treeCfv.expandNode(trace.getName(), "systemd", "we", PROCESS);
+        SWTBotTimeGraphEntry entry = timeGraphCfv.getEntry(trace.getName(), "systemd", "we", PROCESS);
         assertNotNull(entry);
         entry.select();
 
index 3d9be8e5e3110438cf92a345d91b4d11907a4e28..da71d384cd6d4c17b2e01e6ee977e528ac87bf2f 100644 (file)
@@ -38,7 +38,6 @@ import org.eclipse.swtbot.swt.finder.waits.Conditions;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
@@ -279,10 +278,10 @@ public class CallStackViewTest {
     }
 
     private static List<String> getVisibleStackFrames(final SWTBotView viewBot) {
-        SWTBotTree tree = viewBot.bot().tree();
+        SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(viewBot.bot());
         List<String> stackFrames = new ArrayList<>();
-        for (SWTBotTreeItem treeItem : tree.expandNode(TRACE, PROCESS, THREAD).getItems()) {
-            String name = treeItem.cell(0);
+        for (SWTBotTimeGraphEntry entry : timeGraph.getEntry(TRACE, PROCESS, THREAD).getEntries()) {
+            String name = entry.getText();
             if (!name.isEmpty()) {
                 stackFrames.add(name);
             }
@@ -332,7 +331,7 @@ public class CallStackViewTest {
         SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(viewBot.bot());
         SWTBotTimeGraphEntry[] threads = timeGraph.getEntry(TRACE, PROCESS).getEntries();
         assertEquals(1, threads.length);
-        assertEquals(THREAD, threads[0].getText());
+        assertEquals(THREAD, threads[0].getText(0));
         assertEquals(Arrays.asList("main", "event_loop", "handle_event"), getVisibleStackFrames(viewBot));
     }
 
index 83e9ea7d4d574852444dc030ba756f770ac3989a..ddb2441c6dbf1320ea2ab1b748a07552b46600be 100644 (file)
@@ -18,6 +18,7 @@ import java.util.List;
 import java.util.Objects;
 
 import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Rectangle;
@@ -92,11 +93,12 @@ public class SWTBotTimeGraph extends AbstractSWTBotControl<TimeGraphControl> {
      */
     public SWTBotTimeGraphEntry getEntry(String... names) throws WidgetNotFoundException {
         List<ITimeGraphEntry> entries = Arrays.asList(widget.getExpandedElements());
+        ITableLabelProvider labelProvider = widget.getLabelProvider();
         ITimeGraphEntry parent = null;
         for (String name : names) {
             boolean found = false;
             for (ITimeGraphEntry entry : entries) {
-                String label = entry.getName();
+                String label = labelProvider == null ? entry.getName() : labelProvider.getColumnText(entry, 0);
                 if (Objects.equals(entry.getParent(), parent) && name.equals(label)) {
                     parent = entry;
                     found = true;
@@ -126,7 +128,9 @@ public class SWTBotTimeGraph extends AbstractSWTBotControl<TimeGraphControl> {
                     if (element instanceof ITimeGraphEntry) {
                         TableRow tableRow = new TableRow();
                         SWTBotTimeGraphEntry entry = new SWTBotTimeGraphEntry(widget, (ITimeGraphEntry) element);
-                        tableRow.add(entry.getText());
+                        for (int i = 0; i < widget.getTree().getColumnCount(); i++) {
+                            tableRow.add(entry.getText(i));
+                        }
                         collection.add(tableRow);
                     }
                 }
index c49a03d38894d006a54f0b7a91addc34f0fd5e4a..5a1d5319ccb6d5fca52b06778cb18275667a8845 100644 (file)
@@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Control;
@@ -110,9 +111,10 @@ public class SWTBotTimeGraphEntry extends AbstractSWTBotControl<TimeGraphControl
         return syncExec(new Result<SWTBotTimeGraphEntry>() {
             @Override
             public SWTBotTimeGraphEntry run() {
+                ITableLabelProvider labelProvider = widget.getLabelProvider();
                 for (ITimeGraphEntry entry : widget.getExpandedElements()) {
                     if (fEntry.equals(entry.getParent())) {
-                        String label = entry.getName();
+                        String label = labelProvider == null ? entry.getName() : labelProvider.getColumnText(entry, 0);
                         if (name.equals(label)) {
                             return new SWTBotTimeGraphEntry(widget, entry);
                         }
@@ -130,7 +132,19 @@ public class SWTBotTimeGraphEntry extends AbstractSWTBotControl<TimeGraphControl
      */
     @Override
     public String getText() {
-        return fEntry.getName();
+        return getText(0);
+    }
+
+    /**
+     * Get the text of this entry for the given column index
+     *
+     * @param column
+     *            the column index
+     * @return the column text
+     */
+    public String getText(int column) {
+        ITableLabelProvider labelProvider = widget.getLabelProvider();
+        return labelProvider != null ? labelProvider.getColumnText(fEntry, column) : column == 0 ? fEntry.getName() : "";
     }
 
     /**
index 1a562271c6414d30c7921813818443dfa3fd686d..549cdfccffa500aa0afac081cae85cf972b3458f 100644 (file)
@@ -235,8 +235,8 @@ public class TmfAlignTimeAxisTest {
         SWTBotView viewBot = fBot.viewById(viewId);
         switch (viewId) {
         case HistogramView.ID:
-        case CallStackView.ID:
             return new SWTBotSash(viewBot.bot().widget(WidgetOfType.widgetOfType(Sash.class)));
+        case CallStackView.ID:
         case TimeChartView.ID:
             return new SWTBotTimeGraph(viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class)));
         default:
index d80d84077a1c20a600bc0eacf66e2213a449bac6..b9b7c95321bcd987b8a36ff12bbead20f6dea900 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2015 Ericsson
+ * Copyright (c) 2009, 2016 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -576,7 +576,7 @@ public class TsfTraceAnalysisView extends ViewPart implements
                             + "\nClass Name: "
                             + selTrace.getClassName());
 
-            synchViewer.setSelection(selTrace);
+            synchViewer.setSelection(selTrace, true);
         } else {
             System.out
                     .println("TsfTmIncubatorListener.tsfTmProcessEvent() Unexpected event source received: "
index accb5887aabb99149fe82407273acf5fc74c1710..a005a55b24187af0bbd0315418381adbee610b62 100644 (file)
             </message_arguments>
         </filter>
     </resource>
+    <resource path="src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/ITimeGraphEntry.java" type="org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry">
+        <filter comment="API preference INTERFACE_ELEMENT_TYPE_ADDED_DEFAULT_METHOD=Ignore is not properly supported (Bug 507246)" id="403984517">
+            <message_arguments>
+                <message_argument value="org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry"/>
+                <message_argument value="org.eclipse.jface.viewers.ISelection"/>
+                <message_argument value="isEmpty()"/>
+            </message_arguments>
+        </filter>
+    </resource>
 </component>
index b08c2c385ddb2d4b8921cdd25c286434575cca54..33863d26f3523b48fd0c120966152ccb3449f085 100644 (file)
@@ -37,8 +37,6 @@ import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.SWT;
@@ -382,10 +380,10 @@ public class CallStackView extends AbstractTimeGraphView {
             }
         });
 
-        getTimeGraphCombo().getTreeViewer().addDoubleClickListener(new IDoubleClickListener() {
+        getTimeGraphViewer().getTimeGraphControl().addMouseListener(new MouseAdapter() {
             @Override
-            public void doubleClick(DoubleClickEvent event) {
-                Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
+            public void mouseDoubleClick(MouseEvent event) {
+                Object selection = getTimeGraphViewer().getSelection();
                 if (selection instanceof CallStackEntry) {
                     CallStackEntry entry = (CallStackEntry) selection;
                     if (entry.getFunctionName().length() > 0) {
@@ -455,7 +453,7 @@ public class CallStackView extends AbstractTimeGraphView {
         Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
-                if (getTimeGraphCombo().isDisposed()) {
+                if (getTimeGraphViewer().getControl().isDisposed()) {
                     return;
                 }
                 if (beginTime == endTime) {
@@ -850,7 +848,7 @@ public class CallStackView extends AbstractTimeGraphView {
                                 if (stackLevelState.unboxInt() == callStackEntry.getStackLevel() || stackLevelState.isNull()) {
                                     fSyncSelection = false;
                                     Display.getDefault().asyncExec(() -> {
-                                        getTimeGraphCombo().setSelection(callStackEntry);
+                                        getTimeGraphViewer().setSelection(callStackEntry, true);
                                         getTimeGraphViewer().getTimeGraphControl().fireSelectionChanged();
                                     });
                                 }
@@ -875,7 +873,7 @@ public class CallStackView extends AbstractTimeGraphView {
         };
         traceEntries.forEach(consumer);
         if (Display.getCurrent() != null) {
-            getTimeGraphCombo().refresh();
+            getTimeGraphViewer().refresh();
         }
     }
 
@@ -953,7 +951,7 @@ public class CallStackView extends AbstractTimeGraphView {
         manager.add(getSortByIdAction());
         manager.add(getSortByTimeAction());
         manager.add(new Separator());
-        manager.add(getTimeGraphCombo().getShowFilterDialogAction());
+        manager.add(getTimeGraphViewer().getShowFilterDialogAction());
         manager.add(new Separator());
         manager.add(getTimeGraphViewer().getResetScaleAction());
         manager.add(getPreviousEventAction());
@@ -1005,7 +1003,7 @@ public class CallStackView extends AbstractTimeGraphView {
                             stackInterval = ss.querySingleState(Math.min(ss.getCurrentEndTime(), newTime), quark);
                             int stackLevel = stackInterval.getStateValue().unboxInt();
                             ITimeGraphEntry selectedEntry = parentEntry.getChildren().get(Math.max(0, stackLevel - 1));
-                            getTimeGraphCombo().setSelection(selectedEntry);
+                            viewer.setSelection(selectedEntry, true);
                             viewer.getTimeGraphControl().fireSelectionChanged();
                             startZoomThread(viewer.getTime0(), viewer.getTime1());
 
@@ -1034,7 +1032,7 @@ public class CallStackView extends AbstractTimeGraphView {
             fPrevEventAction = new Action() {
                 @Override
                 public void run() {
-                    TimeGraphViewer viewer = getTimeGraphCombo().getTimeGraphViewer();
+                    TimeGraphViewer viewer = getTimeGraphViewer();
                     ITimeGraphEntry entry = viewer.getSelection();
                     if (entry instanceof CallStackEntry) {
                         try {
@@ -1050,7 +1048,7 @@ public class CallStackView extends AbstractTimeGraphView {
                             viewer.setSelectedTimeNotify(stackInterval.getStartTime(), true);
                             int stackLevel = stackInterval.getStateValue().unboxInt();
                             ITimeGraphEntry selectedEntry = parentEntry.getChildren().get(Math.max(0, stackLevel - 1));
-                            getTimeGraphCombo().setSelection(selectedEntry);
+                            viewer.setSelection(selectedEntry, true);
                             viewer.getTimeGraphControl().fireSelectionChanged();
                             startZoomThread(viewer.getTime0(), viewer.getTime1());
 
index 28a198ed714d7b8a1f129b92c51b882066cd7220..2267f14681a3838dac062aa99999ee27ea941edf 100644 (file)
@@ -673,7 +673,7 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
             ITmfTrace trace = signal.getTrace();
             for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {
                 if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {
-                    fViewer.setSelection(fTimeAnalysisEntries.get(i));
+                    fViewer.setSelection(fTimeAnalysisEntries.get(i), true);
                     break;
                 }
             }
index 1a2cc5df578d2640678f41efece55179964221d8..61928f897962202f6448cf57d0ff89c0c025ac6f 100644 (file)
@@ -50,7 +50,6 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IStatusLineManager;
@@ -61,11 +60,8 @@ import org.eclipse.jface.commands.ActionHandler;
 import org.eclipse.jface.viewers.AbstractTreeViewer;
 import org.eclipse.jface.viewers.ILabelProvider;
 import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
@@ -109,7 +105,6 @@ import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphBookmarkListe
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphContentProvider;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider2;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;
-import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphSelectionListener;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphTimeListener;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphBookmarkEvent;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphCombo;
@@ -139,8 +134,7 @@ import org.eclipse.ui.handlers.IHandlerService;
 /**
  * An abstract view all time graph views can inherit
  *
- * This view contains either a time graph viewer, or a time graph combo which is
- * divided between a tree viewer on the left and a time graph viewer on the right.
+ * This view contains a time graph viewer.
  */
 public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeAligned, IResourceChangeListener {
 
@@ -164,8 +158,8 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
     // Fields
     // ------------------------------------------------------------------------
 
-    /** The timegraph wrapper */
-    private ITimeGraphWrapper fTimeGraphWrapper;
+    /** The time graph viewer */
+    private TimeGraphViewer fTimeGraphViewer;
 
     private AtomicInteger fDirty = new AtomicInteger();
 
@@ -225,26 +219,23 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
     /** The presentation provider for this view */
     private final TimeGraphPresentationProvider fPresentation;
 
-    /** The tree column label array, or null if combo is not used */
+    /** The tree column label array, or null for a single default column */
     private String[] fColumns;
 
     private Comparator<ITimeGraphEntry>[] fColumnComparators;
 
-    /** The tree label provider, or null if combo is not used */
-    private TreeLabelProvider fLabelProvider = null;
+    /** The time graph label provider */
+    private ITableLabelProvider fLabelProvider = new TreeLabelProvider();
 
     /** The time graph content provider */
     private @NonNull ITimeGraphContentProvider fTimeGraphContentProvider = new TimeGraphContentProvider();
 
-    /** The relative weight of the sash, ignored if combo is not used */
+    /** The relative weight of the time graph viewer parts */
     private int[] fWeight = { 1, 3 };
 
     /** The filter column label array, or null if filter is not used */
     private String[] fFilterColumns;
 
-    /** The pack done flag */
-    private boolean fPackDone = false;
-
     /** The filter content provider, or null if filter is not used */
     private ITreeContentProvider fFilterContentProvider;
 
@@ -267,8 +258,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
 
     /**
      * Menu Manager for context-sensitive menu for time graph entries.
-     * This will be used on the tree viewer in case of the time graph combo
-     * or the on the namespace in case of a single time graph viewer.
+     * This will be used on the name space of the time graph viewer.
      */
     private final @NonNull MenuManager fEntryMenuManager = new MenuManager();
 
@@ -291,358 +281,6 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
     // Classes
     // ------------------------------------------------------------------------
 
-    private interface ITimeGraphWrapper {
-
-        void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider);
-
-        void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider);
-
-        TimeGraphViewer getTimeGraphViewer();
-
-        void addSelectionListener(ITimeGraphSelectionListener listener);
-
-        ISelectionProvider getSelectionProvider();
-
-        void setFocus();
-
-        boolean isDisposed();
-
-        void refresh();
-
-        void setInput(Object input);
-
-        Object getInput();
-
-        void setFilters(@NonNull ViewerFilter[] filters);
-
-        @NonNull ViewerFilter[] getFilters();
-
-        void redraw();
-
-        void update();
-
-        void setAutoExpandLevel(int level);
-
-        boolean getExpandedState(ITimeGraphEntry entry);
-
-        void setExpandedState(ITimeGraphEntry entry, boolean expanded);
-
-        void setFilterColumns(String[] columnNames);
-
-        void setFilterContentProvider(ITreeContentProvider contentProvider);
-
-        void setFilterLabelProvider(ITableLabelProvider labelProvider);
-
-        IAction getShowFilterDialogAction();
-
-        void performAlign(int offset, int width);
-
-        TmfTimeViewAlignmentInfo getTimeViewAlignmentInfo();
-
-        int getAvailableWidth(int requestedOffset);
-
-        ITimeGraphEntry getSelection();
-
-        void setSelection(ITimeGraphEntry selection);
-
-        void selectAndReveal(@NonNull ITimeGraphEntry selection);
-
-    }
-
-    private class TimeGraphViewerWrapper implements ITimeGraphWrapper {
-        private TimeGraphViewer viewer;
-
-        private TimeGraphViewerWrapper(Composite parent, int style) {
-            viewer = new TimeGraphViewer(parent, style);
-        }
-
-        @Override
-        public void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider) {
-            viewer.setTimeGraphContentProvider(timeGraphContentProvider);
-        }
-
-        @Override
-        public void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider) {
-            viewer.setTimeGraphProvider(timeGraphPresentationProvider);
-        }
-
-        @Override
-        public TimeGraphViewer getTimeGraphViewer() {
-            return viewer;
-        }
-
-        @Override
-        public void addSelectionListener(ITimeGraphSelectionListener listener) {
-            viewer.addSelectionListener(listener);
-        }
-
-        @Override
-        public ISelectionProvider getSelectionProvider() {
-            return viewer.getSelectionProvider();
-        }
-
-        @Override
-        public void setFocus() {
-            viewer.setFocus();
-        }
-
-        @Override
-        public boolean isDisposed() {
-            return viewer.getControl().isDisposed();
-        }
-
-        @Override
-        public void setInput(Object input) {
-            viewer.setInput(input);
-        }
-
-        @Override
-        public Object getInput() {
-            return viewer.getInput();
-        }
-
-        @Override
-        public void setFilterColumns(String[] columnNames) {
-            viewer.setFilterColumns(columnNames);
-        }
-
-        @Override
-        public void setFilterContentProvider(ITreeContentProvider contentProvider) {
-            viewer.setFilterContentProvider(contentProvider);
-        }
-
-        @Override
-        public void setFilterLabelProvider(ITableLabelProvider labelProvider) {
-            viewer.setFilterLabelProvider(labelProvider);
-        }
-
-        @Override
-        public void setFilters(@NonNull ViewerFilter[] filters) {
-            viewer.setFilters(filters);
-        }
-
-        @Override
-        public @NonNull ViewerFilter[] getFilters() {
-            return viewer.getFilters();
-        }
-
-        @Override
-        public IAction getShowFilterDialogAction() {
-            return viewer.getShowFilterDialogAction();
-        }
-
-        @Override
-        public void refresh() {
-            viewer.refresh();
-        }
-
-        @Override
-        public void redraw() {
-            viewer.getControl().redraw();
-        }
-
-        @Override
-        public void update() {
-            viewer.getControl().update();
-        }
-
-        @Override
-        public void setAutoExpandLevel(int level) {
-            viewer.setAutoExpandLevel(level);
-        }
-
-        @Override
-        public boolean getExpandedState(ITimeGraphEntry entry) {
-            return viewer.getExpandedState(entry);
-        }
-
-        @Override
-        public void setExpandedState(ITimeGraphEntry entry, boolean expanded) {
-            viewer.setExpandedState(entry, expanded);
-        }
-
-        @Override
-        public void performAlign(int offset, int width) {
-            viewer.performAlign(offset, width);
-        }
-
-        @Override
-        public TmfTimeViewAlignmentInfo getTimeViewAlignmentInfo() {
-            return viewer.getTimeViewAlignmentInfo();
-        }
-
-        @Override
-        public int getAvailableWidth(int requestedOffset) {
-            return viewer.getAvailableWidth(requestedOffset);
-        }
-
-        @Override
-        public ITimeGraphEntry getSelection() {
-            return viewer.getSelection();
-        }
-
-        @Override
-        public void setSelection(ITimeGraphEntry selection) {
-            viewer.setSelection(selection);
-        }
-
-        @Override
-        public void selectAndReveal(@NonNull ITimeGraphEntry selection) {
-            viewer.selectAndReveal(selection);
-        }
-    }
-
-    private class TimeGraphComboWrapper implements ITimeGraphWrapper {
-        private TimeGraphCombo combo;
-
-        private TimeGraphComboWrapper(Composite parent, int style) {
-            combo = new TimeGraphCombo(parent, style, fWeight);
-        }
-
-        @Override
-        public void setTimeGraphContentProvider(ITimeGraphContentProvider timeGraphContentProvider) {
-            combo.setTimeGraphContentProvider(timeGraphContentProvider);
-        }
-
-        @Override
-        public void setTimeGraphPresentationProvider(TimeGraphPresentationProvider timeGraphPresentationProvider) {
-            combo.setTimeGraphProvider(timeGraphPresentationProvider);
-        }
-
-        @Override
-        public TimeGraphViewer getTimeGraphViewer() {
-            return combo.getTimeGraphViewer();
-        }
-
-        @Override
-        public void addSelectionListener(ITimeGraphSelectionListener listener) {
-            combo.addSelectionListener(listener);
-        }
-
-        @Override
-        public ISelectionProvider getSelectionProvider() {
-            return combo.getTreeViewer();
-        }
-
-        @Override
-        public void setFocus() {
-            combo.setFocus();
-        }
-
-        @Override
-        public boolean isDisposed() {
-            return combo.isDisposed();
-        }
-
-        @Override
-        public void setInput(Object input) {
-            combo.setInput(input);
-        }
-
-        @Override
-        public Object getInput() {
-            return combo.getInput();
-        }
-
-        @Override
-        public void setFilterColumns(String[] columnNames) {
-            combo.setFilterColumns(columnNames);
-        }
-
-        @Override
-        public void setFilterContentProvider(ITreeContentProvider contentProvider) {
-            combo.setFilterContentProvider(contentProvider);
-        }
-
-        @Override
-        public void setFilterLabelProvider(ITableLabelProvider labelProvider) {
-            combo.setFilterLabelProvider(labelProvider);
-        }
-
-        @Override
-        public void setFilters(@NonNull ViewerFilter[] filters) {
-            combo.setFilters(filters);
-        }
-
-        @Override
-        public @NonNull ViewerFilter[] getFilters() {
-            return combo.getFilters();
-        }
-
-        @Override
-        public IAction getShowFilterDialogAction() {
-            return combo.getShowFilterDialogAction();
-        }
-
-        @Override
-        public void refresh() {
-            combo.refresh();
-        }
-
-        @Override
-        public void redraw() {
-            combo.redraw();
-        }
-
-        @Override
-        public void update() {
-            combo.update();
-        }
-
-        @Override
-        public void setAutoExpandLevel(int level) {
-            combo.setAutoExpandLevel(level);
-        }
-
-        @Override
-        public boolean getExpandedState(ITimeGraphEntry entry) {
-            return combo.getExpandedState(entry);
-        }
-
-        @Override
-        public void setExpandedState(ITimeGraphEntry entry, boolean expanded) {
-            combo.setExpandedState(entry, expanded);
-        }
-
-        TimeGraphCombo getTimeGraphCombo() {
-            return combo;
-        }
-
-        TreeViewer getTreeViewer() {
-            return combo.getTreeViewer();
-        }
-
-        @Override
-        public void performAlign(int offset, int width) {
-            combo.performAlign(offset, width);
-        }
-
-        @Override
-        public TmfTimeViewAlignmentInfo getTimeViewAlignmentInfo() {
-            return combo.getTimeViewAlignmentInfo();
-        }
-
-        @Override
-        public int getAvailableWidth(int requestedOffset) {
-            return combo.getAvailableWidth(requestedOffset);
-        }
-
-        @Override
-        public ITimeGraphEntry getSelection() {
-            return combo.getTimeGraphViewer().getSelection();
-        }
-
-        @Override
-        public void setSelection(ITimeGraphEntry selection) {
-            combo.setSelection(selection);
-        }
-
-        @Override
-        public void selectAndReveal(@NonNull ITimeGraphEntry selection) {
-            combo.selectAndReveal(selection);
-        }
-    }
-
     /**
      * Base class to provide the labels for the tree viewer. Views extending
      * this class typically need to override the getColumnText method if they
@@ -847,10 +485,10 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
             markers.addAll(getTraceMarkerList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor()));
             applyResults(() -> {
                 if (events != null) {
-                    fTimeGraphWrapper.getTimeGraphViewer().setLinks(events);
+                    fTimeGraphViewer.setLinks(events);
                 }
-                fTimeGraphWrapper.getTimeGraphViewer().setMarkerCategories(getMarkerCategories());
-                fTimeGraphWrapper.getTimeGraphViewer().setMarkers(markers);
+                fTimeGraphViewer.setMarkerCategories(getMarkerCategories());
+                fTimeGraphViewer.setMarkers(markers);
                 redraw();
             });
         }
@@ -884,11 +522,12 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
     // ------------------------------------------------------------------------
 
     /**
-     * Constructs a time graph view that contains either a time graph viewer or
-     * a time graph combo.
+     * Constructs a time graph view that contains a time graph viewer.
      *
-     * By default, the view uses a time graph viewer. To use a time graph combo,
-     * the subclass constructor must call {@link #setTreeColumns(String[])} and
+     * By default, the view uses a single default column in the name space that
+     * shows the time graph entry name. To use multiple columns and/or
+     * customized label texts, the subclass constructor must call
+     * {@link #setTreeColumns(String[])} and/or
      * {@link #setTreeLabelProvider(TreeLabelProvider)}.
      *
      * @param id
@@ -908,14 +547,13 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
     // ------------------------------------------------------------------------
 
     /**
-     * Getter for the time graph combo
+     * Getter for the time graph combo. No longer used.
      *
-     * @return The time graph combo, or null if combo is not used
+     * @return null
+     * @deprecated Use {@link #getTimeGraphViewer()} instead.
      */
+    @Deprecated
     protected TimeGraphCombo getTimeGraphCombo() {
-        if (fTimeGraphWrapper instanceof TimeGraphComboWrapper) {
-            return ((TimeGraphComboWrapper) fTimeGraphWrapper).getTimeGraphCombo();
-        }
         return null;
     }
 
@@ -925,7 +563,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      * @return The time graph viewer
      */
     protected TimeGraphViewer getTimeGraphViewer() {
-        return fTimeGraphWrapper.getTimeGraphViewer();
+        return fTimeGraphViewer;
     }
 
     /**
@@ -998,16 +636,18 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
     }
 
     /**
-     * Sets the relative weight of each part of the time graph combo.
-     * <p>
-     * This should be called from the constructor.
+     * Sets the relative weight of each part of the time graph viewer. The first
+     * number is the name space width, and the second number is the time space
+     * width.
      *
      * @param weights
-     *            The array (length 2) of relative weights of each part of the combo
+     *            The array of relative weights of each part of the viewer
      */
     protected void setWeight(final int[] weights) {
-        checkPartNotCreated();
         fWeight = weights;
+        if (fTimeGraphViewer != null) {
+            fTimeGraphViewer.setWeights(weights);
+        }
     }
 
     /**
@@ -1150,9 +790,8 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      */
     protected void setAutoExpandLevel(int level) {
         fAutoExpandLevel = level;
-        ITimeGraphWrapper tgWrapper = fTimeGraphWrapper;
-        if (tgWrapper != null) {
-            tgWrapper.setAutoExpandLevel(level);
+        if (fTimeGraphViewer != null) {
+            fTimeGraphViewer.setAutoExpandLevel(level);
         }
     }
 
@@ -1287,30 +926,27 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
     @Override
     public void createPartControl(Composite parent) {
         super.createPartControl(parent);
-        if (fColumns == null || fLabelProvider == null) {
-            fTimeGraphWrapper = new TimeGraphViewerWrapper(parent, SWT.NONE);
-        } else {
-            TimeGraphComboWrapper wrapper = new TimeGraphComboWrapper(parent, SWT.NONE);
-            fTimeGraphWrapper = wrapper;
-            TimeGraphCombo combo = wrapper.getTimeGraphCombo();
-            combo.setTreeContentProvider(fTimeGraphContentProvider);
-            combo.setTreeLabelProvider(fLabelProvider);
-            combo.setTreeColumns(fColumns);
+        fTimeGraphViewer = new TimeGraphViewer(parent, SWT.NONE);
+        if (fLabelProvider != null) {
+            fTimeGraphViewer.setTimeGraphLabelProvider(fLabelProvider);
+        }
+        if (fColumns != null) {
+            fTimeGraphViewer.setColumns(fColumns);
             if (fColumnComparators != null) {
-                createColumnSelectionListener(combo.getTreeViewer());
+                createColumnSelectionListener(fTimeGraphViewer.getTree());
             }
-            // Add double click listener to tree viewer
-            createDoubleClickListener(combo.getTreeViewer());
         }
-        fTimeGraphWrapper.setTimeGraphContentProvider(fTimeGraphContentProvider);
-        fTimeGraphWrapper.setFilterContentProvider(fFilterContentProvider != null ? fFilterContentProvider : fTimeGraphContentProvider);
-        fTimeGraphWrapper.setFilterLabelProvider(fFilterLabelProvider);
-        fTimeGraphWrapper.setFilterColumns(fFilterColumns);
+        fTimeGraphViewer.setTimeGraphContentProvider(fTimeGraphContentProvider);
+        fTimeGraphViewer.setFilterContentProvider(fFilterContentProvider != null ? fFilterContentProvider : fTimeGraphContentProvider);
+        fTimeGraphViewer.setFilterLabelProvider(fFilterLabelProvider);
+        fTimeGraphViewer.setFilterColumns(fFilterColumns);
 
-        fTimeGraphWrapper.setTimeGraphPresentationProvider(fPresentation);
-        fTimeGraphWrapper.setAutoExpandLevel(fAutoExpandLevel);
+        fTimeGraphViewer.setTimeGraphProvider(fPresentation);
+        fTimeGraphViewer.setAutoExpandLevel(fAutoExpandLevel);
 
-        fTimeGraphWrapper.getTimeGraphViewer().addRangeListener(new ITimeGraphRangeListener() {
+        fTimeGraphViewer.setWeights(fWeight);
+
+        fTimeGraphViewer.addRangeListener(new ITimeGraphRangeListener() {
             @Override
             public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {
                 final long startTime = event.getStartTime();
@@ -1321,7 +957,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
             }
         });
 
-        fTimeGraphWrapper.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
+        fTimeGraphViewer.addTimeListener(new ITimeGraphTimeListener() {
             @Override
             public void timeSelected(TimeGraphTimeEvent event) {
                 ITmfTimestamp startTime = TmfTimestamp.fromNanos(event.getBeginTime());
@@ -1330,7 +966,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
             }
         });
 
-        fTimeGraphWrapper.getTimeGraphViewer().addBookmarkListener(new ITimeGraphBookmarkListener() {
+        fTimeGraphViewer.addBookmarkListener(new ITimeGraphBookmarkListener() {
             @Override
             public void bookmarkAdded(final TimeGraphBookmarkEvent event) {
                 try {
@@ -1380,10 +1016,10 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
             }
         });
 
-        fTimeGraphWrapper.getTimeGraphViewer().setTimeFormat(TimeFormat.CALENDAR);
+        fTimeGraphViewer.setTimeFormat(TimeFormat.CALENDAR);
 
         IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
-        fTimeGraphWrapper.getTimeGraphViewer().getTimeGraphControl().setStatusLineManager(statusLineManager);
+        fTimeGraphViewer.getTimeGraphControl().setStatusLineManager(statusLineManager);
 
         // View Action Handling
         makeActions();
@@ -1395,7 +1031,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
         }
 
         // make selection available to other views
-        getSite().setSelectionProvider(fTimeGraphWrapper.getSelectionProvider());
+        getSite().setSelectionProvider(fTimeGraphViewer.getSelectionProvider());
 
         ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
 
@@ -1406,7 +1042,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
 
     @Override
     public void setFocus() {
-        fTimeGraphWrapper.setFocus();
+        fTimeGraphViewer.setFocus();
     }
 
     @Override
@@ -1431,7 +1067,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
     public void resourceChanged(final IResourceChangeEvent event) {
         for (final IMarkerDelta delta : event.findMarkerDeltas(IMarker.BOOKMARK, false)) {
             if (delta.getResource().equals(fEditorFile)) {
-                fTimeGraphWrapper.getTimeGraphViewer().setBookmarks(refreshBookmarks(fEditorFile));
+                fTimeGraphViewer.setBookmarks(refreshBookmarks(fEditorFile));
                 redraw();
                 return;
             }
@@ -1539,15 +1175,15 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
         Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
-                if (fTimeGraphWrapper.isDisposed()) {
+                if (fTimeGraphViewer.getControl().isDisposed()) {
                     return;
                 }
                 if (beginTime == endTime) {
-                    fTimeGraphWrapper.getTimeGraphViewer().setSelectedTime(beginTime, true);
+                    fTimeGraphViewer.setSelectedTime(beginTime, true);
                 } else {
-                    fTimeGraphWrapper.getTimeGraphViewer().setSelectionRange(beginTime, endTime, true);
+                    fTimeGraphViewer.setSelectionRange(beginTime, endTime, true);
                 }
-                synchingToTime(fTimeGraphWrapper.getTimeGraphViewer().getSelectionBegin());
+                synchingToTime(fTimeGraphViewer.getSelectionBegin());
             }
         });
     }
@@ -1572,10 +1208,10 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
         Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
-                if (fTimeGraphWrapper.isDisposed()) {
+                if (fTimeGraphViewer.getControl().isDisposed()) {
                     return;
                 }
-                fTimeGraphWrapper.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
+                fTimeGraphViewer.setStartFinishTime(startTime, endTime);
                 startZoomThread(startTime, endTime);
             }
         });
@@ -1586,7 +1222,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      */
     @TmfSignalHandler
     public void updateTimeFormat( final TmfTimestampFormatUpdateSignal signal){
-        fTimeGraphWrapper.refresh();
+        fTimeGraphViewer.refresh();
     }
 
     /**
@@ -1614,8 +1250,8 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
         }
         if (fTrace != null) {
             /* save the filters of the previous trace */
-            fFiltersMap.put(fTrace, fTimeGraphWrapper.getFilters());
-            fViewContext.put(fTrace, new ViewContext(fCurrentSortColumn, fSortDirection, fTimeGraphWrapper.getSelection()));
+            fFiltersMap.put(fTrace, fTimeGraphViewer.getFilters());
+            fViewContext.put(fTrace, new ViewContext(fCurrentSortColumn, fSortDirection, fTimeGraphViewer.getSelection()));
         }
         fTrace = trace;
 
@@ -1876,12 +1512,11 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
             @Override
             public void run() {
                 LOGGER.info(() -> getLogMessage("RefreshStart", null)); //$NON-NLS-1$
-                if (fTimeGraphWrapper.isDisposed()) {
+                if (fTimeGraphViewer.getControl().isDisposed()) {
                     return;
                 }
                 fDirty.incrementAndGet();
 
-                boolean hasEntries = false;
                 synchronized (fEntryListMap) {
                     fEntryList = fEntryListMap.get(fTrace);
                     if (fEntryList == null) {
@@ -1895,43 +1530,28 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
                         fEntryList.clear();
                         fEntryList.addAll(list);
                     }
-                    hasEntries = !fEntryList.isEmpty();
                 }
-                boolean inputChanged = fEntryList != fTimeGraphWrapper.getInput();
-                TimeGraphCombo combo = getTimeGraphCombo();
-                try {
-                    // Set redraw to false to only draw once
-                    if (combo != null) {
-                        combo.getTreeViewer().getTree().setRedraw(false);
-                    }
-                    getTimeGraphViewer().getTimeGraphControl().setRedraw(false);
-                    if (inputChanged) {
-                        fTimeGraphWrapper.setInput(fEntryList);
-                        /* restore the previously saved filters, if any */
-                        fTimeGraphWrapper.setFilters(fFiltersMap.get(fTrace));
-                        fTimeGraphWrapper.getTimeGraphViewer().setLinks(null);
-                        fTimeGraphWrapper.getTimeGraphViewer().setBookmarks(refreshBookmarks(fEditorFile));
-                        fTimeGraphWrapper.getTimeGraphViewer().setMarkerCategories(getMarkerCategories());
-                        fTimeGraphWrapper.getTimeGraphViewer().setMarkers(null);
-                        applyViewContext();
-                    } else {
-                        fTimeGraphWrapper.refresh();
-                    }
-                    // reveal selection
-                    if (fIsRevealSelection) {
-                        fIsRevealSelection = false;
-                        ITimeGraphEntry entry1 = fTimeGraphWrapper.getSelection();
-                        fTimeGraphWrapper.setSelection(entry1);
-                    }
-                } finally {
-                    if (combo != null) {
-                        combo.getTreeViewer().getTree().setRedraw(true);
-                    }
-                    getTimeGraphViewer().getTimeGraphControl().setRedraw(true);
+                boolean inputChanged = fEntryList != fTimeGraphViewer.getInput();
+                if (inputChanged) {
+                    fTimeGraphViewer.setInput(fEntryList);
+                    /* restore the previously saved filters, if any */
+                    fTimeGraphViewer.setFilters(fFiltersMap.get(fTrace));
+                    fTimeGraphViewer.setLinks(null);
+                    fTimeGraphViewer.setBookmarks(refreshBookmarks(fEditorFile));
+                    fTimeGraphViewer.setMarkerCategories(getMarkerCategories());
+                    fTimeGraphViewer.setMarkers(null);
+                    applyViewContext();
+                } else {
+                    fTimeGraphViewer.refresh();
+                }
+                // reveal selection
+                if (fIsRevealSelection) {
+                    fIsRevealSelection = false;
+                    fTimeGraphViewer.setSelection(fTimeGraphViewer.getSelection(), true);
                 }
                 long startBound = (fStartTime == Long.MAX_VALUE ? SWT.DEFAULT : fStartTime);
                 long endBound = (fEndTime == Long.MIN_VALUE ? SWT.DEFAULT : fEndTime);
-                fTimeGraphWrapper.getTimeGraphViewer().setTimeBounds(startBound, endBound);
+                fTimeGraphViewer.setTimeBounds(startBound, endBound);
 
                 TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext();
                 long selectionBeginTime = fTrace == null ? SWT.DEFAULT : ctx.getSelectionRange().getStartTime().toNanos();
@@ -1940,22 +1560,13 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
                 long endTime = fTrace == null ? SWT.DEFAULT : ctx.getWindowRange().getEndTime().toNanos();
                 startTime = (fStartTime == Long.MAX_VALUE ? SWT.DEFAULT : Math.max(startTime, fStartTime));
                 endTime = (fEndTime == Long.MIN_VALUE ? SWT.DEFAULT : Math.min(endTime, fEndTime));
-                fTimeGraphWrapper.getTimeGraphViewer().setSelectionRange(selectionBeginTime, selectionEndTime, false);
-                fTimeGraphWrapper.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
+                fTimeGraphViewer.setSelectionRange(selectionBeginTime, selectionEndTime, false);
+                fTimeGraphViewer.setStartFinishTime(startTime, endTime);
 
                 if (inputChanged && selectionBeginTime != SWT.DEFAULT) {
                     synchingToTime(selectionBeginTime);
                 }
 
-                if (fTimeGraphWrapper instanceof TimeGraphComboWrapper && !fPackDone) {
-                    for (TreeColumn column : ((TimeGraphComboWrapper) fTimeGraphWrapper).getTreeViewer().getTree().getColumns()) {
-                        column.pack();
-                    }
-                    if (hasEntries) {
-                        fPackDone = true;
-                    }
-                }
-
                 if (!zoomThread) {
                     startZoomThread(startTime, endTime);
                 }
@@ -1982,11 +1593,11 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
             @Override
             public void run() {
                 LOGGER.info(() -> getLogMessage("RedrawStart", null)); //$NON-NLS-1$
-                if (fTimeGraphWrapper.isDisposed()) {
+                if (fTimeGraphViewer.getControl().isDisposed()) {
                     return;
                 }
-                fTimeGraphWrapper.redraw();
-                fTimeGraphWrapper.update();
+                fTimeGraphViewer.getControl().redraw();
+                fTimeGraphViewer.getControl().update();
                 synchronized (fSyncObj) {
                     if (fRedrawState == State.PENDING) {
                         fRedrawState = State.IDLE;
@@ -2066,10 +1677,10 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
     }
 
     private void makeActions() {
-        fPreviousResourceAction = fTimeGraphWrapper.getTimeGraphViewer().getPreviousItemAction();
+        fPreviousResourceAction = fTimeGraphViewer.getPreviousItemAction();
         fPreviousResourceAction.setText(getPrevText());
         fPreviousResourceAction.setToolTipText(getPrevTooltip());
-        fNextResourceAction = fTimeGraphWrapper.getTimeGraphViewer().getNextItemAction();
+        fNextResourceAction = fTimeGraphViewer.getNextItemAction();
         fNextResourceAction.setText(getNextText());
         fNextResourceAction.setToolTipText(getNextTooltip());
     }
@@ -2087,22 +1698,22 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      */
     protected void fillLocalToolBar(IToolBarManager manager) {
         if (fFilterColumns != null && fFilterLabelProvider != null && fFilterColumns.length > 0) {
-            manager.add(fTimeGraphWrapper.getShowFilterDialogAction());
+            manager.add(fTimeGraphViewer.getShowFilterDialogAction());
         }
-        manager.add(fTimeGraphWrapper.getTimeGraphViewer().getShowLegendAction());
+        manager.add(fTimeGraphViewer.getShowLegendAction());
         manager.add(new Separator());
-        manager.add(fTimeGraphWrapper.getTimeGraphViewer().getResetScaleAction());
-        manager.add(fTimeGraphWrapper.getTimeGraphViewer().getPreviousEventAction());
-        manager.add(fTimeGraphWrapper.getTimeGraphViewer().getNextEventAction());
+        manager.add(fTimeGraphViewer.getResetScaleAction());
+        manager.add(fTimeGraphViewer.getPreviousEventAction());
+        manager.add(fTimeGraphViewer.getNextEventAction());
         manager.add(new Separator());
-        manager.add(fTimeGraphWrapper.getTimeGraphViewer().getToggleBookmarkAction());
-        manager.add(fTimeGraphWrapper.getTimeGraphViewer().getPreviousMarkerAction());
-        manager.add(fTimeGraphWrapper.getTimeGraphViewer().getNextMarkerAction());
+        manager.add(fTimeGraphViewer.getToggleBookmarkAction());
+        manager.add(fTimeGraphViewer.getPreviousMarkerAction());
+        manager.add(fTimeGraphViewer.getNextMarkerAction());
         manager.add(new Separator());
         manager.add(fPreviousResourceAction);
         manager.add(fNextResourceAction);
-        manager.add(fTimeGraphWrapper.getTimeGraphViewer().getZoomInAction());
-        manager.add(fTimeGraphWrapper.getTimeGraphViewer().getZoomOutAction());
+        manager.add(fTimeGraphViewer.getZoomInAction());
+        manager.add(fTimeGraphViewer.getZoomOutAction());
         manager.add(new Separator());
     }
 
@@ -2113,7 +1724,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      * @since 2.0
      */
     protected void fillLocalMenu(IMenuManager manager) {
-        manager.add(fTimeGraphWrapper.getTimeGraphViewer().getMarkersMenu());
+        manager.add(fTimeGraphViewer.getMarkersMenu());
     }
 
     /**
@@ -2121,10 +1732,10 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      */
     @Override
     public TmfTimeViewAlignmentInfo getTimeViewAlignmentInfo() {
-        if (fTimeGraphWrapper == null) {
+        if (fTimeGraphViewer == null) {
             return null;
         }
-        return fTimeGraphWrapper.getTimeViewAlignmentInfo();
+        return fTimeGraphViewer.getTimeViewAlignmentInfo();
     }
 
     /**
@@ -2132,10 +1743,10 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      */
     @Override
     public int getAvailableWidth(int requestedOffset) {
-        if (fTimeGraphWrapper == null) {
+        if (fTimeGraphViewer == null) {
             return 0;
         }
-        return fTimeGraphWrapper.getAvailableWidth(requestedOffset);
+        return fTimeGraphViewer.getAvailableWidth(requestedOffset);
     }
 
     /**
@@ -2143,8 +1754,8 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      */
     @Override
     public void performAlign(int offset, int width) {
-        if (fTimeGraphWrapper != null) {
-            fTimeGraphWrapper.performAlign(offset, width);
+        if (fTimeGraphViewer != null) {
+            fTimeGraphViewer.performAlign(offset, width);
         }
     }
 
@@ -2174,7 +1785,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
 
         // If the time graph control hasn't updated all the way to the end of
         // the window range then it's dirty. A refresh should happen later.
-        if (fTimeGraphWrapper.getTimeGraphViewer().getTime0() != startTime || fTimeGraphWrapper.getTimeGraphViewer().getTime1() != endTime) {
+        if (fTimeGraphViewer.getTime0() != startTime || fTimeGraphViewer.getTime1() != endTime) {
             return true;
         }
 
@@ -2188,11 +1799,10 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
         return fDirty.get() != 0 || fZoomThread.getZoomStartTime() != startTime || fZoomThread.getZoomEndTime() != endTime;
     }
 
-    private void createColumnSelectionListener(TreeViewer treeViewer) {
+    private void createColumnSelectionListener(Tree tree) {
         for (int i = 0; i < fColumnComparators.length; i++) {
             final int index = i;
             final Comparator<ITimeGraphEntry> comp = fColumnComparators[index];
-            final Tree tree = treeViewer.getTree();
             final TreeColumn column = tree.getColumn(i);
 
             if (comp != null) {
@@ -2220,9 +1830,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
                         }
                         setEntryComparator(comparator);
                         fIsRevealSelection = true;
-                        if (fTimeGraphWrapper instanceof TimeGraphComboWrapper) {
-                            ((TimeGraphComboWrapper) fTimeGraphWrapper).getTreeViewer().getControl().setFocus();
-                        }
+                        fTimeGraphViewer.getControl().setFocus();
                         refresh();
                     }
                 });
@@ -2230,61 +1838,41 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
         }
     }
 
-    private void createDoubleClickListener(TreeViewer treeViewer) {
-        treeViewer.addDoubleClickListener(event -> {
-            if (event.getSelection() instanceof TreeSelection) {
-                TreeSelection selection = (TreeSelection) event.getSelection();
-                if (selection.getFirstElement() instanceof ITimeGraphEntry) {
-                    ITimeGraphEntry entry = (ITimeGraphEntry) selection.getFirstElement();
-                    if (entry.hasChildren()) {
-                        fTimeGraphWrapper.setExpandedState(entry, !fTimeGraphWrapper.getExpandedState(entry));
-                    }
-                }
-            }
-        });
-    }
-
-
     private void restoreViewContext() {
-        TimeGraphCombo combo = getTimeGraphCombo();
         ViewContext viewContext = fViewContext.get(fTrace);
-        if (combo != null) {
-            if (fColumnComparators != null) {
-                // restore sort settings
-                fSortDirection = SWT.DOWN;
-                fCurrentSortColumn = fInitialSortColumn;
-                if (viewContext != null) {
-                    fSortDirection = viewContext.getSortDirection();
-                    fCurrentSortColumn = viewContext.getSortColumn();
+        if (fColumnComparators != null) {
+            // restore sort settings
+            fSortDirection = SWT.DOWN;
+            fCurrentSortColumn = fInitialSortColumn;
+            if (viewContext != null) {
+                fSortDirection = viewContext.getSortDirection();
+                fCurrentSortColumn = viewContext.getSortColumn();
+            }
+            if ((fCurrentSortColumn < fColumnComparators.length) && (fColumnComparators[fCurrentSortColumn] != null)) {
+                Comparator<ITimeGraphEntry> comparator = fColumnComparators[fCurrentSortColumn];
+                if (comparator instanceof ITimeGraphEntryComparator) {
+                    ((ITimeGraphEntryComparator) comparator).setDirection(fSortDirection);
                 }
-                if ((fCurrentSortColumn < fColumnComparators.length) && (fColumnComparators[fCurrentSortColumn] != null)) {
-                    Comparator<ITimeGraphEntry> comparator = fColumnComparators[fCurrentSortColumn];
-                    if (comparator instanceof ITimeGraphEntryComparator) {
-                        ((ITimeGraphEntryComparator) comparator).setDirection(fSortDirection);
-                    }
-                    if (fSortDirection != SWT.DOWN) {
-                        comparator = checkNotNull(Collections.reverseOrder(comparator));
-                    }
-                    setEntryComparator(comparator);
+                if (fSortDirection != SWT.DOWN) {
+                    comparator = checkNotNull(Collections.reverseOrder(comparator));
                 }
+                setEntryComparator(comparator);
             }
         }
     }
 
     private void applyViewContext() {
-        TimeGraphCombo combo = getTimeGraphCombo();
         ViewContext viewContext = fViewContext.get(fTrace);
-        if (combo != null) {
-            TreeViewer treeViewer = combo.getTreeViewer();
-            final Tree tree = treeViewer.getTree();
+        if (fColumnComparators != null) {
+            final Tree tree = fTimeGraphViewer.getTree();
             final TreeColumn column = tree.getColumn(fCurrentSortColumn);
             tree.setSortDirection(fSortDirection);
             tree.setSortColumn(column);
-            combo.getTreeViewer().getControl().setFocus();
         }
+        fTimeGraphViewer.getControl().setFocus();
         // restore and reveal selection
         if ((viewContext != null) && (viewContext.getSelection() != null)) {
-            fTimeGraphWrapper.setSelection(viewContext.getSelection());
+            fTimeGraphViewer.setSelection(viewContext.getSelection(), true);
         }
         fViewContext.remove(fTrace);
     }
@@ -2356,35 +1944,26 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
     }
 
     private void createContextMenu() {
-        TimeGraphCombo combo = getTimeGraphCombo();
         fEntryMenuManager.setRemoveAllWhenShown(true);
-        if (combo != null) {
-            TreeViewer treeViewer = combo.getTreeViewer();
-            Tree tree = treeViewer.getTree();
-            Menu menu = fEntryMenuManager.createContextMenu(tree);
-            tree.setMenu(menu);
-        } else {
-            TimeGraphControl timeGraphControl = getTimeGraphViewer().getTimeGraphControl();
-            final Menu entryMenu = fEntryMenuManager.createContextMenu(timeGraphControl);
-            timeGraphControl.addTimeGraphEntryMenuListener(new MenuDetectListener() {
-                @Override
-                public void menuDetected(MenuDetectEvent event) {
-                    Point p = timeGraphControl.toControl(event.x, event.y);
-                    /*
-                     * The TimeGraphControl will call the TimeGraphEntryMenuListener
-                     * before the TimeEventMenuListener. If the event is
-                     * triggered on the namespace then show the menu else
-                     * clear the menu.
-                     */
-                    if (p.x < getTimeGraphViewer().getNameSpace()) {
-                        timeGraphControl.setMenu(entryMenu);
-                    } else {
-                        timeGraphControl.setMenu(null);
-                        event.doit = false;
-                    }
+        TimeGraphControl timeGraphControl = getTimeGraphViewer().getTimeGraphControl();
+        final Menu entryMenu = fEntryMenuManager.createContextMenu(timeGraphControl);
+        timeGraphControl.addTimeGraphEntryMenuListener(new MenuDetectListener() {
+            @Override
+            public void menuDetected(MenuDetectEvent event) {
+                Point p = timeGraphControl.toControl(event.x, event.y);
+                /*
+                 * The TimeGraphControl will call the TimeGraphEntryMenuListener
+                 * before the TimeEventMenuListener. If the event is triggered
+                 * on the name space then show the menu else clear the menu.
+                 */
+                if (p.x < getTimeGraphViewer().getNameSpace()) {
+                    timeGraphControl.setMenu(entryMenu);
+                } else {
+                    timeGraphControl.setMenu(null);
+                    event.doit = false;
                 }
-            });
-        }
+            }
+        });
         fEntryMenuManager.addMenuListener(new IMenuListener() {
             @Override
             public void menuAboutToShow(IMenuManager manager) {
@@ -2392,7 +1971,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
                 fEntryMenuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
             }
         });
-        getSite().registerContextMenu(fEntryMenuManager, fTimeGraphWrapper.getSelectionProvider());
+        getSite().registerContextMenu(fEntryMenuManager, fTimeGraphViewer.getSelectionProvider());
     }
 
     /**
@@ -2410,11 +1989,11 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      */
     class FindTarget {
         public ITimeGraphEntry getSelection() {
-            return fTimeGraphWrapper.getSelection();
+            return fTimeGraphViewer.getSelection();
         }
 
         public void selectAndReveal(@NonNull ITimeGraphEntry entry) {
-            fTimeGraphWrapper.selectAndReveal(entry);
+            fTimeGraphViewer.selectAndReveal(entry);
         }
 
         public ITimeGraphEntry[] getEntries() {
index 0c27d2515b296c2fc8907e5f5217a580e6fa2457..6054b6be1f08526143f2b522051ea33e328fcdc0 100644 (file)
@@ -87,7 +87,9 @@ import com.google.common.collect.Iterables;
  * on the right)
  *
  * @author Patrick Tasse
+ * @deprecated Use {@link #getTimeGraphViewer()} instead.
  */
+@Deprecated
 public class TimeGraphCombo extends Composite {
 
     // ------------------------------------------------------------------------
@@ -508,6 +510,9 @@ public class TimeGraphCombo extends Composite {
         tree.setLinesVisible(true);
 
         fTimeGraphViewer = new TimeGraphViewerExtension(fSashForm, SWT.NONE, tree);
+        fTimeGraphViewer.setColumns(new String[0]);
+        fTimeGraphViewer.setNameWidthPref(0);
+        fTimeGraphViewer.setWeights(new int[] { 0, 1 } );
 
         if (fScrollBarsInTreeWorkaround) {
             // Feature in Windows. The tree vertical bar reappears when
@@ -615,7 +620,7 @@ public class TimeGraphCombo extends Composite {
             if (treeItems.isEmpty()) {
                 event.doit = false;
                 fTreeViewer.setSelection(new StructuredSelection());
-                fTimeGraphViewer.setSelection(null);
+                fTimeGraphViewer.setSelection(null, false);
                 return;
             }
             TreeItem lastTreeItem = treeItems.get(treeItems.size() - 1);
@@ -650,7 +655,7 @@ public class TimeGraphCombo extends Composite {
             }
             if (event.keyCode == SWT.ARROW_DOWN) {
                 int index = Math.min(fTimeGraphViewer.getSelectionIndex() + 1, treeItems.size() - 1);
-                fTimeGraphViewer.setSelection((ITimeGraphEntry) treeItems.get(index).getData());
+                fTimeGraphViewer.setSelection((ITimeGraphEntry) treeItems.get(index).getData(), true);
                 event.doit = false;
             } else if (event.keyCode == SWT.PAGE_DOWN) {
                 int height = tree.getSize().y - tree.getHeaderHeight() - tree.getHorizontalBar().getSize().y;
@@ -697,7 +702,7 @@ public class TimeGraphCombo extends Composite {
             if (event.getSelection() instanceof IStructuredSelection) {
                 Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
                 if (selection instanceof ITimeGraphEntry) {
-                    fTimeGraphViewer.setSelection((ITimeGraphEntry) selection);
+                    fTimeGraphViewer.setSelection((ITimeGraphEntry) selection, true);
                 }
                 alignTreeItems(false);
             }
@@ -1174,7 +1179,7 @@ public class TimeGraphCombo extends Composite {
      *            the new selection
      */
     public void setSelection(ITimeGraphEntry selection) {
-        fTimeGraphViewer.setSelection(selection);
+        fTimeGraphViewer.setSelection(selection, true);
         setSelectionInTree(selection);
     }
 
index 0e54f50c6c6c692794bcb95601bf084fd3422a67..9cb9afb73a0c70087114da158fc3c740ce8251ca 100644 (file)
@@ -34,9 +34,14 @@ import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.SWT;
@@ -47,6 +52,8 @@ import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.MenuDetectListener;
 import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.MouseWheelListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
@@ -63,6 +70,8 @@ import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Slider;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
 import org.eclipse.tracecompass.internal.tmf.ui.Activator;
 import org.eclipse.tracecompass.internal.tmf.ui.ITmfImageConstants;
 import org.eclipse.tracecompass.internal.tmf.ui.Messages;
@@ -93,13 +102,13 @@ import org.eclipse.ui.PlatformUI;
  *
  * @author Patrick Tasse, and others
  */
-public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener, SelectionListener {
+public class TimeGraphViewer extends Viewer implements ITimeDataProvider, IMarkerAxisListener, SelectionListener {
 
     /** Constant indicating that all levels of the time graph should be expanded */
     public static final int ALL_LEVELS = AbstractTreeViewer.ALL_LEVELS;
 
     private static final int DEFAULT_NAME_WIDTH = 200;
-    private static final int MIN_NAME_WIDTH = 6;
+    private static final int MIN_NAME_WIDTH = 3;
     private static final int MAX_NAME_WIDTH = 1000;
     private static final int DEFAULT_HEIGHT = 22;
     private static final String HIDE_ARROWS_KEY = "hide.arrows"; //$NON-NLS-1$
@@ -127,9 +136,11 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
     private int fNameWidthPref = DEFAULT_NAME_WIDTH;
     private int fMinNameWidth = MIN_NAME_WIDTH;
     private int fNameWidth;
+    private int[] fWeights;
     private Composite fDataViewer;
 
     private TimeGraphControl fTimeGraphCtrl;
+    private Tree fTree;
     private TimeGraphScale fTimeScaleCtrl;
     private TimeGraphMarkerAxis fMarkerAxisCtrl;
     private Slider fHorizontalScrollBar;
@@ -138,6 +149,7 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
     private Object fInputElement;
     private ITimeGraphContentProvider fTimeGraphContentProvider;
     private ITimeGraphPresentationProvider fTimeGraphProvider;
+    private ITableLabelProvider fLabelProvider;
     private @NonNull ITimeDataProvider fTimeDataProvider = this;
     private TimeGraphTooltipHandler fToolTipHandler;
 
@@ -316,6 +328,19 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         fToolTipHandler.activateHoverHelp(fTimeGraphCtrl);
     }
 
+    /**
+     * Sets the tree label provider used for the name space
+     *
+     * @param labelProvider the tree label provider
+     * @since 2.3
+     */
+    public void setTimeGraphLabelProvider(ITableLabelProvider labelProvider) {
+        fLabelProvider = labelProvider;
+        if (fTimeGraphCtrl != null) {
+            fTimeGraphCtrl.setLabelProvider(labelProvider);
+        }
+    }
+
     /**
      * Sets the tree columns for this time graph combo's filter dialog.
      *
@@ -346,14 +371,10 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         getShowFilterDialogAction().getFilterDialog().setLabelProvider(labelProvider);
     }
 
-    /**
-     * Sets or clears the input for this time graph viewer.
-     *
-     * @param inputElement
-     *            The input of this time graph viewer, or <code>null</code> if
-     *            none
-     */
+    @Override
     public void setInput(Object inputElement) {
+        Object oldInput = fInputElement;
+        fTimeGraphContentProvider.inputChanged(this, oldInput, inputElement);
         fInputElement = inputElement;
         ITimeGraphEntry[] input = fTimeGraphContentProvider.getElements(inputElement);
         fListenerNotifier = null;
@@ -368,11 +389,7 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         }
     }
 
-    /**
-     * Gets the input for this time graph viewer.
-     *
-     * @return The input of this time graph viewer, or <code>null</code> if none
-     */
+    @Override
     public Object getInput() {
         return fInputElement;
     }
@@ -389,9 +406,7 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         }
     }
 
-    /**
-     * Refresh the view
-     */
+    @Override
     public void refresh() {
         ITimeGraphEntry[] input = fTimeGraphContentProvider.getElements(fInputElement);
         setTimeRange(input);
@@ -458,6 +473,7 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         fDataViewer = new Composite(parent, style) {
             @Override
             public void redraw() {
+                fTree.redraw();
                 fTimeScaleCtrl.redraw();
                 fTimeGraphCtrl.redraw();
                 fMarkerAxisCtrl.redraw();
@@ -483,7 +499,7 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
                 super.redraw();
             }
         };
-        GridLayout gl2 = new GridLayout(1, false);
+        GridLayout gl2 = new GridLayout(2, false);
         gl2.marginHeight = fBorderWidth;
         gl2.marginWidth = 0;
         gl2.verticalSpacing = 0;
@@ -491,6 +507,30 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         fTimeAlignedComposite.setLayout(gl2);
         fTimeAlignedComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
+        fTree = new Tree(fTimeAlignedComposite, SWT.NO_SCROLL);
+        fTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        fTree.setHeaderVisible(true);
+        // add a default column
+        TreeColumn column = new TreeColumn(fTree, SWT.LEFT);
+        column.setResizable(false);
+
+        /*
+         * Bug in Linux. The tree header height is 0 in constructor, so we need
+         * to reset it later when the control is painted. This work around used
+         * to be done on control resized but the header height was not
+         * initialized on the initial resize on GTK3.
+         */
+        fTree.addPaintListener(new PaintListener() {
+            @Override
+            public void paintControl(PaintEvent e) {
+                int headerHeight = fTree.getHeaderHeight();
+                if (headerHeight > 0) {
+                    fTree.removePaintListener(this);
+                    setHeaderHeight(headerHeight);
+                }
+            }
+        });
+
         fTimeScaleCtrl = new TimeGraphScale(fTimeAlignedComposite, fColorScheme);
         fTimeScaleCtrl.setTimeProvider(fTimeDataProvider);
         fTimeScaleCtrl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
@@ -512,9 +552,11 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         fTimeGraphCtrl = createTimeGraphControl(fTimeAlignedComposite, fColorScheme);
 
         fTimeGraphCtrl.setTimeProvider(this);
+        fTimeGraphCtrl.setLabelProvider(fLabelProvider);
+        fTimeGraphCtrl.setTree(fTree);
         fTimeGraphCtrl.setTimeGraphScale(fTimeScaleCtrl);
         fTimeGraphCtrl.addSelectionListener(this);
-        fTimeGraphCtrl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        fTimeGraphCtrl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
         fTimeGraphCtrl.addMouseWheelListener(new MouseWheelListener() {
             @Override
             public void mouseScrolled(MouseEvent e) {
@@ -568,7 +610,7 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         });
 
         fMarkerAxisCtrl = createTimeGraphMarkerAxis(fTimeAlignedComposite, fColorScheme, this);
-        fMarkerAxisCtrl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
+        fMarkerAxisCtrl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
         fMarkerAxisCtrl.addMarkerAxisListener(this);
         fMarkerAxisCtrl.addMouseWheelListener(new MouseWheelListener() {
             @Override
@@ -700,6 +742,10 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
             return;
         }
 
+        if (fWeights != null) {
+            setWeights(fWeights);
+            fWeights = null;
+        }
         int width = r.width;
         if (fNameWidth > width - fMinNameWidth) {
             fNameWidth = width - fMinNameWidth;
@@ -707,6 +753,9 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         if (fNameWidth < fMinNameWidth) {
             fNameWidth = fMinNameWidth;
         }
+        if (fTree.getColumnCount() == 1) {
+            fTree.getColumn(0).setWidth(fNameWidth);
+        }
         adjustHorizontalScrollBar();
         adjustVerticalScrollBar();
     }
@@ -839,6 +888,7 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
      *
      * @return The entry that is selected
      */
+    @Override
     public ITimeGraphEntry getSelection() {
         return fTimeGraphCtrl.getSelectedTrace();
     }
@@ -867,6 +917,28 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         return fMinTimeInterval;
     }
 
+    /**
+     * Sets the relative horizontal weight of each part of the time graph
+     * viewer. The first number is the name space weight, and the second number
+     * is the time space weight.
+     *
+     * @param weights
+     *            The array of relative weights of each part of the viewer
+     * @since 2.3
+     */
+    public void setWeights(final int[] weights) {
+        if (weights.length != 2) {
+            return;
+        }
+        int width = fTimeAlignedComposite.getSize().x;
+        if (width == 0) {
+            /* the weigths will be applied when the control is resized */
+            fWeights = weights;
+            return;
+        }
+        setNameSpace(width * weights[0] / (weights[0] + weights[1]));
+    }
+
     @Override
     public int getNameSpace() {
         return fNameWidth;
@@ -882,6 +954,13 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         if (fNameWidth < MIN_NAME_WIDTH) {
             fNameWidth = MIN_NAME_WIDTH;
         }
+        GridData gd = (GridData) fTree.getLayoutData();
+        gd.widthHint = fNameWidth;
+        if (fTree.getColumnCount() == 1) {
+            fTree.getColumn(0).setWidth(fNameWidth);
+        }
+        fTimeAlignedComposite.layout();
+        fTree.redraw();
         fTimeGraphCtrl.redraw();
         fTimeScaleCtrl.redraw();
         fMarkerAxisCtrl.redraw();
@@ -1196,6 +1275,9 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         for (ITimeGraphSelectionListener listener : fSelectionListeners) {
             listener.selectionChanged(event);
         }
+
+        ISelection structuredSelection = (selection == null) ? StructuredSelection.EMPTY : new StructuredSelection(selection);
+        fireSelectionChanged(new SelectionChangedEvent(this, structuredSelection));
     }
 
     /**
@@ -1441,18 +1523,33 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
     }
 
     /**
-     * Callback for a trace selection
+     * Sets a new selection for this viewer and makes it visible.
      *
-     * @param trace
-     *            The trace that was selected
+     * @param entry
+     *            The entry to select
+     * @deprecated Use {@link #setSelection(ISelection, boolean)} instead.
      */
-    public void setSelection(ITimeGraphEntry trace) {
+    @Deprecated
+    public void setSelection(ITimeGraphEntry entry) {
+        setSelection(entry, true);
+    }
+
+    @Override
+    public void setSelection(ISelection selection, boolean reveal) {
         /* if there is a pending selection, ignore this one */
         if (fListenerNotifier != null && fListenerNotifier.hasSelectionChanged()) {
             return;
         }
-        fSelectedEntry = trace;
-        fTimeGraphCtrl.selectItem(trace, false);
+        Object element = selection;
+        if (selection instanceof IStructuredSelection) {
+            element = ((IStructuredSelection) selection).getFirstElement();
+        }
+        if (!(element instanceof ITimeGraphEntry)) {
+            return;
+        }
+        ITimeGraphEntry entry = (ITimeGraphEntry) element;
+        fSelectedEntry = entry;
+        fTimeGraphCtrl.selectItem(entry, false, reveal);
         adjustVerticalScrollBar();
     }
 
@@ -1633,11 +1730,7 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         return fNameWidthPref;
     }
 
-    /**
-     * Returns the primary control associated with this viewer.
-     *
-     * @return the SWT control which displays this viewer's content
-     */
+    @Override
     public Control getControl() {
         return fDataViewer;
     }
@@ -1651,6 +1744,28 @@ public class TimeGraphViewer implements ITimeDataProvider, IMarkerAxisListener,
         return fTimeGraphCtrl;
     }
 
+    /**
+     * Returns the tree control associated with this viewer. The tree is only
+     * used for column handling of the name space and contains no tree items.
+     *
+     * @return the tree control
+     * @since 2.3
+     */
+    public Tree getTree() {
+        return fTree;
+    }
+
+    /**
+     * Sets the columns for this time graph viewer's name space.
+     *
+     * @param columnNames
+     *            the column names
+     * @since 2.3
+     */
+    public void setColumns(String[] columnNames) {
+        fTimeGraphCtrl.setColumns(columnNames);
+    }
+
     /**
      * Returns the time graph scale associated with this viewer.
      *
index 47d8f0e4346e5cd8fa64b1d7b3276970e4057c2f..d55433f6b6ffa14e212daed8f13911e351a037cf 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2014 Ericsson
+ * Copyright (c) 2009, 2016 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -18,6 +18,7 @@ import java.util.List;
 import java.util.regex.Pattern;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jface.viewers.ISelection;
 
 /**
  * Interface for an entry (row) in the time graph view
@@ -25,7 +26,7 @@ import org.eclipse.jdt.annotation.NonNull;
  * @author Alvaro Sanchez-Leon
  * @author Patrick Tasse
  */
-public interface ITimeGraphEntry {
+public interface ITimeGraphEntry extends ISelection {
 
     /**
      * Returns the parent of this entry, or <code>null</code> if it has none.
@@ -114,4 +115,9 @@ public interface ITimeGraphEntry {
      * @since 2.0
      */
     boolean matches(@NonNull Pattern pattern);
+
+    @Override
+    default boolean isEmpty() {
+        return false;
+    }
 }
index 30a49678df374d84e43e38ca7c99ac7b1aa22b30..0969b587a77a6224797eb54e64f95125b64c5c13 100644 (file)
@@ -42,11 +42,14 @@ import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
 import org.eclipse.swt.events.FocusEvent;
 import org.eclipse.swt.events.FocusListener;
 import org.eclipse.swt.events.KeyEvent;
@@ -76,6 +79,8 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
 import org.eclipse.tracecompass.common.core.math.SaturatedArithmetic;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
 import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentInfo;
@@ -126,9 +131,11 @@ public class TimeGraphControl extends TimeGraphBaseControl
     private static final double ZOOM_IN_FACTOR = 0.8;
     private static final double ZOOM_OUT_FACTOR = 1.25;
 
-    private static final int SNAP_WIDTH = 2;
+    private static final int SNAP_WIDTH = 3;
     private static final int ARROW_HOVER_MAX_DIST = 5;
 
+    private static double ARROW_RATIO = Math.sqrt(3) / 2; // base to height ratio
+
     private static final int NO_STATUS = -1;
     private static final int STATUS_WITHOUT_CURSOR_TIME = -2;
 
@@ -139,6 +146,8 @@ public class TimeGraphControl extends TimeGraphBaseControl
 
     private static final int VERTICAL_ZOOM_DELAY = 400;
 
+    private static final String PREFERRED_WIDTH = "width"; //$NON-NLS-1$
+
     /** Resource manager */
     private LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());
 
@@ -146,7 +155,9 @@ public class TimeGraphControl extends TimeGraphBaseControl
     private Color[] fEventColorMap = null;
 
     private ITimeDataProvider fTimeProvider;
+    private ITableLabelProvider fLabelProvider;
     private IStatusLineManager fStatusLineManager = null;
+    private Tree fTree = null;
     private TimeGraphScale fTimeGraphScale = null;
 
     private boolean fIsInFocus = false;
@@ -165,6 +176,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
     private boolean fHasNamespaceFocus = false;
     private long fDragTime0 = 0; // used to preserve accuracy of modified selection
     private int fIdealNameSpace = 0;
+    private boolean fAutoResizeColumns = true;
     private long fTime0bak;
     private long fTime1bak;
     private ITimeGraphPresentationProvider fTimeGraphProvider = null;
@@ -279,6 +291,28 @@ public class TimeGraphControl extends TimeGraphBaseControl
         redraw();
     }
 
+    /**
+     * Set the label provider for the name space
+     *
+     * @param labelProvider
+     *            The label provider
+     * @since 2.3
+     */
+    public void setLabelProvider(ITableLabelProvider labelProvider) {
+        fLabelProvider = labelProvider;
+        redraw();
+    }
+
+    /**
+     * Get the label provider for the name space
+     *
+     * @return The label provider
+     * @since 2.3
+     */
+    public ITableLabelProvider getLabelProvider() {
+        return fLabelProvider;
+    }
+
     /**
      * Assign the status line manager
      *
@@ -292,6 +326,63 @@ public class TimeGraphControl extends TimeGraphBaseControl
         fStatusLineManager = statusLineManager;
     }
 
+    /**
+     * Assign the tree that represents the name space header
+     *
+     * @param tree
+     *            The tree
+     * @since 2.3
+     */
+    public void setTree(Tree tree) {
+        fTree = tree;
+    }
+
+    /**
+     * Returns the tree control associated with this time graph control. The
+     * tree is only used for column handling of the name space and contains no
+     * tree items.
+     *
+     * @return the tree control
+     * @since 2.3
+     */
+    public Tree getTree() {
+        return fTree;
+    }
+
+    /**
+     * Sets the columns for this time graph control's name space.
+     *
+     * @param columnNames
+     *            the column names
+     * @since 2.3
+     */
+    public void setColumns(String[] columnNames) {
+        for (TreeColumn column : fTree.getColumns()) {
+            column.dispose();
+        }
+        ControlListener controlListener = new ControlListener() {
+            @Override
+            public void controlResized(ControlEvent e) {
+                if (fAutoResizeColumns && ((TreeColumn) e.widget).getWidth() < (Integer) e.widget.getData(PREFERRED_WIDTH)) {
+                    fAutoResizeColumns = false;
+                }
+                redraw();
+            }
+            @Override
+            public void controlMoved(ControlEvent e) {
+                redraw();
+            }
+        };
+        for (String columnName : columnNames) {
+            TreeColumn column = new TreeColumn(fTree, SWT.LEFT);
+            column.setMoveable(true);
+            column.setText(columnName);
+            column.pack();
+            column.setData(PREFERRED_WIDTH, column.getWidth());
+            column.addControlListener(controlListener);
+        }
+    }
+
     /**
      * Assign the time graph scale
      *
@@ -1405,7 +1496,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
             return false;
         }
         int nameWidth = fTimeProvider.getNameSpace();
-        return Math.abs(x - nameWidth) < SNAP_WIDTH;
+        return Math.abs(x - nameWidth) <= SNAP_WIDTH;
     }
 
     boolean isOverTimeSpace(int x, int y) {
@@ -1499,6 +1590,10 @@ public class TimeGraphControl extends TimeGraphBaseControl
     }
 
     void selectItem(int idx, boolean addSelection) {
+        selectItem(idx, addSelection, true);
+    }
+
+    void selectItem(int idx, boolean addSelection, boolean reveal) {
         boolean changed = false;
         if (addSelection) {
             if (idx >= 0 && idx < fItemData.fExpandedItems.length) {
@@ -1515,25 +1610,46 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 item.fSelected = i == idx;
             }
         }
-        changed |= ensureVisibleItem(idx, true);
+        if (reveal) {
+            changed |= ensureVisibleItem(idx, true);
+        }
         if (changed) {
             redraw();
         }
     }
 
     /**
-     * Callback for item selection
+     * Select an entry and make it visible
      *
-     * @param trace
-     *            The entry matching the trace
+     * @param entry
+     *            The entry to select
      * @param addSelection
-     *            If the selection is added or removed
+     *            <code>true</code> to add the entry to the current selection,
+     *            or <code>false</code> to set a new selection
      */
-    public void selectItem(ITimeGraphEntry trace, boolean addSelection) {
-        int idx = fItemData.findItemIndex(trace);
+    public void selectItem(ITimeGraphEntry entry, boolean addSelection) {
+        int idx = fItemData.findItemIndex(entry);
         selectItem(idx, addSelection);
     }
 
+    /**
+     * Select an entry
+     *
+     * @param entry
+     *            The entry to select
+     * @param addSelection
+     *            <code>true</code> to add the entry to the current selection,
+     *            or <code>false</code> to set a new selection
+     * @param reveal
+     *            <code>true</code> if the selection is to be made visible, and
+     *            <code>false</code> otherwise
+     * @since 2.3
+     */
+    public void selectItem(ITimeGraphEntry entry, boolean addSelection, boolean reveal) {
+        int idx = fItemData.findItemIndex(entry);
+        selectItem(idx, addSelection, reveal);
+    }
+
     /**
      * Retrieve the number of entries shown per page.
      *
@@ -1727,11 +1843,16 @@ public class TimeGraphControl extends TimeGraphBaseControl
             }
         }
 
-        // draw drag line
-        if (DRAG_SPLIT_LINE == fDragState) {
-            gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.BLACK));
-            gc.drawLine(bounds.x + nameSpace, bounds.y, bounds.x + nameSpace, bounds.y + bounds.height - 1);
-        } else if (DRAG_ZOOM == fDragState && Math.max(fDragX, fDragX0) > nameSpace) {
+        // draw split line
+        if (DRAG_SPLIT_LINE == fDragState ||
+                (DRAG_NONE == fDragState && fMouseOverSplitLine && fTimeProvider.getNameSpace() > 0)) {
+            gc.setBackground(getColorScheme().getColor(TimeGraphColorScheme.DARK_GRAY));
+        } else {
+            gc.setBackground(getColorScheme().getColor(TimeGraphColorScheme.GRAY));
+        }
+        gc.fillRectangle(bounds.x + nameSpace - SNAP_WIDTH, bounds.y, SNAP_WIDTH, bounds.height);
+
+        if (DRAG_ZOOM == fDragState && Math.max(fDragX, fDragX0) > nameSpace) {
             gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.TOOL_FOREGROUND));
             gc.drawLine(fDragX0, bounds.y, fDragX0, bounds.y + bounds.height - 1);
             if (fDragX != fDragX0) {
@@ -1743,9 +1864,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
             if (fDragX != fDragX0) {
                 gc.drawLine(fDragX, bounds.y, fDragX, bounds.y + bounds.height - 1);
             }
-        } else if (DRAG_NONE == fDragState && fMouseOverSplitLine && fTimeProvider.getNameSpace() > 0) {
-            gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.RED));
-            gc.drawLine(bounds.x + nameSpace, bounds.y, bounds.x + nameSpace, bounds.y + bounds.height - 1);
         }
 
         gc.setAlpha(alpha);
@@ -1789,12 +1907,10 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 gc.setBackground(getColorScheme().getBkColor(true, fIsInFocus, false));
                 gc.fillRectangle(nameSpace, itemRect.y, itemRect.width - nameSpace, itemRect.height);
             }
-            // draw the name and middle line
-            if (! item.fEntry.hasTimeEvents()) {
-                drawName(item, itemRect, gc);
-            } else {
-                Rectangle nameRect = new Rectangle(itemRect.x, itemRect.y, nameSpace, itemRect.height);
-                drawName(item, nameRect, gc);
+            // draw the name space
+            Rectangle nameRect = new Rectangle(itemRect.x, itemRect.y, nameSpace, itemRect.height);
+            drawName(item, nameRect, gc);
+            if (item.fEntry.hasTimeEvents()) {
                 Rectangle rect = new Rectangle(nameSpace, itemRect.y, itemRect.width - nameSpace, itemRect.height);
                 drawMidLine(rect, gc);
             }
@@ -2151,7 +2267,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
     }
 
     /**
-     * Draw the name of an item.
+     * Draw the name space of an item.
      *
      * @param item
      *            Item object
@@ -2161,82 +2277,96 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *            Graphics context
      */
     protected void drawName(Item item, Rectangle bounds, GC gc) {
-        boolean hasTimeEvents = item.fEntry.hasTimeEvents();
-
-        // No name to be drawn
+        // No name space to be drawn
         if (fTimeProvider.getNameSpace() == 0) {
             return;
         }
 
+        boolean hasTimeEvents = item.fEntry.hasTimeEvents();
+        if (hasTimeEvents) {
+            gc.setClipping(bounds);
+        }
+
         int height = bounds.height - getMarginForHeight(bounds.height);
         setFontForHeight(height, gc);
 
-        int leftMargin = MARGIN + item.fLevel * EXPAND_SIZE;
-        if (item.fHasChildren) {
-            gc.setForeground(getColorScheme().getFgColorGroup(false, false));
-            gc.setBackground(getColorScheme().getBkColor(false, false, false));
-            Rectangle rect = Utils.clone(bounds);
-            rect.x += leftMargin;
-            rect.y += (bounds.height - EXPAND_SIZE) / 2;
-            rect.width = EXPAND_SIZE;
-            rect.height = EXPAND_SIZE;
-            gc.fillRectangle(rect);
-            gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1);
-            int midy = rect.y + rect.height / 2;
-            gc.drawLine(rect.x + 2, midy, rect.x + rect.width - 3, midy);
-            if (!item.fExpanded) {
-                int midx = rect.x + rect.width / 2;
-                gc.drawLine(midx, rect.y + 2, midx, rect.y + rect.height - 3);
-            }
-        }
-        leftMargin += EXPAND_SIZE + MARGIN;
-
-        Image img = fTimeGraphProvider.getItemImage(item.fEntry);
-        if (img != null) {
-            // draw icon
-            int imgHeight = img.getImageData().height;
-            int imgWidth = img.getImageData().width;
-            int x = leftMargin;
-            int y = bounds.y + (bounds.height - imgHeight) / 2;
-            gc.drawImage(img, x, y);
-            leftMargin += imgWidth + MARGIN;
-        }
-        String name = item.fName;
-        Point size = gc.stringExtent(name);
-        if (fIdealNameSpace < leftMargin + size.x + MARGIN) {
-            fIdealNameSpace = leftMargin + size.x + MARGIN;
-        }
-        if (hasTimeEvents) {
-            // cut long string with "..."
-            int width = bounds.width - leftMargin;
-            int cuts = 0;
-            while (size.x > width && name.length() > 1) {
-                cuts++;
-                name = name.substring(0, name.length() - 1);
-                size = gc.stringExtent(name + "..."); //$NON-NLS-1$
-            }
-            if (cuts > 0) {
-                name += "..."; //$NON-NLS-1$
-            }
-        }
+        String name = fLabelProvider == null ? item.fName : fLabelProvider.getColumnText(item.fEntry, 0);
         Rectangle rect = Utils.clone(bounds);
-        rect.x += leftMargin;
-        rect.width -= leftMargin;
-        // draw text
-        if (rect.width > 0) {
-            rect.y += (bounds.height - gc.stringExtent(name).y) / 2;
+        rect.y += (bounds.height - gc.stringExtent(name).y) / 2;
+        TreeColumn[] columns = fTree.getColumns();
+        int idealNameSpace = 0;
+        for (int i = 0; i < columns.length; i++) {
+            int columnIndex = fTree.getColumnOrder()[i];
+            TreeColumn column = columns[columnIndex];
+            rect.width = column.getWidth();
+            gc.setClipping(rect.x, bounds.y, Math.min(rect.width, bounds.x + bounds.width - rect.x - SNAP_WIDTH), bounds.height);
+            int width = MARGIN;
+            if (i == 0) {
+                // first visible column
+                width += item.fLevel * EXPAND_SIZE;
+                if (item.fHasChildren) {
+                    // draw expand/collapse arrow
+                    gc.setBackground(getColorScheme().getColor(TimeGraphColorScheme.DARK_GRAY));
+                    int arrowHeightHint = (height < 4) ? height : (height < 6) ? height - 1 : height - 2;
+                    int arrowHalfHeight = Math.max(1, Math.min(arrowHeightHint, (int) Math.round((EXPAND_SIZE - 2) / ARROW_RATIO))) / 2;
+                    int arrowHalfWidth = (Math.max(1, Math.min(EXPAND_SIZE - 2, (int) Math.round(arrowHeightHint * ARROW_RATIO))) + 1) / 2;
+                    int x1 = bounds.x + width + 1;
+                    int x2 = x1 + 2 * arrowHalfWidth;
+                    int midy = bounds.y + bounds.height / 2;
+                    int y1 = midy - arrowHalfHeight;
+                    int y2 = midy + arrowHalfHeight;
+                    if (!item.fExpanded) { // >
+                        gc.fillPolygon(new int[] { x1, y1, x2, midy, x1, y2 });
+                    } else { // v
+                        int midx = x1 + arrowHalfWidth;
+                        gc.fillPolygon(new int[] { x1, y1, x2, y1, midx, y2 });
+                    }
+                }
+                width += EXPAND_SIZE + MARGIN;
+
+                Image img = fLabelProvider != null ? fLabelProvider.getColumnImage(item.fEntry, columnIndex)
+                        : columnIndex == 0 ? fTimeGraphProvider.getItemImage(item.fEntry) : null;
+                if (img != null) {
+                    // draw icon
+                    int imgHeight = img.getImageData().height;
+                    int imgWidth = img.getImageData().width;
+                    int x = width;
+                    int y = bounds.y + (bounds.height - imgHeight) / 2;
+                    gc.drawImage(img, x, y);
+                    width += imgWidth + MARGIN;
+                }
+            } else {
+                if (fLabelProvider == null) {
+                    break;
+                }
+            }
+            String label = fLabelProvider != null ? fLabelProvider.getColumnText(item.fEntry, columnIndex)
+                    : columnIndex == 0 ? item.fName : ""; //$NON-NLS-1$
             gc.setForeground(getColorScheme().getFgColor(item.fSelected, fIsInFocus));
-            int textWidth = Utils.drawText(gc, name, rect, true);
-            leftMargin += textWidth + MARGIN;
-
-            if (hasTimeEvents) {
-                // draw middle line
-                rect.x = bounds.x + leftMargin;
-                rect.y = bounds.y;
-                rect.width = bounds.width - rect.x;
-                drawMidLine(rect, gc);
+            Rectangle textRect = new Rectangle(rect.x + width, rect.y, rect.width - width, rect.height);
+            int textWidth = Utils.drawText(gc, label, textRect, true);
+            width += textWidth + MARGIN;
+            if (textWidth > 0) {
+                idealNameSpace = rect.x + width;
+            }
+            if (columns.length == 1) {
+                drawMidLine(new Rectangle(bounds.x + width, bounds.y, bounds.x + bounds.width, bounds.height), gc);
             }
+            if (fAutoResizeColumns && width > column.getWidth()) {
+                column.setData(PREFERRED_WIDTH, width);
+                column.setWidth(width);
+            }
+            gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.MID_LINE));
+            if (i < columns.length - 1) {
+                // not the last visible column: draw the vertical cell border
+                int x = rect.x + rect.width - 1;
+                gc.drawLine(x, bounds.y, x, bounds.y + bounds.height);
+            }
+            rect.x += rect.width;
         }
+        fIdealNameSpace = Math.max(fIdealNameSpace, idealNameSpace);
+
+        gc.setClipping((Rectangle) null);
     }
 
     /**
@@ -2711,12 +2841,9 @@ public class TimeGraphControl extends TimeGraphBaseControl
 
     @Override
     public void mouseDown(MouseEvent e) {
-        if (fDragState != DRAG_NONE || null == fTimeProvider ||
-                fTimeProvider.getTime0() == fTimeProvider.getTime1() ||
-                getSize().x - fTimeProvider.getNameSpace() <= 0) {
+        if (fDragState != DRAG_NONE) {
             return;
         }
-        int idx;
         if (1 == e.button && (e.stateMask & SWT.MODIFIER_MASK) == 0) {
             int nameSpace = fTimeProvider.getNameSpace();
             if (nameSpace != 0 && isOverSplitLine(e.x)) {
@@ -2724,13 +2851,17 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 fDragButton = e.button;
                 fDragX = e.x;
                 fDragX0 = fDragX;
-                fTime0bak = fTimeProvider.getTime0();
-                fTime1bak = fTimeProvider.getTime1();
                 redraw();
                 updateCursor(e.x, e.stateMask);
                 return;
             }
         }
+        if (fTimeProvider == null ||
+                fTimeProvider.getTime0() == fTimeProvider.getTime1() ||
+                getSize().x - fTimeProvider.getNameSpace() <= 0) {
+            return;
+        }
+        int idx;
         if (1 == e.button && ((e.stateMask & SWT.MODIFIER_MASK) == 0 || (e.stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT)) {
             int nameSpace = fTimeProvider.getNameSpace();
             idx = getItemIndexAtY(e.y);
index 4cecd5708c0dc7043d2b5520953ff5c130ce6687..af4670a0981285f702bad7e6f9b798bb246728bc 100644 (file)
@@ -57,7 +57,6 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
         MouseListener, MouseMoveListener {
 
     private static final int BASE_10 = 10;
-    private static final int X_OFFSET = 4;
     private static final int Y_OFFSET = 4;
 
     private static final int MIN_SECOND_FACTOR = 20;
@@ -317,7 +316,6 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
 
         long time0 = fTimeProvider.getTime0();
         long time1 = fTimeProvider.getTime1();
-        int leftSpace = fTimeProvider.getNameSpace();
         int timeSpace = fTimeProvider.getTimeSpace();
 
         gc.setBackground(getColorScheme().getColor(TimeGraphColorScheme.TOOL_BACKGROUND));
@@ -325,18 +323,6 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
         Rectangle rect0 = new Rectangle(0, 0, 0, 0);
         Utils.init(rect0, rect);
 
-        // draw top left area
-        rect0.width = leftSpace;
-        rect0.x += X_OFFSET;
-        rect0.width -= X_OFFSET;
-        Rectangle absHeaderRect = new Rectangle(rect0.x, rect0.y, rect0.width, rect0.height);
-        rect0.x -= X_OFFSET;
-        rect0.width += X_OFFSET;
-
-        // prepare and draw right rect of the timescale
-        rect0.x += leftSpace;
-        rect0.width = rect.width - leftSpace;
-
         // draw bottom border and erase all other area
         gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1,
                 rect.y + rect.height - 1);
@@ -359,23 +345,17 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
 
         // draw range decorators
         if (DRAG_EXTERNAL == fDragState) {
-            int x1 = leftSpace + fDragX0;
-            int x2 = leftSpace + fDragX;
+            int x1 = fDragX0;
+            int x2 = fDragX;
             drawRangeDecorators(rect0, gc, x1, x2);
         } else {
-            int x1;
-            int x2;
             long selectionBegin = fTimeProvider.getSelectionBegin();
             long selectionEnd = fTimeProvider.getSelectionEnd();
-            x1 = SaturatedArithmetic.add(leftSpace, (int) ((selectionBegin - time0) * pixelsPerNanoSec));
-            x2 = SaturatedArithmetic.add(leftSpace, (int) ((selectionEnd - time0) * pixelsPerNanoSec));
+            int x1 = (int) ((selectionBegin - time0) * pixelsPerNanoSec);
+            int x2 = (int) ((selectionEnd - time0) * pixelsPerNanoSec);
             drawRangeDecorators(rect0, gc, x1, x2);
         }
 
-        if (rect0.isEmpty()) {
-            return;
-        }
-
         // draw time scale ticks
         rect0.y = rect.y;
         rect0.height = rect.height - Y_OFFSET;
@@ -393,23 +373,19 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
 
         int y = rect0.y + rect0.height;
 
-        if (fTimeProvider != null && fTimeProvider.getTimeFormat() == TimeFormat.CALENDAR) {
-            timeDraw.drawAbsHeader(gc, time, absHeaderRect);
-        }
-
         List<Integer> tickList = new ArrayList<>();
         while (true) {
-            int x = SaturatedArithmetic.add(rect.x + leftSpace, (int) (Math.floor((time - time0) * pixelsPerNanoSec)));
-            if (x >= rect.x + leftSpace + rect.width - rect0.width) {
+            int x = SaturatedArithmetic.add(rect.x, (int) (Math.floor((time - time0) * pixelsPerNanoSec)));
+            if (x >= rect.x + rect.width - rect0.width) {
                 break;
             }
-            if (x >= rect.x + leftSpace) {
+            if (x >= rect.x) {
                 gc.drawLine(x, y, x, y + Y_OFFSET);
                 rect0.x = x;
                 if (x + rect0.width <= rect.x + rect.width) {
                     timeDraw.draw(gc, time, rect0);
                 }
-                tickList.add(x);
+                tickList.add(x + fTimeProvider.getNameSpace());
             }
             if (pixelsPerNanoSec == 0 || time > Long.MAX_VALUE - timeDelta || timeDelta == 0) {
                 break;
This page took 0.110881 seconds and 5 git commands to generate.