tmf: Add support for time range selection
authorPatrick Tasse <patrick.tasse@gmail.com>
Thu, 4 Jul 2013 22:09:47 +0000 (18:09 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Mon, 29 Jul 2013 20:50:09 +0000 (16:50 -0400)
Time graph:
- Add time data provider interface extension to set and get selection
range
- Support left-button drag and Shift-left-click to set selection range
- Support middle-button and Ctrl-left-button drag to move the view left
or right
- Update cursors for mouse operations
- Add support for status line display of time coordinates of cursor
position and selection range
- Update time graph time listener event for selection range
- Remove right-mouse-drag support for setting zoom range in time graph
scale
- Add interface between time graph scale and control to display drag
range decorators in scale

Signals:
- Remove current time from TmfRangeSynchSignal
- Replace current time with begin and end time in TmfTimeSynchSignal

Trace Manager:
- Update trace manager for selection range

Views:
- Update statistics viewer to use selection range instead of view range
- Update Call Stack view for selection range
- Update Histogram view for selection range
- Support Shift-click in histogram
- Update Time Chart view for selection range
- Update abstract time graph view for selection range

Change-Id: I30b215f6c6b2ed2623978e83d3b96e117eff586c
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/14292
Tested-by: Hudson CI
29 files changed:
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceManagerTest.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/signal/TmfRangeSynchSignal.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/signal/TmfTimeSynchSignal.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTraceContext.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTraceManager.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/histogram/HistogramDataModelTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderSignalTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderTimeTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/test/stub/views/TsfTraceAnalysisView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/messages.properties
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/callstack/CallStackView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramCurrentTimeControl.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramDataModel.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramScaledData.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statesystem/TmfStateSystemExplorer.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timegraph/AbstractTimeGraphView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphTimeEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider2.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphScale.java

index d9aa4f0231abc78a6a12ad34d170107079b49251..2b9b1e289aeef6bdef18f40357491b0d157b0982 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Alexandre Montplaisir - Initial API and implementation
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.tests.trace;
@@ -121,7 +122,7 @@ public class TmfTraceManagerTest {
     }
 
     private void selectTimeRange(TmfTimeRange tr) {
-        TmfSignalManager.dispatchSignal(new TmfRangeSynchSignal(this, tr, null));
+        TmfSignalManager.dispatchSignal(new TmfRangeSynchSignal(this, tr));
     }
 
     // ------------------------------------------------------------------------
@@ -213,7 +214,9 @@ public class TmfTraceManagerTest {
         ITmfTimestamp ts = new TmfTimestamp(t2start + ONE_SECOND, SCALE);
         selectTimestamp(ts);
 
-        ITmfTimestamp afterTs = tm.getCurrentTime();
+        ITmfTimestamp afterTs = tm.getSelectionBeginTime();
+        assertEquals(ts, afterTs);
+        afterTs = tm.getSelectionEndTime();
         assertEquals(ts, afterTs);
     }
 
@@ -224,11 +227,13 @@ public class TmfTraceManagerTest {
     @Test
     public void testTimestampBefore() {
         openTrace(trace2);
-        ITmfTimestamp beforeTs = tm.getCurrentTime();
+        ITmfTimestamp beforeTs = tm.getSelectionBeginTime();
         ITmfTimestamp ts = new TmfTimestamp(t2start - ONE_SECOND, SCALE);
         selectTimestamp(ts);
 
-        ITmfTimestamp curTs = tm.getCurrentTime();
+        ITmfTimestamp curTs = tm.getSelectionBeginTime();
+        assertEquals(beforeTs, curTs);
+        curTs = tm.getSelectionEndTime();
         assertEquals(beforeTs, curTs);
     }
 
@@ -239,11 +244,13 @@ public class TmfTraceManagerTest {
     @Test
     public void testTimestampAfter() {
         openTrace(trace2);
-        ITmfTimestamp beforeTs = tm.getCurrentTime();
+        ITmfTimestamp beforeTs = tm.getSelectionBeginTime();
         ITmfTimestamp ts = new TmfTimestamp(t2end + ONE_SECOND, SCALE);
         selectTimestamp(ts);
 
-        ITmfTimestamp curTs = tm.getCurrentTime();
+        ITmfTimestamp curTs = tm.getSelectionBeginTime();
+        assertEquals(beforeTs, curTs);
+        curTs = tm.getSelectionEndTime();
         assertEquals(beforeTs, curTs);
     }
 
@@ -335,11 +342,13 @@ public class TmfTraceManagerTest {
         selectTimestamp(ts);
 
         /* Timestamp of trace1 should have been updated */
-        assertEquals(ts, tm.getCurrentTime());
+        assertEquals(ts, tm.getSelectionBeginTime());
+        assertEquals(ts, tm.getSelectionEndTime());
 
         /* Timestamp of trace2 should not have changed */
         selectTrace(trace2);
-        assertEquals(trace2.getStartTime(), tm.getCurrentTime());
+        assertEquals(trace2.getStartTime(), tm.getSelectionBeginTime());
+        assertEquals(trace2.getStartTime(), tm.getSelectionEndTime());
     }
 
     /**
@@ -358,11 +367,13 @@ public class TmfTraceManagerTest {
         selectTimestamp(ts);
 
         /* Timestamp of trace1 should not have changed */
-        assertEquals(trace1.getStartTime(), tm.getCurrentTime());
+        assertEquals(trace1.getStartTime(), tm.getSelectionBeginTime());
+        assertEquals(trace1.getStartTime(), tm.getSelectionEndTime());
 
         /* Timestamp of trace2 should not have changed */
         selectTrace(trace2);
-        assertEquals(trace2.getStartTime(), tm.getCurrentTime());
+        assertEquals(trace2.getStartTime(), tm.getSelectionBeginTime());
+        assertEquals(trace2.getStartTime(), tm.getSelectionEndTime());
     }
 
     /**
@@ -380,11 +391,13 @@ public class TmfTraceManagerTest {
         selectTimestamp(ts);
 
         /* Timestamp of trace1 should not have changed */
-        assertEquals(trace1.getStartTime(), tm.getCurrentTime());
+        assertEquals(trace1.getStartTime(), tm.getSelectionBeginTime());
+        assertEquals(trace1.getStartTime(), tm.getSelectionEndTime());
 
         /* Timestamp of trace2 should not have changed */
         selectTrace(trace2);
-        assertEquals(trace2.getStartTime(), tm.getCurrentTime());
+        assertEquals(trace2.getStartTime(), tm.getSelectionBeginTime());
+        assertEquals(trace2.getStartTime(), tm.getSelectionEndTime());
     }
 
     /**
@@ -516,7 +529,8 @@ public class TmfTraceManagerTest {
         selectTimestamp(ts);
 
         /* The experiment's current time should be updated. */
-        assertEquals(ts, tm.getCurrentTime());
+        assertEquals(ts, tm.getSelectionBeginTime());
+        assertEquals(ts, tm.getSelectionEndTime());
     }
 
     /**
@@ -534,7 +548,8 @@ public class TmfTraceManagerTest {
         selectTimestamp(ts);
 
         /* The experiment's current time should be updated. */
-        assertEquals(ts, tm.getCurrentTime());
+        assertEquals(ts, tm.getSelectionBeginTime());
+        assertEquals(ts, tm.getSelectionEndTime());
     }
 
     /**
@@ -551,7 +566,8 @@ public class TmfTraceManagerTest {
         selectTimestamp(ts);
 
         /* The experiment's current time should NOT be updated. */
-        assertEquals(trace1.getStartTime(), tm.getCurrentTime());
+        assertEquals(trace1.getStartTime(), tm.getSelectionBeginTime());
+        assertEquals(trace1.getStartTime(), tm.getSelectionEndTime());
     }
 
     /**
index 19fe56fa744ce3198cda59977ad2c129f3cff4f1..ce12780ff20031f15073079d0485a3cb31c33ec4 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
+ *   Patrick Tasse - Deprecate current time
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.signal;
@@ -16,7 +17,10 @@ import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
 
 /**
- * A new active time range has been selected
+ * A new time range has been selected.
+ *
+ * This is the visible (zoom) time range. To synchronize on the selection range,
+ * use {@link TmfTimeSynchSignal}.
  *
  * @version 1.0
  * @author Francois Chouinard
@@ -24,7 +28,6 @@ import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
 public class TmfRangeSynchSignal extends TmfSignal {
 
     private final TmfTimeRange fCurrentRange;
-    private final ITmfTimestamp fCurrentTime;
 
     /**
      * Constructor
@@ -35,13 +38,28 @@ public class TmfRangeSynchSignal extends TmfSignal {
      *            The time range to which we synchronized
      * @param ts
      *            The current selected timestamp, independent from the time
-     *            range
+     *            range (ignored)
      * @since 2.0
+     * @deprecated As of 2.1, use {@link #TmfRangeSynchSignal(Object, TmfTimeRange)}
      */
+    @Deprecated
     public TmfRangeSynchSignal(Object source, TmfTimeRange range, ITmfTimestamp ts) {
         super(source);
         fCurrentRange = range;
-        fCurrentTime = ts;
+    }
+
+    /**
+     * Constructor
+     *
+     * @param source
+     *            Object sending this signal
+     * @param range
+     *            The new time range
+     * @since 2.1
+     */
+    public TmfRangeSynchSignal(Object source, TmfTimeRange range) {
+        super(source);
+        fCurrentRange = range;
     }
 
     /**
@@ -55,9 +73,11 @@ public class TmfRangeSynchSignal extends TmfSignal {
     /**
      * @return This signal's current selected timestamp
      * @since 2.0
+     * @deprecated As of 2.1, this returns null
      */
+    @Deprecated
     public ITmfTimestamp getCurrentTime() {
-        return fCurrentTime;
+        return null;
     }
 
 }
index 9ad5454fc4bb498453a436b201748ffb1763d624..6fa68e2913b5b1c847a74838bfdbf07d8b5cdc68 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.signal;
@@ -15,14 +16,18 @@ package org.eclipse.linuxtools.tmf.core.signal;
 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
 
 /**
- * A new current time is selected (for component synchronization)
-  *
+ * A new time or time range selection has been made.
+ *
+ * This is the selected time or time range. To synchronize on the visible
+ * (zoom) range, use {@link TmfRangeSynchSignal}.
+ *
  * @version 1.0
  * @author Francois Chouinard
 */
 public class TmfTimeSynchSignal extends TmfSignal {
 
-    private final ITmfTimestamp fCurrentTime;
+    private final ITmfTimestamp fBeginTime;
+    private final ITmfTimestamp fEndTime;
 
     /**
      * Constructor
@@ -30,25 +35,71 @@ public class TmfTimeSynchSignal extends TmfSignal {
      * @param source
      *            Object sending this signal
      * @param ts
-     *            Synchronize to which timestamp
+     *            Timestamp of selection
      * @since 2.0
      */
     public TmfTimeSynchSignal(Object source, ITmfTimestamp ts) {
         super(source);
-        fCurrentTime = ts;
+        fBeginTime = ts;
+        fEndTime = ts;
+    }
+
+    /**
+     * Constructor
+     *
+     * @param source
+     *            Object sending this signal
+     * @param begin
+     *            Timestamp of begin of selection range
+     * @param end
+     *            Timestamp of end of selection range
+     * @since 2.1
+     */
+    public TmfTimeSynchSignal(Object source, ITmfTimestamp begin, ITmfTimestamp end) {
+        super(source);
+        fBeginTime = begin;
+        fEndTime = end;
     }
 
     /**
      * @return The synchronization timestamp of this signal
      * @since 2.0
+     * @deprecated As of 2.1, use {@link #getBeginTime()} and {@link #getEndTime()}
      */
+    @Deprecated
     public ITmfTimestamp getCurrentTime() {
-        return fCurrentTime;
+        return fBeginTime;
+    }
+
+    /**
+     * @return The begin timestamp of selection
+     * @since 2.1
+     */
+    public ITmfTimestamp getBeginTime() {
+        return fBeginTime;
+    }
+
+    /**
+     * @return The end timestamp of selection
+     * @since 2.1
+     */
+    public ITmfTimestamp getEndTime() {
+        return fEndTime;
     }
 
     @Override
     public String toString() {
-        return "[TmfTimeSynchSignal (" + fCurrentTime.toString() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$
+        StringBuilder sb = new StringBuilder();
+        sb.append("[TmfTimeSynchSignal ("); //$NON-NLS-1$
+        if (fBeginTime != null) {
+            sb.append(fBeginTime.toString());
+            if (!fBeginTime.equals(fEndTime) && fEndTime != null) {
+                sb.append('-');
+                sb.append(fEndTime.toString());
+            }
+        }
+        sb.append(")]"); //$NON-NLS-1$
+        return sb.toString();
     }
 
 }
index 29e895a6dbbbfe50903e8b7b8da8f740b10081dd..66370834b13102d61a49653642698037020aee04 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Alexandre Montplaisir - Initial API and implementation
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.trace;
@@ -18,7 +19,7 @@ import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
 
 /**
  * Context of a trace, which is the representation of the "view" the user
- * currently has on this trace (selected time range, selected time stamp).
+ * currently has on this trace (window time range, selected time or time range).
  *
  * TODO could be extended to support the notion of current location too.
  *
@@ -28,32 +29,42 @@ import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
 final class TmfTraceContext {
 
     static final TmfTraceContext NULL_CONTEXT =
-            new TmfTraceContext(TmfTimestamp.BIG_CRUNCH, TmfTimeRange.NULL_RANGE);
+            new TmfTraceContext(TmfTimestamp.BIG_CRUNCH, TmfTimestamp.BIG_CRUNCH, TmfTimeRange.NULL_RANGE);
 
-    private final ITmfTimestamp fTimestamp;
-    private final TmfTimeRange fTimerange;
+    private final TmfTimeRange fSelection;
+    private final TmfTimeRange fWindowRange;
 
-    public TmfTraceContext(ITmfTimestamp ts, TmfTimeRange tr) {
-        fTimestamp = ts;
-        fTimerange = tr;
+    public TmfTraceContext(ITmfTimestamp beginTs, ITmfTimestamp endTs, TmfTimeRange tr) {
+        fSelection = new TmfTimeRange(beginTs, endTs);
+        fWindowRange = tr;
     }
 
-    public TmfTraceContext(TmfTraceContext prevCtx, ITmfTimestamp ts) {
-        fTimestamp = ts;
-        fTimerange = prevCtx.fTimerange;
+    public TmfTraceContext(TmfTraceContext prevCtx, ITmfTimestamp beginTs, ITmfTimestamp endTs) {
+        fSelection = new TmfTimeRange(beginTs, endTs);
+        fWindowRange = prevCtx.fWindowRange;
     }
 
-    public ITmfTimestamp getTimestamp() {
-        return fTimestamp;
+    public TmfTraceContext(TmfTraceContext prevCtx, TmfTimeRange tr) {
+        fSelection = prevCtx.fSelection;
+        fWindowRange = tr;
     }
 
-    public TmfTimeRange getTimerange() {
-        return fTimerange;
+    public ITmfTimestamp getSelectionBegin() {
+        return fSelection.getStartTime();
+    }
+
+    public ITmfTimestamp getSelectionEnd() {
+        return fSelection.getEndTime();
+    }
+
+    public TmfTimeRange getWindowRange() {
+        return fWindowRange;
     }
 
     public boolean isValid() {
-        if (fTimestamp.compareTo(TmfTimestamp.ZERO) <= 0 ||
-                fTimerange.getEndTime().compareTo(fTimerange.getStartTime()) <= 0) {
+        if (fSelection.getStartTime().compareTo(TmfTimestamp.ZERO) <= 0 ||
+                fSelection.getEndTime().compareTo(TmfTimestamp.ZERO) <= 0 ||
+                fWindowRange.getEndTime().compareTo(fWindowRange.getStartTime()) <= 0) {
             return false;
         }
         return true;
@@ -61,7 +72,7 @@ final class TmfTraceContext {
 
     @Override
     public String toString() {
-        return getClass().getSimpleName() + "[fTimestamp=" + fTimestamp.toString() + //$NON-NLS-1$
-                ", fTimerange=" + fTimerange + ']'; //$NON-NLS-1$
+        return getClass().getSimpleName() + "[fSelection=" + fSelection + //$NON-NLS-1$
+                ", fWindowRange=" + fWindowRange + ']'; //$NON-NLS-1$
     }
 }
index 94c51802e833755c2b04a325ff559977395a9625..a2a5d15d0c4c31ddc8951385a3c59b975f0cad77 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Alexandre Montplaisir - Initial API and implementation
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.trace;
@@ -34,8 +35,8 @@ import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
 
 /**
  * Central trace manager for TMF. It tracks the currently opened traces and
- * experiment, as well as the currently-selected timestamps and time ranges for
- * each one of those.
+ * experiment, as well as the currently-selected time or time range and the
+ * current window time range for each one of those.
  *
  * It's a singleton class, so only one instance should exist (available via
  * {@link #getInstance()}).
@@ -86,18 +87,36 @@ public final class TmfTraceManager {
      * Return the current selected time.
      *
      * @return the current time stamp
+     * @deprecated As of 2.1, use {@link #getSelectionBeginTime()} and {@link #getSelectionEndTime()}
      */
+    @Deprecated
     public synchronized ITmfTimestamp getCurrentTime() {
-        return getCurrentTraceContext().getTimestamp();
+        return getCurrentTraceContext().getSelectionBegin();
     }
 
     /**
-     * Return the current selected range.
+     * @return The begin timestamp of selection
+     * @since 2.1
+     */
+    public ITmfTimestamp getSelectionBeginTime() {
+        return getCurrentTraceContext().getSelectionBegin();
+    }
+
+    /**
+     * @return The end timestamp of selection
+     * @since 2.1
+     */
+    public ITmfTimestamp getSelectionEndTime() {
+        return getCurrentTraceContext().getSelectionEnd();
+    }
+
+    /**
+     * Return the current window time range.
      *
-     * @return the current time range
+     * @return the current window time range
      */
     public synchronized TmfTimeRange getCurrentRange() {
-        return getCurrentTraceContext().getTimerange();
+        return getCurrentTraceContext().getWindowRange();
     }
 
     /**
@@ -209,7 +228,7 @@ public final class TmfTraceManager {
         long endTime = startTs.normalize(0, SCALE).getValue() + offset;
         final TmfTimeRange startTr = new TmfTimeRange(startTs, new TmfTimestamp(endTime, SCALE));
 
-        final TmfTraceContext startCtx = new TmfTraceContext(startTs, startTr);
+        final TmfTraceContext startCtx = new TmfTraceContext(startTs, startTs, startTr);
 
         fTraces.put(trace, startCtx);
 
@@ -255,20 +274,21 @@ public final class TmfTraceManager {
      * Signal handler for the TmfTimeSynchSignal signal.
      *
      * The current time of *all* traces whose range contains the requested new
-     * time will be updated.
+     * selection time range will be updated.
      *
      * @param signal
      *            The incoming signal
      */
     @TmfSignalHandler
     public synchronized void timeUpdated(final TmfTimeSynchSignal signal) {
-        final ITmfTimestamp ts = signal.getCurrentTime();
+        final ITmfTimestamp beginTs = signal.getBeginTime();
+        final ITmfTimestamp endTs = signal.getEndTime();
 
         for (Map.Entry<ITmfTrace, TmfTraceContext> entry : fTraces.entrySet()) {
             final ITmfTrace trace = entry.getKey();
-            if (ts.intersects(getValidTimeRange(trace))) {
+            if (beginTs.intersects(getValidTimeRange(trace)) || endTs.intersects(getValidTimeRange(trace))) {
                 TmfTraceContext prevCtx = entry.getValue();
-                TmfTraceContext newCtx = new TmfTraceContext(prevCtx, ts);
+                TmfTraceContext newCtx = new TmfTraceContext(prevCtx, beginTs, endTs);
                 entry.setValue(newCtx);
             }
         }
@@ -277,7 +297,7 @@ public final class TmfTraceManager {
     /**
      * Signal handler for the TmfRangeSynchSignal signal.
      *
-     * The current timestamp and timerange of *all* valid traces will be updated
+     * The current window time range of *all* valid traces will be updated
      * to the new requested times.
      *
      * @param signal
@@ -285,28 +305,18 @@ public final class TmfTraceManager {
      */
     @TmfSignalHandler
     public synchronized void timeRangeUpdated(final TmfRangeSynchSignal signal) {
-        final ITmfTimestamp signalTs = signal.getCurrentTime();
-
         for (Map.Entry<ITmfTrace, TmfTraceContext> entry : fTraces.entrySet()) {
             final ITmfTrace trace = entry.getKey();
             final TmfTraceContext curCtx = entry.getValue();
 
             final TmfTimeRange validTr = getValidTimeRange(trace);
 
-            /* Determine the new time stamp */
-            ITmfTimestamp newTs;
-            if (signalTs != null && signalTs.intersects(validTr)) {
-                newTs = signalTs;
-            } else {
-                newTs = curCtx.getTimestamp();
-            }
-
             /* Determine the new time range */
             TmfTimeRange targetTr = signal.getCurrentRange().getIntersection(validTr);
-            TmfTimeRange newTr = (targetTr == null ? curCtx.getTimerange() : targetTr);
+            TmfTimeRange newTr = (targetTr == null ? curCtx.getWindowRange() : targetTr);
 
             /* Update the values */
-            TmfTraceContext newCtx = new TmfTraceContext(newTs, newTr);
+            TmfTraceContext newCtx = new TmfTraceContext(curCtx, newTr);
             entry.setValue(newCtx);
         }
     }
@@ -316,8 +326,8 @@ public final class TmfTraceManager {
     // ------------------------------------------------------------------------
 
     /**
-     * Return the valid time range of a trace (not the "current time range", but
-     * the range of all possible valid timestamps).
+     * Return the valid time range of a trace (not the current window time
+     * range, but the range of all possible valid timestamps).
      *
      * For a real trace this is the whole range of the trace. For an experiment,
      * it goes from the start time of the earliest trace to the end time of the
index 5a947946a1b528de97252ad7fef7e8fbd2e3526f..e1304d2e3d2f1e3ab19bc327edd1bbc7cd197ff5 100644 (file)
@@ -10,6 +10,7 @@
  *   Francois Chouinard - Initial API and implementation
  *   Bernd Hufmann - Adapt to junit.framework.TestCase
  *   Alexandre Montplaisir - Port to JUnit4
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.tests.histogram;
@@ -463,7 +464,8 @@ public class HistogramDataModelTest {
         HistogramScaledData result = model.scaleTo(width, maxHeight, barWidth);
 
         assertEquals(4 * 26, result.fBucketDuration);
-        assertEquals(0, result.fCurrentBucket);
+        assertEquals(0, result.fSelectionBeginBucket);
+        assertEquals(0, result.fSelectionEndBucket);
         assertEquals(0, result.fFirstBucketTime);
         assertEquals(0, result.fFirstEventTime);
         assertEquals(1, result.fLastBucket);
@@ -514,7 +516,8 @@ public class HistogramDataModelTest {
         HistogramScaledData result = model.scaleTo(width, maxHeight, barWidth);
 
         assertEquals(4 * 6, result.fBucketDuration);
-        assertEquals(0, result.fCurrentBucket);
+        assertEquals(0, result.fSelectionBeginBucket);
+        assertEquals(0, result.fSelectionEndBucket);
         assertEquals(-3, result.fFirstBucketTime); // negative is correct, can happen when reverse
         assertEquals(0, result.fFirstEventTime);
         assertEquals(9, result.fLastBucket);
@@ -575,7 +578,8 @@ public class HistogramDataModelTest {
 
         // For the above number of events, result and revResult are exactly the same.
         assertEquals(result.fBucketDuration, revResult.fBucketDuration);
-        assertEquals(result.fCurrentBucket, revResult.fCurrentBucket);
+        assertEquals(result.fSelectionBeginBucket, revResult.fSelectionBeginBucket);
+        assertEquals(result.fSelectionEndBucket, revResult.fSelectionEndBucket);
         assertEquals(result.fFirstBucketTime, revResult.fFirstBucketTime);
         assertEquals(result.fMaxValue, revResult.fMaxValue);
         assertEquals(result.fScalingFactor, revResult.fScalingFactor, DELTA);
index 8633c543e0172c03ee3f6f6d99dc931136d17aa3..c7910d7cc0a85931c2965daf542d4c2d4e410ad9 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011-2013 Ericsson
+ * Copyright (c) 20112013 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -9,6 +9,7 @@
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
  *   Alexandre Montplaisir - Port to JUnit4
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
@@ -18,6 +19,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
@@ -52,7 +54,8 @@ public class TmfUml2SDSyncLoaderSignalTest {
         rangeWindow = (TmfTimestamp) range.getEndTime().getDelta(range.getStartTime());
         currentTime = new Uml2SDTestTimestamp(9789773782043L);
 
-        fFacility.getTrace().broadcast(new TmfRangeSynchSignal(fFacility, range, currentTime));
+        fFacility.getTrace().broadcast(new TmfRangeSynchSignal(fFacility, range));
+        fFacility.getTrace().broadcast(new TmfTimeSynchSignal(fFacility, currentTime));
         fFacility.delay(IUml2SDTestConstants.BROADCAST_DELAY);
 
         fTmfComponent = new Uml2SDSignalValidator();
index deec8dc5f02a2c35a1a3303bd440f0ae83387fb2..829858322db5056f16bc3de833a065248114c83b 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011-2013 Ericsson
+ * Copyright (c) 20112013 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -9,6 +9,7 @@
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
  *   Alexandre Montplaisir - Port to JUnit4
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
@@ -277,7 +278,7 @@ public class TmfUml2SDSyncLoaderTimeTest {
         TmfTimeRange range = new TmfTimeRange(TC_008_START_TIME_VALUE, TC_008_END_TIME_VALUE);
         fFacility.getLoader().waitForCompletion();
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
-        fFacility.getTrace().broadcast(new TmfRangeSynchSignal(this, range, TC_008_TIME_VALUE));
+        fFacility.getTrace().broadcast(new TmfRangeSynchSignal(this, range));
         assertEquals("synchToTimeRange", TC_008_PAGE_VALUE, fFacility.getLoader().currentPage());
         assertNotNull("synchToTimeRange", fFacility.getLoader().getCurrentTime());
         assertEquals("synchToTimeRange", 0, TC_008_TIME_VALUE.compareTo(fFacility.getLoader().getCurrentTime(), false));
@@ -296,7 +297,7 @@ public class TmfUml2SDSyncLoaderTimeTest {
     @Test
     public void verifyTimeRangeDifferentPages() {
         TmfTimeRange range = new TmfTimeRange(TC_009_START_TIME_VALUE, TC_009_END_TIME_VALUE);
-        fFacility.getTrace().broadcast(new TmfRangeSynchSignal(this, range, TC_009_TIME_VALUE));
+        fFacility.getTrace().broadcast(new TmfRangeSynchSignal(this, range));
         fFacility.getLoader().waitForCompletion();
         fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
         assertEquals("synchToTimeRange", TC_009_PAGE_VALUE, fFacility.getLoader().currentPage());
index 6f6bd8160568872b75a08f25f1f5dff00cb712e0..d41bc282a08784f425bb3300cceaf794f0a5fdad 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
 
@@ -62,7 +63,7 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal
         // Set results so that it can be validated in the test case
         setSignalReceived(true);
         setSourceError(getSource() != signal.getSource());
-        setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
+        setCurrentTimeError(!getCurrentTime().equals(signal.getBeginTime()));
     }
 
     /**
@@ -76,9 +77,6 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal
         if (getSource() != null) {
             setSourceError(getSource() != signal.getSource());
         }
-        if (getCurrentTime() != null) {
-            setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
-        }
         if (getCurrentRange() != null) {
             setRangeError(!getCurrentRange().equals(signal.getCurrentRange()));
         }
index fe2ea4e62d1f9814e025bfb50af524bacc0ec7ca..c8506e1db5554de2976efcbab884db72cfd6f345 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.test.stub.views;
 
@@ -603,18 +604,18 @@ public class TsfTraceAnalysisView extends ViewPart implements
         } else {
             synchViewer = tsfviewer;
         }
-        long selTimens = event.getTime();
+        long selTimens = event.getBeginTime();
         long tms = (long) (selTimens * 1E-6);
         Date date = new Date(tms);
         String fDate = stimeformat.format(date);
         String ns = formatNs(selTimens);
 
         System.out.println("TsfTraceAnalysisView.timeSelected() Selected Event: \nTime: "
-                + event.getTime()
+                + event.getBeginTime()
                 + "\nSelected Time: "
                 + selTimens + " " + fDate + " " + ns);
 
-        synchViewer.setSelectedTime(event.getTime(), true);
+        synchViewer.setSelectedTime(event.getBeginTime(), true);
     }
 
     @Override
index e2697cb953ee51206e1ef1096985d9dce138098e..45bff88f9fa26d974b64f6801fe72e1c3cd92210 100644 (file)
@@ -2149,7 +2149,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
             // the method fTrace.getRank() from interfering and delaying ongoing requests.
             final TmfDataRequest subRequest = new TmfDataRequest(ITmfEvent.class, 0, 1, ExecutionType.FOREGROUND) {
 
-                TmfTimestamp ts = new TmfTimestamp(signal.getCurrentTime());
+                TmfTimestamp ts = new TmfTimestamp(signal.getBeginTime());
 
                 @Override
                 public void handleData(final ITmfEvent event) {
index d873d4455a67b20c5e0e1fe76c04125d4786de65..d46bc5c75f67c82ae4fe99f16384b9d10412b44f 100644 (file)
@@ -9,6 +9,7 @@
  * Contributors:
  *   Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and implementation
  *   Alexandre Montplaisir - Port to ITmfStatistics provider
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.viewers.statistics;
@@ -25,6 +26,7 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.linuxtools.tmf.core.signal.TmfStatsUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceRangeUpdatedSignal;
 import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
@@ -243,7 +245,10 @@ public class TmfStatisticsViewer extends TmfViewer {
             // Sends the time range request only once from this method.
             if (fSendRangeRequest) {
                 fSendRangeRequest = false;
-                requestTimeRangeData(trace, fTraceManager.getCurrentRange());
+                ITmfTimestamp begin = fTraceManager.getSelectionBeginTime();
+                ITmfTimestamp end = fTraceManager.getSelectionEndTime();
+                TmfTimeRange timeRange = new TmfTimeRange(begin, end);
+                requestTimeRangeData(trace, timeRange);
             }
         }
         requestData(trace, signal.getRange());
@@ -255,13 +260,31 @@ public class TmfStatisticsViewer extends TmfViewer {
      *
      * @param signal
      *            Contains the information about the new selected time range.
+     * @deprecated
+     *            As of 2.1, use {@link #timeSynchUpdated(TmfTimeSynchSignal)}
      */
+    @Deprecated
     @TmfSignalHandler
     public void timeRangeUpdated(TmfRangeSynchSignal signal) {
+    }
+
+    /**
+     * Handles the time synch updated signal. It updates the time range
+     * statistics.
+     *
+     * @param signal
+     *            Contains the information about the new selected time range.
+     * @since 2.1
+     */
+    @TmfSignalHandler
+    public void timeSynchUpdated(TmfTimeSynchSignal signal) {
         if (fTrace == null) {
             return;
         }
-        requestTimeRangeData(fTrace, signal.getCurrentRange());
+        ITmfTimestamp begin = signal.getBeginTime();
+        ITmfTimestamp end = signal.getEndTime();
+        TmfTimeRange timeRange = new TmfTimeRange(begin, end);
+        requestTimeRangeData(fTrace, timeRange);
     }
 
     /**
index b99673020816325a7a4060e23dced3c2dcda863e..484648adca15166e86f1ed3e6d383ac8697d0867 100755 (executable)
@@ -15,6 +15,6 @@ TmfStatisticsData_EventTypes=Event Types
 TmfStatisticsView_LevelColumn=Level
 TmfStatisticsView_LevelColumnTip=Level at which statistics apply.
 TmfStatisticsView_NbEventsColumn=Events total
-TmfStatisticsView_NbEventsTip=Total amount of events contained in the trace/experiment.
-TmfStatisticsView_NbEventsTimeRangeColumn=Events in selected time range
+TmfStatisticsView_NbEventsTip=Total amount of events contained in the trace
+TmfStatisticsView_NbEventsTimeRangeColumn=Events in selection
 TmfStatisticsView_NbEventsTimeRangeTip=Number of events in the currently selected time range
index 7495ad4004953d0c623e3d7b4f38337888e24fda..b34a7d14612eb3fee16190eb0387bbc1d537650f 100644 (file)
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IStatusLineManager;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.util.IPropertyChangeListener;
@@ -496,8 +497,7 @@ public class CallStackView extends TmfView {
                 long startTime = event.getStartTime();
                 long endTime = event.getEndTime();
                 TmfTimeRange range = new TmfTimeRange(new CtfTmfTimestamp(startTime), new CtfTmfTimestamp(endTime));
-                TmfTimestamp time = new CtfTmfTimestamp(fTimeGraphCombo.getTimeGraphViewer().getSelectedTime());
-                broadcast(new TmfRangeSynchSignal(CallStackView.this, range, time));
+                broadcast(new TmfRangeSynchSignal(CallStackView.this, range));
                 startZoomThread(startTime, endTime);
             }
         });
@@ -505,9 +505,10 @@ public class CallStackView extends TmfView {
         fTimeGraphCombo.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
             @Override
             public void timeSelected(TimeGraphTimeEvent event) {
-                long time = event.getTime();
-                selectTime(time);
-                broadcast(new TmfTimeSynchSignal(CallStackView.this, new CtfTmfTimestamp(time)));
+                long beginTime = event.getBeginTime();
+                long endTime = event.getEndTime();
+                selectTime(beginTime);
+                broadcast(new TmfTimeSynchSignal(CallStackView.this, new CtfTmfTimestamp(beginTime), new CtfTmfTimestamp(endTime)));
             }
         });
 
@@ -534,8 +535,7 @@ public class CallStackView extends TmfView {
                         startTime -= spacingTime;
                         endTime += spacingTime;
                         TmfTimeRange range = new TmfTimeRange(new CtfTmfTimestamp(startTime), new CtfTmfTimestamp(endTime));
-                        TmfTimestamp time = new CtfTmfTimestamp(fTimeGraphCombo.getTimeGraphViewer().getSelectedTime());
-                        broadcast(new TmfRangeSynchSignal(CallStackView.this, range, time));
+                        broadcast(new TmfRangeSynchSignal(CallStackView.this, range));
                         fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
                         startZoomThread(startTime, endTime);
                     }
@@ -558,8 +558,7 @@ public class CallStackView extends TmfView {
                         startTime -= spacingTime;
                         endTime += spacingTime;
                         TmfTimeRange range = new TmfTimeRange(new CtfTmfTimestamp(startTime), new CtfTmfTimestamp(endTime));
-                        TmfTimestamp time = new CtfTmfTimestamp(fTimeGraphCombo.getTimeGraphViewer().getSelectedTime());
-                        broadcast(new TmfRangeSynchSignal(CallStackView.this, range, time));
+                        broadcast(new TmfRangeSynchSignal(CallStackView.this, range));
                         fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
                         startZoomThread(startTime, endTime);
                     }
@@ -567,6 +566,9 @@ public class CallStackView extends TmfView {
             }
         });
 
+        IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
+        fTimeGraphCombo.getTimeGraphViewer().getTimeGraphControl().setStatusLineManager(statusLineManager);
+
         // View Action Handling
         makeActions();
         contributeToActionBars();
@@ -649,19 +651,25 @@ public class CallStackView extends TmfView {
     @TmfSignalHandler
     public void synchToTime(final TmfTimeSynchSignal signal) {
 
-        fSavedTimeSyncSignal = isPinned() ? new TmfTimeSynchSignal(signal.getSource(), signal.getCurrentTime()) : null;
+        fSavedTimeSyncSignal = isPinned() ? new TmfTimeSynchSignal(signal.getSource(), signal.getBeginTime(), signal.getEndTime()) : null;
 
         if (signal.getSource() == this || fTrace == null || isPinned()) {
             return;
         }
-        final long time = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+        final long beginTime = signal.getBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+        final long endTime = signal.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
         Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
                 if (fTimeGraphCombo.isDisposed()) {
                     return;
                 }
-                selectTime(time);
+                if (beginTime == endTime) {
+                    fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(beginTime, true);
+                } else {
+                    fTimeGraphCombo.getTimeGraphViewer().setSelectionRange(beginTime, endTime);
+                }
+                selectTime(beginTime);
                 startZoomThread(fTimeGraphCombo.getTimeGraphViewer().getTime0(), fTimeGraphCombo.getTimeGraphViewer().getTime1());
                 if (fEntryList == null) {
                     return;
@@ -669,13 +677,13 @@ public class CallStackView extends TmfView {
                 TimeGraphViewer viewer = fTimeGraphCombo.getTimeGraphViewer();
                 for (ThreadEntry threadEntry : fEntryList) {
                     ITmfStateSystem ss = threadEntry.getTrace().getStateSystems().get(CallStackStateProvider.ID);
-                    if (ss == null || time < ss.getStartTime() || time > ss.getCurrentEndTime()) {
+                    if (ss == null || beginTime < ss.getStartTime() || beginTime > ss.getCurrentEndTime()) {
                         continue;
                     }
                     try {
                         int quark = ss.getQuarkRelative(threadEntry.getThreadQuark(), CallStackStateProvider.CALL_STACK);
-                        ITmfStateInterval stackInterval = ss.querySingleState(time, quark);
-                        if (time == stackInterval.getStartTime()) {
+                        ITmfStateInterval stackInterval = ss.querySingleState(beginTime, quark);
+                        if (beginTime == stackInterval.getStartTime()) {
                             int stackLevel = stackInterval.getStateValue().unboxInt();
                             CallStackEntry selectedEntry = threadEntry.getChildren().get(Math.max(0, stackLevel - 1));
                             fTimeGraphCombo.setSelection(selectedEntry);
@@ -707,7 +715,7 @@ public class CallStackView extends TmfView {
 
         if (isPinned()) {
             fSavedRangeSyncSignal =
-                    new TmfRangeSynchSignal(signal.getSource(), new TmfTimeRange(signal.getCurrentRange().getStartTime(), signal.getCurrentRange().getEndTime()), signal.getCurrentTime());
+                    new TmfRangeSynchSignal(signal.getSource(), new TmfTimeRange(signal.getCurrentRange().getStartTime(), signal.getCurrentRange().getEndTime()));
 
             fSavedTimeSyncSignal = null;
         }
@@ -720,7 +728,6 @@ public class CallStackView extends TmfView {
         }
         final long startTime = signal.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
         final long endTime = signal.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
-        final long time = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
         Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
@@ -728,7 +735,6 @@ public class CallStackView extends TmfView {
                     return;
                 }
                 fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
-                fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(time, false);
                 startZoomThread(startTime, endTime);
             }
         });
@@ -883,7 +889,6 @@ public class CallStackView extends TmfView {
         if (fEntryList == null) {
             return;
         }
-        fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(time, true);
         for (ThreadEntry threadEntry : fEntryList) {
             ITmfStateSystem ss = threadEntry.fThreadTrace.getStateSystems().get(CallStackStateProvider.ID);
             if (ss == null || !ss.waitUntilBuilt()) {
@@ -920,7 +925,6 @@ public class CallStackView extends TmfView {
             }
         }
         fTimeGraphCombo.refresh();
-        fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(time, true);
     }
 
     private void refresh() {
@@ -941,12 +945,14 @@ public class CallStackView extends TmfView {
                 fTimeGraphCombo.setInput(entries);
                 fTimeGraphCombo.getTimeGraphViewer().setTimeBounds(fStartTime, fEndTime);
 
-                long timestamp = fTrace == null ? 0 : fTraceManager.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+                long selectionBeginTime = fTrace == null ? 0 : fTraceManager.getSelectionBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+                long selectionEndTime = fTrace == null ? 0 : fTraceManager.getSelectionEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
                 long startTime = fTrace == null ? 0 : fTraceManager.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
                 long endTime = fTrace == null ? 0 : fTraceManager.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
                 startTime = Math.max(startTime, fStartTime);
                 endTime = Math.min(endTime, fEndTime);
-                selectTime(timestamp);
+                fTimeGraphCombo.getTimeGraphViewer().setSelectionRange(selectionBeginTime, selectionEndTime);
+                selectTime(selectionBeginTime);
                 fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
                 startZoomThread(startTime, endTime);
             }
@@ -1051,7 +1057,7 @@ public class CallStackView extends TmfView {
                             CallStackEntry callStackEntry = (CallStackEntry) entry;
                             ITmfTrace trace = callStackEntry.getTrace();
                             ITmfStateSystem ss = trace.getStateSystems().get(CallStackStateProvider.ID);
-                            long time = Math.max(ss.getStartTime(), Math.min(ss.getCurrentEndTime(), viewer.getSelectedTime()));
+                            long time = Math.max(ss.getStartTime(), Math.min(ss.getCurrentEndTime(), viewer.getSelectionBegin()));
                             ThreadEntry threadEntry = (ThreadEntry) callStackEntry.getParent();
                             int quark = ss.getQuarkRelative(threadEntry.getThreadQuark(), CallStackStateProvider.CALL_STACK);
                             ITmfStateInterval stackInterval = ss.querySingleState(time, quark);
@@ -1101,7 +1107,7 @@ public class CallStackView extends TmfView {
                             CallStackEntry callStackEntry = (CallStackEntry) entry;
                             ITmfTrace trace = callStackEntry.getTrace();
                             ITmfStateSystem ss = trace.getStateSystems().get(CallStackStateProvider.ID);
-                            long time = Math.max(ss.getStartTime(), Math.min(ss.getCurrentEndTime(), viewer.getSelectedTime()));
+                            long time = Math.max(ss.getStartTime(), Math.min(ss.getCurrentEndTime(), viewer.getSelectionBegin()));
                             ThreadEntry threadEntry = (ThreadEntry) callStackEntry.getParent();
                             int quark = ss.getQuarkRelative(threadEntry.getThreadQuark(), CallStackStateProvider.CALL_STACK);
                             ITmfStateInterval stackInterval = ss.querySingleState(time, quark);
index c81cc7d070b2f92d86e01ddf071f664baee69759..890158d84305b33a301c55c8cf15307add2ecf0c 100644 (file)
@@ -10,6 +10,7 @@
  *   Francois Chouinard - Initial API and implementation
  *   Bernd Hufmann - Changed to updated histogram data model
  *   Francois Chouinard - Reformat histogram labels on format change
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.views.histogram;
@@ -94,7 +95,8 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
 
     // Histogram colors
     private final Color fBackgroundColor = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
-    private final Color fCurrentEventColor = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
+    private final Color fSelectionForegroundColor = Display.getCurrent().getSystemColor(SWT.COLOR_BLUE);
+    private final Color fSelectionBackgroundColor = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
     private final Color fLastEventColor = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
     private final Color fHistoBarColor = new Color(Display.getDefault(), 74, 112, 139);
 
@@ -136,6 +138,16 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
      */
     protected long fCurrentEventTime = 0L;
 
+    /**
+     * The current selection begin time
+     */
+    private long fSelectionBegin = 0L;
+
+    /**
+     * The current selection end time
+     */
+    private long fSelectionEnd = 0L;
+
     // ------------------------------------------------------------------------
     // Construction
     // ------------------------------------------------------------------------
@@ -357,10 +369,28 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
      *
      * @param timestamp
      *            The time of the current event
+     * @deprecated As of 2.1, use {@link #setSelection(long, long)}
      */
+    @Deprecated
     public void setCurrentEvent(final long timestamp) {
-        fCurrentEventTime = (timestamp > 0) ? timestamp : 0;
-        fDataModel.setCurrentEventNotifyListeners(timestamp);
+        fSelectionBegin = (timestamp > 0) ? timestamp : 0;
+        fSelectionEnd = (timestamp > 0) ? timestamp : 0;
+        fDataModel.setSelectionNotifyListeners(timestamp, timestamp);
+    }
+
+    /**
+     * Sets the current selection time range and refresh the display
+     *
+     * @param beginTime
+     *            The begin time of the current selection
+     * @param endTime
+     *            The end time of the current selection
+     * @since 2.1
+     */
+    public void setSelection(final long beginTime, final long endTime) {
+        fSelectionBegin = (beginTime > 0) ? beginTime : 0;
+        fSelectionEnd = (endTime > 0) ? endTime : 0;
+        fDataModel.setSelectionNotifyListeners(beginTime, endTime);
     }
 
     /**
@@ -398,10 +428,6 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
      */
     protected void moveCursor(final int keyCode) {
 
-        if (fScaledData.fCurrentBucket == HistogramScaledData.OUT_OF_RANGE_BUCKET) {
-            return;
-        }
-
         int index;
         switch (keyCode) {
 
@@ -411,17 +437,17 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
                     index++;
                 }
                 if (index < fScaledData.fLastBucket) {
-                    fScaledData.fCurrentBucket = index;
+                    fScaledData.fSelectionBeginBucket = index;
                 }
                 break;
 
             case SWT.ARROW_RIGHT:
-                index = fScaledData.fCurrentBucket + 1;
+                index = Math.max(0, fScaledData.fSelectionBeginBucket + 1);
                 while (index < fScaledData.fWidth && fScaledData.fData[index] == 0) {
                     index++;
                 }
                 if (index < fScaledData.fLastBucket) {
-                    fScaledData.fCurrentBucket = index;
+                    fScaledData.fSelectionBeginBucket = index;
                 }
                 break;
 
@@ -431,17 +457,17 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
                     index--;
                 }
                 if (index >= 0) {
-                    fScaledData.fCurrentBucket = index;
+                    fScaledData.fSelectionBeginBucket = index;
                 }
                 break;
 
             case SWT.ARROW_LEFT:
-                index = fScaledData.fCurrentBucket - 1;
+                index = Math.min(fScaledData.fLastBucket - 1, fScaledData.fSelectionBeginBucket - 1);
                 while (index >= 0 && fScaledData.fData[index] == 0) {
                     index--;
                 }
                 if (index >= 0) {
-                    fScaledData.fCurrentBucket = index;
+                    fScaledData.fSelectionBeginBucket = index;
                 }
                 break;
 
@@ -449,7 +475,10 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
                 return;
         }
 
-        updateCurrentEventTime();
+        fScaledData.fSelectionEndBucket = fScaledData.fSelectionBeginBucket;
+        fSelectionBegin = getTimestamp(fScaledData.fSelectionBeginBucket);
+        fSelectionEnd = fSelectionBegin;
+        updateSelectionTime();
     }
 
     /**
@@ -468,7 +497,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
                         if (canvasWidth <= 0 || canvasHeight <= 0) {
                             return;
                         }
-                        fDataModel.setCurrentEvent(fCurrentEventTime);
+                        fDataModel.setSelection(fSelectionBegin, fSelectionEnd);
                         fScaledData = fDataModel.scaleTo(canvasWidth, canvasHeight, 1);
                         synchronized(fDataModel) {
                             if (fScaledData != null) {
@@ -514,9 +543,8 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
     // Helper functions
     // ------------------------------------------------------------------------
 
-    private void updateCurrentEventTime() {
-        final long bucketStartTime = getTimestamp(fScaledData.fCurrentBucket);
-        ((HistogramView) fParentView).updateCurrentEventTime(bucketStartTime);
+    private void updateSelectionTime() {
+        ((HistogramView) fParentView).updateSelectionTime(fSelectionBegin, fSelectionEnd);
     }
 
     // ------------------------------------------------------------------------
@@ -578,12 +606,6 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
                 imageGC.fillRectangle(i, height - value, 1, value);
             }
 
-            // Draw the current event bar
-            final int currentBucket = scaledData.fCurrentBucket;
-            if (currentBucket >= 0 && currentBucket < limit) {
-                drawDelimiter(imageGC, fCurrentEventColor, height, currentBucket);
-            }
-
             // Add a dashed line as a delimiter (at the right of the last bar)
             int lastEventIndex = limit - 1;
             while (lastEventIndex >= 0 && scaledData.fData[lastEventIndex] == 0) {
@@ -591,6 +613,24 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
             }
             lastEventIndex += (lastEventIndex < limit - 1) ? 1 : 0;
             drawDelimiter(imageGC, fLastEventColor, height, lastEventIndex);
+
+            // Draw the selection bars
+            int alpha = imageGC.getAlpha();
+            imageGC.setAlpha(100);
+            imageGC.setForeground(fSelectionForegroundColor);
+            imageGC.setBackground(fSelectionBackgroundColor);
+            final int beginBucket = scaledData.fSelectionBeginBucket;
+            if (beginBucket >= 0 && beginBucket < limit) {
+                imageGC.drawLine(beginBucket, 0, beginBucket, height);
+            }
+            final int endBucket = Math.min(lastEventIndex, scaledData.fSelectionEndBucket);
+            if (endBucket >= 0 && endBucket < limit && endBucket != beginBucket) {
+                imageGC.drawLine(endBucket, 0, endBucket, height);
+            }
+            if (endBucket - beginBucket > 1) {
+                imageGC.fillRectangle(beginBucket + 1, 0, endBucket - beginBucket - 1, height);
+            }
+            imageGC.setAlpha(alpha);
         } catch (final Exception e) {
             // Do nothing
         }
@@ -630,8 +670,29 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
     @Override
     public void mouseDown(final MouseEvent event) {
         if (fDataModel.getNbEvents() > 0 && fScaledData.fLastBucket >= event.x) {
-            fScaledData.fCurrentBucket = event.x;
-            updateCurrentEventTime();
+            if ((event.stateMask & SWT.MODIFIER_MASK) == 0) {
+                fScaledData.fSelectionBeginBucket = event.x;
+                fScaledData.fSelectionEndBucket = event.x;
+                fSelectionBegin = getTimestamp(event.x);
+                fSelectionEnd = fSelectionBegin;
+            } else if ((event.stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT) {
+                if (fSelectionBegin == fSelectionEnd) {
+                    if (event.x < fScaledData.fSelectionBeginBucket) {
+                        fScaledData.fSelectionBeginBucket = event.x;
+                        fSelectionBegin = getTimestamp(event.x);
+                    } else {
+                        fScaledData.fSelectionEndBucket = event.x;
+                        fSelectionEnd = getTimestamp(event.x);
+                    }
+                } else if (Math.abs(event.x - fScaledData.fSelectionBeginBucket) <= Math.abs(event.x - fScaledData.fSelectionEndBucket)) {
+                    fScaledData.fSelectionBeginBucket = event.x;
+                    fSelectionBegin = getTimestamp(event.x);
+                } else {
+                    fScaledData.fSelectionEndBucket = event.x;
+                    fSelectionEnd = getTimestamp(event.x);
+                }
+            }
+            updateSelectionTime();
         }
     }
 
index d9679862a49e9b2328bf9f479a339ef54938a4e8..74640dcb20fcf91ede085a8a0415517de1569919 100644 (file)
@@ -92,7 +92,7 @@ public class HistogramCurrentTimeControl extends HistogramTextControl {
 
             // Set and propagate
             setValue(value);
-            fParentView.updateCurrentEventTime(value);
+            fParentView.updateSelectionTime(value, value);
         } else {
             setValue(value);
         }
index 4246b42737a661af0d864c5a65577a3503d5ae1c..a59b178fa5531ac418e809673017b4fe6d23d7ba 100644 (file)
@@ -12,6 +12,7 @@
  *                   time stamp in any order
  *   Francois Chouinard - Moved from LTTng to TMF
  *   Francois Chouinard - Added support for empty initial buckets
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.views.histogram;
@@ -93,7 +94,8 @@ public class HistogramDataModel implements IHistogramDataModel {
     private long fFirstBucketTime; // could be negative when analyzing events with descending order!!!
     private long fFirstEventTime;
     private long fLastEventTime;
-    private long fCurrentEventTime;
+    private long fSelectionBegin;
+    private long fSelectionEnd;
     private long fTimeLimit;
 
     // Private listener lists
@@ -154,7 +156,8 @@ public class HistogramDataModel implements IHistogramDataModel {
         fFirstBucketTime = other.fFirstBucketTime;
         fFirstEventTime = other.fFirstEventTime;
         fLastEventTime = other.fLastEventTime;
-        fCurrentEventTime = other.fCurrentEventTime;
+        fSelectionBegin = other.fSelectionBegin;
+        fSelectionEnd = other.fSelectionEnd;
         fTimeLimit = other.fTimeLimit;
         fModelListeners = new ListenerList();
         Object[] listeners = other.fModelListeners.getListeners();
@@ -233,9 +236,29 @@ public class HistogramDataModel implements IHistogramDataModel {
     /**
      * Returns the time of the current event in the model.
      * @return the time of the current event.
+     * @deprecated As of 2.1, use {@link #getSelectionBegin()} and {@link #getSelectionEnd()}
      */
+    @Deprecated
     public long getCurrentEventTime() {
-        return fCurrentEventTime;
+        return fSelectionBegin;
+    }
+
+    /**
+     * Returns the begin time of the current selection in the model.
+     * @return the begin time of the current selection.
+     * @since 2.1
+     */
+    public long getSelectionBegin() {
+        return fSelectionBegin;
+    }
+
+    /**
+     * Returns the end time of the current selection in the model.
+     * @return the end time of the current selection.
+     * @since 2.1
+     */
+    public long getSelectionEnd() {
+        return fSelectionEnd;
     }
 
     /**
@@ -301,7 +324,8 @@ public class HistogramDataModel implements IHistogramDataModel {
         fNbEvents = 0;
         fFirstBucketTime = 0;
         fLastEventTime = 0;
-        fCurrentEventTime = 0;
+        fSelectionBegin = 0;
+        fSelectionEnd = 0;
         fLastBucket = 0;
         fBucketDuration = 1;
         updateEndTime();
@@ -312,18 +336,49 @@ public class HistogramDataModel implements IHistogramDataModel {
      * Sets the current event time (no notification of listeners)
      *
      * @param timestamp A time stamp to set.
+     * @deprecated As of 2.1, use {@link #setSelection(long, long)}
      */
+    @Deprecated
     public void setCurrentEvent(long timestamp) {
-        fCurrentEventTime = timestamp;
+        fSelectionBegin = timestamp;
+        fSelectionEnd = timestamp;
     }
 
     /**
      * Sets the current event time with notification of listeners
      *
      * @param timestamp A time stamp to set.
+     * @deprecated As of 2.1, use {@link #setSelectionNotifyListeners(long, long)}
      */
+    @Deprecated
     public void setCurrentEventNotifyListeners(long timestamp) {
-        fCurrentEventTime = timestamp;
+        fSelectionBegin = timestamp;
+        fSelectionEnd = timestamp;
+        fireModelUpdateNotification();
+    }
+
+    /**
+     * Sets the current selection time range (no notification of listeners)
+     *
+     * @param beginTime The selection begin time.
+     * @param endTime The selection end time.
+     * @since 2.1
+     */
+    public void setSelection(long beginTime, long endTime) {
+        fSelectionBegin = beginTime;
+        fSelectionEnd = endTime;
+    }
+
+    /**
+     * Sets the current selection time range with notification of listeners
+     *
+     * @param beginTime The selection begin time.
+     * @param endTime The selection end time.
+     * @since 2.1
+     */
+    public void setSelectionNotifyListeners(long beginTime, long endTime) {
+        fSelectionBegin = beginTime;
+        fSelectionEnd = endTime;
         fireModelUpdateNotification();
     }
 
@@ -442,11 +497,20 @@ public class HistogramDataModel implements IHistogramDataModel {
         }
 
         fBucketDuration = Math.max(fBucketDuration, 1);
-        // Set the current event index in the scaled histogram
-        if ((fCurrentEventTime >= fFirstBucketTime) && (fCurrentEventTime <= fLastEventTime)) {
-            result.fCurrentBucket = (int) ((fCurrentEventTime - fFirstBucketTime) / fBucketDuration) / bucketsPerBar;
+        // Set selection begin and end index in the scaled histogram
+        if (fSelectionBegin < fFirstBucketTime) {
+            result.fSelectionBeginBucket = -1;
+        } else if (fSelectionBegin > fLastEventTime) {
+            result.fSelectionBeginBucket = fLastBucket;
+        } else {
+            result.fSelectionBeginBucket = (int) ((fSelectionBegin - fFirstBucketTime) / fBucketDuration) / bucketsPerBar;
+        }
+        if (fSelectionEnd < fFirstBucketTime) {
+            result.fSelectionEndBucket = -1;
+        } else if (fSelectionEnd > fLastEventTime) {
+            result.fSelectionEndBucket = fLastBucket;
         } else {
-            result.fCurrentBucket = HistogramScaledData.OUT_OF_RANGE_BUCKET;
+            result.fSelectionEndBucket = (int) ((fSelectionEnd - fFirstBucketTime) / fBucketDuration) / bucketsPerBar;
         }
 
         result.fFirstBucketTime = fFirstBucketTime;
index a21e73424f99e0c1a423a0d06913a34b8d9497e2..52487a7b6aee6956a89f1835f365c948e2dc470b 100644 (file)
@@ -10,6 +10,7 @@
  *   Francois Chouinard - Initial API and implementation
  *   Bernd Hufmann - Added setter and getter and bar width support
  *   Francois Chouinard - Moved from LTTng to TMF
+ *   Patrick Tasse - Support selection range
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.views.histogram;
@@ -63,7 +64,18 @@ public class HistogramScaledData {
     /**
      * The index of the current bucket.
      */
+    @Deprecated
     public int fCurrentBucket;
+    /**
+     * The index of the selection begin bucket.
+     * @since 2.1
+     */
+    public int fSelectionBeginBucket;
+    /**
+     * The index of the selection end bucket.
+     * @since 2.1
+     */
+    public int fSelectionEndBucket;
     /**
      * The index of the last bucket.
      */
@@ -99,7 +111,8 @@ public class HistogramScaledData {
         Arrays.fill(fData, 0);
         fBucketDuration = 1;
         fMaxValue = 0;
-        fCurrentBucket = 0;
+        fSelectionBeginBucket = 0;
+        fSelectionEndBucket = 0;
         fLastBucket = 0;
         fScalingFactor = 1;
         fFirstBucketTime = 0;
@@ -116,7 +129,8 @@ public class HistogramScaledData {
         fData = Arrays.copyOf(other.fData, fWidth);
         fBucketDuration = other.fBucketDuration;
         fMaxValue = other.fMaxValue;
-        fCurrentBucket = other.fCurrentBucket;
+        fSelectionBeginBucket = other.fSelectionBeginBucket;
+        fSelectionEndBucket = other.fSelectionEndBucket;
         fLastBucket = other.fLastBucket;
         fScalingFactor = other.fScalingFactor;
         fFirstBucketTime = other.fFirstBucketTime;
index 45cd97e821c838e21822a77be1ed9680aa110481..e41d14c6c38b569cf5a57bcc6144e5b98df01dad 100644 (file)
@@ -18,7 +18,6 @@
 
 package org.eclipse.linuxtools.tmf.ui.views.histogram;
 
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
 import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
@@ -83,7 +82,8 @@ public class HistogramView extends TmfView {
     private long fWindowStartTime;
     private long fWindowEndTime;
     private long fWindowSpan;
-    private long fCurrentTimestamp;
+    private long fSelectionBeginTime;
+    private long fSelectionEndTime;
 
     // Time controls
     private HistogramTextControl fCurrentEventTimeControl;
@@ -297,29 +297,20 @@ public class HistogramView extends TmfView {
     // ------------------------------------------------------------------------
 
     /**
-     * Broadcast TmfSignal about new current time value.
-     * @param newTime the new current time.
+     * Broadcast TmfSignal about new current selection time range.
+     * @param beginTime the begin time of current selection.
+     * @param endTime the end time of current selection.
      */
-    void updateCurrentEventTime(long newTime) {
-        if (fTrace != null) {
-            TmfTimeRange timeRange = new TmfTimeRange(new TmfTimestamp(newTime, ITmfTimestamp.NANOSECOND_SCALE), TmfTimestamp.BIG_CRUNCH);
-            HistogramRequest request = new HistogramRequest(fTimeRangeHistogram.getDataModel(), timeRange, 0, 1, 0, ExecutionType.FOREGROUND) {
-                @Override
-                public void handleData(ITmfEvent event) {
-                    if (event != null) {
-                        ITmfTimestamp ts = event.getTimestamp();
-                        updateDisplayedCurrentTime(ts.normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
-                        TmfTimeSynchSignal signal = new TmfTimeSynchSignal(this, ts);
-                        fTimeSyncThrottle.queue(signal);
-                    }
-                }
-            };
-            fTrace.sendRequest(request);
-        }
+    void updateSelectionTime(long beginTime, long endTime) {
+        updateDisplayedSelectionTime(beginTime, endTime);
+        TmfTimestamp beginTs = new TmfTimestamp(beginTime, ITmfTimestamp.NANOSECOND_SCALE);
+        TmfTimestamp endTs = new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE);
+        TmfTimeSynchSignal signal = new TmfTimeSynchSignal(this, beginTs, endTs);
+        fTimeSyncThrottle.queue(signal);
     }
 
     /**
-     * Broadcast TmfSignal about new selected time range.
+     * Broadcast TmfSignal about new selection time range.
      * @param startTime the new start time
      * @param endTime the new end time
      */
@@ -329,13 +320,12 @@ public class HistogramView extends TmfView {
             TmfTimeRange timeRange = new TmfTimeRange(
                     new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE),
                     new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE));
-            ITmfTimestamp currentTime = new TmfTimestamp(fCurrentTimestamp, ITmfTimestamp.NANOSECOND_SCALE);
             fTimeSpanControl.setValue(endTime - startTime);
 
             updateDisplayedTimeRange(startTime, endTime);
 
             // Send the FW signal
-            TmfRangeSynchSignal signal = new TmfRangeSynchSignal(this, timeRange, currentTime);
+            TmfRangeSynchSignal signal = new TmfRangeSynchSignal(this, timeRange);
             fTimeRangeSyncThrottle.queue(signal);
         }
     }
@@ -435,7 +425,8 @@ public class HistogramView extends TmfView {
         fWindowStartTime = 0L;
         fWindowEndTime = 0L;
         fWindowSpan = 0L;
-        fCurrentTimestamp = 0L;
+        fSelectionBeginTime = 0L;
+        fSelectionEndTime = 0L;
 
         // Clear the UI widgets
         fFullTraceHistogram.clear();
@@ -507,9 +498,10 @@ public class HistogramView extends TmfView {
         // Because this can't happen :-)
         assert (signal != null);
 
-        // Update the selected event time
-        ITmfTimestamp currentTime = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
-        updateDisplayedCurrentTime(currentTime.getValue());
+        // Update the selected time range
+        ITmfTimestamp beginTime = signal.getBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
+        ITmfTimestamp endTime = signal.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
+        updateDisplayedSelectionTime(beginTime.getValue(), endTime.getValue());
     }
 
     /**
@@ -545,7 +537,8 @@ public class HistogramView extends TmfView {
 
     private void initializeHistograms() {
         TmfTimeRange fullRange = updateTraceTimeRange();
-        long timestamp = fTraceManager.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+        long selectionBeginTime = fTraceManager.getSelectionBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+        long selectionEndTime = fTraceManager.getSelectionEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
         long startTime = fTraceManager.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
         long duration = fTraceManager.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue() - startTime;
 
@@ -555,7 +548,7 @@ public class HistogramView extends TmfView {
         fTimeRangeHistogram.clear();
         fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
         fTimeRangeHistogram.setTimeRange(startTime, duration);
-        fTimeRangeHistogram.setCurrentEvent(timestamp);
+        fTimeRangeHistogram.setSelection(selectionBeginTime, selectionEndTime);
 
         if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
             fFullTraceRequest.cancel();
@@ -563,14 +556,15 @@ public class HistogramView extends TmfView {
         fFullTraceHistogram.clear();
         fFullTraceHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
         fFullTraceHistogram.setTimeRange(startTime, duration);
-        fFullTraceHistogram.setCurrentEvent(timestamp);
+        fFullTraceHistogram.setSelection(selectionBeginTime, selectionEndTime);
 
         fWindowStartTime = startTime;
         fWindowSpan = duration;
         fWindowEndTime = startTime + duration;
 
-        fCurrentTimestamp = timestamp;
-        fCurrentEventTimeControl.setValue(fCurrentTimestamp);
+        fSelectionBeginTime = selectionBeginTime;
+        fSelectionEndTime = selectionEndTime;
+        fCurrentEventTimeControl.setValue(fSelectionBeginTime);
 
         fTimeSpanControl.setValue(duration);
 
@@ -580,12 +574,13 @@ public class HistogramView extends TmfView {
         }
     }
 
-    private void updateDisplayedCurrentTime(long time) {
-        fCurrentTimestamp = time;
+    private void updateDisplayedSelectionTime(long beginTime, long endTime) {
+        fSelectionBeginTime = beginTime;
+        fSelectionEndTime = endTime;
 
-        fFullTraceHistogram.setCurrentEvent(fCurrentTimestamp);
-        fTimeRangeHistogram.setCurrentEvent(fCurrentTimestamp);
-        fCurrentEventTimeControl.setValue(fCurrentTimestamp);
+        fFullTraceHistogram.setSelection(fSelectionBeginTime, fSelectionEndTime);
+        fTimeRangeHistogram.setSelection(fSelectionBeginTime, fSelectionEndTime);
+        fCurrentEventTimeControl.setValue(fSelectionBeginTime);
     }
 
     private void updateDisplayedTimeRange(long start, long end) {
index ec4f1b445b21bc12505d1599500c14dbc4b32b36..35819243820e68d588256ee1a3cb557b7d8f8421 100644 (file)
@@ -481,7 +481,7 @@ public class TmfStateSystemExplorer extends TmfView {
         Thread thread = new Thread("State system visualizer update") { //$NON-NLS-1$
             @Override
             public void run() {
-                ITmfTimestamp currentTime = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
+                ITmfTimestamp currentTime = signal.getBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
                 fCurrentTimestamp = currentTime.getValue();
 
                 if (filterStatus) {
index b36d9ff62293420d641c61d492822b27bb860b3b..899b6862586862adbbb826d5b84306f87af043d5 100644 (file)
@@ -24,6 +24,7 @@ import org.eclipse.core.resources.IResourceChangeEvent;
 import org.eclipse.core.resources.IResourceChangeListener;
 import org.eclipse.core.resources.IResourceDelta;
 import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.action.IStatusLineManager;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.signal.TmfEventFilterAppliedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfEventSearchAppliedSignal;
@@ -108,6 +109,9 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
         fViewer.addSelectionListener(this);
         fViewer.setMinimumItemWidth(1);
 
+        IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
+        fViewer.getTimeGraphControl().setStatusLineManager(statusLineManager);
+
         IEditorReference[] editorReferences = getSite().getPage().getEditorReferences();
         for (IEditorReference editorReference : editorReferences) {
             IEditorPart editor = editorReference.getEditor(false);
@@ -524,8 +528,7 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
         final ITmfTimestamp startTimestamp = new TmfTimestamp(event.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE);
         final ITmfTimestamp endTimestamp = new TmfTimestamp(event.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE);
         TmfTimeRange range = new TmfTimeRange(startTimestamp, endTimestamp);
-        TmfTimestamp timestamp = new TmfTimestamp(fViewer.getSelectedTime(), ITmfTimestamp.NANOSECOND_SCALE);
-        broadcast(new TmfRangeSynchSignal(this, range, timestamp));
+        broadcast(new TmfRangeSynchSignal(this, range));
     }
 
     @Override
@@ -543,7 +546,7 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
 
     @Override
     public void timeSelected(TimeGraphTimeEvent event) {
-        broadcast(new TmfTimeSynchSignal(this, new TmfTimestamp(event.getTime(), TIMESTAMP_SCALE)));
+        broadcast(new TmfTimeSynchSignal(this, new TmfTimestamp(event.getBeginTime(), TIMESTAMP_SCALE), new TmfTimestamp(event.getEndTime(), TIMESTAMP_SCALE)));
     }
 
     @Override
@@ -647,7 +650,9 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
                     break;
                 }
             }
-            fViewer.setSelectedTime(fTraceManager.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(), false);
+            long beginTime = fTraceManager.getSelectionBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+            long endTime = fTraceManager.getSelectionEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+            fViewer.setSelectionRange(beginTime, endTime);
         }
     }
 
@@ -677,11 +682,21 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
      */
     @TmfSignalHandler
     public void currentTimeUpdated(TmfTimeSynchSignal signal) {
-        final long time = signal.getCurrentTime().normalize(0, TIMESTAMP_SCALE).getValue();
+        final long beginTime = signal.getBeginTime().normalize(0, TIMESTAMP_SCALE).getValue();
+        final long endTime = signal.getEndTime().normalize(0, TIMESTAMP_SCALE).getValue();
         Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
-                fViewer.setSelectedTime(time, true);
+                if (beginTime == endTime) {
+                    fViewer.setSelectedTime(beginTime, true);
+                    if (fStartTime != fViewer.getTime0() || fStopTime != fViewer.getTime1()) {
+                        fStartTime = fViewer.getTime0();
+                        fStopTime = fViewer.getTime1();
+                        itemize(fStartTime, fStopTime);
+                    }
+                } else {
+                    fViewer.setSelectionRange(beginTime, endTime);
+                }
             }
         });
     }
@@ -700,7 +715,6 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
         }
         final long startTime = signal.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
         final long endTime = signal.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
-        final long time = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
         Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
@@ -708,7 +722,6 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
                 fStopTime = endTime;
                 itemize(fStartTime, fStopTime);
                 fViewer.setStartFinishTime(startTime, endTime);
-                fViewer.setSelectedTime(time, false);
             }
         });
     }
index 54223a7429ce7ee595be86f49fd21d2bcee28a7a..b054c9232d1e554b407898b8d577a75de290831a 100644 (file)
@@ -26,6 +26,7 @@ import java.util.Map;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IStatusLineManager;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.viewers.ILabelProviderListener;
@@ -42,7 +43,6 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.ui.views.TmfView;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;
@@ -524,8 +524,7 @@ public abstract class AbstractTimeGraphView extends TmfView {
                 final long startTime = event.getStartTime();
                 final long endTime = event.getEndTime();
                 TmfTimeRange range = new TmfTimeRange(new CtfTmfTimestamp(startTime), new CtfTmfTimestamp(endTime));
-                TmfTimestamp time = new CtfTmfTimestamp(fTimeGraphCombo.getTimeGraphViewer().getSelectedTime());
-                broadcast(new TmfRangeSynchSignal(AbstractTimeGraphView.this, range, time));
+                broadcast(new TmfRangeSynchSignal(AbstractTimeGraphView.this, range));
                 if (fZoomThread != null) {
                     fZoomThread.cancel();
                 }
@@ -536,8 +535,9 @@ public abstract class AbstractTimeGraphView extends TmfView {
         fTimeGraphCombo.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
             @Override
             public void timeSelected(TimeGraphTimeEvent event) {
-                long time = event.getTime();
-                broadcast(new TmfTimeSynchSignal(AbstractTimeGraphView.this, new CtfTmfTimestamp(time)));
+                CtfTmfTimestamp startTime = new CtfTmfTimestamp(event.getBeginTime());
+                CtfTmfTimestamp endTime = new CtfTmfTimestamp(event.getEndTime());
+                broadcast(new TmfTimeSynchSignal(AbstractTimeGraphView.this, startTime, endTime));
             }
         });
 
@@ -550,6 +550,9 @@ public abstract class AbstractTimeGraphView extends TmfView {
 
         fTimeGraphCombo.getTimeGraphViewer().setTimeFormat(TimeFormat.CALENDAR);
 
+        IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
+        fTimeGraphCombo.getTimeGraphViewer().getTimeGraphControl().setStatusLineManager(statusLineManager);
+
         // View Action Handling
         makeActions();
         contributeToActionBars();
@@ -630,7 +633,7 @@ public abstract class AbstractTimeGraphView extends TmfView {
     }
 
     /**
-     * Handler for the synch signal
+     * Handler for the time synch signal
      *
      * @param signal
      *            The signal that's received
@@ -640,7 +643,8 @@ public abstract class AbstractTimeGraphView extends TmfView {
         if (signal.getSource() == this || fTrace == null) {
             return;
         }
-        final long time = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+        final long beginTime = signal.getBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+        final long endTime = signal.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
 
         Display.getDefault().asyncExec(new Runnable() {
             @Override
@@ -648,16 +652,20 @@ public abstract class AbstractTimeGraphView extends TmfView {
                 if (fTimeGraphCombo.isDisposed()) {
                     return;
                 }
-                fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(time, true);
+                if (beginTime == endTime) {
+                    fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(beginTime, true);
+                } else {
+                    fTimeGraphCombo.getTimeGraphViewer().setSelectionRange(beginTime, endTime);
+                }
                 startZoomThread(fTimeGraphCombo.getTimeGraphViewer().getTime0(), fTimeGraphCombo.getTimeGraphViewer().getTime1());
 
-                synchingToTime(time);
+                synchingToTime(beginTime);
             }
         });
     }
 
     /**
-     * Handler for the range sync signal
+     * Handler for the range synch signal
      *
      * @param signal
      *            The signal that's received
@@ -672,7 +680,6 @@ public abstract class AbstractTimeGraphView extends TmfView {
         }
         final long startTime = signal.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
         final long endTime = signal.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
-        final long time = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
         Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
@@ -680,7 +687,6 @@ public abstract class AbstractTimeGraphView extends TmfView {
                     return;
                 }
                 fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
-                fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(time, false);
                 startZoomThread(startTime, endTime);
             }
         });
@@ -781,12 +787,13 @@ public abstract class AbstractTimeGraphView extends TmfView {
                 fTimeGraphCombo.setInput(entries);
                 fTimeGraphCombo.getTimeGraphViewer().setTimeBounds(fStartTime, fEndTime);
 
-                long timestamp = fTrace == null ? 0 : fTraceManager.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+                long selectionBeginTime = fTrace == null ? 0 : fTraceManager.getSelectionBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+                long selectionEndTime = fTrace == null ? 0 : fTraceManager.getSelectionEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
                 long startTime = fTrace == null ? 0 : fTraceManager.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
                 long endTime = fTrace == null ? 0 : fTraceManager.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
                 startTime = Math.max(startTime, fStartTime);
                 endTime = Math.min(endTime, fEndTime);
-                fTimeGraphCombo.getTimeGraphViewer().setSelectedTime(timestamp, false);
+                fTimeGraphCombo.getTimeGraphViewer().setSelectionRange(selectionBeginTime, selectionEndTime);
                 fTimeGraphCombo.getTimeGraphViewer().setStartFinishTime(startTime, endTime);
 
                 for (TreeColumn column : fTimeGraphCombo.getTreeViewer().getTree().getColumns()) {
index 442b8058f38e1da8f839304fa03174c6edae10f5..d098ac7c72774dd97344609f5c5b240b0b8480ac 100644 (file)
@@ -462,7 +462,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
         fLock.lock();
         try {
             if ((signal.getSource() != this) && (fFrame != null) && (fCheckPoints.size() > 0)) {
-                fCurrentTime = signal.getCurrentTime();
+                fCurrentTime = signal.getBeginTime();
                 fIsSelect = true;
                 moveToMessage();
             }
@@ -1105,7 +1105,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
 
         if (notifyAll) {
             TmfTimeRange timeRange = getSignalTimeRange(window.getStartTime());
-            broadcast(new TmfRangeSynchSignal(this, timeRange, timeRange.getStartTime()));
+            broadcast(new TmfRangeSynchSignal(this, timeRange));
         }
     }
 
index b6c476ce30f594051447f4fe9cf58e137b638f50..bee7bb2feb4abbafd516982b583bf37fc6672ccb 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2013 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -15,7 +15,7 @@ package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
 import java.util.EventObject;
 
 /**
- * Event for the time graph view
+ * Time selection event
  *
  * @version 1.0
  * @author Patrick Tasse
@@ -29,9 +29,14 @@ public class TimeGraphTimeEvent extends EventObject {
     private static final long serialVersionUID = 1L;
 
     /**
-     * The selected time.
+     * The selection begin time.
      */
-    private final long fTime;
+    private final long fBeginTime;
+
+    /**
+     * The selection end time.
+     */
+    private final long fEndTime;
 
     /**
      * Standard constructor
@@ -40,17 +45,55 @@ public class TimeGraphTimeEvent extends EventObject {
      *            The source of this event
      * @param time
      *            The time that was requested
+     * @deprecated As of 2.1, use {@link #TimeGraphTimeEvent(Object, long, long)}
      */
+    @Deprecated
     public TimeGraphTimeEvent(Object source, long time) {
         super(source);
-        fTime = time;
+        fBeginTime = time;
+        fEndTime = time;
+    }
+
+    /**
+     * Standard constructor
+     *
+     * @param source
+     *            The source of this event
+     * @param beginTime
+     *            The selection begin time
+     * @param endTime
+     *            The selection end time
+     * @since 2.1
+     */
+    public TimeGraphTimeEvent(Object source, long beginTime, long endTime) {
+        super(source);
+        fBeginTime = beginTime;
+        fEndTime = endTime;
     }
 
     /**
      * @return the selected time
+     * @deprecated As of 2.1, use {@link #getBeginTime()} and {@link #getEndTime()}
      */
+    @Deprecated
     public long getTime() {
-        return fTime;
+        return fBeginTime;
+    }
+
+    /**
+     * @return the selection begin time
+     * @since 2.1
+     */
+    public long getBeginTime() {
+        return fBeginTime;
+    }
+
+    /**
+     * @return the selection end time
+     * @since 2.1
+     */
+    public long getEndTime() {
+        return fEndTime;
     }
 
 }
index 2debbd2afeda4ef5e0ad487c6c7bb1f23957710b..16bcab2856336e6ee50d402da328bb23ef716ffd 100644 (file)
@@ -27,7 +27,7 @@ import org.eclipse.linuxtools.internal.tmf.ui.Messages;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs.TimeGraphLegend;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider2;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphScale;
@@ -60,7 +60,7 @@ import org.eclipse.swt.widgets.Slider;
  * @version 1.0
  * @author Patrick Tasse, and others
  */
-public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
+public class TimeGraphViewer implements ITimeDataProvider2, SelectionListener {
 
     private static final int DEFAULT_NAME_WIDTH = 200;
     private static final int MIN_NAME_WIDTH = 6;
@@ -69,12 +69,13 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
     private static final long RECENTERING_MARGIN_FACTOR = 50;
 
     private long fMinTimeInterval;
-    private long fSelectedTime;
     private ITimeGraphEntry fSelectedEntry;
     private long fBeginTime;
     private long fEndTime;
     private long fTime0;
     private long fTime1;
+    private long fSelectionBegin = 0;
+    private long fSelectionEnd = 0;
     private long fTime0Bound;
     private long fTime1Bound;
     private long fTime0ExtSynch = 0;
@@ -149,7 +150,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
             setTimeRange(realInput);
             fVerticalScrollBar.setEnabled(true);
             setTopIndex(0);
-            fSelectedTime = 0;
+            fSelectionBegin = 0;
+            fSelectionEnd = 0;
             fSelectedEntry = null;
             refreshAllData(realInput);
         }
@@ -228,7 +230,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
 
     void loadOptions() {
         fMinTimeInterval = 1;
-        fSelectedTime = -1;
+        fSelectionBegin = -1;
+        fSelectionEnd = -1;
         fNameWidth = Utils.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$
                 fNameWidthPref, fMinNameWidth, MAX_NAME_WIDTH);
     }
@@ -282,6 +285,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
         fTimeGraphCtrl = createTimeGraphControl(fDataViewer, fColorScheme);
 
         fTimeGraphCtrl.setTimeProvider(this);
+        fTimeGraphCtrl.setTimeGraphScale(fTimeScaleCtrl);
         fTimeGraphCtrl.addSelectionListener(this);
         fTimeGraphCtrl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
         fTimeGraphCtrl.addMouseWheelListener(new MouseWheelListener() {
@@ -431,10 +435,15 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
      */
     private void refreshAllData(ITimeGraphEntry[] traces) {
         setTimeBounds();
-        if (fSelectedTime < fBeginTime) {
-            fSelectedTime = fBeginTime;
-        } else if (fSelectedTime > fEndTime) {
-            fSelectedTime = fEndTime;
+        if (fSelectionBegin < fBeginTime) {
+            fSelectionBegin = fBeginTime;
+        } else if (fSelectionBegin > fEndTime) {
+            fSelectionBegin = fEndTime;
+        }
+        if (fSelectionEnd < fBeginTime) {
+            fSelectionEnd = fBeginTime;
+        } else if (fSelectionEnd > fEndTime) {
+            fSelectionEnd = fEndTime;
         }
         fTimeGraphCtrl.refreshData(traces);
         fTimeScaleCtrl.redraw();
@@ -518,9 +527,11 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
         return w - fNameWidth;
     }
 
+    @SuppressWarnings("deprecation")
+    @Deprecated
     @Override
     public long getSelectedTime() {
-        return fSelectedTime;
+        return fSelectionBegin;
     }
 
     @Override
@@ -543,6 +554,22 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
         return fTime0Bound;
     }
 
+    /**
+     * @since 2.1
+     */
+    @Override
+    public long getSelectionBegin() {
+        return fSelectionBegin;
+    }
+
+    /**
+     * @since 2.1
+     */
+    @Override
+    public long getSelectionEnd() {
+        return fSelectionEnd;
+    }
+
     @Override
     public void setStartFinishTimeNotify(long time0, long time1) {
         setStartFinishTime(time0, time1);
@@ -611,6 +638,32 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
         setSelectedTimeInt(time, ensureVisible, false);
     }
 
+    /**
+     * @since 2.1
+     */
+    @Override
+    public void setSelectionRangeNotify(long beginTime, long endTime) {
+        boolean changed = (beginTime != fSelectionBegin || endTime != fSelectionEnd);
+        fSelectionBegin = Math.max(fTime0Bound, Math.min(fTime1Bound, beginTime));
+        fSelectionEnd = Math.max(fTime0Bound, Math.min(fTime1Bound, endTime));
+        fTimeGraphCtrl.redraw();
+        fTimeScaleCtrl.redraw();
+        if (changed) {
+            notifyTimeListeners(fSelectionBegin, fSelectionEnd);
+        }
+    }
+
+    /**
+     * @since 2.1
+     */
+    @Override
+    public void setSelectionRange(long beginTime, long endTime) {
+        fSelectionBegin = Math.max(fTime0Bound, Math.min(fTime1Bound, beginTime));
+        fSelectionEnd = Math.max(fTime0Bound, Math.min(fTime1Bound, endTime));
+        fTimeGraphCtrl.redraw();
+        fTimeScaleCtrl.redraw();
+    }
+
     private void setSelectedTimeInt(long time, boolean ensureVisible, boolean doNotify) {
         long time0 = fTime0;
         long time1 = fTime1;
@@ -641,16 +694,16 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
         fTimeGraphCtrl.redraw();
         fTimeScaleCtrl.redraw();
 
-
-        boolean notifySelectedTime = (time != fSelectedTime);
-        fSelectedTime = time;
+        boolean notifySelectedTime = (time != fSelectionBegin || time != fSelectionEnd);
+        fSelectionBegin = time;
+        fSelectionEnd = time;
 
         if (doNotify && ((time0 != fTime0) || (time1 != fTime1))) {
             notifyRangeListeners(fTime0, fTime1);
         }
 
         if (doNotify && notifySelectedTime) {
-            notifyTimeListeners(fSelectedTime);
+            notifyTimeListeners(fSelectionBegin, fSelectionEnd);
         }
     }
 
@@ -779,8 +832,8 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
         fTimeListeners.remove(listener);
     }
 
-    private void notifyTimeListeners(long time) {
-        TimeGraphTimeEvent event = new TimeGraphTimeEvent(this, time);
+    private void notifyTimeListeners(long startTime, long endTime) {
+        TimeGraphTimeEvent event = new TimeGraphTimeEvent(this, startTime, endTime);
 
         for (ITimeGraphTimeListener listener : fTimeListeners) {
             listener.timeSelected(event);
index 49de317110c12be8bb48368ffd1ec48d6f87209e..dd2a197efd6f97df8fbb514108d63cf5e20cafef 100644 (file)
@@ -28,7 +28,10 @@ public interface ITimeDataProvider {
 
     /**
      * @return The selected time
+     *
+     * @deprecated As of 2.1, replaced by {@link ITimeDataProvider2#getSelectionBegin()} and {@link ITimeDataProvider2#getSelectionEnd()}
      */
+    @Deprecated
     long getSelectedTime();
 
     /**
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider2.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider2.java
new file mode 100644 (file)
index 0000000..946f77f
--- /dev/null
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2013 Ã‰cole Polytechnique de Montréal, Ericsson.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Geneviève Bastien - Added methods to save a time range selection
+ *   Patrick Tasse - Support for range selection
+ *****************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
+
+
+/**
+ * Extension of the ITimeDateProvider interface to avoid API breakage
+ *
+ * @version 1.0
+ * @TODO: Move these to the ITimeDateProvider interface when API 3.0 is reached
+ * @since 2.1
+ */
+public interface ITimeDataProvider2 extends ITimeDataProvider {
+
+    /**
+     * Updates the selection begin and end time and notifies any registered
+     * listeners about the new time range (if necessary)
+     *
+     * @param beginTime the selection begin time
+     * @param endTime the selection end time
+     */
+    void setSelectionRangeNotify(long beginTime, long endTime);
+
+    /**
+     * Updates the selection begin and end time
+     *
+     * @param beginTime the selection begin time
+     * @param endTime the selection end time
+     */
+    void setSelectionRange(long beginTime, long endTime);
+
+    /**
+     * @return The begin time of the current selection
+     */
+    long getSelectionBegin();
+
+    /**
+     * @return The end time of the current selection
+     */
+    long getSelectionEnd();
+
+}
index df69754014fb0238bdb5939fc3c57a282589415a..52f24d4192824e41a5522a92d3d44f1066808acc 100644 (file)
@@ -22,12 +22,16 @@ import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
+import org.eclipse.jface.action.IStatusLineManager;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.resource.LocalResourceManager;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampDelta;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider2;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTreeListener;
@@ -84,6 +88,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
     private static final int DRAG_TRACE_ITEM = 1;
     private static final int DRAG_SPLIT_LINE = 2;
     private static final int DRAG_ZOOM = 3;
+    private static final int DRAG_SELECTION = 4;
 
     private static final int CUSTOM_ITEM_HEIGHT = -1; // get item height from provider
 
@@ -91,6 +96,10 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
     private static final double ZOOM_IN_FACTOR = 0.8;
     private static final double ZOOM_OUT_FACTOR = 1.25;
 
+    private static final int SNAP_WIDTH = 2;
+
+    private static final int NO_STATUS = -1;
+
     /** Resource manager */
     private LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());
 
@@ -98,16 +107,19 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
     private Color[] fEventColorMap = null;
 
     private ITimeDataProvider fTimeProvider;
+    private IStatusLineManager fStatusLineManager = null;
+    private TimeGraphScale fTimeGraphScale = null;
+
     private boolean fIsInFocus = false;
-    private boolean fIsDragCursor = false;
-    private boolean fIsWaitCursor = true;
     private boolean fMouseOverSplitLine = false;
     private int fGlobalItemHeight = CUSTOM_ITEM_HEIGHT;
     private int fMinimumItemWidth = 0;
     private int fTopIndex = 0;
     private int fDragState = DRAG_NONE;
+    private int fDragButton;
     private int fDragX0 = 0;
     private int fDragX = 0;
+    private long fDragTime0 = 0; // used to preserve accuracy of modified selection
     private int fIdealNameSpace = 0;
     private long fTime0bak;
     private long fTime1bak;
@@ -118,8 +130,10 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
     private final List<ITimeGraphTreeListener> fTreeListeners = new ArrayList<ITimeGraphTreeListener>();
     private final List<MenuDetectListener> fTimeGraphEntryMenuListeners = new ArrayList<MenuDetectListener>();
     private final List<MenuDetectListener> fTimeEventMenuListeners = new ArrayList<MenuDetectListener>();
-    private final Cursor fDragCursor;
-    private final Cursor fWaitCursor;
+    private final Cursor fDragCursor = Display.getDefault().getSystemCursor(SWT.CURSOR_HAND);
+    private final Cursor fResizeCursor = Display.getDefault().getSystemCursor(SWT.CURSOR_IBEAM);
+    private final Cursor fWaitCursor = Display.getDefault().getSystemCursor(SWT.CURSOR_WAIT);
+    private final Cursor fZoomCursor = Display.getDefault().getSystemCursor(SWT.CURSOR_SIZEWE);
     private final List<ViewerFilter> fFilters = new ArrayList<ViewerFilter>();
     private MenuDetectEvent fPendingMenuDetectEvent = null;
 
@@ -194,16 +208,11 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         if (scrollHor != null) {
             scrollHor.addSelectionListener(this);
         }
-
-        fDragCursor = new Cursor(super.getDisplay(), SWT.CURSOR_SIZEWE);
-        fWaitCursor = new Cursor(super.getDisplay(), SWT.CURSOR_WAIT);
     }
 
     @Override
     public void dispose() {
         super.dispose();
-        fDragCursor.dispose();
-        fWaitCursor.dispose();
         fResourceManager.dispose();
     }
 
@@ -247,6 +256,31 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         redraw();
     }
 
+    /**
+     * Assign the status line manager
+     *
+     * @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) {
+            fStatusLineManager.setMessage(""); //$NON-NLS-1$
+        }
+        fStatusLineManager = statusLineManager;
+    }
+
+    /**
+     * Assign the time graph scale
+     *
+     * @param timeGraphScale
+     *            The time graph scale
+     * @since 2.1
+     */
+    public void setTimeGraphScale(TimeGraphScale timeGraphScale) {
+        fTimeGraphScale = timeGraphScale;
+    }
+
     /**
      * Add a selection listener
      *
@@ -580,12 +614,18 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         }
     }
 
+    @SuppressWarnings("deprecation")
     @Override
     public ISelection getSelection() {
         TimeGraphSelection sel = new TimeGraphSelection();
         ITimeGraphEntry trace = getSelectedTrace();
         if (null != trace && null != fTimeProvider) {
-            long selectedTime = fTimeProvider.getSelectedTime();
+            long selectedTime;
+            if (fTimeProvider instanceof ITimeDataProvider2) {
+                selectedTime = ((ITimeDataProvider2) fTimeProvider).getSelectionBegin();
+            } else {
+                selectedTime = fTimeProvider.getSelectedTime();
+            }
             ITimeEvent event = Utils.findEvent(trace, selectedTime, 0);
             if (event != null) {
                 sel.add(event);
@@ -670,7 +710,14 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         if (trace == null) {
             return;
         }
-        long selectedTime = fTimeProvider.getSelectedTime();
+        long selectedTime;
+        if (fTimeProvider instanceof ITimeDataProvider2) {
+            selectedTime = ((ITimeDataProvider2) fTimeProvider).getSelectionBegin();
+        } else {
+            @SuppressWarnings("deprecation")
+            long time = fTimeProvider.getSelectedTime();
+            selectedTime = time;
+        }
         long endTime = fTimeProvider.getEndTime();
         ITimeEvent nextEvent;
         if (-1 == n && selectedTime > endTime) {
@@ -782,7 +829,15 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         if (prevRange == 0) {
             return;
         }
-        long selTime = fTimeProvider.getSelectedTime();
+        long selTime;
+        if (fTimeProvider instanceof ITimeDataProvider2) {
+            ITimeDataProvider2 provider = ((ITimeDataProvider2) fTimeProvider);
+            selTime = (provider.getSelectionEnd() + provider.getSelectionBegin()) / 2;
+        } else {
+            @SuppressWarnings("deprecation")
+            long selectedTime = fTimeProvider.getSelectedTime();
+            selTime = selectedTime;
+        }
         if (selTime <= prevTime0 || selTime >= prevTime1) {
             selTime = (prevTime0 + prevTime1) / 2;
         }
@@ -811,7 +866,15 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
     public void zoomOut() {
         long prevTime0 = fTimeProvider.getTime0();
         long prevTime1 = fTimeProvider.getTime1();
-        long selTime = fTimeProvider.getSelectedTime();
+        long selTime;
+        if (fTimeProvider instanceof ITimeDataProvider2) {
+            ITimeDataProvider2 provider = ((ITimeDataProvider2) fTimeProvider);
+            selTime = (provider.getSelectionEnd() + provider.getSelectionBegin()) / 2;
+        } else {
+            @SuppressWarnings("deprecation")
+            long selectedTime = fTimeProvider.getSelectedTime();
+            selTime = selectedTime;
+        }
         if (selTime <= prevTime0 || selTime >= prevTime1) {
             selTime = (prevTime0 + prevTime1) / 2;
         }
@@ -900,12 +963,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         if (x < 0 || null == fTimeProvider) {
             return false;
         }
-        int w = 4;
         int nameWidth = fTimeProvider.getNameSpace();
-        if (x > nameWidth - w && x < nameWidth + w) {
-            return true;
-        }
-        return false;
+        return Math.abs(x - nameWidth) < SNAP_WIDTH;
     }
 
     ITimeGraphEntry getEntry(Point pt) {
@@ -1113,41 +1172,86 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         gc.setBackground(getColorScheme().getBkColor(false, false, true));
         drawBackground(gc, bounds.x, bounds.y, nameSpace, bounds.height);
 
-        if (fDragState == DRAG_ZOOM) {
-            // draw selected zoom region background
-            gc.setBackground(getColorScheme().getBkColor(false, false, true));
-            if (fDragX0 < fDragX) {
-                gc.fillRectangle(new Rectangle(fDragX0, bounds.y, fDragX - fDragX0, bounds.height));
-            } else if (fDragX0 > fDragX) {
-                gc.fillRectangle(new Rectangle(fDragX, bounds.y, fDragX0 - fDragX, bounds.height));
-            }
-        }
-
+        // draw items
         drawItems(bounds, fTimeProvider, fItemData.fExpandedItems, fTopIndex, nameSpace, gc);
 
-        // draw selected time
+        int alpha = gc.getAlpha();
+        gc.setAlpha(100);
+
         long time0 = fTimeProvider.getTime0();
         long time1 = fTimeProvider.getTime1();
-        long selectedTime = fTimeProvider.getSelectedTime();
+        long selectionBegin;
+        long selectionEnd;
+        if (fTimeProvider instanceof ITimeDataProvider2) {
+            selectionBegin = ((ITimeDataProvider2) fTimeProvider).getSelectionBegin();
+            selectionEnd = ((ITimeDataProvider2) fTimeProvider).getSelectionEnd();
+        } else {
+            @SuppressWarnings("deprecation")
+            long selectedTime = fTimeProvider.getSelectedTime();
+            selectionBegin = selectedTime;
+            selectionEnd = selectedTime;
+        }
         double pixelsPerNanoSec = (bounds.width - nameSpace <= RIGHT_MARGIN) ? 0 : (double) (bounds.width - nameSpace - RIGHT_MARGIN) / (time1 - time0);
-        int x = bounds.x + nameSpace + (int) ((selectedTime - time0) * pixelsPerNanoSec);
-        if (x >= nameSpace && x < bounds.x + bounds.width) {
+        int x0 = bounds.x + nameSpace + (int) ((selectionBegin - time0) * pixelsPerNanoSec);
+        int x1 = bounds.x + nameSpace + (int) ((selectionEnd - time0) * pixelsPerNanoSec);
+
+        // draw selection lines
+        if (fDragState != DRAG_SELECTION) {
             gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.SELECTED_TIME));
-            gc.drawLine(x, bounds.y, x, bounds.y + bounds.height);
+            if (x0 >= nameSpace && x0 < bounds.x + bounds.width) {
+                gc.drawLine(x0, bounds.y, x0, bounds.y + bounds.height);
+            }
+            if (x1 != x0) {
+                if (x1 >= nameSpace && x1 < bounds.x + bounds.width) {
+                    gc.drawLine(x1, bounds.y, x1, bounds.y + bounds.height);
+                }
+            }
         }
 
-        // draw drag line, no line if name space is 0.
+        // draw selection background
+        if (selectionBegin != 0 && selectionEnd != 0 && fDragState != DRAG_SELECTION) {
+            x0 = Math.max(nameSpace, Math.min(bounds.x + bounds.width, x0));
+            x1 = Math.max(nameSpace, Math.min(bounds.x + bounds.width, x1));
+            gc.setBackground(getColorScheme().getBkColor(false, false, true));
+            if (x1 - x0 > 1) {
+                gc.fillRectangle(new Rectangle(x0 + 1, bounds.y, x1 - x0 - 1, bounds.height));
+            } else if (x0 - x1 > 1) {
+                gc.fillRectangle(new Rectangle(x1 + 1, bounds.y, x0 - x1 - 1, bounds.height));
+            }
+        }
+
+        // draw drag selection background
+        if (fDragState == DRAG_ZOOM || fDragState == DRAG_SELECTION) {
+            gc.setBackground(getColorScheme().getBkColor(false, false, true));
+            if (fDragX0 < fDragX) {
+                gc.fillRectangle(new Rectangle(fDragX0, bounds.y, fDragX - fDragX0, bounds.height));
+            } else if (fDragX0 > fDragX) {
+                gc.fillRectangle(new Rectangle(fDragX, bounds.y, fDragX0 - fDragX, bounds.height));
+            }
+        }
+
+        // draw drag line
         if (DRAG_SPLIT_LINE == fDragState) {
             gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.BLACK));
             gc.drawLine(bounds.x + nameSpace, bounds.y, bounds.x + nameSpace, bounds.y + bounds.height - 1);
-        } else if (DRAG_ZOOM == fDragState && Math.max(fDragX, fDragX0) > nameSpace && fDragX != fDragX0) {
+        } else if (DRAG_ZOOM == fDragState && Math.max(fDragX, fDragX0) > nameSpace) {
             gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.TOOL_FOREGROUND));
             gc.drawLine(fDragX0, bounds.y, fDragX0, bounds.y + bounds.height - 1);
-            gc.drawLine(fDragX, bounds.y, fDragX, bounds.y + bounds.height - 1);
+            if (fDragX != fDragX0) {
+                gc.drawLine(fDragX, bounds.y, fDragX, bounds.y + bounds.height - 1);
+            }
+        } else if (DRAG_SELECTION == fDragState && Math.max(fDragX, fDragX0) > nameSpace) {
+            gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.SELECTED_TIME));
+            gc.drawLine(fDragX0, bounds.y, fDragX0, bounds.y + bounds.height - 1);
+            if (fDragX != fDragX0) {
+                gc.drawLine(fDragX, bounds.y, fDragX, bounds.y + bounds.height - 1);
+            }
         } else if (DRAG_NONE == fDragState && fMouseOverSplitLine && fTimeProvider.getNameSpace() > 0) {
             gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.RED));
             gc.drawLine(bounds.x + nameSpace, bounds.y, bounds.x + nameSpace, bounds.y + bounds.height - 1);
         }
+
+        gc.setAlpha(alpha);
     }
 
     /**
@@ -1189,7 +1293,14 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         ITimeGraphEntry entry = item.fTrace;
         long time0 = timeProvider.getTime0();
         long time1 = timeProvider.getTime1();
-        long selectedTime = timeProvider.getSelectedTime();
+        long selectedTime;
+        if (fTimeProvider instanceof ITimeDataProvider2) {
+            selectedTime = ((ITimeDataProvider2) fTimeProvider).getSelectionBegin();
+        } else {
+            @SuppressWarnings("deprecation")
+            long time = fTimeProvider.getSelectedTime();
+            selectedTime = time;
+        }
 
         Rectangle nameRect = getNameRect(bounds, i, nameSpace);
         if (nameRect.y >= bounds.y + bounds.height) {
@@ -1524,10 +1635,14 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
             selectItem(idx, false);
             fireSelectionChanged();
         }
+        int x = toControl(e.display.getCursorLocation()).x;
+        updateCursor(x, e.stateMask | e.keyCode);
     }
 
     @Override
     public void keyReleased(KeyEvent e) {
+        int x = toControl(e.display.getCursorLocation()).x;
+        updateCursor(x, e.stateMask & ~e.keyCode);
     }
 
     @Override
@@ -1545,6 +1660,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
             getDisplay().addFilter(SWT.MouseWheel, fMouseScrollFilterListener);
         }
         redraw();
+        updateStatusLine(NO_STATUS);
     }
 
     @Override
@@ -1559,6 +1675,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
             fDragState = DRAG_NONE;
         }
         redraw();
+        updateStatusLine(NO_STATUS);
     }
 
     /**
@@ -1578,40 +1695,84 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         // Update cursor as indicated
         if (waitInd) {
             setCursor(fWaitCursor);
-            fIsWaitCursor = true;
         } else {
             setCursor(null);
-            fIsWaitCursor = false;
         }
+    }
 
-        // Get ready for next mouse move
-        fIsDragCursor = false;
+    private void updateCursor(int x, int stateMask) {
+        // if Wait cursor not active, check for the need to change the cursor
+        if (getCursor() == fWaitCursor) {
+            return;
+        }
+        Cursor cursor = null;
+        if (fDragState == DRAG_SPLIT_LINE) {
+        } else if (fDragState == DRAG_SELECTION) {
+            cursor = fResizeCursor;
+        } else if (fDragState == DRAG_TRACE_ITEM) {
+            cursor = fDragCursor;
+        } else if (fDragState == DRAG_ZOOM) {
+            cursor = fZoomCursor;
+        } else if ((stateMask & SWT.MODIFIER_MASK) == SWT.CTRL) {
+            cursor = fDragCursor;
+        } else if ((stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT) {
+            cursor = fResizeCursor;
+        } else {
+            if (!isOverSplitLine(x) &&fTimeProvider instanceof ITimeDataProvider2) {
+                long selectionBegin = ((ITimeDataProvider2) fTimeProvider).getSelectionBegin();
+                long selectionEnd = ((ITimeDataProvider2) fTimeProvider).getSelectionEnd();
+                int xBegin = getXForTime(selectionBegin);
+                int xEnd = getXForTime(selectionEnd);
+                if (Math.abs(x - xBegin) < SNAP_WIDTH || Math.abs(x - xEnd) < SNAP_WIDTH) {
+                    cursor = fResizeCursor;
+                }
+            }
+        }
+        if (getCursor() != cursor) {
+            setCursor(cursor);
+        }
     }
 
-    /**
-     * <p>
-     * If the x, y position is over the vertical split line (name to time
-     * ranges), then change the cursor to a drag cursor to indicate the user the
-     * possibility of resizing
-     * </p>
-     *
-     * @param x
-     * @param y
-     */
-    void updateCursor(int x, int y) {
-        // if Wait cursor not active, check for the need to change to a drag
-        // cursor
-        if (!fIsWaitCursor) {
-            boolean isSplitLine = isOverSplitLine(x);
-            // No dragcursor is name space is fixed to zero
-            if (isSplitLine && !fIsDragCursor && fTimeProvider.getNameSpace() > 0) {
-                setCursor(fDragCursor);
-                fIsDragCursor = true;
-            } else if (!isSplitLine && fIsDragCursor) {
-                setCursor(null);
-                fIsDragCursor = false;
+    private void updateStatusLine(int x) {
+        if (fStatusLineManager == null) {
+            return;
+        }
+        StringBuilder message = new StringBuilder();
+        if (x >= 0 && fDragState == DRAG_NONE) {
+            long time = getTimeAtX(x);
+            if (time >= 0) {
+                message.append("T: "); //$NON-NLS-1$
+                message.append(new CtfTmfTimestamp(time).toString());
+                message.append("     T1: "); //$NON-NLS-1$
+                if (fTimeProvider instanceof ITimeDataProvider2) {
+                    long selectionBegin = ((ITimeDataProvider2) fTimeProvider).getSelectionBegin();
+                    long selectionEnd = ((ITimeDataProvider2) fTimeProvider).getSelectionEnd();
+                    message.append(new CtfTmfTimestamp(Math.min(selectionBegin, selectionEnd)).toString());
+                    if (selectionBegin != selectionEnd) {
+                        message.append("     T2: "); //$NON-NLS-1$
+                        message.append(new CtfTmfTimestamp(Math.max(selectionBegin, selectionEnd)).toString());
+                        message.append("     \u0394: "); //$NON-NLS-1$
+                        message.append(new TmfTimestampDelta(Math.abs(selectionBegin - selectionEnd), ITmfTimestamp.NANOSECOND_SCALE));
+                    }
+                } else {
+                    @SuppressWarnings("deprecation")
+                    long selectedTime = fTimeProvider.getSelectedTime();
+                    message.append(new CtfTmfTimestamp(selectedTime));
+                }
+            }
+        } else if (fDragState == DRAG_SELECTION || fDragState == DRAG_ZOOM) {
+            long time0 = fDragTime0;
+            long time = getTimeAtX(fDragX);
+            message.append("T1: "); //$NON-NLS-1$
+            message.append(new CtfTmfTimestamp(Math.min(time, time0)).toString());
+            if (time != time0) {
+                message.append("     T2: "); //$NON-NLS-1$
+                message.append(new CtfTmfTimestamp(Math.max(time, time0)).toString());
+                message.append("     \u0394: "); //$NON-NLS-1$
+                message.append(new TmfTimestampDelta(Math.abs(time - time0), ITmfTimestamp.NANOSECOND_SCALE));
             }
         }
+        fStatusLineManager.setMessage(message.toString());
     }
 
     @Override
@@ -1622,9 +1783,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         Point size = getCtrlSize();
         if (DRAG_TRACE_ITEM == fDragState) {
             int nameWidth = fTimeProvider.getNameSpace();
-            int x = e.x - nameWidth;
-            if (x > 0 && size.x > nameWidth && fDragX != x) {
-                fDragX = x;
+            if (e.x > nameWidth && size.x > nameWidth && fDragX != e.x) {
+                fDragX = e.x;
                 double pixelsPerNanoSec = (size.x - nameWidth <= RIGHT_MARGIN) ? 0 : (double) (size.x - nameWidth - RIGHT_MARGIN) / (fTime1bak - fTime0bak);
                 long timeDelta = (long) ((pixelsPerNanoSec == 0) ? 0 : ((fDragX - fDragX0) / pixelsPerNanoSec));
                 long time1 = fTime1bak - timeDelta;
@@ -1642,9 +1802,16 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         } else if (DRAG_SPLIT_LINE == fDragState) {
             fDragX = e.x;
             fTimeProvider.setNameSpace(e.x);
+        } else if (DRAG_SELECTION == fDragState) {
+            if (fTimeProvider instanceof ITimeDataProvider2) {
+                fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), size.x - RIGHT_MARGIN);
+                redraw();
+                fTimeGraphScale.setDragRange(fDragX0, fDragX);
+            }
         } else if (DRAG_ZOOM == fDragState) {
             fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), size.x - RIGHT_MARGIN);
             redraw();
+            fTimeGraphScale.setDragRange(fDragX0, fDragX);
         } else if (DRAG_NONE == fDragState) {
             boolean mouseOverSplitLine = isOverSplitLine(e.x);
             if (fMouseOverSplitLine != mouseOverSplitLine) {
@@ -1652,7 +1819,8 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
             }
             fMouseOverSplitLine = mouseOverSplitLine;
         }
-        updateCursor(e.x, e.y);
+        updateCursor(e.x, e.stateMask);
+        updateStatusLine(e.x);
     }
 
     @Override
@@ -1684,41 +1852,87 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
             return;
         }
         int idx;
-        if (1 == e.button) {
+        if (1 == e.button && (e.stateMask & SWT.MODIFIER_MASK) == 0) {
             int nameSpace = fTimeProvider.getNameSpace();
             if (nameSpace != 0 && isOverSplitLine(e.x)) {
                 fDragState = DRAG_SPLIT_LINE;
+                fDragButton = e.button;
                 fDragX = e.x;
                 fDragX0 = fDragX;
                 fTime0bak = fTimeProvider.getTime0();
                 fTime1bak = fTimeProvider.getTime1();
                 redraw();
+                updateCursor(e.x, e.stateMask);
                 return;
             }
-
+        }
+        if (1 == e.button && ((e.stateMask & SWT.MODIFIER_MASK) == 0 || (e.stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT)) {
+            int nameSpace = fTimeProvider.getNameSpace();
             idx = getItemIndexAtY(e.y);
             if (idx >= 0) {
                 Item item = fItemData.fExpandedItems[idx];
                 if (item.fHasChildren && e.x < nameSpace && e.x < MARGIN + (item.fLevel + 1) * EXPAND_SIZE) {
                     toggle(idx);
-                } else {
-                    long hitTime = getTimeAtX(e.x);
-                    if (hitTime >= 0) {
-                        setCapture(true);
-                        fDragState = DRAG_TRACE_ITEM;
-                        fDragX = e.x - nameSpace;
-                        fDragX0 = fDragX;
-                        fTime0bak = fTimeProvider.getTime0();
-                        fTime1bak = fTimeProvider.getTime1();
-                    }
+                    return;
                 }
                 selectItem(idx, false);
                 fireSelectionChanged();
             } else {
                 selectItem(idx, false); // clear selection
-                redraw();
                 fireSelectionChanged();
             }
+            long hitTime = getTimeAtX(e.x);
+            if (hitTime >= 0) {
+                setCapture(true);
+
+                fDragState = DRAG_SELECTION;
+                fDragButton = e.button;
+                fDragX = e.x;
+                fDragX0 = fDragX;
+                fDragTime0 = getTimeAtX(fDragX0);
+                if (fTimeProvider instanceof ITimeDataProvider2) {
+                    long selectionBegin = ((ITimeDataProvider2) fTimeProvider).getSelectionBegin();
+                    long selectionEnd = ((ITimeDataProvider2) fTimeProvider).getSelectionEnd();
+                    int xBegin = getXForTime(selectionBegin);
+                    int xEnd = getXForTime(selectionEnd);
+                    if ((e.stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT) {
+                        long time = getTimeAtX(e.x);
+                        if (Math.abs(time - selectionBegin) < Math.abs(time - selectionEnd)) {
+                            fDragX0 = xEnd;
+                            fDragTime0 = selectionEnd;
+                        } else {
+                            fDragX0 = xBegin;
+                            fDragTime0 = selectionBegin;
+                        }
+                    } else {
+                        long time = getTimeAtX(e.x);
+                        if (Math.abs(e.x - xBegin) < SNAP_WIDTH && Math.abs(time - selectionBegin) <= Math.abs(time - selectionEnd)) {
+                            fDragX0 = xEnd;
+                            fDragTime0 = selectionEnd;
+                        } else if (Math.abs(e.x - xEnd) < SNAP_WIDTH && Math.abs(time - selectionEnd) <= Math.abs(time - selectionBegin)) {
+                            fDragX0 = xBegin;
+                            fDragTime0 = selectionBegin;
+                        }
+                    }
+                }
+                fTime0bak = fTimeProvider.getTime0();
+                fTime1bak = fTimeProvider.getTime1();
+                redraw();
+                updateCursor(e.x, e.stateMask);
+                fTimeGraphScale.setDragRange(fDragX0, fDragX);
+            }
+        } else if (2 == e.button || (1 == e.button && (e.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL)) {
+            long hitTime = getTimeAtX(e.x);
+            if (hitTime > 0) {
+                setCapture(true);
+                fDragState = DRAG_TRACE_ITEM;
+                fDragButton = e.button;
+                fDragX = e.x;
+                fDragX0 = fDragX;
+                fTime0bak = fTimeProvider.getTime0();
+                fTime1bak = fTimeProvider.getTime1();
+                updateCursor(e.x, e.stateMask);
+            }
         } else if (3 == e.button) {
             if (fTimeProvider.getTime0() == fTimeProvider.getTime1() || getCtrlSize().x - fTimeProvider.getNameSpace() <= 0) {
                 return;
@@ -1727,6 +1941,10 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
             fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), getCtrlSize().x - RIGHT_MARGIN);
             fDragX0 = fDragX;
             fDragState = DRAG_ZOOM;
+            fDragButton = e.button;
+            redraw();
+            updateCursor(e.x, e.stateMask);
+            fTimeGraphScale.setDragRange(fDragX0, fDragX);
         }
     }
 
@@ -1737,20 +1955,31 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
         }
         if (DRAG_NONE != fDragState) {
             setCapture(false);
-            if (e.button == 1 && DRAG_TRACE_ITEM == fDragState) {
-                if (fDragX == fDragX0) { // click without drag
+            if (e.button == fDragButton && DRAG_TRACE_ITEM == fDragState) {
+                if (fDragX != fDragX0) {
+                    fTimeProvider.notifyStartFinishTime();
+                }
+                fDragState = DRAG_NONE;
+            } else if (e.button == fDragButton && DRAG_SPLIT_LINE == fDragState) {
+                fDragState = DRAG_NONE;
+                redraw();
+            }  else if (e.button == fDragButton && DRAG_SELECTION == fDragState) {
+                if (fDragX == fDragX0) { // click without selecting anything
                     long time = getTimeAtX(e.x);
                     fTimeProvider.setSelectedTimeNotify(time, false);
                 } else {
-                    // Notify time provider to check the need for listener
-                    // notification
-                    fTimeProvider.notifyStartFinishTime();
+                    long time0 = fDragTime0;
+                    long time1 = getTimeAtX(fDragX);
+                    if (time0 <= time1) {
+                        ((ITimeDataProvider2) fTimeProvider).setSelectionRangeNotify(time0, time1);
+                    } else {
+                        ((ITimeDataProvider2) fTimeProvider).setSelectionRangeNotify(time1, time0);
+                    }
                 }
                 fDragState = DRAG_NONE;
-            } else if (e.button == 1 && DRAG_SPLIT_LINE == fDragState) {
                 redraw();
-                fDragState = DRAG_NONE;
-            } else if (e.button == 3 && DRAG_ZOOM == fDragState) {
+                fTimeGraphScale.setDragRange(-1, -1);
+            } else if (e.button == fDragButton && DRAG_ZOOM == fDragState) {
                 int nameWidth = fTimeProvider.getNameSpace();
                 if (Math.max(fDragX, fDragX0) > nameWidth && fDragX != fDragX0) {
                     long time0 = getTimeAtX(fDragX0);
@@ -1764,8 +1993,11 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
                     redraw();
                 }
                 fDragState = DRAG_NONE;
+                fTimeGraphScale.setDragRange(-1, -1);
             }
         }
+        updateCursor(e.x, e.stateMask);
+        updateStatusLine(e.x);
     }
 
     @Override
@@ -1778,6 +2010,7 @@ public class TimeGraphControl extends TimeGraphBaseControl implements FocusListe
             fMouseOverSplitLine = false;
             redraw();
         }
+        updateStatusLine(NO_STATUS);
     }
 
     @Override
index 143369beeb94c4ab8747fc4ad9f4acc435919ba4..0cd8d65d29494ebae22826fc15aa02102c33eafc 100644 (file)
@@ -80,9 +80,9 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
     private static final TimeDraw TIMEDRAW_ABS_YEAR = new TimeDrawAbsYear();
     private static final TimeDraw TIMEDRAW_NUMBER = new TimeDrawNumber();
 
+    private static final int DRAG_EXTERNAL = -1;
     private static final int NO_BUTTON = 0;
     private static final int LEFT_BUTTON = 1;
-    private static final int RIGHT_BUTTON = 3;
 
     private ITimeDataProvider fTimeProvider;
     private int fDragState = NO_BUTTON;
@@ -140,6 +140,28 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
         this.fHeight = height;
     }
 
+    /**
+     * Set the drag range to paint decorators
+     *
+     * @param begin
+     *            The begin x-coordinate
+     * @param end
+     *            The end x-coordinate
+     * @since 2.1
+     */
+    public void setDragRange(int begin, int end) {
+        if (NO_BUTTON == fDragState || DRAG_EXTERNAL == fDragState) {
+            fDragX0 = begin - fTimeProvider.getNameSpace();
+            fDragX = end - fTimeProvider.getNameSpace();
+            if (begin >= 0 || end >= 0) {
+                fDragState = DRAG_EXTERNAL;
+            } else {
+                fDragState = NO_BUTTON;
+            }
+        }
+        redraw();
+    }
+
     private long calcTimeDelta(int width, double pixelsPerNanoSec) {
         long timeDelta;
         double minDelta = (pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec;
@@ -243,7 +265,6 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
 
         long time0 = fTimeProvider.getTime0();
         long time1 = fTimeProvider.getTime1();
-        long selectedTime = fTimeProvider.getSelectedTime();
         int leftSpace = fTimeProvider.getNameSpace();
         int timeSpace = fTimeProvider.getTimeSpace();
 
@@ -270,16 +291,6 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
         rect0.height--;
         gc.fillRectangle(rect0);
 
-        if (RIGHT_BUTTON == fDragState && null != fTimeProvider) {
-            // draw selected zoom region background
-            gc.setBackground(getColorScheme().getBkColor(true, false, true));
-            if (fDragX0 < fDragX) {
-                gc.fillRectangle(new Rectangle(leftSpace + fDragX0, rect0.y, fDragX - fDragX0, rect0.height));
-            } else if (fDragX0 > fDragX) {
-                gc.fillRectangle(new Rectangle(leftSpace + fDragX, rect0.y, fDragX0 - fDragX, rect0.height));
-            }
-        }
-
         if (time1 <= time0 || timeSpace < 2) {
             return;
         }
@@ -293,25 +304,32 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
 
         TimeDraw timeDraw = getTimeDraw(timeDelta);
 
-        // draw selected zoom region lines
-        if (RIGHT_BUTTON == fDragState && null != fTimeProvider) {
-            gc.drawLine(leftSpace + fDragX0, rect.y, leftSpace + fDragX0, rect.y + rect.height);
-            gc.drawLine(leftSpace + fDragX, rect.y, leftSpace + fDragX, rect.y + rect.height);
+        // draw range decorators
+        if (DRAG_EXTERNAL == fDragState) {
+            int x1 = leftSpace + Math.min(fDragX0, fDragX);
+            int x2 = leftSpace + Math.max(fDragX0, fDragX);
+            drawRangeDecorators(rect0, gc, x1, x2);
+        } else {
+            int x1;
+            int x2;
+            if (fTimeProvider instanceof ITimeDataProvider2) {
+                long selectionBegin = ((ITimeDataProvider2) fTimeProvider).getSelectionBegin();
+                long selectionEnd = ((ITimeDataProvider2) fTimeProvider).getSelectionEnd();
+                x1 = leftSpace + (int) ((selectionBegin - time0) * pixelsPerNanoSec);
+                x2 = leftSpace + (int) ((selectionEnd - time0) * pixelsPerNanoSec);
+            } else {
+                @SuppressWarnings("deprecation")
+                long selectedTime = fTimeProvider.getSelectedTime();
+                x1 = leftSpace + (int) ((selectedTime - time0) * pixelsPerNanoSec);
+                x2 = x1;
+            }
+            drawRangeDecorators(rect0, gc, x1, x2);
         }
 
         if (rect0.isEmpty()) {
             return;
         }
 
-        // draw selected time
-        int x = rect0.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);
-        if (x >= rect0.x && x < rect0.x + rect0.width) {
-            gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.SELECTED_TIME));
-            gc.drawLine(x, rect0.y + rect0.height - 6, x, rect0.y
-                    + rect0.height);
-            gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.TOOL_FOREGROUND));
-        }
-
         // draw time scale ticks
         rect0.y = rect.y;
         rect0.height = rect.height - 4;
@@ -334,7 +352,7 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
         }
 
         while (true) {
-            x = rect.x + leftSpace + (int) (Math.floor((time - time0) * pixelsPerNanoSec));
+            int x = rect.x + leftSpace + (int) (Math.floor((time - time0) * pixelsPerNanoSec));
             if (x >= rect.x + leftSpace + rect.width - rect0.width) {
                 break;
             }
@@ -376,6 +394,30 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
         }
     }
 
+    private static void drawRangeDecorators(Rectangle rect, GC gc, int x1, int x2) {
+        int y1 = rect.y + rect.height - 9;
+        int y2 = rect.y + rect.height - 5;
+        int ym = (y1 + y2) / 2;
+        if (x1 >= rect.x) {
+            // T1
+            gc.drawLine(x1 - 3, y1, x1 - 3, y2);
+            gc.drawLine(x1 - 4, y1, x1 - 2, y1);
+            gc.drawLine(x1, y1, x1, y2);
+        }
+        if (x2 >= rect.x && x2 - x1 > 3) {
+            // T2
+            gc.drawLine(x2 - 2, y1, x2 - 2, y2);
+            gc.drawLine(x2 - 3, y1, x2 - 1, y1);
+        }
+        if (x2 >= rect.x && x2 - x1 > 0) {
+            gc.drawLine(x2 + 1, y1, x2 + 3, y1);
+            gc.drawLine(x2 + 3, y1, x2 + 3, ym);
+            gc.drawLine(x2 + 1, ym, x2 + 3, ym);
+            gc.drawLine(x2 + 1, ym, x2 + 1, y2);
+            gc.drawLine(x2 + 1, y2, x2 + 3, y2);
+        }
+    }
+
     private static long floorToCalendar(long time, long timeDelta) {
         long ret = time;
 
@@ -448,8 +490,6 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
             if (LEFT_BUTTON == e.button && x > 0) {
                 setCapture(true);
                 fDragState = LEFT_BUTTON;
-            } else if (RIGHT_BUTTON == e.button) {
-                fDragState = RIGHT_BUTTON;
             }
             if (x < 0) {
                 x = 0;
@@ -473,28 +513,6 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
             if (fDragX != fDragX0 && fTimeProvider.getTime0() != fTimeProvider.getTime1()) {
                 fTimeProvider.setStartFinishTimeNotify(fTimeProvider.getTime0(), fTimeProvider.getTime1());
             }
-        } else if (e.button == RIGHT_BUTTON && fDragState == RIGHT_BUTTON && null != fTimeProvider) {
-            fDragState = NO_BUTTON;
-            if (fDragX0 == fDragX || fTimeProvider.getTime0() == fTimeProvider.getTime1()) {
-                redraw();
-                return;
-            }
-            int timeSpace = fTimeProvider.getTimeSpace();
-            int leftSpace = fTimeProvider.getNameSpace();
-            int x = Math.max(0, e.x - leftSpace);
-            if (timeSpace > 0) {
-                fDragX = x;
-                if (fDragX0 > fDragX) { // drag right to left
-                    fDragX = fDragX0;
-                    fDragX0 = x;
-                }
-                long time0 = fTime0bak + (long) ((fTime1bak - fTime0bak) * ((double) fDragX0 / timeSpace));
-                long time1 = fTime0bak + (long) ((fTime1bak - fTime0bak) * ((double) fDragX / timeSpace));
-
-                fTimeProvider.setStartFinishTimeNotify(time0, time1);
-                fTime0bak = fTimeProvider.getTime0();
-                fTime1bak = fTimeProvider.getTime1();
-            }
         }
     }
 
@@ -505,7 +523,6 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
         }
         Point size = getSize();
         int leftSpace = fTimeProvider.getNameSpace();
-        int timeSpace = fTimeProvider.getTimeSpace();
         int x = e.x - leftSpace;
         if (LEFT_BUTTON == fDragState) {
             if (x > 0 && size.x > leftSpace && fDragX != x) {
@@ -521,15 +538,6 @@ public class TimeGraphScale extends TimeGraphBaseControl implements
                     fTimeProvider.setStartFinishTime(fTime0bak, time1);
                 }
             }
-        } else if (RIGHT_BUTTON == fDragState) {
-            if (x < 0) {
-                fDragX = 0;
-            } else if (x > timeSpace) {
-                fDragX = timeSpace;
-            } else {
-                fDragX = x;
-            }
-            redraw();
         }
     }
 
This page took 0.06881 seconds and 5 git commands to generate.