|
Lines 248-253
Link Here
|
| 248 |
return sel; |
248 |
return sel; |
| 249 |
} |
249 |
} |
| 250 |
|
250 |
|
|
|
251 |
public void selectThread(int n) { |
| 252 |
if (n != 1 && n != -1) |
| 253 |
return; |
| 254 |
boolean changed = false; |
| 255 |
int lastSelection = -1; |
| 256 |
for (int i = 0; i < _data._items.length; i++) { |
| 257 |
Item item = (Item) _data._items[i]; |
| 258 |
if (item._selected) { |
| 259 |
lastSelection = i; |
| 260 |
if (1 == n && i < _data._items.length - 1) { |
| 261 |
item._selected = false; |
| 262 |
if (item._hasChildren) |
| 263 |
_data.expandItem(i, true); |
| 264 |
item = (Item) _data._items[i + 1]; |
| 265 |
if (item._hasChildren) { |
| 266 |
_data.expandItem(i + 1, true); |
| 267 |
item = (Item) _data._items[i + 2]; |
| 268 |
} |
| 269 |
item._selected = true; |
| 270 |
changed = true; |
| 271 |
} else if (-1 == n && i > 0) { |
| 272 |
i--; |
| 273 |
Item prevItem = (Item) _data._items[i]; |
| 274 |
if (prevItem._hasChildren) { |
| 275 |
if (prevItem._expanded) { |
| 276 |
if (i > 0) { |
| 277 |
i--; |
| 278 |
prevItem = (Item) _data._items[i]; |
| 279 |
} |
| 280 |
} |
| 281 |
if (!prevItem._expanded) { |
| 282 |
int added = _data.expandItem(i, true); |
| 283 |
prevItem = (Item) _data._items[i + added]; |
| 284 |
item._selected = false; |
| 285 |
prevItem._selected = true; |
| 286 |
changed = true; |
| 287 |
} |
| 288 |
} else { |
| 289 |
item._selected = false; |
| 290 |
prevItem._selected = true; |
| 291 |
changed = true; |
| 292 |
} |
| 293 |
} |
| 294 |
break; |
| 295 |
} |
| 296 |
} |
| 297 |
if (lastSelection < 0 && _data._items.length > 0) { |
| 298 |
Item item = (Item) _data._items[0]; |
| 299 |
if (item._hasChildren) { |
| 300 |
_data.expandItem(0, true); |
| 301 |
item = (Item) _data._items[1]; |
| 302 |
item._selected = true; |
| 303 |
changed = true; |
| 304 |
} else { |
| 305 |
item._selected = true; |
| 306 |
changed = true; |
| 307 |
} |
| 308 |
} |
| 309 |
if (changed) { |
| 310 |
redraw(); |
| 311 |
fireSelectionChanged(); |
| 312 |
} |
| 313 |
} |
| 314 |
|
| 251 |
public void selectEvent(int n) { |
315 |
public void selectEvent(int n) { |
| 252 |
if (null == _timeProvider) |
316 |
if (null == _timeProvider) |
| 253 |
return; |
317 |
return; |
|
Lines 261-266
Link Here
|
| 261 |
nextEvent = findEvent(thread, selectedTime, 0); |
325 |
nextEvent = findEvent(thread, selectedTime, 0); |
| 262 |
else |
326 |
else |
| 263 |
nextEvent = findEvent(thread, selectedTime, n); |
327 |
nextEvent = findEvent(thread, selectedTime, n); |
|
|
328 |
if (null == nextEvent && -1 == n) |
| 329 |
nextEvent = getFirstEvent(thread); |
| 264 |
if (null != nextEvent) { |
330 |
if (null != nextEvent) { |
| 265 |
_timeProvider.setSelectedTime(nextEvent.getTime(), true); |
331 |
_timeProvider.setSelectedTime(nextEvent.getTime(), true); |
| 266 |
fireSelectionChanged(); |
332 |
fireSelectionChanged(); |
|
Lines 279-284
Link Here
|
| 279 |
selectEvent(-1); |
345 |
selectEvent(-1); |
| 280 |
} |
346 |
} |
| 281 |
|
347 |
|
|
|
348 |
public void selectNextThread() { |
| 349 |
selectThread(1); |
| 350 |
} |
| 351 |
|
| 352 |
public void selectPrevThread() { |
| 353 |
selectThread(-1); |
| 354 |
} |
| 355 |
|
| 282 |
public TRCThread getSelectedThread() { |
356 |
public TRCThread getSelectedThread() { |
| 283 |
TRCThread thread = null; |
357 |
TRCThread thread = null; |
| 284 |
int idx = getSelectedIndex(); |
358 |
int idx = getSelectedIndex(); |
|
Lines 441-474
Link Here
|
| 441 |
} |
515 |
} |
| 442 |
|
516 |
|
| 443 |
void drawName(Item item, Rectangle rect, GC gc) { |
517 |
void drawName(Item item, Rectangle rect, GC gc) { |
| 444 |
if (item instanceof GroupItem) { |
518 |
boolean group = item instanceof GroupItem; |
| 445 |
gc.setBackground(_colors |
519 |
int elemHeight = rect.height / 2; |
| 446 |
.getBkColorGroup(item._selected, _isInFocus)); |
520 |
int elemWidth = elemHeight; |
|
|
521 |
if (group) { |
| 522 |
gc.setBackground(_colors.getBkColorGroup(item._selected, _isInFocus)); |
| 447 |
gc.fillRectangle(rect); |
523 |
gc.fillRectangle(rect); |
| 448 |
if (item._selected && _isInFocus) { |
524 |
if (item._selected && _isInFocus) { |
| 449 |
gc.setForeground(_colors.getBkColor(item._selected, _isInFocus, |
525 |
gc.setForeground(_colors.getBkColor(item._selected, _isInFocus, false)); |
| 450 |
false)); |
526 |
//gc.drawRectangle(rect.x, rect.y, rect.width - 2, rect.height - 2); |
| 451 |
gc.drawRectangle(rect.x, rect.y, rect.width - 2, |
527 |
gc.drawRoundRectangle(rect.x, rect.y, rect.width - 2, rect.height - 2, 2, 2); |
| 452 |
rect.height - 2); |
|
|
| 453 |
} |
528 |
} |
| 454 |
gc.setForeground(_colors.getBkColor(false, false, false)); |
529 |
gc.setForeground(_colors.getBkColor(false, false, false)); |
| 455 |
gc.drawLine(rect.x, rect.y + rect.height - 1, rect.width - 1, |
530 |
gc.drawLine(rect.x, rect.y + rect.height - 1, rect.width - 1, rect.y + rect.height - 1); |
| 456 |
rect.y + rect.height - 1); |
531 |
gc.setForeground(_colors.getFgColorGroup(false, false)); |
| 457 |
gc.setForeground(_colors |
532 |
gc.setBackground(_colors.getBkColor(false, false, false)); |
| 458 |
.getFgColorGroup(item._selected, _isInFocus)); |
533 |
Utils.init(_rect1, rect); |
|
|
534 |
_rect1.x += 2; |
| 535 |
_rect1.y += (rect.height - elemHeight) / 2; |
| 536 |
_rect1.width = elemWidth; |
| 537 |
_rect1.height = elemHeight; |
| 538 |
gc.fillRectangle(_rect1); |
| 539 |
gc.drawRectangle(_rect1.x, _rect1.y, _rect1.width - 1, _rect1.height - 1); |
| 540 |
int p = _rect1.y + _rect1.height / 2; |
| 541 |
gc.drawLine(_rect1.x + 2, p, _rect1.x + _rect1.width - 3, p); |
| 542 |
if (!item._expanded) { |
| 543 |
p = _rect1.x + _rect1.width / 2; |
| 544 |
gc.drawLine(p, _rect1.y + 2, p, _rect1.y + _rect1.height - 3); |
| 545 |
} |
| 546 |
gc.setForeground(_colors.getFgColorGroup(item._selected, _isInFocus)); |
| 547 |
elemWidth+= 4; |
| 459 |
} else { |
548 |
} else { |
| 460 |
gc.setBackground(_colors.getBkColor(item._selected, _isInFocus, |
549 |
gc.setBackground(_colors.getBkColor(item._selected, _isInFocus, true)); |
| 461 |
true)); |
|
|
| 462 |
gc.setForeground(_colors.getFgColor(item._selected, _isInFocus)); |
550 |
gc.setForeground(_colors.getFgColor(item._selected, _isInFocus)); |
| 463 |
gc.fillRectangle(rect); |
551 |
gc.fillRectangle(rect); |
| 464 |
} |
552 |
} |
| 465 |
Utils.init(_rect1, rect); |
553 |
Utils.init(_rect1, rect); |
| 466 |
_rect1.x += 4; |
554 |
int leftMargin = 4 + (group ? elemWidth : 0); |
| 467 |
_rect1.width -= 4; |
555 |
_rect1.x += leftMargin; |
|
|
556 |
_rect1.width -= leftMargin; |
| 468 |
int textWidth = 0; |
557 |
int textWidth = 0; |
| 469 |
// draw text |
558 |
// draw text |
| 470 |
if (_rect1.width > 0) |
559 |
if (_rect1.width > 0) { |
| 471 |
textWidth = Utils.drawText(gc, item._name, _rect1, true) + 8; |
560 |
String name = group ? item._name + " (group}" : item._name; |
|
|
561 |
textWidth = Utils.drawText(gc, name, _rect1, true) + 8; |
| 562 |
} |
| 472 |
// draw middle line |
563 |
// draw middle line |
| 473 |
Utils.init(_rect1, rect); |
564 |
Utils.init(_rect1, rect); |
| 474 |
_rect1.x += textWidth; |
565 |
_rect1.x += textWidth; |
|
Lines 855-860
Link Here
|
| 855 |
_items = itemList.toArray(); |
946 |
_items = itemList.toArray(); |
| 856 |
} |
947 |
} |
| 857 |
|
948 |
|
|
|
949 |
public int expandItem(int idx, boolean expand) { |
| 950 |
if (idx < 0 || idx >= _items.length) |
| 951 |
return 0; |
| 952 |
int ret = 0; |
| 953 |
Item item = (Item) _items[idx]; |
| 954 |
if (item._hasChildren && !item._expanded) { |
| 955 |
item._expanded = expand; |
| 956 |
ret = _items.length; |
| 957 |
updateItems(); |
| 958 |
ret = _items.length - ret; |
| 959 |
} |
| 960 |
return ret; |
| 961 |
} |
| 962 |
|
| 858 |
public void refreshData(Object threads[]) { |
963 |
public void refreshData(Object threads[]) { |
| 859 |
clearGroups(); |
964 |
clearGroups(); |
| 860 |
_threads = threads; |
965 |
_threads = threads; |