|
Lines 57-103
Link Here
|
| 57 |
import org.eclipse.swt.widgets.TableColumn; |
57 |
import org.eclipse.swt.widgets.TableColumn; |
| 58 |
import org.eclipse.swt.widgets.Tree; |
58 |
import org.eclipse.swt.widgets.Tree; |
| 59 |
import org.eclipse.swt.widgets.TreeItem; |
59 |
import org.eclipse.swt.widgets.TreeItem; |
|
|
60 |
import org.eclipse.tptp.trace.jvmti.internal.client.widgets.Utils; |
| 60 |
|
61 |
|
| 61 |
/** |
62 |
/** |
| 62 |
* This view contains thread statistics data. |
63 |
* This view contains thread statistics data. |
| 63 |
*/ |
64 |
*/ |
| 64 |
public class ThreadStatisticView extends StatisticView { |
65 |
public class ThreadStatisticView extends StatisticView { |
| 65 |
|
66 |
|
|
|
67 |
static final int COL_CLASS_NAME = 0; |
| 68 |
static final int COL_THREAD_NAME = 1; |
| 69 |
static final int COL_STATE = 2; |
| 70 |
static final int COL_RUN_TIME = 3; |
| 71 |
static final int COL_WAIT_TIME = 4; |
| 72 |
static final int COL_BLOCK_TIME = 5; |
| 73 |
static final int COL_BLOCK_COUNT = 6; |
| 74 |
static final int COL_DEADLOCK_TIME = 7; |
| 75 |
static final int COL_DEADLOCK_COUNT = 8; |
| 76 |
|
| 66 |
public static String PREFERENCE_KEY_PREFIX = "org.eclipse.hyades.trace.views.statistic."; |
77 |
public static String PREFERENCE_KEY_PREFIX = "org.eclipse.hyades.trace.views.statistic."; |
| 67 |
private boolean _isEmpty; |
78 |
private boolean _isEmpty; |
| 68 |
protected ContextInfoContainer _contextInfo; |
79 |
protected ContextInfoContainer _contextInfo; |
| 69 |
|
80 |
|
| 70 |
protected ColumnLabelAdapter[] _columns; |
81 |
protected ColumnLabelAdapter[] _columns; |
| 71 |
|
82 |
|
| 72 |
public ThreadStatisticView(Composite parent, TraceViewerPage page){ |
83 |
public ThreadStatisticView(Composite parent, TraceViewerPage page) { |
| 73 |
super(parent, page); |
84 |
super(parent, page); |
| 74 |
|
85 |
|
| 75 |
createColumnsLabelProviders(); |
86 |
createColumnsLabelProviders(); |
| 76 |
} |
87 |
} |
| 77 |
|
88 |
|
| 78 |
protected String getContextHelpId() |
89 |
protected String getContextHelpId() { |
| 79 |
{ |
90 |
return TraceUIPlugin.getPluginId() + ".stvw0001"; |
| 80 |
return TraceUIPlugin.getPluginId()+".stvw0001"; |
91 |
} |
| 81 |
} |
92 |
|
| 82 |
|
93 |
public void createColumnsLabelProviders() { |
| 83 |
public void createColumnsLabelProviders() |
|
|
| 84 |
{ |
| 85 |
_columns = new ColumnLabelAdapter[] { |
94 |
_columns = new ColumnLabelAdapter[] { |
| 86 |
new ThreadClassNameColumnLabel(), |
95 |
new ThreadClassNameColumnLabel(), |
| 87 |
new ThreadNameColumnLabel(), |
96 |
new ThreadNameColumnLabel(), |
| 88 |
new ThreadStartTimeColumnLabel(), |
97 |
//new ThreadStartTimeColumnLabel(), |
| 89 |
new ThreadStopTimeColumnLabel(), |
98 |
//new ThreadStopTimeColumnLabel(), |
| 90 |
new ThreadStateColumnLabel(), |
99 |
new ThreadStateColumnLabel(), |
| 91 |
new ThreadRunningTimeColumnLabel(), |
100 |
new ThreadRunningTimeColumnLabel(), |
| 92 |
// new ThreadSleepingTimeColumnLabel(), |
101 |
//new ThreadSleepingTimeColumnLabel(), |
| 93 |
new ThreadWaitingTimeColumnLabel(), |
102 |
new ThreadWaitingTimeColumnLabel(), |
| 94 |
new ThreadBlockedTimeColumnLabel(), |
103 |
new ThreadBlockedTimeColumnLabel(), |
| 95 |
new ThreadBlockCountColumnLabel(), |
104 |
new ThreadBlockCountColumnLabel(), |
| 96 |
new ThreadDeadlockedTimeColumnLabel(), |
105 |
new ThreadDeadlockedTimeColumnLabel(), |
| 97 |
new ThreadDeadlockCountColumnLabel() |
106 |
new ThreadDeadlockCountColumnLabel() }; |
| 98 |
}; |
|
|
| 99 |
} |
107 |
} |
| 100 |
|
108 |
|
| 101 |
class ThreadStatisticTreeViewer extends TreeViewer { |
109 |
class ThreadStatisticTreeViewer extends TreeViewer { |
| 102 |
public ThreadStatisticTreeViewer(Composite parent) { |
110 |
public ThreadStatisticTreeViewer(Composite parent) { |
| 103 |
super(parent); |
111 |
super(parent); |
|
Lines 111-160
Link Here
|
| 111 |
item.setExpanded(true); |
119 |
item.setExpanded(true); |
| 112 |
createChildren(item); |
120 |
createChildren(item); |
| 113 |
} |
121 |
} |
| 114 |
|
122 |
|
| 115 |
/** |
123 |
/** |
| 116 |
* Returns the current selection for this provider. |
124 |
* Returns the current selection for this provider. |
| 117 |
* |
125 |
* |
| 118 |
* @return the current selection |
126 |
* @return the current selection |
| 119 |
*/ |
127 |
*/ |
| 120 |
public ISelection getSelection() |
128 |
public ISelection getSelection() { |
| 121 |
{ |
129 |
ISelection sel = super.getSelection(); |
| 122 |
ISelection sel = super.getSelection(); |
130 |
if (sel != null && !sel.isEmpty()) { |
| 123 |
if(sel != null && !sel.isEmpty()) |
131 |
Object obj = ((IStructuredSelection) sel).getFirstElement(); |
| 124 |
{ |
132 |
if (obj instanceof ThreadDetails) |
| 125 |
Object obj = ((IStructuredSelection)sel).getFirstElement(); |
133 |
return new StructuredSelection(((ThreadDetails) obj).getThread()); |
| 126 |
if(obj instanceof ThreadDetails) |
134 |
} |
| 127 |
return new StructuredSelection(((ThreadDetails)obj).getThread()); |
135 |
return sel; |
| 128 |
} |
136 |
} |
| 129 |
return sel; |
137 |
|
| 130 |
} |
138 |
} |
| 131 |
|
139 |
|
| 132 |
} |
140 |
public class ThreadStatisticContentProvider implements ITreeContentProvider { |
| 133 |
|
141 |
|
| 134 |
public class ThreadStatisticContentProvider implements ITreeContentProvider |
142 |
public Object[] getChildren(Object element) { |
| 135 |
{ |
|
|
| 136 |
|
| 137 |
public Object[] getChildren(Object element) |
| 138 |
{ |
| 139 |
return null; |
143 |
return null; |
| 140 |
} |
144 |
} |
| 141 |
|
145 |
|
| 142 |
public Object getParent(Object element) { |
146 |
public Object getParent(Object element) { |
| 143 |
return null; |
147 |
return null; |
| 144 |
} |
148 |
} |
| 145 |
|
149 |
|
| 146 |
public boolean hasChildren(Object element) { |
150 |
public boolean hasChildren(Object element) { |
| 147 |
return false; |
151 |
return false; |
| 148 |
} |
152 |
} |
| 149 |
|
153 |
|
| 150 |
/** |
154 |
/** |
| 151 |
* return the list of elements to display in the table tree |
155 |
* return the list of elements to display in the table tree |
| 152 |
*/ |
156 |
*/ |
| 153 |
public Object[] getElements(Object inputElement) { |
157 |
public Object[] getElements(Object inputElement) { |
| 154 |
Object[] threads = PerftraceUtil.getAllThreads(_page.getMOFObject(), false); |
158 |
Object[] threads = PerftraceUtil.getAllThreads( |
|
|
159 |
_page.getMOFObject(), false); |
| 155 |
Object[] elements = new Object[threads.length]; |
160 |
Object[] elements = new Object[threads.length]; |
| 156 |
for (int i=0; i < threads.length; i++) { |
161 |
for (int i = 0; i < threads.length; i++) { |
| 157 |
elements[i] = new ThreadDetails((TRCThread)threads[i]); |
162 |
elements[i] = new ThreadDetails((TRCThread) threads[i]); |
| 158 |
} |
163 |
} |
| 159 |
return elements; |
164 |
return elements; |
| 160 |
} |
165 |
} |
|
Lines 165-231
Link Here
|
| 165 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
170 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
| 166 |
} |
171 |
} |
| 167 |
} |
172 |
} |
| 168 |
|
173 |
|
| 169 |
public class ThreadStatisticLabelProvider extends LabelProvider |
174 |
public class ThreadStatisticLabelProvider extends LabelProvider implements |
| 170 |
implements ITableLabelProvider { |
175 |
ITableLabelProvider { |
| 171 |
protected StatisticView _viewer; |
176 |
protected StatisticView _viewer; |
| 172 |
|
177 |
|
| 173 |
public ThreadStatisticLabelProvider(StatisticView viewer) { |
178 |
public ThreadStatisticLabelProvider(StatisticView viewer) { |
| 174 |
_viewer = viewer; |
179 |
_viewer = viewer; |
| 175 |
} |
180 |
} |
| 176 |
|
181 |
|
| 177 |
public String getColumnText(Object obj, int col) { |
182 |
public String getColumnText(Object obj, int col) { |
| 178 |
StatisticTableColumnInfo info = StatisticTableColumnInfo.getStatisticTableColumnInfo(_viewer.getTree().getColumn(col)); |
183 |
StatisticTableColumnInfo info = |
| 179 |
int pos = info.getColumnData().getInitalPos(); |
184 |
StatisticTableColumnInfo.getStatisticTableColumnInfo(_viewer.getTree().getColumn(col)); |
| 180 |
|
185 |
int pos = info.getColumnData().getInitalPos(); |
| 181 |
if (pos >= 0 && pos < _columns.length) { |
186 |
|
| 182 |
return getElementColumnText(obj, _columns[pos], info.isDeltaColumn()); |
187 |
if (pos >= 0 && pos < _columns.length) { |
| 183 |
} else { |
188 |
return getElementColumnText(obj, _columns[pos], info.isDeltaColumn()); |
| 184 |
return ""; |
189 |
} else { |
| 185 |
} |
190 |
return ""; |
|
|
191 |
} |
| 186 |
} |
192 |
} |
| 187 |
|
193 |
|
| 188 |
public Image getColumnImage(Object obj, int col) { |
194 |
public Image getColumnImage(Object obj, int col) { |
| 189 |
StatisticTableColumnInfo info = StatisticTableColumnInfo.getStatisticTableColumnInfo(_viewer.getTree().getColumn(col)); |
195 |
StatisticTableColumnInfo info = |
| 190 |
int pos = info.getColumnData().getInitalPos(); |
196 |
StatisticTableColumnInfo.getStatisticTableColumnInfo(_viewer.getTree().getColumn(col)); |
| 191 |
|
197 |
int pos = info.getColumnData().getInitalPos(); |
| 192 |
if (pos == 4) { // thread state |
198 |
|
| 193 |
|
199 |
if (pos == COL_STATE) { // thread state |
| 194 |
} |
200 |
} |
| 195 |
|
201 |
|
| 196 |
if(info.isDeltaColumn()) |
202 |
if (info.isDeltaColumn()) |
| 197 |
return null; |
203 |
return null; |
| 198 |
|
204 |
|
| 199 |
if (pos >= 0 && pos < _columns.length) { |
205 |
if (pos >= 0 && pos < _columns.length) { |
| 200 |
return getElementColumnImage(obj, _columns[pos], info.isDeltaColumn()); |
206 |
return getElementColumnImage(obj, _columns[pos], info.isDeltaColumn()); |
| 201 |
} else { |
207 |
} else { |
| 202 |
return null; |
208 |
return null; |
| 203 |
} |
209 |
} |
| 204 |
} |
210 |
} |
| 205 |
} |
211 |
} |
| 206 |
|
212 |
|
| 207 |
public class ThreadStatisticSorter extends StatisticSorter { |
213 |
public class ThreadStatisticSorter extends StatisticSorter { |
| 208 |
|
214 |
|
| 209 |
public int compare(Viewer viewer, Object e1, Object e2) { |
215 |
public int compare(Viewer viewer, Object e1, Object e2) { |
| 210 |
if (_pos >= 0 && _pos < _columns.length) { |
216 |
if (_pos >= 0 && _pos < _columns.length) { |
| 211 |
return _sortSequence * compareElements(e1, e2, _columns[_pos], _info.isDeltaColumn()); |
217 |
return _sortSequence * compareElements(e1, e2, _columns[_pos], _info.isDeltaColumn()); |
| 212 |
} else { |
218 |
} else { |
| 213 |
return 0; |
219 |
return 0; |
| 214 |
} |
220 |
} |
| 215 |
} |
221 |
} |
| 216 |
} |
222 |
} |
| 217 |
|
223 |
|
| 218 |
public class ThreadStatisticFilter extends StatisticFilter{ |
224 |
public class ThreadStatisticFilter extends StatisticFilter { |
| 219 |
|
225 |
|
| 220 |
public ThreadStatisticFilter() { |
226 |
public ThreadStatisticFilter() { |
| 221 |
super(); |
227 |
super(); |
| 222 |
} |
228 |
} |
| 223 |
|
229 |
|
| 224 |
public boolean select(Viewer viewer, Object parent, Object element) { |
230 |
public boolean select(Viewer viewer, Object parent, Object element) { |
| 225 |
|
231 |
|
| 226 |
boolean flag = true; |
232 |
boolean flag = true; |
| 227 |
String compareText = (element instanceof TRCThread) ? |
233 |
String compareText = (element instanceof TRCThread) ? PerftraceUtil.getThreadName((TRCThread) element) : ""; |
| 228 |
PerftraceUtil.getThreadName((TRCThread)element) : ""; |
|
|
| 229 |
|
234 |
|
| 230 |
if (_noPattern) |
235 |
if (_noPattern) |
| 231 |
return true; |
236 |
return true; |
|
Lines 259-353
Link Here
|
| 259 |
return flag; |
264 |
return flag; |
| 260 |
} |
265 |
} |
| 261 |
} |
266 |
} |
| 262 |
|
267 |
|
| 263 |
public String getDefaultColumnsTemplate() |
268 |
public String getDefaultColumnsTemplate() { |
| 264 |
{ |
269 |
return IContextAttributes.THREAD_CLASS_NAME + ":" + COL_CLASS_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:150," |
| 265 |
return IContextAttributes.THREAD_CLASS_NAME + ":0:" |
270 |
+ IContextAttributes.THREAD_NAME + ":" + COL_THREAD_NAME + ":" + String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:120," |
| 266 |
+ String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:150," |
271 |
//+ IContextAttributes.THREAD_START_TIME + ":2:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," |
| 267 |
+ IContextAttributes.THREAD_NAME + ":1:" |
272 |
//+ IContextAttributes.THREAD_STOP_TIME + ":3:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," |
| 268 |
+ String.valueOf(ColumnData.NONDELETABLE | ColumnData.IS_VISIBLE | ColumnData.NONMOVABLE) + ":left:120," |
273 |
+ IContextAttributes.THREAD_STATE + ":" + COL_STATE + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," |
| 269 |
+ IContextAttributes.THREAD_START_TIME + ":2:" |
274 |
+ IContextAttributes.THREAD_RUNNING_TIME + ":" + COL_RUN_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," |
| 270 |
+ String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," |
275 |
//+ IContextAttributes.THREAD_SLEEPING_TIME + ":6:" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," |
| 271 |
+ IContextAttributes.THREAD_STOP_TIME + ":3:" |
276 |
+ IContextAttributes.THREAD_WAITING_TIME + ":" + COL_WAIT_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," |
| 272 |
+ String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," |
277 |
+ IContextAttributes.THREAD_BLOCKED_TIME + ":" + COL_BLOCK_TIME+ ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," |
| 273 |
+ IContextAttributes.THREAD_STATE + ":4:" |
278 |
+ IContextAttributes.THREAD_BLOCK_COUNT + ":" + COL_BLOCK_COUNT + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," |
| 274 |
+ String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," |
279 |
+ IContextAttributes.THREAD_DEADLOCKED_TIME + ":" + COL_DEADLOCK_TIME + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," |
| 275 |
+ IContextAttributes.THREAD_RUNNING_TIME + ":5:" |
280 |
+ IContextAttributes.THREAD_DEADLOCK_COUNT + ":" + COL_DEADLOCK_COUNT + ":" + String.valueOf(ColumnData.IS_VISIBLE) + ":right:80" |
| 276 |
+ String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," |
|
|
| 277 |
// + IContextAttributes.THREAD_SLEEPING_TIME + ":6:" |
| 278 |
// + String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," |
| 279 |
+ IContextAttributes.THREAD_WAITING_TIME + ":6:" |
| 280 |
+ String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," |
| 281 |
+ IContextAttributes.THREAD_BLOCKED_TIME + ":7:" |
| 282 |
+ String.valueOf(ColumnData.IS_VISIBLE) + ":right:120," |
| 283 |
+ IContextAttributes.THREAD_BLOCK_COUNT + ":8:" |
| 284 |
+ String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," |
| 285 |
+ IContextAttributes.THREAD_DEADLOCKED_TIME+ ":9:" |
| 286 |
+ String.valueOf(ColumnData.IS_VISIBLE) + ":right:80," |
| 287 |
+ IContextAttributes.THREAD_DEADLOCK_COUNT + ":10:" |
| 288 |
+ String.valueOf(ColumnData.IS_VISIBLE) + ":right:80" |
| 289 |
; |
281 |
; |
| 290 |
} |
282 |
} |
| 291 |
|
283 |
|
| 292 |
public boolean isEmptyUpdate() |
284 |
public boolean isEmptyUpdate() { |
| 293 |
{ |
285 |
// Object[] threads = PerftraceUtil.getAllThreads(_page.getMOFObject(), false); |
| 294 |
// Object[] threads = PerftraceUtil.getAllThreads(_page.getMOFObject(), false); |
286 |
// for (int i = 0; i < threads.length; i++) { |
| 295 |
// for (int i = 0; i < threads.length; i++) { |
287 |
// TRCThread thread = (TRCThread)threads[i]; |
| 296 |
// TRCThread thread = (TRCThread)threads[i]; |
288 |
// for (Iterator it = thread.getThreadEvents().iterator(); it.hasNext(); |
| 297 |
// for (Iterator it = thread.getThreadEvents().iterator(); it.hasNext(); ) { |
289 |
// ) { |
| 298 |
// Object event = it.next(); |
290 |
// Object event = it.next(); |
| 299 |
// if (event instanceof TRCThreadWaitingForLockEvent |
291 |
// if (event instanceof TRCThreadWaitingForLockEvent |
| 300 |
// || event instanceof TRCThreadWaitingForObjectEvent |
292 |
// || event instanceof TRCThreadWaitingForObjectEvent |
| 301 |
// || event instanceof TRCThreadSleepingEvent |
293 |
// || event instanceof TRCThreadSleepingEvent |
| 302 |
// || event instanceof TRCThreadDeadLockEvent) { |
294 |
// || event instanceof TRCThreadDeadLockEvent) { |
| 303 |
return false; |
295 |
return false; |
| 304 |
// } |
296 |
// } |
| 305 |
// } |
297 |
// } |
| 306 |
// } |
298 |
// } |
| 307 |
// return true; |
299 |
// return true; |
| 308 |
} |
300 |
} |
| 309 |
|
301 |
|
| 310 |
public IContentProvider getContentProvider() |
302 |
public IContentProvider getContentProvider() { |
| 311 |
{ |
|
|
| 312 |
return new ThreadStatisticContentProvider(); |
303 |
return new ThreadStatisticContentProvider(); |
| 313 |
} |
304 |
} |
| 314 |
|
305 |
|
| 315 |
public LabelProvider getTableLabelProvider() |
306 |
public LabelProvider getTableLabelProvider() { |
| 316 |
{ |
|
|
| 317 |
return new ThreadStatisticLabelProvider(this); |
307 |
return new ThreadStatisticLabelProvider(this); |
| 318 |
} |
308 |
} |
| 319 |
|
309 |
|
| 320 |
protected StatisticSorter getViewerSorterInstance() |
310 |
protected StatisticSorter getViewerSorterInstance() { |
| 321 |
{ |
|
|
| 322 |
return new ThreadStatisticSorter(); |
311 |
return new ThreadStatisticSorter(); |
| 323 |
} |
312 |
} |
| 324 |
|
313 |
|
| 325 |
protected StatisticFilter getFilterInstance() |
314 |
protected StatisticFilter getFilterInstance() { |
| 326 |
{ |
|
|
| 327 |
return new ThreadStatisticFilter(); |
315 |
return new ThreadStatisticFilter(); |
| 328 |
} |
316 |
} |
| 329 |
|
317 |
|
| 330 |
public String getColumnsPreferencesKey() |
318 |
public String getColumnsPreferencesKey() { |
| 331 |
{ |
319 |
return PREFERENCE_KEY_PREFIX + "ThreadStats2"; |
| 332 |
return PREFERENCE_KEY_PREFIX + "ThreadStats1"; |
320 |
} |
| 333 |
} |
321 |
|
| 334 |
|
322 |
protected String getViewTypeStr() { |
| 335 |
protected String getViewTypeStr() |
|
|
| 336 |
{ |
| 337 |
return org.eclipse.hyades.trace.views.adapter.internal.TraceConstants.THREAD_STATS_VIEW; |
323 |
return org.eclipse.hyades.trace.views.adapter.internal.TraceConstants.THREAD_STATS_VIEW; |
| 338 |
} |
324 |
} |
| 339 |
|
325 |
|
| 340 |
public void updateButtons() { |
326 |
public void updateButtons() { |
| 341 |
} |
327 |
} |
| 342 |
|
328 |
|
| 343 |
protected void showPercentUpdate() { |
329 |
protected void showPercentUpdate() { |
| 344 |
} |
330 |
} |
| 345 |
|
331 |
|
| 346 |
|
332 |
public void update() { |
| 347 |
public void update() |
333 |
if (_page instanceof ThreadStatisticPage) { |
| 348 |
{ |
|
|
| 349 |
if(_page instanceof ThreadStatisticPage) |
| 350 |
{ |
| 351 |
if (_contextInfo != null) |
334 |
if (_contextInfo != null) |
| 352 |
_contextInfo.setMOFObject(_page.getMOFObject()); |
335 |
_contextInfo.setMOFObject(_page.getMOFObject()); |
| 353 |
} |
336 |
} |
|
Lines 355-369
Link Here
|
| 355 |
for (int i = 0; i < _columns.length; i++) { |
338 |
for (int i = 0; i < _columns.length; i++) { |
| 356 |
_columns[i].resetMap(); |
339 |
_columns[i].resetMap(); |
| 357 |
} |
340 |
} |
| 358 |
|
341 |
|
| 359 |
super.update(); |
342 |
super.update(); |
| 360 |
|
343 |
|
| 361 |
if(_page instanceof ThreadStatisticPage) |
344 |
if (_page instanceof ThreadStatisticPage) { |
| 362 |
{ |
|
|
| 363 |
_isEmpty = isEmptyUpdate(); |
345 |
_isEmpty = isEmptyUpdate(); |
| 364 |
} |
346 |
} |
| 365 |
} |
347 |
} |
| 366 |
|
348 |
|
| 367 |
public boolean isEmpty() { |
349 |
public boolean isEmpty() { |
| 368 |
return _isEmpty; |
350 |
return _isEmpty; |
| 369 |
} |
351 |
} |
|
Lines 385-391
Link Here
|
| 385 |
if (width > 0) { |
367 |
if (width > 0) { |
| 386 |
Region region = new Region(); |
368 |
Region region = new Region(); |
| 387 |
gc.getClipping(region); |
369 |
gc.getClipping(region); |
| 388 |
region.add(event.x, event.y, width, event.height); |
370 |
region.add(event.x, event.y, width, event.height); |
| 389 |
gc.setClipping(region); |
371 |
gc.setClipping(region); |
| 390 |
region.dispose(); |
372 |
region.dispose(); |
| 391 |
} |
373 |
} |
|
Lines 398-413
Link Here
|
| 398 |
gc.setBackground(background); |
380 |
gc.setBackground(background); |
| 399 |
event.detail &= ~SWT.SELECTED; |
381 |
event.detail &= ~SWT.SELECTED; |
| 400 |
} |
382 |
} |
| 401 |
} |
383 |
} |
| 402 |
|
384 |
|
| 403 |
ThreadDetails thread = (ThreadDetails) event.item.getData(); |
385 |
ThreadDetails thread = (ThreadDetails) event.item.getData(); |
| 404 |
int state = ThreadDetails.UNKNOWN; |
386 |
int state = ThreadDetails.UNKNOWN; |
| 405 |
if (event.index == 4) { // thread state |
387 |
if (event.index == COL_STATE) { // thread state |
| 406 |
state = thread.getState(); |
388 |
state = thread.getState(); |
| 407 |
} else if (event.index == 8 // block count |
389 |
} else if (event.index == COL_BLOCK_COUNT // block count |
| 408 |
&& thread.getBlockCount() > 0) { |
390 |
&& thread.getBlockCount() > 0) { |
| 409 |
state = ThreadDetails.BLOCKED; |
391 |
state = ThreadDetails.BLOCKED; |
| 410 |
} else if (event.index == 10 // deadlock count |
392 |
} else if (event.index == COL_DEADLOCK_COUNT // deadlock count |
| 411 |
&& thread.getDeadlockCount() > 0) { |
393 |
&& thread.getDeadlockCount() > 0) { |
| 412 |
state = ThreadDetails.DEADLOCK; |
394 |
state = ThreadDetails.DEADLOCK; |
| 413 |
} |
395 |
} |
|
Lines 416-451
Link Here
|
| 416 |
GC gc = event.gc; |
398 |
GC gc = event.gc; |
| 417 |
Color foreground = gc.getForeground(); |
399 |
Color foreground = gc.getForeground(); |
| 418 |
Color background = gc.getBackground(); |
400 |
Color background = gc.getBackground(); |
| 419 |
|
401 |
|
| 420 |
int c1 = ThreadDetails.getStateColor(state); |
402 |
int c1 = ThreadDetails.getStateColor(state); |
| 421 |
int c2 = selected ? SWT.COLOR_GRAY : SWT.COLOR_WHITE; |
403 |
int c2 = selected ? SWT.COLOR_GRAY : SWT.COLOR_WHITE; |
| 422 |
Color sysBack = display.getSystemColor(c1); |
404 |
Color sysBack = display.getSystemColor(c1); |
| 423 |
Color sysFore = display.getSystemColor(c2); |
405 |
Color sysFore = display.getSystemColor(c2); |
| 424 |
Color fore = mixColors(display, sysBack, sysFore, 1, 4); |
406 |
Color fore = Utils.mixColors(display, sysBack, sysFore, 1, 4); |
| 425 |
Color back = mixColors(display, sysBack, sysFore, 1, 1); |
407 |
Color back = Utils.mixColors(display, sysBack, sysFore, 1, 1); |
|
|
408 |
|
| 409 |
gc.setAdvanced(true); |
| 410 |
if (gc.getAdvanced()) { |
| 411 |
gc.setAlpha(180); |
| 412 |
} |
| 426 |
|
413 |
|
| 427 |
gc.setAdvanced(true); |
|
|
| 428 |
if (gc.getAdvanced()) { |
| 429 |
gc.setAlpha(180); |
| 430 |
} |
| 431 |
|
| 432 |
gc.setBackground(back); |
414 |
gc.setBackground(back); |
| 433 |
gc.setForeground(fore); |
415 |
gc.setForeground(fore); |
| 434 |
gc.fillGradientRectangle(event.x, event.y, event.width, event.height, false); |
416 |
gc.fillGradientRectangle(event.x, event.y, event.width, event.height, false); |
| 435 |
|
417 |
|
| 436 |
gc.setForeground(foreground); |
418 |
gc.setForeground(foreground); |
| 437 |
gc.setBackground(background); |
419 |
gc.setBackground(background); |
| 438 |
back.dispose(); |
420 |
back.dispose(); |
| 439 |
fore.dispose(); |
421 |
fore.dispose(); |
| 440 |
} |
422 |
} |
| 441 |
} |
423 |
} |
| 442 |
|
|
|
| 443 |
private Color mixColors(Display display, Color c1, Color c2, int w1, int w2) { |
| 444 |
return new Color(display, |
| 445 |
(w1 * c1.getRed() + w2 * c2.getRed()) / (w1 + w2), |
| 446 |
(w1 * c1.getGreen() + w2 * c2.getGreen()) / (w1 + w2), |
| 447 |
(w1 * c1.getBlue() + w2 * c2.getBlue()) / (w1 + w2)); |
| 448 |
} |
| 449 |
}; |
424 |
}; |
| 450 |
tree.addListener(SWT.EraseItem, listener); |
425 |
tree.addListener(SWT.EraseItem, listener); |
| 451 |
return tree; |
426 |
return tree; |
|
Lines 460-521
Link Here
|
| 460 |
} |
435 |
} |
| 461 |
|
436 |
|
| 462 |
protected void handleSelectionEvent() { |
437 |
protected void handleSelectionEvent() { |
| 463 |
ITraceSelection model = |
438 |
ITraceSelection model = UIPlugin.getDefault().getSelectionModel(_page.getMOFObject()); |
| 464 |
UIPlugin.getDefault().getSelectionModel(_page.getMOFObject()); |
|
|
| 465 |
if (model.size() > 0) { |
439 |
if (model.size() > 0) { |
| 466 |
Object sel = model.getFirstElement(); |
440 |
Object sel = model.getFirstElement(); |
| 467 |
if (sel != null) { |
441 |
if (sel != null) { |
| 468 |
select(sel); |
442 |
select(sel); |
| 469 |
|
|
|
| 470 |
if (sel instanceof EObject) |
443 |
if (sel instanceof EObject) |
| 471 |
updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject)sel))); |
444 |
updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject) sel))); |
| 472 |
} |
445 |
} |
| 473 |
} |
446 |
} |
| 474 |
} |
447 |
} |
| 475 |
|
448 |
|
| 476 |
public void updateModelSelection() { |
449 |
public void updateModelSelection() { |
| 477 |
ISelection selection = getTreeViewer().getSelection(); |
450 |
ISelection selection = getTreeViewer().getSelection(); |
| 478 |
if(selection != null && !selection.isEmpty()) |
451 |
Object sel = null; |
| 479 |
{ |
452 |
if (selection != null && !selection.isEmpty()) { |
| 480 |
Object sel = ((IStructuredSelection)selection).getFirstElement(); |
453 |
sel = ((IStructuredSelection) selection).getFirstElement(); |
| 481 |
if(sel instanceof ThreadDetails) |
454 |
if (sel instanceof ThreadDetails) |
| 482 |
notifyViewSelectionChanged(this, ((ThreadDetails)sel).getThread()); |
455 |
sel = ((ThreadDetails) sel).getThread(); |
| 483 |
else |
456 |
notifyViewSelectionChanged(this, sel); |
| 484 |
notifyViewSelectionChanged(this,sel); |
457 |
} |
|
|
458 |
} |
| 459 |
|
| 460 |
public TRCThread getSelectedThread() { |
| 461 |
TRCThread thread = null; |
| 462 |
ISelection selection = getTreeViewer().getSelection(); |
| 463 |
if (selection != null && !selection.isEmpty()) { |
| 464 |
Object sel = ((IStructuredSelection) selection).getFirstElement(); |
| 465 |
if (sel instanceof TRCThread) |
| 466 |
thread = (TRCThread) sel; |
| 467 |
if (sel instanceof ThreadDetails) |
| 468 |
thread = ((ThreadDetails) sel).getThread(); |
| 485 |
} |
469 |
} |
|
|
470 |
return thread; |
| 486 |
} |
471 |
} |
| 487 |
|
472 |
|
| 488 |
public void handleViewSelectionChangedEvent(ViewSelectionChangedEvent event) { |
473 |
public void handleViewSelectionChangedEvent(ViewSelectionChangedEvent event) { |
| 489 |
Object source = event.getSource(); |
474 |
Object source = event.getSource(); |
| 490 |
if(source!=this){ |
475 |
if (source != this) { |
| 491 |
handleSelectionEvent(); |
476 |
handleSelectionEvent(); |
| 492 |
} |
477 |
} else { |
| 493 |
else |
478 |
ITraceSelection model = UIPlugin.getDefault().getSelectionModel(_page.getMOFObject()); |
| 494 |
{ |
|
|
| 495 |
ITraceSelection model = |
| 496 |
UIPlugin.getDefault().getSelectionModel(_page.getMOFObject()); |
| 497 |
if (model.size() > 0) { |
479 |
if (model.size() > 0) { |
| 498 |
Object sel = model.getFirstElement(); |
480 |
Object sel = model.getFirstElement(); |
| 499 |
if (sel != null && sel instanceof EObject) |
481 |
if (sel != null && sel instanceof EObject) |
| 500 |
updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject)sel))); |
482 |
updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject) sel))); |
| 501 |
} |
483 |
} |
| 502 |
} |
484 |
} |
| 503 |
} |
485 |
} |
| 504 |
|
486 |
|
| 505 |
public void menuAboutToShow(IMenuManager menu) { |
487 |
public void menuAboutToShow(IMenuManager menu) { |
| 506 |
|
|
|
| 507 |
menu.add(getUpdateAction()); |
488 |
menu.add(getUpdateAction()); |
| 508 |
menu.add(fSeparator); |
489 |
menu.add(fSeparator); |
| 509 |
resetChooseColumnsAction(); |
490 |
resetChooseColumnsAction(); |
| 510 |
menu.add( |
491 |
menu.add(getChooseColumnsAction(getColumnDataList(), |
| 511 |
getChooseColumnsAction( |
|
|
| 512 |
getColumnDataList(), |
| 513 |
getColumnsPreferencesKey())); |
492 |
getColumnsPreferencesKey())); |
| 514 |
menu.add( |
493 |
menu.add(getSortByColumnAction()); |
| 515 |
getSortByColumnAction()); |
|
|
| 516 |
|
| 517 |
} |
494 |
} |
| 518 |
|
495 |
|
| 519 |
public void widgetSelected(SelectionEvent e) { |
496 |
public void widgetSelected(SelectionEvent e) { |
| 520 |
super.widgetSelected(e); |
497 |
super.widgetSelected(e); |
| 521 |
if (e.widget instanceof TableColumn) { |
498 |
if (e.widget instanceof TableColumn) { |
|
Lines 528-534
Link Here
|
| 528 |
super.resetColumns(list); |
505 |
super.resetColumns(list); |
| 529 |
expandFirstElement(); |
506 |
expandFirstElement(); |
| 530 |
} |
507 |
} |
| 531 |
|
508 |
|
| 532 |
protected void resetChooseColumnsAction() { |
509 |
protected void resetChooseColumnsAction() { |
| 533 |
_chooseColumnAction = null; |
510 |
_chooseColumnAction = null; |
| 534 |
} |
511 |
} |
|
Lines 538-556
Link Here
|
| 538 |
return; |
515 |
return; |
| 539 |
} |
516 |
} |
| 540 |
if (obj instanceof ThreadDetails) { |
517 |
if (obj instanceof ThreadDetails) { |
| 541 |
obj = ((ThreadDetails)obj).getThread(); |
518 |
obj = ((ThreadDetails) obj).getThread(); |
| 542 |
} |
519 |
} |
| 543 |
Tree tree = getTree(); |
520 |
Tree tree = getTree(); |
| 544 |
TreeItem[] items = tree.getItems(); |
521 |
TreeItem[] items = tree.getItems(); |
| 545 |
|
522 |
|
| 546 |
TreeItem item = null; |
523 |
TreeItem item = null; |
| 547 |
for (int j = 0; j < items.length; j++) { |
524 |
for (int j = 0; j < items.length; j++) { |
| 548 |
item = items[j]; |
525 |
item = items[j]; |
| 549 |
|
526 |
|
| 550 |
if (item!=null && !item.isDisposed()) { |
527 |
if (item != null && !item.isDisposed()) { |
| 551 |
Object data = item.getData(); |
528 |
Object data = item.getData(); |
| 552 |
if (data instanceof ThreadDetails) { |
529 |
if (data instanceof ThreadDetails) { |
| 553 |
data = ((ThreadDetails)data).getThread(); |
530 |
data = ((ThreadDetails) data).getThread(); |
| 554 |
} |
531 |
} |
| 555 |
if (data == obj) { |
532 |
if (data == obj) { |
| 556 |
tree.setSelection(item); |
533 |
tree.setSelection(item); |
|
Lines 562-592
Link Here
|
| 562 |
|
539 |
|
| 563 |
protected Composite createControl(Composite parent, ArrayList cols) { |
540 |
protected Composite createControl(Composite parent, ArrayList cols) { |
| 564 |
final Composite vc = super.createControl(parent, cols); |
541 |
final Composite vc = super.createControl(parent, cols); |
| 565 |
|
542 |
|
| 566 |
if (_page.getTraceViewer() instanceof MultiLevelStatisticViewer) |
543 |
if (_page.getTraceViewer() instanceof MultiLevelStatisticViewer) { |
| 567 |
{ |
|
|
| 568 |
_contextInfo = new ContextInfoContainer(); |
544 |
_contextInfo = new ContextInfoContainer(); |
| 569 |
_contextInfo.setViewer((IContextViewer)_page.getTraceViewer()); |
545 |
_contextInfo.setViewer((IContextViewer) _page.getTraceViewer()); |
| 570 |
_contextInfo.createControl(vc); |
546 |
_contextInfo.createControl(vc); |
| 571 |
_contextInfo.addContextInfoContainerListener( |
547 |
_contextInfo.addContextInfoContainerListener(new IContextInfoContainerListener() { |
| 572 |
new IContextInfoContainerListener() |
548 |
public void visibilityChanged(boolean isVisible) { |
| 573 |
{ |
|
|
| 574 |
public void visibilityChanged(boolean isVisible) |
| 575 |
{ |
| 576 |
vc.layout(true, true); |
549 |
vc.layout(true, true); |
| 577 |
} |
550 |
} |
| 578 |
}); |
551 |
}); |
| 579 |
} |
552 |
} |
| 580 |
|
553 |
|
| 581 |
return vc; |
554 |
return vc; |
| 582 |
} |
555 |
} |
| 583 |
|
556 |
|
| 584 |
protected void updateStatusContext(IContextLanguage language) |
557 |
protected void updateStatusContext(IContextLanguage language) { |
| 585 |
{ |
|
|
| 586 |
if (_contextInfo != null) |
558 |
if (_contextInfo != null) |
| 587 |
_contextInfo.updateStatusContext(language); |
559 |
_contextInfo.updateStatusContext(language); |
| 588 |
} |
560 |
} |
| 589 |
|
561 |
|
| 590 |
protected void firstTimeUpdate() { |
562 |
protected void firstTimeUpdate() { |
| 591 |
super.firstTimeUpdate(); |
563 |
super.firstTimeUpdate(); |
| 592 |
redrawTable(); |
564 |
redrawTable(); |
|
Lines 598-609
Link Here
|
| 598 |
|
570 |
|
| 599 |
public void redrawTable() { |
571 |
public void redrawTable() { |
| 600 |
getTree().setRedraw(false); |
572 |
getTree().setRedraw(false); |
| 601 |
|
573 |
ArrayList list = ColumnData.createColumnData(getColumnsPreferencesKey() |
| 602 |
ArrayList list = ColumnData.createColumnData(getColumnsPreferencesKey(), getDefaultColumnsTemplate()); |
574 |
, getDefaultColumnsTemplate()); |
| 603 |
resetColumns(list); |
575 |
resetColumns(list); |
| 604 |
_currentColumns = list; |
576 |
_currentColumns = list; |
| 605 |
getTree().setRedraw(true); |
577 |
getTree().setRedraw(true); |
| 606 |
|
|
|
| 607 |
refresh(); |
578 |
refresh(); |
| 608 |
} |
579 |
} |
|
|
580 |
|
| 581 |
public void dispose() { |
| 582 |
super.dispose(); |
| 583 |
} |
| 584 |
|
| 585 |
public void widgetDefaultSelected(SelectionEvent arg0) { |
| 586 |
OpenCallStackViewAction.openCallStackView(false); |
| 587 |
} |
| 609 |
} |
588 |
} |