tmf: Fix mouse detect handling in TimeGraphControl
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Thu, 7 Apr 2016 12:42:38 +0000 (08:42 -0400)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Tue, 12 Apr 2016 14:12:59 +0000 (10:12 -0400)
Prevent the menu be shown before mouse up event is received. Otherwise
the zoom won't work. This is because the mouse up event will be received
by the menu pop-up and not by the TimeGraphControl instance.

Change-Id: Iaa905d39205a4a45abb8fd5cfeaac81664561820
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/70138
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/resources/ResourcesView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java

index 6e2df727d3f6f4f85e44163477c2cca51a30fc65..deb5b62f27955c5c000c1e32ccbfef029ed481d9 100644 (file)
@@ -25,14 +25,14 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernel.Attributes;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.swt.events.MenuDetectEvent;
 import org.eclipse.swt.events.MenuDetectListener;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Menu;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernel.Attributes;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.signals.TmfCpuSelectedSignal;
 import org.eclipse.tracecompass.analysis.os.linux.ui.views.resources.ResourcesEntry.Type;
 import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Messages;
@@ -114,7 +114,7 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
         final TimeGraphViewer timeGraphViewer = getTimeGraphViewer();
         Menu menu = fMenuMgr.createContextMenu(timeGraphViewer.getTimeGraphControl());
         timeGraphViewer.getTimeGraphControl().setMenu(menu);
-        getTimeGraphViewer().getTimeGraphControl().addMenuDetectListener(new MenuDetectListener() {
+        getTimeGraphViewer().getTimeGraphControl().addTimeGraphEntryMenuListener(new MenuDetectListener() {
             @Override
             public void menuDetected(MenuDetectEvent event) {
                 fMenuMgr.removeAll();
index f05e76d4b8395b62f48267b25a9963cd50ee8803..b1e75b710597303d98f7bdcf6347386c6be8fbe3 100644 (file)
@@ -70,6 +70,7 @@ import org.eclipse.swt.widgets.Composite;
 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.tracecompass.tmf.core.signal.TmfSignalManager;
 import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentInfo;
 import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentSignal;
@@ -3176,6 +3177,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
         if (null == fTimeProvider) {
             return;
         }
+        Point p = toControl(e.x, e.y);
         if (e.detail == SWT.MENU_MOUSE) {
             if (fPendingMenuDetectEvent == null) {
                 /* Feature in Linux. The MenuDetectEvent is received before mouseDown.
@@ -3183,10 +3185,16 @@ public class TimeGraphControl extends TimeGraphBaseControl
                  * This allows for the method to detect if mouse is used to drag zoom.
                  */
                 fPendingMenuDetectEvent = e;
+                /*
+                 *  Prevent the platform to show the menu when returning. The
+                 *  menu will be shown (see below) when this method is called
+                 *  again during mouseup().
+                 */
+                e.doit = false;
                 return;
             }
             fPendingMenuDetectEvent = null;
-            if (fDragState != DRAG_ZOOM || fDragX != fDragX0) {
+            if ((p.x >= fTimeProvider.getNameSpace()) && (fDragState != DRAG_ZOOM || fDragX != fDragX0)) {
                 return;
             }
         } else {
@@ -3194,9 +3202,9 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 return;
             }
         }
-        Point p = toControl(e.x, e.y);
         int idx = getItemIndexAtY(p.y);
         if (idx >= 0 && idx < fItemData.fExpandedItems.length) {
+            e.doit = true;
             Item item = fItemData.fExpandedItems[idx];
             ITimeGraphEntry entry = item.fEntry;
             if (entry.hasTimeEvents()) {
@@ -3204,11 +3212,19 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 if (event != null) {
                     e.data = event;
                     fireMenuEventOnTimeEvent(e);
+                    Menu menu = getMenu();
+                    if (e.doit && (menu != null)) {
+                        menu.setVisible(true);
+                    }
                     return;
                 }
             }
             e.data = entry;
             fireMenuEventOnTimeGraphEntry(e);
+            Menu menu = getMenu();
+            if (e.doit && (menu != null)) {
+                menu.setVisible(true);
+            }
         }
     }
 
This page took 0.029018 seconds and 5 git commands to generate.