analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / widgets / timegraph / widgets / TimeGraphControl.java
index cb3942bd534975e7d3833913f20805a1a2c3edba..136105c39c57bd5300dbc239ebb238d015486ea1 100644 (file)
@@ -22,6 +22,7 @@ package org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -63,6 +64,10 @@ 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.tracecompass.tmf.core.signal.TmfSignalManager;
+import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentInfo;
+import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentSignal;
+import org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphColorListener;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider2;
@@ -80,7 +85,6 @@ import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.TimeForma
 /**
  * Time graph control implementation
  *
- * @version 1.0
  * @author Alvaro Sanchez-Leon
  * @author Patrick Tasse
  */
@@ -89,8 +93,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
         MouseWheelListener, MouseTrackListener, TraverseListener, ISelectionProvider,
         MenuDetectListener, ITmfTimeGraphDrawingHelper, ITimeGraphColorListener, Listener {
 
-    /** Constant indicating that all levels of the time graph should be expanded
-     * @since 3.1 */
+    /** Constant indicating that all levels of the time graph should be expanded */
     public static final int ALL_LEVELS = AbstractTreeViewer.ALL_LEVELS;
 
     private static final int DRAG_NONE = 0;
@@ -109,6 +112,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
     private static final int ARROW_HOVER_MAX_DIST = 5;
 
     private static final int NO_STATUS = -1;
+    private static final int STATUS_WITHOUT_CURSOR_TIME = -2;
 
     /** Resource manager */
     private LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());
@@ -126,6 +130,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
     private int fMinimumItemWidth = 0;
     private int fTopIndex = 0;
     private int fDragState = DRAG_NONE;
+    private boolean fDragBeginMarker = false;
     private int fDragButton;
     private int fDragX0 = 0;
     private int fDragX = 0;
@@ -205,7 +210,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * Gets the timegraph provider used by this timegraph viewer.
      *
      * @return the timegraph provider, or <code>null</code> if not set.
-     * @since 3.0
      */
     public ITimeGraphPresentationProvider getTimeGraphProvider() {
         return fTimeGraphProvider;
@@ -215,7 +219,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * Gets the color map used by this timegraph viewer.
      *
      * @return a color map, or <code>null</code> if not set.
-     * @since 3.0
      */
     public Color[] getEventColorMap() {
         return fEventColorMap;
@@ -237,7 +240,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *
      * @param statusLineManager
      *            The status line manager, or null to disable status line messages
-     * @since 2.1
      */
     public void setStatusLineManager(IStatusLineManager statusLineManager) {
         if (fStatusLineManager != null && statusLineManager == null) {
@@ -251,7 +253,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *
      * @param timeGraphScale
      *            The time graph scale
-     * @since 2.1
      */
     public void setTimeGraphScale(TimeGraphScale timeGraphScale) {
         fTimeGraphScale = timeGraphScale;
@@ -316,7 +317,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *
      * @param listener
      *            The listener to add
-     * @since 3.1
      */
     public void addDragSelectionListener(ITimeGraphTimeListener listener) {
         if (listener == null) {
@@ -333,7 +333,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *
      * @param listener
      *            The listener to remove
-     * @since 3.1
      */
     public void removeDragSelectionListener(ITimeGraphTimeListener listener) {
         if (null != fDragSelectionListeners) {
@@ -348,7 +347,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *            Time interval start
      * @param end
      *            Time interval end
-     * @since 3.1
      */
     public void fireDragSelectionChanged(long start, long end) {
         // check for backward intervals
@@ -410,13 +408,23 @@ public class TimeGraphControl extends TimeGraphBaseControl
     /**
      * Refresh the links (arrows) of this widget
      *
-     * @param events The link events to refresh
-     * @since 2.1
+     * @param events The link event list
      */
     public void refreshArrows(List<ILinkEvent> events) {
         fItemData.refreshArrows(events);
     }
 
+    /**
+     * Get the links (arrows) of this widget
+     *
+     * @return The unmodifiable link event list
+     *
+     * @since 1.0
+     */
+    public List<ILinkEvent> getArrows() {
+        return Collections.unmodifiableList(fItemData.fLinks);
+    }
+
     boolean ensureVisibleItem(int idx, boolean redraw) {
         boolean changed = false;
         int index = idx;
@@ -475,7 +483,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * @param level
      *            non-negative level, or <code>ALL_LEVELS</code> to expand all
      *            levels of the tree
-     * @since 3.1
      */
     public void setAutoExpandLevel(int level) {
         fAutoExpandLevel = level;
@@ -487,7 +494,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * @return non-negative level, or <code>ALL_LEVELS</code> if all levels of
      *         the tree are expanded automatically
      * @see #setAutoExpandLevel
-     * @since 3.1
      */
     public int getAutoExpandLevel() {
         return fAutoExpandLevel;
@@ -512,8 +518,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
 
     /**
      * Collapses all nodes of the viewer's tree, starting with the root.
-     *
-     * @since 2.0
      */
     public void collapseAll() {
         for (Item item : fItemData.fItems) {
@@ -525,8 +529,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
 
     /**
      * Expands all nodes of the viewer's tree, starting with the root.
-     *
-     * @since 2.0
      */
     public void expandAll() {
         for (Item item : fItemData.fItems) {
@@ -581,9 +583,9 @@ public class TimeGraphControl extends TimeGraphBaseControl
 
     /**
      * Add a menu listener on {@link ITimeGraphEntry}s
+     *
      * @param listener
      *            The listener to add
-     * @since 1.2
      */
     public void addTimeGraphEntryMenuListener(MenuDetectListener listener) {
         if (!fTimeGraphEntryMenuListeners.contains(listener)) {
@@ -596,7 +598,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *
      * @param listener
      *            The listener to remove
-     * @since 1.2
      */
     public void removeTimeGraphEntryMenuListener(MenuDetectListener listener) {
         if (fTimeGraphEntryMenuListeners.contains(listener)) {
@@ -621,7 +622,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *
      * @param listener
      *            The listener to add
-     * @since 1.2
      */
     public void addTimeEventMenuListener(MenuDetectListener listener) {
         if (!fTimeEventMenuListeners.contains(listener)) {
@@ -634,7 +634,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *
      * @param listener
      *            The listener to remove
-     * @since 1.2
      */
     public void removeTimeEventMenuListener(MenuDetectListener listener) {
         if (fTimeEventMenuListeners.contains(listener)) {
@@ -735,8 +734,11 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *
      * @param n
      *            1 for next event, -1 for previous event
+     * @param extend
+     *            true to extend selection range, false for single selection
+     * @since 1.0
      */
-    public void selectEvent(int n) {
+    public void selectEvent(int n, boolean extend) {
         if (null == fTimeProvider) {
             return;
         }
@@ -744,15 +746,15 @@ public class TimeGraphControl extends TimeGraphBaseControl
         if (trace == null) {
             return;
         }
-        long selectedTime = fTimeProvider.getSelectionBegin();
-        long endTime = fTimeProvider.getEndTime();
+        long selectedTime = fTimeProvider.getSelectionEnd();
+        long endTime = fTimeProvider.getMaxTime();
         ITimeEvent nextEvent;
-        if (-1 == n && selectedTime > endTime) {
+        if (n == -1 && selectedTime > endTime) {
             nextEvent = Utils.findEvent(trace, selectedTime, 0);
         } else {
             nextEvent = Utils.findEvent(trace, selectedTime, n);
         }
-        if (null == nextEvent && -1 == n) {
+        if (null == nextEvent && n == -1) {
             nextEvent = Utils.getFirstEvent(trace);
         }
         if (null != nextEvent) {
@@ -770,28 +772,45 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 // for previous event go to its end time unless we were already there
                 nextTime = nextEvent.getTime() + nextEvent.getDuration();
             }
-            fTimeProvider.setSelectedTimeNotify(nextTime, true);
+            if (extend) {
+                fTimeProvider.setSelectionRangeNotify(fTimeProvider.getSelectionBegin(), nextTime);
+            } else {
+                fTimeProvider.setSelectedTimeNotify(nextTime, true);
+            }
             fireSelectionChanged();
-        } else if (1 == n) {
-            fTimeProvider.setSelectedTimeNotify(endTime, true);
+        } else if (n == 1) {
+            if (extend) {
+                fTimeProvider.setSelectionRangeNotify(fTimeProvider.getSelectionBegin(), endTime);
+            } else {
+                fTimeProvider.setSelectedTimeNotify(endTime, true);
+            }
             fireSelectionChanged();
         }
+        updateStatusLine(STATUS_WITHOUT_CURSOR_TIME);
     }
 
     /**
      * Select the next event
+     *
+     * @param extend
+     *            true to extend selection range, false for single selection
+     * @since 1.0
      */
-    public void selectNextEvent() {
-        selectEvent(1);
+    public void selectNextEvent(boolean extend) {
+        selectEvent(1, extend);
         // Notify if visible time window has been adjusted
         fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getTime0(), fTimeProvider.getTime1());
     }
 
     /**
      * Select the previous event
+     *
+     * @param extend
+     *            true to extend selection range, false for single selection
+     * @since 1.0
      */
-    public void selectPrevEvent() {
-        selectEvent(-1);
+    public void selectPrevEvent(boolean extend) {
+        selectEvent(-1, extend);
         // Notify if visible time window has been adjusted
         fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getTime0(), fTimeProvider.getTime1());
     }
@@ -815,8 +834,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *
      * @param left
      *            true to scroll left, false to scroll right
-     *
-     * @since 3.2
      */
     public void horizontalScroll(boolean left) {
         long time0 = fTimeProvider.getTime0();
@@ -928,8 +945,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * Hide arrows
      *
      * @param hideArrows true to hide arrows
-     *
-     * @since 2.1
      */
     public void hideArrows(boolean hideArrows) {
         fHideArrows = hideArrows;
@@ -938,53 +953,67 @@ public class TimeGraphControl extends TimeGraphBaseControl
     /**
      * Follow the arrow forward
      *
-     * @since 2.1
+     * @param extend
+     *            true to extend selection range, false for single selection
+     * @since 1.0
      */
-    public void followArrowFwd() {
+    public void followArrowFwd(boolean extend) {
         ITimeGraphEntry trace = getSelectedTrace();
         if (trace == null) {
             return;
         }
-        long selectedTime = fTimeProvider.getSelectionBegin();
+        long selectedTime = fTimeProvider.getSelectionEnd();
         for (ILinkEvent link : fItemData.fLinks) {
             if (link.getEntry() == trace && link.getTime() == selectedTime) {
                 selectItem(link.getDestinationEntry(), false);
                 if (link.getDuration() != 0) {
-                    fTimeProvider.setSelectedTimeNotify(link.getTime() + link.getDuration(), true);
+                    if (extend) {
+                        fTimeProvider.setSelectionRangeNotify(fTimeProvider.getSelectionBegin(), link.getTime() + link.getDuration());
+                    } else {
+                        fTimeProvider.setSelectedTimeNotify(link.getTime() + link.getDuration(), true);
+                    }
                     // Notify if visible time window has been adjusted
                     fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getTime0(), fTimeProvider.getTime1());
                 }
                 fireSelectionChanged();
+                updateStatusLine(STATUS_WITHOUT_CURSOR_TIME);
                 return;
             }
         }
-        selectNextEvent();
+        selectNextEvent(extend);
     }
 
     /**
      * Follow the arrow backward
      *
-     * @since 2.1
+     * @param extend
+     *            true to extend selection range, false for single selection
+     * @since 1.0
      */
-    public void followArrowBwd() {
+    public void followArrowBwd(boolean extend) {
         ITimeGraphEntry trace = getSelectedTrace();
         if (trace == null) {
             return;
         }
-        long selectedTime = fTimeProvider.getSelectionBegin();
+        long selectedTime = fTimeProvider.getSelectionEnd();
         for (ILinkEvent link : fItemData.fLinks) {
             if (link.getDestinationEntry() == trace && link.getTime() + link.getDuration() == selectedTime) {
                 selectItem(link.getEntry(), false);
                 if (link.getDuration() != 0) {
-                    fTimeProvider.setSelectedTimeNotify(link.getTime(), true);
+                    if (extend) {
+                        fTimeProvider.setSelectionRangeNotify(fTimeProvider.getSelectionBegin(), link.getTime());
+                    } else {
+                        fTimeProvider.setSelectedTimeNotify(link.getTime(), true);
+                    }
                     // Notify if visible time window has been adjusted
                     fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getTime0(), fTimeProvider.getTime1());
                 }
                 fireSelectionChanged();
+                updateStatusLine(STATUS_WITHOUT_CURSOR_TIME);
                 return;
             }
         }
-        selectPrevEvent();
+        selectPrevEvent(extend);
     }
 
     /**
@@ -1039,7 +1068,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * @param y
      *            the y coordinate
      * @return the index of the item at the given location, of -1 if none.
-     * @since 3.0
      */
     protected int getItemIndexAtY(int y) {
         if (y < 0) {
@@ -1070,7 +1098,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *            a point in the widget
      * @return the {@link ITimeGraphEntry} at this point, or <code>null</code>
      *         if none.
-     * @since 3.0
      */
     protected ITimeGraphEntry getEntry(Point pt) {
         int idx = getItemIndexAtY(pt.y);
@@ -1084,7 +1111,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * @param pt
      *            a point in the widget
      * @return The closest arrow event, or null if there is none close enough.
-     * @since 3.2
      */
     protected ILinkEvent getArrow(Point pt) {
         if (fHideArrows) {
@@ -1112,9 +1138,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
         return null;
     }
 
-    /**
-     * @since 2.0
-     */
     @Override
     public int getXForTime(long time) {
         if (null == fTimeProvider) {
@@ -1129,9 +1152,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
         return x;
     }
 
-    /**
-     * @since 2.0
-     */
     @Override
     public long getTimeAtX(int coord) {
         if (null == fTimeProvider) {
@@ -1404,7 +1424,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
         ITimeGraphEntry entry = item.fEntry;
         long time0 = timeProvider.getTime0();
         long time1 = timeProvider.getTime1();
-        long selectedTime = fTimeProvider.getSelectionBegin();
+        long selectedTime = fTimeProvider.getSelectionEnd();
 
         Rectangle nameRect = getNameRect(bounds, i, nameSpace);
         if (nameRect.y >= bounds.y + bounds.height) {
@@ -1489,7 +1509,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *            The width reserved for the names
      * @param gc
      *            Reference to the SWT GC object
-     * @since 2.1
      */
     public void drawLinks(Rectangle bounds, ITimeDataProvider timeProvider,
             List<ILinkEvent> links, int nameSpace, GC gc) {
@@ -1516,7 +1535,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      *            the name space
      * @param gc
      *            Graphics context
-     * @since 2.1
      */
     protected void drawLink(ILinkEvent event, Rectangle bounds, ITimeDataProvider timeProvider, int nameSpace, GC gc) {
         drawArrow(getColorScheme(), event, getArrowRectangle(bounds, event), gc);
@@ -1559,7 +1577,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * @param gc
      *            Graphics context
      * @return true if the state was drawn
-     * @since 2.1
      */
     protected boolean drawArrow(TimeGraphColorScheme colors, ITimeEvent event,
             Rectangle rect, GC gc) {
@@ -1737,7 +1754,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * @param timeSelected
      *            Is the timestamp currently selected
      * @return true if the state was drawn
-     * @since 2.0
      */
     protected boolean drawState(TimeGraphColorScheme colors, ITimeEvent event,
             Rectangle rect, GC gc, boolean selected, boolean timeSelected) {
@@ -1842,10 +1858,12 @@ public class TimeGraphControl extends TimeGraphBaseControl
             } else if (idx > 0) {
                 idx--;
             }
-        } else if (SWT.ARROW_LEFT == e.keyCode) {
-            selectPrevEvent();
-        } else if (SWT.ARROW_RIGHT == e.keyCode) {
-            selectNextEvent();
+        } else if (SWT.ARROW_LEFT == e.keyCode && fDragState == DRAG_NONE) {
+            boolean extend = (e.stateMask & SWT.SHIFT) != 0;
+            selectPrevEvent(extend);
+        } else if (SWT.ARROW_RIGHT == e.keyCode && fDragState == DRAG_NONE) {
+            boolean extend = (e.stateMask & SWT.SHIFT) != 0;
+            selectNextEvent(extend);
         } else if (SWT.PAGE_DOWN == e.keyCode) {
             int page = countPerPage();
             idx = getSelectedIndex();
@@ -1895,7 +1913,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
     public void focusGained(FocusEvent e) {
         fIsInFocus = true;
         redraw();
-        updateStatusLine(NO_STATUS);
+        updateStatusLine(STATUS_WITHOUT_CURSOR_TIME);
     }
 
     @Override
@@ -1972,44 +1990,49 @@ public class TimeGraphControl extends TimeGraphBaseControl
         TimeFormat tf = tdp.getTimeFormat();
         Resolution res = Resolution.NANOSEC;
         StringBuilder message = new StringBuilder();
-        if (x >= 0 && fDragState == DRAG_NONE) {
-            long time = getTimeAtX(x);
-            if (time >= 0) {
-                if (tdp instanceof ITimeDataProviderConverter) {
-                    time = ((ITimeDataProviderConverter) tdp).convertTime(time);
-                }
-                long selectionBegin = tdp.getSelectionBegin();
-                long selectionEnd = tdp.getSelectionEnd();
-                message.append(NLS.bind("T: {0}{1}     T1: {2}{3}", //$NON-NLS-1$
-                        new Object[] {
-                                tf == TimeFormat.CALENDAR ? Utils.formatDate(time) + ' ' : "", //$NON-NLS-1$
-                                Utils.formatTime(time, tf, res),
-                                tf == TimeFormat.CALENDAR ? Utils.formatDate(Math.min(selectionBegin, selectionEnd)) + ' ' : "", //$NON-NLS-1$
-                                Utils.formatTime(Math.min(selectionBegin, selectionEnd), tf, res)
-                        }));
-                if (selectionBegin != selectionEnd) {
-                    message.append(NLS.bind("     T2: {0}{1}     \u0394: {2}", //$NON-NLS-1$
+        if ((x >= 0 || x == STATUS_WITHOUT_CURSOR_TIME) && fDragState == DRAG_NONE) {
+            if (x != STATUS_WITHOUT_CURSOR_TIME) {
+                long time = getTimeAtX(x);
+                if (time >= 0) {
+                    if (tdp instanceof ITimeDataProviderConverter) {
+                        time = ((ITimeDataProviderConverter) tdp).convertTime(time);
+                    }
+                    message.append(NLS.bind("T: {0}{1}     ", //$NON-NLS-1$
                             new Object[] {
-                                    tf == TimeFormat.CALENDAR ? Utils.formatDate(Math.max(selectionBegin, selectionEnd)) + ' ' : "", //$NON-NLS-1$
-                                    Utils.formatTime(Math.max(selectionBegin, selectionEnd), tf, res),
-                                    Utils.formatDelta(Math.abs(selectionBegin - selectionEnd), tf, res)
+                                    tf == TimeFormat.CALENDAR ? Utils.formatDate(time) + ' ' : "", //$NON-NLS-1$
+                                    Utils.formatTime(time, tf, res)
                             }));
                 }
             }
+            long selectionBegin = tdp.getSelectionBegin();
+            long selectionEnd = tdp.getSelectionEnd();
+            message.append(NLS.bind("T1: {0}{1}", //$NON-NLS-1$
+                    new Object[] {
+                            tf == TimeFormat.CALENDAR ? Utils.formatDate(selectionBegin) + ' ' : "", //$NON-NLS-1$
+                            Utils.formatTime(selectionBegin, tf, res)
+                    }));
+            if (selectionBegin != selectionEnd) {
+                message.append(NLS.bind("     T2: {0}{1}     \u0394: {2}", //$NON-NLS-1$
+                        new Object[] {
+                                tf == TimeFormat.CALENDAR ? Utils.formatDate(selectionEnd) + ' ' : "", //$NON-NLS-1$
+                                Utils.formatTime(selectionEnd, tf, res),
+                                Utils.formatDelta(selectionEnd - selectionBegin, tf, res)
+                        }));
+            }
         } else if (fDragState == DRAG_SELECTION || fDragState == DRAG_ZOOM) {
-            long time0 = fDragTime0;
-            long time = getTimeAtX(fDragX);
+            long time0 = fDragBeginMarker ? getTimeAtX(fDragX0) : fDragTime0;
+            long time = fDragBeginMarker ? fDragTime0 : getTimeAtX(fDragX);
             if (tdp instanceof ITimeDataProviderConverter) {
                 time0 = ((ITimeDataProviderConverter) tdp).convertTime(time0);
                 time = ((ITimeDataProviderConverter) tdp).convertTime(time);
             }
             message.append(NLS.bind("T1: {0}{1}     T2: {2}{3}     \u0394: {4}", //$NON-NLS-1$
                     new Object[] {
-                            tf == TimeFormat.CALENDAR ? Utils.formatDate(Math.min(time, time0)) + ' ' : "", //$NON-NLS-1$
-                            Utils.formatTime(Math.min(time, time0), tf, res),
-                            tf == TimeFormat.CALENDAR ? Utils.formatDate(Math.max(time, time0)) + ' ' : "", //$NON-NLS-1$
-                            Utils.formatTime(Math.max(time, time0), tf, res),
-                            Utils.formatDelta(Math.abs(time - time0), tf, res)
+                            tf == TimeFormat.CALENDAR ? Utils.formatDate(time0) + ' ' : "", //$NON-NLS-1$
+                            Utils.formatTime(time0, tf, res),
+                            tf == TimeFormat.CALENDAR ? Utils.formatDate(time) + ' ' : "", //$NON-NLS-1$
+                            Utils.formatTime(time, tf, res),
+                            Utils.formatDelta(time - time0, tf, res)
                     }));
         }
         fStatusLineManager.setMessage(message.toString());
@@ -2037,13 +2060,18 @@ public class TimeGraphControl extends TimeGraphBaseControl
                     time0 = fTimeProvider.getMinTime();
                     time1 = time0 + (fTime1bak - fTime0bak);
                 }
-                fTimeProvider.setStartFinishTime(time0, time1);
+                fTimeProvider.setStartFinishTimeNotify(time0, time1);
             }
         } else if (DRAG_SPLIT_LINE == fDragState) {
             fDragX = e.x;
             fTimeProvider.setNameSpace(e.x);
+            TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(this, getTimeViewAlignmentInfo()));
         } else if (DRAG_SELECTION == fDragState) {
-            fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), size.x - RIGHT_MARGIN);
+            if (fDragBeginMarker) {
+                fDragX0 = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), size.x - RIGHT_MARGIN);
+            } else {
+                fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), size.x - RIGHT_MARGIN);
+            }
             redraw();
             fTimeGraphScale.setDragRange(fDragX0, fDragX);
             fireDragSelectionChanged(getTimeAtX(fDragX0), getTimeAtX(fDragX));
@@ -2075,6 +2103,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
                     redraw();
                 }
                 fMouseOverSplitLine = mouseOverSplitLine;
+                TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(this, getTimeViewAlignmentInfo()));
                 return;
             }
             int idx = getItemIndexAtY(e.y);
@@ -2127,6 +2156,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 setCapture(true);
 
                 fDragState = DRAG_SELECTION;
+                fDragBeginMarker = false;
                 fDragButton = e.button;
                 fDragX = e.x;
                 fDragX0 = fDragX;
@@ -2138,7 +2168,9 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 if ((e.stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT) {
                     long time = getTimeAtX(e.x);
                     if (Math.abs(time - selectionBegin) < Math.abs(time - selectionEnd)) {
-                        fDragX0 = xEnd;
+                        fDragBeginMarker = true;
+                        fDragX = xEnd;
+                        fDragX0 = e.x;
                         fDragTime0 = selectionEnd;
                     } else {
                         fDragX0 = xBegin;
@@ -2147,7 +2179,9 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 } else {
                     long time = getTimeAtX(e.x);
                     if (Math.abs(e.x - xBegin) < SNAP_WIDTH && Math.abs(time - selectionBegin) <= Math.abs(time - selectionEnd)) {
-                        fDragX0 = xEnd;
+                        fDragBeginMarker = true;
+                        fDragX = xEnd;
+                        fDragX0 = e.x;
                         fDragTime0 = selectionEnd;
                     } else if (Math.abs(e.x - xEnd) < SNAP_WIDTH && Math.abs(time - selectionEnd) <= Math.abs(time - selectionBegin)) {
                         fDragX0 = xBegin;
@@ -2205,13 +2239,9 @@ public class TimeGraphControl extends TimeGraphBaseControl
                     long time = getTimeAtX(e.x);
                     fTimeProvider.setSelectedTimeNotify(time, false);
                 } else {
-                    long time0 = fDragTime0;
-                    long time1 = getTimeAtX(fDragX);
-                    if (time0 <= time1) {
-                        fTimeProvider.setSelectionRangeNotify(time0, time1);
-                    } else {
-                        fTimeProvider.setSelectionRangeNotify(time1, time0);
-                    }
+                    long time0 = fDragBeginMarker ? getTimeAtX(fDragX0) : fDragTime0;
+                    long time1 = fDragBeginMarker ? fDragTime0 : getTimeAtX(fDragX);
+                    fTimeProvider.setSelectionRangeNotify(time0, time1);
                 }
                 fDragState = DRAG_NONE;
                 redraw();
@@ -2247,7 +2277,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
             fMouseOverSplitLine = false;
             redraw();
         }
-        updateStatusLine(NO_STATUS);
+        updateStatusLine(STATUS_WITHOUT_CURSOR_TIME);
     }
 
     @Override
@@ -2373,8 +2403,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
      * @param rowHeight
      *            The height
      * @return true if the height is successfully stored, false otherwise
-     *
-     * @since 2.1
      */
     public boolean setItemHeight(ITimeGraphEntry entry, int rowHeight) {
         Item item = fItemData.findItem(entry);
@@ -2403,8 +2431,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
 
     /**
      * @return The entries that are currently filtered out
-     *
-     * @since 2.0
      */
     public List<ITimeGraphEntry> getFilteredOut() {
         return fItemData.getFilteredOut();
@@ -2439,7 +2465,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
 
     /**
      * @param filter The filter object to be attached to the view
-     * @since 2.0
      */
     public void addFilter(ViewerFilter filter) {
         if (!fFilters.contains(filter)) {
@@ -2449,15 +2474,11 @@ public class TimeGraphControl extends TimeGraphBaseControl
 
     /**
      * @param filter The filter object to be attached to the view
-     * @since 2.0
      */
     public void removeFilter(ViewerFilter filter) {
         fFilters.remove(filter);
     }
 
-    /**
-     * @since 3.0
-     */
     @Override
     public void colorSettingsChanged(StateItem[] stateItems) {
         /* Destroy previous colors from the resource manager */
@@ -2638,9 +2659,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
         }
     }
 
-    /**
-     * @since 1.2
-     */
     @Override
     public void menuDetected(MenuDetectEvent e) {
         if (null == fTimeProvider) {
@@ -2682,6 +2700,32 @@ public class TimeGraphControl extends TimeGraphBaseControl
         }
     }
 
+    /**
+     * Perform the alignment operation.
+     *
+     * @param offset
+     *            the alignment offset
+     *
+     * @see ITmfTimeAligned
+     *
+     * @since 1.0
+     */
+    public void performAlign(int offset) {
+        fTimeProvider.setNameSpace(offset);
+    }
+
+    /**
+     * Return the time alignment information
+     *
+     * @return the time alignment information
+     *
+     * @see ITmfTimeAligned
+     *
+     * @since 1.0
+     */
+    public TmfTimeViewAlignmentInfo getTimeViewAlignmentInfo() {
+        return new TmfTimeViewAlignmentInfo(getShell(), toDisplay(0, 0), fTimeProvider.getNameSpace());
+    }
 }
 
 
This page took 0.032916 seconds and 5 git commands to generate.