1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
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
10 * Alexandre Montplaisir - Initial API and implementation
11 * Patrick Tasse - Support selection range
12 * Xavier Raynaud - Support filters tracking
13 *******************************************************************************/
15 package org
.eclipse
.tracecompass
.tmf
.core
.trace
;
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
;
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).
28 * TODO could be extended to support the notion of current location too.
30 * FIXME Is this really the right place for the Editor File ?
32 * @author Alexandre Montplaisir
36 public final class TmfTraceContext
{
38 static final TmfTraceContext NULL_CONTEXT
=
39 new TmfTraceContext(new TmfTimeRange(TmfTimestamp
.BIG_CRUNCH
, TmfTimestamp
.BIG_CRUNCH
),
40 TmfTimeRange
.NULL_RANGE
, null, null);
42 private final TmfTimeRange fSelection
;
43 private final TmfTimeRange fWindowRange
;
44 private final @Nullable IFile fEditorFile
;
45 private final @Nullable ITmfFilter fFilter
;
48 * Build a new trace context.
51 * The selected time range
53 * The visible window's time range
55 * The file representing the selected editor
57 * The currently applied filter. 'null' for none.
59 public TmfTraceContext(TmfTimeRange selection
, TmfTimeRange windowRange
,
60 @Nullable IFile editorFile
, @Nullable ITmfFilter filter
) {
61 fSelection
= selection
;
62 fWindowRange
= windowRange
;
63 fEditorFile
= editorFile
;
68 * Return the time range representing the current active selection.
70 * @return The selected time range
72 public TmfTimeRange
getSelectionRange() {
77 * Return the current window time range.
79 * @return The current window time range
81 public TmfTimeRange
getWindowRange() {
87 * Get the editor's file
89 * @return The editor file
91 public @Nullable IFile
getEditorFile() {
96 * Gets the filter applied to the current trace
98 * @return The current filter, or <code>null</code> if there is none
100 public @Nullable ITmfFilter
getFilter() {
105 public String
toString() {
106 return getClass().getSimpleName() + "[fSelection=" + fSelection
+ //$NON-NLS-1$
107 ", fWindowRange=" + fWindowRange
+ ']'; //$NON-NLS-1$