Remove all existing @since annotations
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / trace / TmfTraceContext.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Alexandre Montplaisir - Initial API and implementation
11 * Patrick Tasse - Support selection range
12 * Xavier Raynaud - Support filters tracking
13 *******************************************************************************/
14
15 package org.eclipse.tracecompass.tmf.core.trace;
16
17 import org.eclipse.core.resources.IFile;
18 import org.eclipse.tracecompass.tmf.core.filter.ITmfFilter;
19 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
20 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
21 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
22
23 /**
24 * Context of a trace, which is the representation of the "view" the user
25 * currently has on this trace (window time range, selected time or time range).
26 *
27 * TODO could be extended to support the notion of current location too.
28 *
29 * @author Alexandre Montplaisir
30 */
31 final class TmfTraceContext {
32
33 static final TmfTraceContext NULL_CONTEXT =
34 new TmfTraceContext(TmfTimestamp.BIG_CRUNCH, TmfTimestamp.BIG_CRUNCH, TmfTimeRange.NULL_RANGE, null);
35
36 private final TmfTimeRange fSelection;
37 private final TmfTimeRange fWindowRange;
38 private final IFile fEditorFile;
39 private final ITmfFilter fFilter;
40
41 public TmfTraceContext(ITmfTimestamp beginTs, ITmfTimestamp endTs, TmfTimeRange tr, IFile editorFile) {
42 fSelection = new TmfTimeRange(beginTs, endTs);
43 fWindowRange = tr;
44 fEditorFile = editorFile;
45 fFilter = null;
46 }
47
48 public TmfTraceContext(TmfTraceContext prevCtx, ITmfTimestamp beginTs, ITmfTimestamp endTs) {
49 fSelection = new TmfTimeRange(beginTs, endTs);
50 fWindowRange = prevCtx.fWindowRange;
51 fEditorFile = prevCtx.fEditorFile;
52 fFilter = prevCtx.fFilter;
53 }
54
55 public TmfTraceContext(TmfTraceContext prevCtx, TmfTimeRange tr) {
56 fSelection = prevCtx.fSelection;
57 fWindowRange = tr;
58 fEditorFile = prevCtx.fEditorFile;
59 fFilter = prevCtx.fFilter;
60 }
61
62 /**
63 * @param prevCtx
64 * The previous context
65 * @param filter
66 * The applied filter
67 */
68 public TmfTraceContext(TmfTraceContext prevCtx, ITmfFilter filter) {
69 fSelection = prevCtx.fSelection;
70 fWindowRange = prevCtx.fWindowRange;
71 fEditorFile = prevCtx.fEditorFile;
72 fFilter = filter;
73 }
74
75 public ITmfTimestamp getSelectionBegin() {
76 return fSelection.getStartTime();
77 }
78
79 public ITmfTimestamp getSelectionEnd() {
80 return fSelection.getEndTime();
81 }
82
83 public TmfTimeRange getWindowRange() {
84 return fWindowRange;
85 }
86
87 public IFile getEditorFile() {
88 return fEditorFile;
89 }
90
91 /**
92 * @return the current filter applied to the trace
93 */
94 public ITmfFilter getFilter() {
95 return fFilter;
96 }
97
98 public boolean isValid() {
99 if (fSelection.getStartTime().compareTo(TmfTimestamp.ZERO) <= 0 ||
100 fSelection.getEndTime().compareTo(TmfTimestamp.ZERO) <= 0 ||
101 fWindowRange.getEndTime().compareTo(fWindowRange.getStartTime()) <= 0) {
102 return false;
103 }
104 return true;
105 }
106
107 @Override
108 public String toString() {
109 return getClass().getSimpleName() + "[fSelection=" + fSelection + //$NON-NLS-1$
110 ", fWindowRange=" + fWindowRange + ']'; //$NON-NLS-1$
111 }
112 }
This page took 0.035457 seconds and 6 git commands to generate.