tmf.ui: [bug 494974] Fix left panel click handling in timegraph in Linux
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / widgets / timegraph / TimeGraphCombo.java
index bc582af9140c3c0ee1fdb5869c5f36726a1ce245..de2c062932a24ed642df070aa87c1f914fffc06a 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2015 Ericsson, others
+ * Copyright (c) 2012, 2016 Ericsson, others
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -189,6 +189,9 @@ public class TimeGraphCombo extends Composite {
                      * finished updating the item heights.
                      */
                     getDisplay().asyncExec(() -> {
+                        if (isDisposed()) {
+                            return;
+                        }
                         super.setElementPosition(entry, y);
                         alignTreeItems(false);
                     });
@@ -608,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<TreeItem> 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<TreeItem> 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));
@@ -848,7 +852,7 @@ public class TimeGraphCombo extends Composite {
      * Get the show filter dialog action.
      *
      * @return The Action object
-     * @since 2.0
+     * @since 1.2
      */
     public ShowFilterDialogAction getShowFilterDialogAction() {
         if (fShowFilterDialogAction == null) {
@@ -1029,6 +1033,9 @@ public class TimeGraphCombo extends Composite {
         getDisplay().asyncExec(new Runnable() {
             @Override
             public void run() {
+                if (isDisposed()) {
+                    return;
+                }
                 alignTreeItems(true);
             }
         });
@@ -1085,7 +1092,7 @@ public class TimeGraphCombo extends Composite {
      * Returns this viewer's filters.
      *
      * @return an array of viewer filters
-     * @since 2.0
+     * @since 1.2
      */
     public @NonNull ViewerFilter[] getFilters() {
         return fTimeGraphViewer.getFilters();
@@ -1097,7 +1104,7 @@ public class TimeGraphCombo extends Composite {
      *
      * @param filters
      *            an array of viewer filters, or null
-     * @since 2.0
+     * @since 1.2
      */
     public void setFilters(@NonNull ViewerFilter[] filters) {
         fInhibitTreeSelection = true;
This page took 0.026063 seconds and 5 git commands to generate.