From 9d92c2d255711df9a36271447c71d39d8ebbffe3 Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Tue, 27 Sep 2016 11:46:01 -0400 Subject: [PATCH] timing.ui: Make doubleclicking on a flame graph event zoom on it 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 Reviewed-on: https://git.eclipse.org/r/82012 Reviewed-by: Hudson CI Reviewed-by: Patrick Tasse Tested-by: Patrick Tasse --- .../timing/ui/flamegraph/FlameGraphView.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/flamegraph/FlameGraphView.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/flamegraph/FlameGraphView.java index 575fcf9260..87c9773c96 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/flamegraph/FlameGraphView.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/flamegraph/FlameGraphView.java @@ -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(); -- 2.34.1