analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / trace / TmfTraceContext.java
index f5eaf4965f33ad69bbc9b09e01c9e48e9315e983..e13a3b0c0eaf762438262e4b729f03b1a5c9fc12 100644 (file)
@@ -18,7 +18,6 @@ import org.eclipse.core.resources.IFile;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.tmf.core.filter.ITmfFilter;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
 
@@ -28,85 +27,80 @@ import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
  *
  * TODO could be extended to support the notion of current location too.
  *
+ * FIXME Is this really the right place for the Editor File ?
+ *
  * @author Alexandre Montplaisir
+ * @since 1.0
  */
 @NonNullByDefault
-final class TmfTraceContext {
+public final class TmfTraceContext {
 
     static final TmfTraceContext NULL_CONTEXT =
-            new TmfTraceContext(TmfTimestamp.BIG_CRUNCH, TmfTimestamp.BIG_CRUNCH, TmfTimeRange.NULL_RANGE, null);
+            new TmfTraceContext(new TmfTimeRange(TmfTimestamp.BIG_CRUNCH, TmfTimestamp.BIG_CRUNCH),
+                    TmfTimeRange.NULL_RANGE, null, null);
 
     private final TmfTimeRange fSelection;
     private final TmfTimeRange fWindowRange;
     private final @Nullable IFile fEditorFile;
     private final @Nullable ITmfFilter fFilter;
 
-    public TmfTraceContext(ITmfTimestamp beginTs, ITmfTimestamp endTs, TmfTimeRange tr, @Nullable IFile editorFile) {
-        fSelection = new TmfTimeRange(beginTs, endTs);
-        fWindowRange = tr;
-        fEditorFile = editorFile;
-        fFilter = null;
-    }
-
-    public TmfTraceContext(TmfTraceContext prevCtx, ITmfTimestamp beginTs, ITmfTimestamp endTs) {
-        fSelection = new TmfTimeRange(beginTs, endTs);
-        fWindowRange = prevCtx.fWindowRange;
-        fEditorFile = prevCtx.fEditorFile;
-        fFilter = prevCtx.fFilter;
-    }
-
-    public TmfTraceContext(TmfTraceContext prevCtx, TmfTimeRange tr) {
-        fSelection = prevCtx.fSelection;
-        fWindowRange = tr;
-        fEditorFile = prevCtx.fEditorFile;
-        fFilter = prevCtx.fFilter;
-    }
-
     /**
-     * @param prevCtx
-     *              The previous context
+     * Build a new trace context.
+     *
+     * @param selection
+     *            The selected time range
+     * @param windowRange
+     *            The visible window's time range
+     * @param editorFile
+     *            The file representing the selected editor
      * @param filter
-     *              The applied filter
+     *            The currently applied filter. 'null' for none.
      */
-    public TmfTraceContext(TmfTraceContext prevCtx, @Nullable ITmfFilter filter) {
-        fSelection = prevCtx.fSelection;
-        fWindowRange = prevCtx.fWindowRange;
-        fEditorFile = prevCtx.fEditorFile;
+    public TmfTraceContext(TmfTimeRange selection, TmfTimeRange windowRange,
+            @Nullable IFile editorFile, @Nullable ITmfFilter filter) {
+        fSelection = selection;
+        fWindowRange = windowRange;
+        fEditorFile = editorFile;
         fFilter = filter;
     }
 
-    public ITmfTimestamp getSelectionBegin() {
-        return fSelection.getStartTime();
-    }
-
-    public ITmfTimestamp getSelectionEnd() {
-        return fSelection.getEndTime();
+    /**
+     * Return the time range representing the current active selection.
+     *
+     * @return The selected time range
+     */
+    public TmfTimeRange getSelectionRange() {
+        return fSelection;
     }
 
+    /**
+     * Return the current window time range.
+     *
+     * @return The current window time range
+     */
     public TmfTimeRange getWindowRange() {
         return fWindowRange;
     }
 
+
+    /**
+     * Get the editor's file
+     *
+     * @return The editor file
+     */
     public @Nullable IFile getEditorFile() {
         return fEditorFile;
     }
 
     /**
-     * @return the current filter applied to the trace
+     * Gets the filter applied to the current trace
+     *
+     * @return The current filter, or <code>null</code> if there is none
      */
     public @Nullable ITmfFilter getFilter() {
         return fFilter;
     }
 
-    public boolean isValid() {
-        if (fSelection.getStartTime().compareTo(TmfTimestamp.ZERO) <= 0 ||
-                fSelection.getEndTime().compareTo(TmfTimestamp.ZERO) <= 0 ||
-                fWindowRange.getEndTime().compareTo(fWindowRange.getStartTime()) <= 0) {
-            return false;
-        }
-        return true;
-    }
-
     @Override
     public String toString() {
         return getClass().getSimpleName() + "[fSelection=" + fSelection + //$NON-NLS-1$
This page took 0.036857 seconds and 5 git commands to generate.