Commit | Line | Data |
---|---|---|
8c8bf09f | 1 | /******************************************************************************* |
be4a197a | 2 | * Copyright (c) 2009, 2014 Ericsson |
4f8ca6a1 | 3 | * |
8c8bf09f ASL |
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 | |
4f8ca6a1 | 8 | * |
8c8bf09f ASL |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
0fcf3b09 | 11 | * Patrick Tasse - Support selection range |
8c8bf09f ASL |
12 | *******************************************************************************/ |
13 | ||
2bdf0193 | 14 | package org.eclipse.tracecompass.tmf.core.signal; |
8c8bf09f | 15 | |
6cfc180e GB |
16 | import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; |
17 | ||
18 | import org.eclipse.jdt.annotation.NonNullByDefault; | |
19 | import org.eclipse.jdt.annotation.Nullable; | |
2bdf0193 | 20 | import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; |
8c8bf09f ASL |
21 | |
22 | /** | |
0fcf3b09 PT |
23 | * A new time or time range selection has been made. |
24 | * | |
25 | * This is the selected time or time range. To synchronize on the visible | |
26 | * (zoom) range, use {@link TmfRangeSynchSignal}. | |
27 | * | |
4b7b3670 FC |
28 | * @author Francois Chouinard |
29 | */ | |
6cfc180e | 30 | @NonNullByDefault |
8c8bf09f ASL |
31 | public class TmfTimeSynchSignal extends TmfSignal { |
32 | ||
0fcf3b09 PT |
33 | private final ITmfTimestamp fBeginTime; |
34 | private final ITmfTimestamp fEndTime; | |
4f8ca6a1 AM |
35 | |
36 | /** | |
37 | * Constructor | |
38 | * | |
39 | * @param source | |
40 | * Object sending this signal | |
41 | * @param ts | |
0fcf3b09 | 42 | * Timestamp of selection |
4f8ca6a1 | 43 | */ |
6cfc180e | 44 | public TmfTimeSynchSignal(@Nullable Object source, ITmfTimestamp ts) { |
4f8ca6a1 | 45 | super(source); |
0fcf3b09 PT |
46 | fBeginTime = ts; |
47 | fEndTime = ts; | |
48 | } | |
49 | ||
50 | /** | |
51 | * Constructor | |
52 | * | |
53 | * @param source | |
54 | * Object sending this signal | |
55 | * @param begin | |
56 | * Timestamp of begin of selection range | |
57 | * @param end | |
58 | * Timestamp of end of selection range | |
0fcf3b09 | 59 | */ |
6cfc180e | 60 | public TmfTimeSynchSignal(@Nullable Object source, ITmfTimestamp begin, ITmfTimestamp end) { |
0fcf3b09 PT |
61 | super(source); |
62 | fBeginTime = begin; | |
63 | fEndTime = end; | |
4f8ca6a1 AM |
64 | } |
65 | ||
0fcf3b09 PT |
66 | /** |
67 | * @return The begin timestamp of selection | |
0fcf3b09 PT |
68 | */ |
69 | public ITmfTimestamp getBeginTime() { | |
70 | return fBeginTime; | |
71 | } | |
72 | ||
73 | /** | |
74 | * @return The end timestamp of selection | |
0fcf3b09 PT |
75 | */ |
76 | public ITmfTimestamp getEndTime() { | |
77 | return fEndTime; | |
4f8ca6a1 AM |
78 | } |
79 | ||
4f8ca6a1 AM |
80 | @Override |
81 | public String toString() { | |
0fcf3b09 PT |
82 | StringBuilder sb = new StringBuilder(); |
83 | sb.append("[TmfTimeSynchSignal ("); //$NON-NLS-1$ | |
6cfc180e GB |
84 | sb.append(fBeginTime.toString()); |
85 | if (!fBeginTime.equals(fEndTime)) { | |
86 | sb.append('-'); | |
87 | sb.append(fEndTime.toString()); | |
0fcf3b09 PT |
88 | } |
89 | sb.append(")]"); //$NON-NLS-1$ | |
6cfc180e | 90 | return checkNotNull(sb.toString()); |
4f8ca6a1 | 91 | } |
8d2e2848 | 92 | |
8c8bf09f | 93 | } |