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 | ||
6c13869b | 14 | package org.eclipse.linuxtools.tmf.core.signal; |
8c8bf09f | 15 | |
3bd46eef | 16 | import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; |
8c8bf09f ASL |
17 | |
18 | /** | |
0fcf3b09 PT |
19 | * A new time or time range selection has been made. |
20 | * | |
21 | * This is the selected time or time range. To synchronize on the visible | |
22 | * (zoom) range, use {@link TmfRangeSynchSignal}. | |
23 | * | |
4b7b3670 FC |
24 | * @version 1.0 |
25 | * @author Francois Chouinard | |
26 | */ | |
8c8bf09f ASL |
27 | public class TmfTimeSynchSignal extends TmfSignal { |
28 | ||
0fcf3b09 PT |
29 | private final ITmfTimestamp fBeginTime; |
30 | private final ITmfTimestamp fEndTime; | |
4f8ca6a1 AM |
31 | |
32 | /** | |
33 | * Constructor | |
34 | * | |
35 | * @param source | |
36 | * Object sending this signal | |
37 | * @param ts | |
0fcf3b09 | 38 | * Timestamp of selection |
3bd46eef | 39 | * @since 2.0 |
4f8ca6a1 AM |
40 | */ |
41 | public TmfTimeSynchSignal(Object source, ITmfTimestamp ts) { | |
42 | super(source); | |
0fcf3b09 PT |
43 | fBeginTime = ts; |
44 | fEndTime = ts; | |
45 | } | |
46 | ||
47 | /** | |
48 | * Constructor | |
49 | * | |
50 | * @param source | |
51 | * Object sending this signal | |
52 | * @param begin | |
53 | * Timestamp of begin of selection range | |
54 | * @param end | |
55 | * Timestamp of end of selection range | |
4b121c48 | 56 | * @since 2.1 |
0fcf3b09 PT |
57 | */ |
58 | public TmfTimeSynchSignal(Object source, ITmfTimestamp begin, ITmfTimestamp end) { | |
59 | super(source); | |
60 | fBeginTime = begin; | |
61 | fEndTime = end; | |
4f8ca6a1 AM |
62 | } |
63 | ||
0fcf3b09 PT |
64 | /** |
65 | * @return The begin timestamp of selection | |
4b121c48 | 66 | * @since 2.1 |
0fcf3b09 PT |
67 | */ |
68 | public ITmfTimestamp getBeginTime() { | |
69 | return fBeginTime; | |
70 | } | |
71 | ||
72 | /** | |
73 | * @return The end timestamp of selection | |
4b121c48 | 74 | * @since 2.1 |
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$ | |
84 | if (fBeginTime != null) { | |
85 | sb.append(fBeginTime.toString()); | |
86 | if (!fBeginTime.equals(fEndTime) && fEndTime != null) { | |
87 | sb.append('-'); | |
88 | sb.append(fEndTime.toString()); | |
89 | } | |
90 | } | |
91 | sb.append(")]"); //$NON-NLS-1$ | |
92 | return sb.toString(); | |
4f8ca6a1 | 93 | } |
8d2e2848 | 94 | |
8c8bf09f | 95 | } |