(no commit message)
[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 public long getTime() {
68 // The value provided by this method is used to start drawing the
69 // time-range,
70 // so a null value shall not be provided.
71 // If the actual start time is unknown then use the start of the Trace
72 // as the
73 // starting reference point.
74 if (startTime == null) {
75 return eventParent.getStartTime();
76 }
77 return startTime;
78 }
79
80 /*
81 * (non-Javadoc)
82 *
83 * @see
84 * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent#getEntry
85 * ()
86 */
87 public ITmfTimeAnalysisEntry getEntry() {
88 return parent;
89 }
90
91 /**
92 * return the duration between end and start time , if the start time or end
93 * time are unknown, use the Trace start and End times to estimate it, this
94 * value will be used to draw the time range and need to provide a valid
95 * time width.
96 *
97 * @return the duration
98 */
99 /*
100 * (non-Javadoc)
101 *
102 * @seeorg.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent#
103 * getDuration()
104 */
105 public long getDuration() {
106 long duration = -1;
107 long endT = (stopTime == null) ? parent.getStopTime() : stopTime;
108 long startT = (startTime == null) ? parent.getStartTime() : startTime;
109
110 if (endT > startT) {
111 return stopTime - startTime;
112 }
113 return duration;
114 }
115
116 /**
117 * @return
118 */
119 public String getStateMode() {
120 return stateMode;
121 }
122
123 /**
124 * @param stateMode
125 */
126 public void setStateMode(String stateMode) {
127 if (stateMode != null) {
128 this.stateMode = stateMode;
129 }
130 }
131
132 /*
133 * (non-Javadoc)
134 *
135 * @see org.eclipse.linuxtools.lttng.ui.model.ITimeRangeComponent#getName()
136 */
137 @Override
138 public String getName() {
139 return stateMode;
140 }
141
142 /**
143 * @return
144 */
145 public Type getEventType() {
146 return eventType;
147 }
148
149 /**
150 * @param eventType
151 */
152 public void setEventType(Type eventType) {
153 this.eventType = eventType;
154 }
155
156 }
This page took 0.033424 seconds and 5 git commands to generate.