tmf: Add support for time range selection
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / signal / TmfTimeSynchSignal.java
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();
     }
 
 }
This page took 0.024647 seconds and 5 git commands to generate.