Fix for Bug338151
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / model / trange / TimeRangeComponent.java
1 /*******************************************************************************
2 * Copyright (c) 2009 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 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.linuxtools.lttng.ui.model.trange;
13
14 import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;
15 import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
16
17
18 /**
19 * @author alvaro
20 *
21 */
22 public abstract class TimeRangeComponent implements ITimeRangeComponent, ITimeEvent {
23
24 // ========================================================================
25 // Data
26 // =======================================================================
27 protected Long startTime = 0L;
28 protected Long stopTime = Long.MAX_VALUE;
29 protected TimeRangeComposite eventParent = null;
30 private boolean visible = true;
31
32
33
34 // ========================================================================
35 // Constructor
36 // =======================================================================
37 public TimeRangeComponent(Long stime, Long etime,
38 TimeRangeComposite eventParent) {
39 this.startTime = stime;
40 this.stopTime = etime;
41 this.eventParent = eventParent;
42 }
43
44 // ========================================================================
45 // Methods
46 // =======================================================================
47 /**
48 * This method shall not be used to estimate the starting drawing point of
49 * the time range-event. see interface method getTime(). However this method
50 * can be used to retrieve the tool tip information where we need to reflect
51 * that the actual start of this event is unknown
52 *
53 * @param time
54 */
55 @Override
56 public long getStartTime() {
57 return startTime.longValue();
58 }
59
60 @Override
61 public void setStartTime(long time) {
62 if (time > -1) {
63 startTime = time;
64 }
65 }
66
67 @Override
68 public long getStopTime() {
69 return stopTime.longValue();
70 }
71
72 @Override
73 public void setStopTime(long stopTime) {
74 if (stopTime > -1) {
75 this.stopTime = stopTime;
76 }
77 }
78
79 @Override
80 public ITimeRangeComponent getEventParent() {
81 return eventParent;
82 }
83
84 public void setEventParent(TimeRangeComposite eventParent) {
85 this.eventParent = eventParent;
86 }
87
88 @Override
89 public abstract String getName();
90
91
92 public void setVisible(boolean visible) {
93 this.visible = visible;
94 }
95
96 /* (non-Javadoc)
97 * @see org.eclipse.linuxtools.lttng.ui.model.trange.ITimeRangeComponent#isVisible()
98 */
99 @Override
100 public boolean isVisible() {
101 return visible;
102 }
103
104 @Override
105 public ITmfTimeAnalysisEntry getEntry() {
106 return eventParent;
107 }
108
109 @Override
110 public long getTime() {
111 return startTime;
112 }
113
114 @Override
115 public long getDuration() {
116 return stopTime - startTime;
117 }
118
119 @Override
120 @SuppressWarnings("nls")
121 public String toString() {
122 return "[TimeRangeComponent:" + "startTime=" + startTime + ",stopTime=" + stopTime +
123 ",parent=" + (eventParent != null ? eventParent.id : "null") + "]";
124 }
125
126 }
This page took 0.03537 seconds and 5 git commands to generate.