tmf.ui: bug 505695 fix time graph views with GTK
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / widgets / timegraph / TimeGraphCombo.java
index b861f6ff288be9fef93db9f9271ba30a770dc4f1..0c27d2515b296c2fc8907e5f5217a580e6fa2457 100644 (file)
@@ -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<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));
@@ -851,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) {
@@ -1091,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();
@@ -1103,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;
@@ -1379,18 +1380,6 @@ public class TimeGraphCombo extends Composite {
                 tree.removePaintListener(this);
                 doAlignTreeItems();
                 redraw();
-                /*
-                 * Bug in GTK. Calling setTopItem() can scroll to the wrong item
-                 * when the 'tree view' is dirty. Set it again once it is clean.
-                 */
-                if (SWT.getPlatform().equals("gtk")) { //$NON-NLS-1$
-                    tree.getDisplay().asyncExec(() -> {
-                        TreeItem topItem = tree.getTopItem();
-                        if (!tree.isDisposed() && topItem != null && !topItem.isDisposed()) {
-                            tree.setTopItem(topItem);
-                        }
-                    });
-                }
             }
         });
         /* Make sure the paint event is triggered. */
This page took 0.028267 seconds and 5 git commands to generate.