2010-10-26 Francois Chouinard <fchouinard@gmail.com> Contribution for Bug309042
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / model / trange / TimeRangeEvent.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
13 package org.eclipse.linuxtools.lttng.ui.model.trange;
14
15 import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;
16 import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
17
18 /**
19 * @author alvaro
20 *
21 */
22 public class TimeRangeEvent extends TimeRangeComponent implements ITimeEvent {
23 // =======================================================================
24 // Data
25 // =======================================================================
26 TimeRangeComposite parent = null;
27
28 public static enum Type {
29 UNKNOWN, PROPERTY, PROCESS_MODE, BDEV_MODE, TRAP_MODE, SOFT_IRQ_MODE, IRQ_MODE, CPU_MODE
30 }
31
32 protected Type eventType = Type.UNKNOWN;
33 protected String stateMode = "";
34
35 // =======================================================================
36 // Constructors
37 // =======================================================================
38 /**
39 * @param stime
40 * Event Start Time (may be unknown)
41 * @param etime
42 * Event EndTime (may be unknown)
43 * @param eventParent
44 * @param type
45 * @param duration
46 */
47 public TimeRangeEvent(Long stime, Long etime,
48 TimeRangeComposite eventParent, Type type, String stateMode) {
49 super(stime, etime, eventParent);
50
51 this.eventType = type;
52 this.stateMode = stateMode;
53 }
54
55 // =======================================================================
56 // Methods
57 // =======================================================================
58
59 // @Override
60 /*
61 * (non-Javadoc)
62 *
63 * @see
64 * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent#getTime
65 * ()
66 */
67 @Override
68 public long getTime() {
69 // The value provided by this method is used to start drawing the
70 // time-range,
71 // so a null value shall not be provided.
72 // If the actual start time is unknown then use the start of the Trace
73 // as the
74 // starting reference point.
75 if (startTime == null) {
76 return eventParent.getStartTime();
77 }
78 return startTime;
79 }
80
81 /*
82 * (non-Javadoc)
83 *
84 * @see
85 * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent#getEntry
86 * ()
87 */
88 @Override
89 public ITmfTimeAnalysisEntry getEntry() {
90 return parent;
91 }
92
93 /**
94 * return the duration between end and start time , if the start time or end
95 * time are unknown, use the Trace start and End times to estimate it, this
96 * value will be used to draw the time range and need to provide a valid
97 * time width.
98 *
99 * @return the duration
100 */
101 /*
102 * (non-Javadoc)
103 *
104 * @seeorg.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent#
105 * getDuration()
106 */
107 @Override
108 public long getDuration() {
109 long duration = -1;
110 long endT = (stopTime == null) ? parent.getStopTime() : stopTime;
111 long startT = (startTime == null) ? parent.getStartTime() : startTime;
112
113 if (endT > startT) {
114 return stopTime - startTime;
115 }
116 return duration;
117 }
118
119 /**
120 * @return
121 */
122 public String getStateMode() {
123 return stateMode;
124 }
125
126 /**
127 * @param stateMode
128 */
129 public void setStateMode(String stateMode) {
130 if (stateMode != null) {
131 this.stateMode = stateMode;
132 }
133 }
134
135 /*
136 * (non-Javadoc)
137 *
138 * @see org.eclipse.linuxtools.lttng.ui.model.ITimeRangeComponent#getName()
139 */
140 @Override
141 public String getName() {
142 return stateMode;
143 }
144
145 /**
146 * @return
147 */
148 public Type getEventType() {
149 return eventType;
150 }
151
152 /**
153 * @param eventType
154 */
155 public void setEventType(Type eventType) {
156 this.eventType = eventType;
157 }
158
159 }
This page took 0.032869 seconds and 5 git commands to generate.