tmf: Switch tmf.ui to Java 7 + fix warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / callstack / CallStackEntry.java
1 /*******************************************************************************
2 * Copyright (c) 2013 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 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.views.callstack;
14
15 import java.util.ArrayList;
16 import java.util.Iterator;
17 import java.util.List;
18
19 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
20 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.EventIterator;
21 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
22 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
23
24 /**
25 * An entry, or row, in the Call Stack view
26 *
27 * @author Patrick Tasse
28 * @since 2.0
29 */
30 public class CallStackEntry implements ITimeGraphEntry {
31
32 private final int fQuark;
33 private final int fStackLevel;
34 private final ITmfTrace fTrace;
35 private ITimeGraphEntry fParent = null;
36 private String fName;
37 private String fFunctionName;
38 private long fStartTime;
39 private long fEndTime;
40 private List<ITimeEvent> fEventList = new ArrayList<>(1);
41 private List<ITimeEvent> fZoomedEventList = null;
42
43 /**
44 * Standard constructor
45 *
46 * @param quark
47 * The event stack quark
48 * @param stackLevel
49 * The stack level
50 * @param trace
51 * The trace that this view is talking about
52 */
53 public CallStackEntry(int quark, int stackLevel, ITmfTrace trace) {
54 fQuark = quark;
55 fStackLevel = stackLevel;
56 fTrace = trace;
57 fFunctionName = ""; //$NON-NLS-1$
58 }
59
60 @Override
61 public ITimeGraphEntry getParent() {
62 return fParent;
63 }
64
65 @Override
66 public boolean hasChildren() {
67 return false;
68 }
69
70 @Override
71 public List<CallStackEntry> getChildren() {
72 return null;
73 }
74
75 @Override
76 public String getName() {
77 return ""; //$NON-NLS-1$
78 }
79
80 /**
81 * Get the function name of the call stack entry
82 * @return the function name
83 */
84 public String getFunctionName() {
85 return fFunctionName;
86 }
87
88 /**
89 * Set the function name of the call stack entry
90 * @param functionName the function name
91 */
92 public void setFunctionName(String functionName) {
93 fFunctionName = functionName;
94 }
95
96 @Override
97 public long getStartTime() {
98 return fStartTime;
99 }
100
101 /**
102 * Set the start time of the call stack entry
103 * @param startTime the start time
104 */
105 public void setStartTime(long startTime) {
106 fStartTime = startTime;
107 }
108
109 @Override
110 public long getEndTime() {
111 return fEndTime;
112 }
113
114 /**
115 * Set the end time of the call stack entry
116 * @param endTime the end time
117 */
118 public void setEndTime(long endTime) {
119 fEndTime = endTime;
120 }
121
122 @Override
123 public boolean hasTimeEvents() {
124 return fEventList != null;
125 }
126
127 @Override
128 public Iterator<ITimeEvent> getTimeEventsIterator() {
129 return new EventIterator(fEventList, fZoomedEventList);
130 }
131
132 @Override
133 public Iterator<ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {
134 return new EventIterator(fEventList, fZoomedEventList, startTime, stopTime);
135 }
136
137 /**
138 * Assign a parent entry to this one, to organize them in a tree in the
139 * view.
140 *
141 * @param parent
142 * The parent entry
143 */
144 public void setParent(ITimeGraphEntry parent) {
145 fParent = parent;
146 }
147
148 /**
149 * Retrieve the attribute quark that's represented by this entry.
150 *
151 * @return The integer quark
152 */
153 public int getQuark() {
154 return fQuark;
155 }
156
157 /**
158 * Retrieve the stack level associated with this entry.
159 *
160 * @return The stack level or 0
161 */
162 public int getStackLevel() {
163 return fStackLevel;
164 }
165
166 /**
167 * Retrieve the trace that is associated to this view.
168 *
169 * @return The trace
170 */
171 public ITmfTrace getTrace() {
172 return fTrace;
173 }
174
175 /**
176 * Assign the target event list to this view.
177 *
178 * @param eventList
179 * The list of time events
180 */
181 public void setEventList(List<ITimeEvent> eventList) {
182 fEventList = eventList;
183 if (eventList != null && eventList.size() > 0) {
184 fStartTime = eventList.get(0).getTime();
185 ITimeEvent lastEvent = eventList.get(eventList.size() - 1);
186 fEndTime = lastEvent.getTime() + lastEvent.getDuration();
187 }
188 }
189
190 /**
191 * Assign the zoomed event list to this view.
192 *
193 * @param eventList
194 * The list of "zoomed" time events
195 */
196 public void setZoomedEventList(List<ITimeEvent> eventList) {
197 fZoomedEventList = eventList;
198 }
199
200 /**
201 * Add an event to the event list
202 *
203 * @param timeEvent
204 * The event
205 */
206 public void addEvent(ITimeEvent timeEvent) {
207 fEventList.add(timeEvent);
208 }
209
210 @Override
211 public String toString() {
212 return getClass().getSimpleName() + " name=" + fName; //$NON-NLS-1$
213 }
214 }
This page took 0.072099 seconds and 5 git commands to generate.