timing.ui: Make doubleclicking on a flame graph event zoom on it
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 27 Sep 2016 15:46:01 +0000 (11:46 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 30 Sep 2016 15:07:46 +0000 (11:07 -0400)
This aims to bring feature parity between trace compass flame graphs
and the original flame graphs designed by Brendan Gregg.

Change-Id: I6194b1c95b33e258cfcb40991949bbd19a25ce73
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/82012
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/flamegraph/FlameGraphView.java

index 575fcf926019d26247905878d8a02f0134e7e57c..87c9773c965597c033f96da38b495c29729f3511 100644 (file)
@@ -31,6 +31,8 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.MenuDetectEvent;
 import org.eclipse.swt.events.MenuDetectListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Menu;
@@ -74,7 +76,6 @@ public class FlameGraphView extends TmfView {
     private static final ImageDescriptor SORT_BY_ID_ICON = Activator.getDefault().getImageDescripterFromPath("icons/etool16/sort_num.gif"); //$NON-NLS-1$
     private static final ImageDescriptor SORT_BY_ID_REV_ICON = Activator.getDefault().getImageDescripterFromPath("icons/etool16/sort_num_rev.gif"); //$NON-NLS-1$
 
-
     private TimeGraphViewer fTimeGraphViewer;
 
     private FlameGraphContentProvider fTimeGraphContentProvider;
@@ -114,9 +115,29 @@ public class FlameGraphView extends TmfView {
 
         getSite().setSelectionProvider(fTimeGraphViewer.getSelectionProvider());
         createTimeEventContextMenu();
+        fTimeGraphViewer.getTimeGraphControl().addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseDoubleClick(MouseEvent e) {
+                TimeGraphControl timeGraphControl = getTimeGraphViewer().getTimeGraphControl();
+                ISelection selection = timeGraphControl.getSelection();
+                if (selection instanceof IStructuredSelection) {
+                    for (Object object : ((IStructuredSelection) selection).toList()) {
+                        if (object instanceof FlamegraphEvent) {
+                            FlamegraphEvent event = (FlamegraphEvent) object;
+                            long startTime = event.getTime();
+                            long endTime = startTime + event.getDuration();
+                            getTimeGraphViewer().setStartFinishTime(startTime, endTime);
+                            break;
+                        }
+                    }
+                }
+            }
+        });
     }
 
-
+    private TimeGraphViewer getTimeGraphViewer() {
+        return fTimeGraphViewer;
+    }
     /**
      * Handler for the trace opened signal
      *
@@ -241,7 +262,7 @@ public class FlameGraphView extends TmfView {
      * Fill context menu
      *
      * @param menuManager
-     *          a menuManager to fill
+     *            a menuManager to fill
      */
     protected void fillTimeEventContextMenu(@NonNull IMenuManager menuManager) {
         ISelection selection = getSite().getSelectionProvider().getSelection();
This page took 0.025434 seconds and 5 git commands to generate.