tmf: Rename time range signals
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / signal / TmfSelectionRangeUpdatedSignal.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 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 * Francois Chouinard - Initial API and implementation
11 * Patrick Tasse - Support selection range
12 *******************************************************************************/
13
14 package org.eclipse.tracecompass.tmf.core.signal;
15
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;
20 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
21
22 /**
23 * A new time range selection has been made.
24 *
25 * This is the selected time or time range. A single-timestamp selection is
26 * represented by a range where the start time is equal to the end time.
27 *
28 * To update the visible (zoom) range instead, use
29 * {@link TmfWindowRangeUpdatedSignal}.
30 *
31 * @author Francois Chouinard
32 * @since 1.0
33 */
34 @NonNullByDefault
35 public class TmfSelectionRangeUpdatedSignal extends TmfSignal {
36
37 private final ITmfTimestamp fBeginTime;
38 private final ITmfTimestamp fEndTime;
39
40 /**
41 * Constructor for a single timestamp selection (start and end times will be
42 * the same).
43 *
44 * @param source
45 * Object sending this signal
46 * @param ts
47 * Timestamp of selection
48 */
49 public TmfSelectionRangeUpdatedSignal(@Nullable Object source, ITmfTimestamp ts) {
50 super(source);
51 fBeginTime = ts;
52 fEndTime = ts;
53 }
54
55 /**
56 * Constructor for a time range selection.
57 *
58 * @param source
59 * Object sending this signal
60 * @param begin
61 * Timestamp of begin of selection range
62 * @param end
63 * Timestamp of end of selection range
64 */
65 public TmfSelectionRangeUpdatedSignal(@Nullable Object source, ITmfTimestamp begin, ITmfTimestamp end) {
66 super(source);
67 fBeginTime = begin;
68 fEndTime = end;
69 }
70
71 /**
72 * @return The begin timestamp of selection
73 */
74 public ITmfTimestamp getBeginTime() {
75 return fBeginTime;
76 }
77
78 /**
79 * @return The end timestamp of selection
80 */
81 public ITmfTimestamp getEndTime() {
82 return fEndTime;
83 }
84
85 @Override
86 public String toString() {
87 StringBuilder sb = new StringBuilder();
88 sb.append(getClass().getSimpleName());
89 sb.append(" ["); //$NON-NLS-1$
90 sb.append(fBeginTime.toString());
91 if (!fBeginTime.equals(fEndTime)) {
92 sb.append('-');
93 sb.append(fEndTime.toString());
94 }
95 sb.append("]"); //$NON-NLS-1$
96 return checkNotNull(sb.toString());
97 }
98
99 }
This page took 0.033535 seconds and 5 git commands to generate.