a9ae5238746b0d5258cf0937448f2da22f9bbd99
[deliverable/tracecompass.git] / tmf / 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.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.eclipse.tracecompass.tmf.core.filter.ITmfFilter;
21 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
22 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
23
24 /**
25 * Context of a trace, which is the representation of the "view" the user
26 * currently has on this trace (window time range, selected time or time range).
27 *
28 * TODO could be extended to support the notion of current location too.
29 *
30 * FIXME Is this really the right place for the Editor File ?
31 *
32 * @author Alexandre Montplaisir
33 * @since 1.0
34 */
35 @NonNullByDefault
36 public class TmfTraceContext implements ITraceContextSignalHandler {
37
38 static final TmfTraceContext NULL_CONTEXT = new TmfTraceContext(new TmfTimeRange(TmfTimestamp.BIG_CRUNCH, TmfTimestamp.BIG_CRUNCH),
39 TmfTimeRange.NULL_RANGE, null, null);
40
41 private final TmfTimeRange fSelection;
42 private final TmfTimeRange fWindowRange;
43 private final @Nullable IFile fEditorFile;
44 private final @Nullable ITmfFilter fFilter;
45
46 /**
47 * Build a new trace context.
48 *
49 * @param selection
50 * The selected time range
51 * @param windowRange
52 * The visible window's time range
53 * @param editorFile
54 * The file representing the selected editor
55 * @param filter
56 * The currently applied filter. 'null' for none.
57 */
58 public TmfTraceContext(TmfTimeRange selection, TmfTimeRange windowRange,
59 @Nullable IFile editorFile, @Nullable ITmfFilter filter) {
60 fSelection = selection;
61 fWindowRange = windowRange;
62 fEditorFile = editorFile;
63 fFilter = filter;
64 }
65
66 /**
67 * Return the time range representing the current active selection.
68 *
69 * @return The selected time range
70 */
71 public TmfTimeRange getSelectionRange() {
72 return fSelection;
73 }
74
75 /**
76 * Return the current window time range.
77 *
78 * @return The current window time range
79 */
80 public TmfTimeRange getWindowRange() {
81 return fWindowRange;
82 }
83
84 /**
85 * Get the editor's file
86 *
87 * @return The editor file
88 */
89 public @Nullable IFile getEditorFile() {
90 return fEditorFile;
91 }
92
93 /**
94 * Gets the filter applied to the current trace
95 *
96 * @return The current filter, or <code>null</code> if there is none
97 */
98 public @Nullable ITmfFilter getFilter() {
99 return fFilter;
100 }
101
102 @Override
103 public String toString() {
104 return getClass().getSimpleName() + "[fSelection=" + fSelection + //$NON-NLS-1$
105 ", fWindowRange=" + fWindowRange + ']'; //$NON-NLS-1$
106 }
107
108 }
This page took 0.03389 seconds and 4 git commands to generate.