lttng: Add arrows in Control Flow view
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / widgets / timegraph / TimeGraphViewer.java
index cbbb5b2190f2ff4400d32c3f9eebae820b9bdfb7..02bbf5acaaef64774629f918481afa4b055d9d12 100644 (file)
@@ -20,6 +20,8 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.linuxtools.internal.tmf.ui.Activator;
@@ -69,6 +71,7 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     private static final int MAX_NAME_WIDTH = 1000;
     private static final int DEFAULT_HEIGHT = 22;
     private static final long RECENTERING_MARGIN_FACTOR = 50;
+    private static final String HIDE_ARROWS_KEY = "hide.arrows"; //$NON-NLS-1$
 
     private long fMinTimeInterval;
     private ITimeGraphEntry fSelectedEntry;
@@ -98,7 +101,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     private List<ITimeGraphTimeListener> fTimeListeners = new ArrayList<ITimeGraphTimeListener>();
     private List<ITimeGraphRangeListener> fRangeListeners = new ArrayList<ITimeGraphRangeListener>();
 
-    // Time format, using Epoch reference, Relative time format(default) or Number
+    // Time format, using Epoch reference, Relative time format(default) or
+    // Number
     private TimeFormat fTimeFormat = TimeFormat.RELATIVE;
     private int fBorderWidth = 0;
     private int fTimeScaleHeight = DEFAULT_HEIGHT;
@@ -111,6 +115,7 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     private Action fPreviousItemAction;
     private Action fZoomInAction;
     private Action fZoomOutAction;
+    private Action fHideArrowsAction;
 
     /**
      * Standard constructor
@@ -127,7 +132,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     /**
      * Sets the timegraph provider used by this timegraph viewer.
      *
-     * @param timeGraphProvider the timegraph provider
+     * @param timeGraphProvider
+     *            the timegraph provider
      */
     public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider) {
         fTimeGraphProvider = timeGraphProvider;
@@ -137,10 +143,12 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     }
 
     /**
-     * Sets or clears the input for this time graph viewer.
-     * The input array should only contain top-level elements.
+     * Sets or clears the input for this time graph viewer. The input array
+     * should only contain top-level elements.
      *
-     * @param input The input of this time graph viewer, or <code>null</code> if none
+     * @param input
+     *            The input of this time graph viewer, or <code>null</code> if
+     *            none
      */
     public void setInput(ITimeGraphEntry[] input) {
         ITimeGraphEntry[] realInput = input;
@@ -982,7 +990,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     }
 
     /**
-     * @param tf the {@link TimeFormat} used to display timestamps
+     * @param tf
+     *            the {@link TimeFormat} used to display timestamps
      * @since 2.0
      */
     public void setTimeFormat(TimeFormat tf) {
@@ -1007,7 +1016,7 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     public void setBorderWidth(int borderWidth) {
         if (borderWidth > -1) {
             this.fBorderWidth = borderWidth;
-            GridLayout gl = (GridLayout)fDataViewer.getLayout();
+            GridLayout gl = (GridLayout) fDataViewer.getLayout();
             gl.marginHeight = borderWidth;
         }
     }
@@ -1073,7 +1082,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     /**
      * Set the width for the name column
      *
-     * @param width The width
+     * @param width
+     *            The width
      */
     public void setNameWidthPref(int width) {
         fNameWidthPref = width;
@@ -1126,7 +1136,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     /**
      * Return the x coordinate corresponding to a time
      *
-     * @param time the time
+     * @param time
+     *            the time
      * @return the x coordinate corresponding to the time
      *
      * @since 2.0
@@ -1138,7 +1149,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     /**
      * Return the time corresponding to an x coordinate
      *
-     * @param x the x coordinate
+     * @param x
+     *            the x coordinate
      * @return the time corresponding to the x coordinate
      *
      * @since 2.0
@@ -1445,6 +1457,40 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
         return fZoomOutAction;
     }
 
+    /**
+     * Get the hide arrows action
+     *
+     * @param dialogSettings
+     *            The dialog settings section where the state should be stored,
+     *            or null
+     *
+     * @return The Action object
+     *
+     * @since 2.1
+     */
+    public Action getHideArrowsAction(final IDialogSettings dialogSettings) {
+        if (fHideArrowsAction == null) {
+            fHideArrowsAction = new Action(Messages.TmfTimeGraphViewer_HideArrowsActionNameText, IAction.AS_CHECK_BOX) {
+                @Override
+                public void run() {
+                    boolean hideArrows = fHideArrowsAction.isChecked();
+                    fTimeGraphCtrl.hideArrows(hideArrows);
+                    refresh();
+                    if (dialogSettings != null) {
+                        dialogSettings.put(HIDE_ARROWS_KEY, hideArrows);
+                    }
+                }
+            };
+            fHideArrowsAction.setToolTipText(Messages.TmfTimeGraphViewer_HideArrowsActionToolTipText);
+            fHideArrowsAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HIDE_ARROWS));
+            if (dialogSettings != null) {
+                boolean hideArrows = dialogSettings.getBoolean(HIDE_ARROWS_KEY);
+                fTimeGraphCtrl.hideArrows(hideArrows);
+                fHideArrowsAction.setChecked(hideArrows);
+            }
+        }
+        return fHideArrowsAction;
+    }
 
     private void adjustVerticalScrollBar() {
         int topIndex = fTimeGraphCtrl.getTopIndex();
@@ -1464,7 +1510,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     }
 
     /**
-     * @param listener a {@link MenuDetectListener}
+     * @param listener
+     *            a {@link MenuDetectListener}
      * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#addTimeGraphEntryMenuListener(org.eclipse.swt.events.MenuDetectListener)
      * @since 1.2
      */
@@ -1473,7 +1520,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     }
 
     /**
-     * @param listener a {@link MenuDetectListener}
+     * @param listener
+     *            a {@link MenuDetectListener}
      * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#removeTimeGraphEntryMenuListener(org.eclipse.swt.events.MenuDetectListener)
      * @since 1.2
      */
@@ -1482,7 +1530,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     }
 
     /**
-     * @param listener a {@link MenuDetectListener}
+     * @param listener
+     *            a {@link MenuDetectListener}
      * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#addTimeEventMenuListener(org.eclipse.swt.events.MenuDetectListener)
      * @since 1.2
      */
@@ -1491,7 +1540,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     }
 
     /**
-     * @param listener a {@link MenuDetectListener}
+     * @param listener
+     *            a {@link MenuDetectListener}
      * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#removeTimeEventMenuListener(org.eclipse.swt.events.MenuDetectListener)
      * @since 1.2
      */
@@ -1500,7 +1550,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     }
 
     /**
-     * @param filter The filter object to be attached to the view
+     * @param filter
+     *            The filter object to be attached to the view
      * @since 2.0
      */
     public void addFilter(ViewerFilter filter) {
@@ -1509,7 +1560,8 @@ public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
     }
 
     /**
-     * @param filter The filter object to be attached to the view
+     * @param filter
+     *            The filter object to be attached to the view
      * @since 2.0
      */
     public void removeFilter(ViewerFilter filter) {
This page took 0.028122 seconds and 5 git commands to generate.