From: Matthew Khouzam Date: Tue, 31 May 2016 00:19:22 +0000 (-0400) Subject: tmf.ui: [bug 494974] Fix left panel click handling in timegraph in Linux X-Git-Url: http://git.efficios.com/?p=deliverable%2Ftracecompass.git;a=commitdiff_plain;h=8f5566f487567d35819733915d4d4f51f01e1f4d tmf.ui: [bug 494974] Fix left panel click handling in timegraph in Linux Clicking on the left panel in Linux currently deselects the entry. This behavior is particularly egregious in the case of UI unit tests. Change-Id: I18fbe001c6b7325c6618e46c22f13ad976357abe Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/73998 Reviewed-by: Hudson CI Reviewed-by: Patrick Tasse Tested-by: Patrick Tasse --- diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphCombo.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphCombo.java index 1191865d4b..de2c062932 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphCombo.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphCombo.java @@ -611,15 +611,16 @@ public class TimeGraphCombo extends Composite { // prevent mouse button from selecting a filler tree item tree.addListener(SWT.MouseDown, event -> { - TreeItem treeItem = tree.getItem(new Point(event.x, event.y)); - if (treeItem == null || treeItem.getData() == FILLER) { + List treeItems = getVisibleExpandedItems(tree, false); + if (treeItems.isEmpty()) { + event.doit = false; + fTreeViewer.setSelection(new StructuredSelection()); + fTimeGraphViewer.setSelection(null); + return; + } + TreeItem lastTreeItem = treeItems.get(treeItems.size() - 1); + if (event.y >= lastTreeItem.getBounds().y + lastTreeItem.getBounds().height) { event.doit = false; - List treeItems = getVisibleExpandedItems(tree, false); - if (treeItems.size() == 0) { - fTreeViewer.setSelection(new StructuredSelection()); - fTimeGraphViewer.setSelection(null); - return; - } // this prevents from scrolling up when selecting // the partially visible tree item at the bottom tree.select(treeItems.get(treeItems.size() - 1));