Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 325016 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java (-141 / +108 lines)
Lines 64-69 Link Here
64
 */
64
 */
65
public class TmfTimeStatesCtrl extends TraceCtrl implements FocusListener, KeyListener, MouseMoveListener, MouseListener, MouseWheelListener, ControlListener, SelectionListener, MouseTrackListener, TraverseListener, ISelectionProvider {
65
public class TmfTimeStatesCtrl extends TraceCtrl implements FocusListener, KeyListener, MouseMoveListener, MouseListener, MouseWheelListener, ControlListener, SelectionListener, MouseTrackListener, TraverseListener, ISelectionProvider {
66
66
67
    private static final int DRAG_NONE = 0;
68
    private static final int DRAG_TRACE_ITEM = 1;
69
    private static final int DRAG_GROUP_ITEM = 2;
70
    private static final int DRAG_SPLIT_LINE = 3;
67
    public static final boolean DEFAULT_DRAW_THREAD_JOIN = true;
71
    public static final boolean DEFAULT_DRAW_THREAD_JOIN = true;
68
    public static final boolean DEFAULT_DRAW_THREAD_WAIT = true;
72
    public static final boolean DEFAULT_DRAW_THREAD_WAIT = true;
69
    public static final boolean DEFAULT_DRAW_THREAD_RELEASE = true;
73
    public static final boolean DEFAULT_DRAW_THREAD_RELEASE = true;
Lines 78-85 Link Here
78
    private boolean _mouseHover = false;
82
    private boolean _mouseHover = false;
79
    private int _itemHeightDefault = 19;
83
    private int _itemHeightDefault = 19;
80
    private int _itemHeight = _itemHeightDefault;
84
    private int _itemHeight = _itemHeightDefault;
85
    private int _minimumItemWidth = 0;
81
    private int _topItem = 0;
86
    private int _topItem = 0;
82
    private int _dragState = 0;
87
    private int _dragState = DRAG_NONE;
83
    private int _hitIdx = 0;
88
    private int _hitIdx = 0;
84
    private int _dragX0 = 0;
89
    private int _dragX0 = 0;
85
    private int _dragX = 0;
90
    private int _dragX = 0;
Lines 132-145 Link Here
132
        if (scrollHor != null) {
137
        if (scrollHor != null) {
133
            scrollHor.addSelectionListener(this);
138
            scrollHor.addSelectionListener(this);
134
        }
139
        }
135
        mouseScrollFilterListener = new Listener() {
136
            // This filter is used to prevent scrolling of the view when the
137
            // mouse wheel is used to zoom
138
            @Override
139
            public void handleEvent(Event event) {
140
                event.doit = false;
141
            }
142
        };
143
140
144
        _dragCursor3 = new Cursor(super.getDisplay(), SWT.CURSOR_SIZEWE);
141
        _dragCursor3 = new Cursor(super.getDisplay(), SWT.CURSOR_SIZEWE);
145
        _WaitCursor = new Cursor(super.getDisplay(), SWT.CURSOR_WAIT);
142
        _WaitCursor = new Cursor(super.getDisplay(), SWT.CURSOR_WAIT);
Lines 451-457 Link Here
451
        if (zoomIn) {
448
        if (zoomIn) {
452
            newInterval = Math.max(Math.round((double) interval * 0.8), _timeProvider.getMinTimeInterval());
449
            newInterval = Math.max(Math.round((double) interval * 0.8), _timeProvider.getMinTimeInterval());
453
        } else {
450
        } else {
454
            newInterval = Math.round((double) interval * 1.25);
451
            newInterval = (long) Math.ceil((double) interval * 1.25);
455
        }
452
        }
456
        long center = time0 + Math.round(((double) (xPos - nameSpace) / timeSpace * interval));
453
        long center = time0 + Math.round(((double) (xPos - nameSpace) / timeSpace * interval));
457
        long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval);
454
        long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval);
Lines 621-627 Link Here
621
        return idx >= 0 ? (Item) _data._items[idx] : null;
618
        return idx >= 0 ? (Item) _data._items[idx] : null;
622
    }
619
    }
623
620
624
    long hitTimeTest(int x, int y) {
621
    long hitTimeTest(int x) {
625
        if (null == _timeProvider)
622
        if (null == _timeProvider)
626
            return -1;
623
            return -1;
627
        long hitTime = -1;
624
        long hitTime = -1;
Lines 644-668 Link Here
644
    }
641
    }
645
642
646
    void selectItem(int idx, boolean addSelection) {
643
    void selectItem(int idx, boolean addSelection) {
644
        boolean changed = false;
647
        if (addSelection) {
645
        if (addSelection) {
648
            if (idx >= 0 && idx < _data._items.length) {
646
            if (idx >= 0 && idx < _data._items.length) {
649
                Item item = (Item) _data._items[idx];
647
                Item item = (Item) _data._items[idx];
648
                changed = (item._selected == false);
650
                item._selected = true;
649
                item._selected = true;
651
            }
650
            }
652
        } else {
651
        } else {
653
            for (int i = 0; i < _data._items.length; i++) {
652
            for (int i = 0; i < _data._items.length; i++) {
654
                Item item = (Item) _data._items[i];
653
                Item item = (Item) _data._items[i];
654
                if (i == idx && item._selected == false) {
655
                    changed = true;
656
                }
655
                item._selected = i == idx;
657
                item._selected = i == idx;
656
            }
658
            }
657
        }
659
        }
658
        boolean changed = ensureVisibleItem(idx, true);
660
        changed |= ensureVisibleItem(idx, true);
659
        if (!changed)
661
        if (changed)
660
            redraw();
662
            redraw();
661
    }
663
    }
662
664
663
    public void selectItem(ITmfTimeAnalysisEntry trace, boolean addSelection) {
665
    public void selectItem(ITmfTimeAnalysisEntry trace, boolean addSelection) {
664
        Integer idx = _data.findTraceItemIndex(trace);
666
        Integer idx = _data.findTraceItemIndex(trace);
665
        selectItem(idx, addSelection);
667
        if (idx != null) {
668
            selectItem(idx, addSelection);
669
        }
666
    }
670
    }
667
671
668
    public int countPerPage() {
672
    public int countPerPage() {
Lines 946-956 Link Here
946
        if (drawTracesInteraction)
950
        if (drawTracesInteraction)
947
            drawTraceInteractions(bound, e.gc);
951
            drawTraceInteractions(bound, e.gc);
948
952
953
        // draw empty name space background
954
        if (_itemHeight * items.length < bound.height) {
955
            gc.setBackground(_colors.getBkColor(false, false, true));
956
            drawBackground(gc, bound.x, _itemHeight * items.length, nameWidth, bound.height - _itemHeight * items.length);
957
        }
958
949
        // draw drag line, no line if name space is 0.
959
        // draw drag line, no line if name space is 0.
950
        if (3 == _dragState) {
960
        if (DRAG_SPLIT_LINE == _dragState) {
951
            gc.setForeground(_colors.getColor(TraceColorScheme.BLACK));
961
            gc.setForeground(_colors.getColor(TraceColorScheme.BLACK));
952
            gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, bound.y + bound.height - 1);
962
            gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, bound.y + bound.height - 1);
953
        } else if (0 == _dragState && _mouseHover && _timeProvider.getNameSpace() > 0) {
963
        } else if (DRAG_NONE == _dragState && _mouseHover && _timeProvider.getNameSpace() > 0) {
954
            gc.setForeground(_colors.getColor(TraceColorScheme.RED));
964
            gc.setForeground(_colors.getColor(TraceColorScheme.RED));
955
            gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, bound.y + bound.height - 1);
965
            gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, bound.y + bound.height - 1);
956
        }
966
        }
Lines 1066-1077 Link Here
1066
            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;
1076
            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;
1067
1077
1068
            int x0 = rect.x;
1078
            int x0 = rect.x;
1069
            List<TimeEvent> list = trace.getTraceEvents();
1079
            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator();
1070
            // Iterator it = list.iterator();
1071
            int count = list.size();
1072
            ITimeEvent lastEvent = null;
1080
            ITimeEvent lastEvent = null;
1073
            if (count > 0) {
1081
            if (iterator.hasNext()) {
1074
                ITimeEvent currEvent = list.get(0);
1082
                ITimeEvent currEvent = iterator.next();
1075
                ITimeEvent nextEvent = null;
1083
                ITimeEvent nextEvent = null;
1076
                long currEventTime = currEvent.getTime();
1084
                long currEventTime = currEvent.getTime();
1077
                long nextEventTime = currEventTime;
1085
                long nextEventTime = currEventTime;
Lines 1083-1096 Link Here
1083
                // reduce rect
1091
                // reduce rect
1084
                _rect1.y += 3;
1092
                _rect1.y += 3;
1085
                _rect1.height -= 6;
1093
                _rect1.height -= 6;
1086
                fillSpace(rect, gc, selected, _rect1.x, x0, xEnd);
1094
                fillSpace(rect, gc, selected);
1087
1095
1088
                // draw event states
1096
                // draw event states
1089
                while (x0 <= xEnd && null != currEvent) {
1097
                while (x0 <= xEnd && null != currEvent) {
1090
                    boolean stopped = false;// currEvent instanceof
1098
                    boolean stopped = false;// currEvent instanceof
1091
                    // TsfTmTraceDeadEvent;
1099
                    // TsfTmTraceDeadEvent;
1092
                    if (idx < count) {
1100
                    if (iterator.hasNext()) {
1093
                        nextEvent = list.get(idx);
1101
                        nextEvent = iterator.next();
1094
                        nextEventTime = nextEvent.getTime();
1102
                        nextEventTime = nextEvent.getTime();
1095
                        idx++;
1103
                        idx++;
1096
                    } else if (stopped) {
1104
                    } else if (stopped) {
Lines 1133-1154 Link Here
1133
                gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);
1141
                gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);
1134
                gc.setLineWidth(lw);
1142
                gc.setLineWidth(lw);
1135
            }
1143
            }
1136
1137
            // draw focus ares
1138
            Utils.init(_rect1, rect);
1139
            gc.setForeground(_colors.getBkColor(selected, _isInFocus, false));
1140
            int y = _rect1.y;
1141
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1142
            y++;
1143
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1144
            y++;
1145
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1146
            y = _rect1.y + _rect1.height - 1;
1147
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1148
            y--;
1149
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1150
            y--;
1151
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1152
        }
1144
        }
1153
1145
1154
        // draw selected time
1146
        // draw selected time
Lines 1205-1217 Link Here
1205
            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;
1197
            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;
1206
1198
1207
            double x0 = rect.x;
1199
            double x0 = rect.x;
1208
            List<TimeEvent> list = trace.getTraceEvents();
1200
            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator();
1209
            // Iterator it = list.iterator();
1210
            int count = list.size();
1211
            ITimeEvent lastEvent = null;
1201
            ITimeEvent lastEvent = null;
1212
            // Trace.debug("count is: " + count);
1202
            // Trace.debug("count is: " + count);
1213
            if (count > 0) {
1203
            if (iterator.hasNext()) {
1214
                ITimeEvent currEvent = list.get(0);
1204
                ITimeEvent currEvent = iterator.next();
1215
                ITimeEvent nextEvent = null;
1205
                ITimeEvent nextEvent = null;
1216
                long currEventTime = currEvent.getTime();
1206
                long currEventTime = currEvent.getTime();
1217
                long nextEventTime = currEventTime;
1207
                long nextEventTime = currEventTime;
Lines 1229-1241 Link Here
1229
                _rect1.height -= 6;
1219
                _rect1.height -= 6;
1230
1220
1231
                // Clean up to empty line to draw on top
1221
                // Clean up to empty line to draw on top
1232
                fillSpace(rect, gc, selected, _rect1.x, xEnd, xEnd);
1222
                fillSpace(rect, gc, selected);
1233
                // draw event states
1223
                // draw event states
1234
                while (x0 <= xEnd && null != currEvent) {
1224
                while (x0 <= xEnd && null != currEvent) {
1235
                    boolean stopped = false;// currEvent instanceof
1225
                    boolean stopped = false;// currEvent instanceof
1236
                    // TsfTmTraceDeadEvent;
1226
                    // TsfTmTraceDeadEvent;
1237
                    if (idx < count) {
1227
                    if (iterator.hasNext()) {
1238
                        nextEvent = list.get(idx);
1228
                        nextEvent = iterator.next();
1239
                        nextEventTime = nextEvent.getTime();
1229
                        nextEventTime = nextEvent.getTime();
1240
                        idx++;
1230
                        idx++;
1241
                    } else if (stopped) {
1231
                    } else if (stopped) {
Lines 1268-1274 Link Here
1268
                        xNext = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);
1258
                        xNext = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);
1269
                    }
1259
                    }
1270
                    // Fill space till next event
1260
                    // Fill space till next event
1271
                    fillSpace(rect, gc, selected, x0, xNext, xEnd);
1261
                    fillSpace(rect, gc, selected);
1272
1262
1273
                    lastEvent = currEvent;
1263
                    lastEvent = currEvent;
1274
                    currEvent = nextEvent;
1264
                    currEvent = nextEvent;
Lines 1299-1320 Link Here
1299
                gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);
1289
                gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);
1300
                gc.setLineWidth(lw);
1290
                gc.setLineWidth(lw);
1301
            }
1291
            }
1302
1303
            // draw focus area
1304
            Utils.init(_rect1, rect);
1305
            gc.setForeground(_colors.getBkColor(selected, _isInFocus, false));
1306
            int y = _rect1.y;
1307
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1308
            y++;
1309
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1310
            y++;
1311
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1312
            y = _rect1.y + _rect1.height - 1;
1313
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1314
            y--;
1315
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1316
            y--;
1317
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1318
        }
1292
        }
1319
1293
1320
        // draw selected time
1294
        // draw selected time
Lines 1370-1379 Link Here
1370
            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;
1344
            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;
1371
1345
1372
            double x0 = rect.x;
1346
            double x0 = rect.x;
1373
            @SuppressWarnings("unchecked")
1347
            long maxDuration = (_timeProvider.getTimeSpace() == 0) ? Long.MAX_VALUE : 1 * (_timeProvider.getTime1() - _timeProvider.getTime0()) / _timeProvider.getTimeSpace();
1374
            List<TimeEvent> list = (List<TimeEvent>) trace.getTraceEvents().clone();
1348
            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator(_timeProvider.getTime0(), _timeProvider.getTime1(), maxDuration);
1375
            // Iterator it = list.iterator();
1376
            int count = list.size();
1377
            // ITimeEvent lastEvent = null;
1349
            // ITimeEvent lastEvent = null;
1378
            // if (Trace.isDEBUG()) {
1350
            // if (Trace.isDEBUG()) {
1379
            // Trace.debug("\n\t\t\tTrace: " + trace.getName()
1351
            // Trace.debug("\n\t\t\tTrace: " + trace.getName()
Lines 1386-1394 Link Here
1386
1358
1387
            // Clean up to empty line to draw on top
1359
            // Clean up to empty line to draw on top
1388
            int xEnd = rect.x + rect.width;
1360
            int xEnd = rect.x + rect.width;
1389
            fillSpace(rect, gc, selected, _rect1.x, xEnd, xEnd);
1361
            fillSpace(rect, gc, selected);
1390
            if (count > 0) {
1362
            if (iterator.hasNext()) {
1391
                ITimeEvent currEvent = list.get(0);
1363
                ITimeEvent currEvent = iterator.next();
1392
                ITimeEvent nextEvent = null;
1364
                ITimeEvent nextEvent = null;
1393
                long currEventTime = currEvent.getTime();
1365
                long currEventTime = currEvent.getTime();
1394
                long currEventDuration = currEvent.getDuration();
1366
                long currEventDuration = currEvent.getDuration();
Lines 1408-1415 Link Here
1408
                    // refresh current event duration as the loop moves
1380
                    // refresh current event duration as the loop moves
1409
                    currEventDuration = currEvent.getDuration();
1381
                    currEventDuration = currEvent.getDuration();
1410
                    // TsfTmTraceDeadEvent;
1382
                    // TsfTmTraceDeadEvent;
1411
                    if (idx < count) {
1383
                    if (iterator.hasNext()) {
1412
                        nextEvent = list.get(idx);
1384
                        nextEvent = iterator.next();
1413
                        nextEventTime = nextEvent.getTime();
1385
                        nextEventTime = nextEvent.getTime();
1414
                        idx++;
1386
                        idx++;
1415
                    } else if (stopped) {
1387
                    } else if (stopped) {
Lines 1448-1458 Link Here
1448
                    if (x1 >= rect.x && x0 <= xEnd) {
1420
                    if (x1 >= rect.x && x0 <= xEnd) {
1449
                        if (currEventDuration != 0) {
1421
                        if (currEventDuration != 0) {
1450
                            x0 = (double) (x0 >= rect.x ? x0 : rect.x);
1422
                            x0 = (double) (x0 >= rect.x ? x0 : rect.x);
1451
                            _rect1.width = (int) ((x1 <= xEnd ? x1 : xEnd) - x0);
1423
                            _rect1.width = (int) Math.ceil(x1 <= xEnd ? x1 : xEnd) - (int) x0;
1452
                        } else {
1424
                        } else {
1453
                            _rect1.width = 2; // make punctual events 2 pixels
1425
                            _rect1.width = 1;
1454
                                              // wide
1455
                        }
1426
                        }
1427
                        _rect1.width = Math.max(_minimumItemWidth, _rect1.width);
1456
                        _rect1.x = (int) x0;
1428
                        _rect1.x = (int) x0;
1457
                        boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime;
1429
                        boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime;
1458
                        utilImpl.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected);
1430
                        utilImpl.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected);
Lines 1480-1501 Link Here
1480
                    // + K + " = " + x0);
1452
                    // + K + " = " + x0);
1481
                }
1453
                }
1482
            }
1454
            }
1483
1484
            // draw focus area
1485
            Utils.init(_rect1, rect);
1486
            gc.setForeground(_colors.getBkColor(selected, _isInFocus, false));
1487
            int y = _rect1.y;
1488
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1489
            y++;
1490
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1491
            y++;
1492
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1493
            y = _rect1.y + _rect1.height - 1;
1494
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1495
            y--;
1496
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1497
            y--;
1498
            gc.drawLine(_rect1.x, y, _rect1.x + _rect1.width, y);
1499
        }
1455
        }
1500
1456
1501
        // draw selected time
1457
        // draw selected time
Lines 1509-1535 Link Here
1509
        }
1465
        }
1510
    }
1466
    }
1511
1467
1512
    private void fillSpace(Rectangle rect, GC gc, boolean selected, double x0, double x1, double xEnd) {
1468
    private void fillSpace(Rectangle rect, GC gc, boolean selected) {
1513
        // fill space before first event
1469
        gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));
1514
        if (x0 >= rect.x && x0 < xEnd) {
1470
        gc.fillRectangle(rect);
1515
            // _rect1.width = (int) ((x1 <= xEnd ? x1 : xEnd) - x0);
1471
        // draw middle line
1516
            // Trace.debug("Drawing Space: " + _rect1.x + "," + _rect1.y + ","
1472
        gc.setForeground(_colors.getColor(TraceColorScheme.MID_LINE));
1517
            // + _rect1.height + ", " + _rect1.width + "--> "
1473
        int midy = rect.y + rect.height / 2;
1518
            // + ((int) _rect1.x + (int) _rect1.width));
1474
        gc.drawLine(rect.x, midy, rect.x + rect.width, midy);
1519
1520
            // if (_rect1.width < 0) {
1521
            // Trace.debug("Incorrect width:" + _rect1.width);
1522
            // }
1523
            gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));
1524
            gc.fillRectangle(_rect1);
1525
            // draw middle line
1526
            gc.setForeground(_colors.getColor(TraceColorScheme.MID_LINE));
1527
            int midy = _rect1.y + _rect1.height / 2;
1528
            gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);
1529
        } else {
1530
            // Trace.debug("No space added since, x0 is out of range " + x0
1531
            // + " rect.x: " + rect.x + " xEnd: " + xEnd);
1532
        }
1533
    }
1475
    }
1534
1476
1535
    @Override
1477
    @Override
Lines 1601-1618 Link Here
1601
    public void focusGained(FocusEvent e) {
1543
    public void focusGained(FocusEvent e) {
1602
        _isInFocus = true;
1544
        _isInFocus = true;
1603
        redraw();
1545
        redraw();
1604
        getDisplay().addFilter(SWT.MouseWheel, mouseScrollFilterListener);
1546
        if (mouseScrollFilterListener == null) {
1547
            mouseScrollFilterListener = new Listener() {
1548
                // This filter is used to prevent scrolling of the view when the
1549
                // mouse wheel is used to zoom
1550
                @Override
1551
                public void handleEvent(Event event) {
1552
                    event.doit = false;
1553
                }
1554
            };
1555
            getDisplay().addFilter(SWT.MouseWheel, mouseScrollFilterListener);
1556
        }
1605
    }
1557
    }
1606
1558
1607
    @Override
1559
    @Override
1608
    public void focusLost(FocusEvent e) {
1560
    public void focusLost(FocusEvent e) {
1609
        _isInFocus = false;
1561
        _isInFocus = false;
1610
        if (0 != _dragState) {
1562
        if (DRAG_NONE != _dragState) {
1611
            setCapture(false);
1563
            setCapture(false);
1612
            _dragState = 0;
1564
            _dragState = DRAG_NONE;
1613
        }
1565
        }
1614
        redraw();
1566
        redraw();
1615
        getDisplay().removeFilter(SWT.MouseWheel, mouseScrollFilterListener);
1567
        if (mouseScrollFilterListener != null) {
1568
            getDisplay().removeFilter(SWT.MouseWheel, mouseScrollFilterListener);
1569
            mouseScrollFilterListener = null;
1570
        }
1616
    }
1571
    }
1617
1572
1618
    public boolean isInFocus() {
1573
    public boolean isInFocus() {
Lines 1624-1630 Link Here
1624
        if (null == _timeProvider)
1579
        if (null == _timeProvider)
1625
            return;
1580
            return;
1626
        Point size = getCtrlSize();
1581
        Point size = getCtrlSize();
1627
        if (1 == _dragState) {
1582
        if (DRAG_TRACE_ITEM == _dragState) {
1628
            int nameWidth = _timeProvider.getNameSpace();
1583
            int nameWidth = _timeProvider.getNameSpace();
1629
            int x = e.x - nameWidth;
1584
            int x = e.x - nameWidth;
1630
            if (x > 0 && size.x > nameWidth && _dragX != x) {
1585
            if (x > 0 && size.x > nameWidth && _dragX != x) {
Lines 1642-1651 Link Here
1642
                }
1597
                }
1643
                _timeProvider.setStartFinishTime(time0, time1);
1598
                _timeProvider.setStartFinishTime(time0, time1);
1644
            }
1599
            }
1645
        } else if (3 == _dragState) {
1600
        } else if (DRAG_SPLIT_LINE == _dragState) {
1646
            _dragX = e.x;
1601
            _dragX = e.x;
1647
            _timeProvider.setNameSpace(_hitIdx + _dragX - _dragX0);
1602
            _timeProvider.setNameSpace(_hitIdx + _dragX - _dragX0);
1648
        } else if (0 == _dragState) {
1603
        } else if (DRAG_NONE == _dragState) {
1649
            boolean mouseHover = hitSplitTest(e.x, e.y) > 0;
1604
            boolean mouseHover = hitSplitTest(e.x, e.y) > 0;
1650
            if (_mouseHover != mouseHover)
1605
            if (_mouseHover != mouseHover)
1651
                redraw();
1606
                redraw();
Lines 1734-1740 Link Here
1734
            if (namewidth != 0) {
1689
            if (namewidth != 0) {
1735
                idx = hitSplitTest(e.x, e.y);
1690
                idx = hitSplitTest(e.x, e.y);
1736
                if (idx > 0) {
1691
                if (idx > 0) {
1737
                    _dragState = 3;
1692
                    _dragState = DRAG_SPLIT_LINE;
1738
                    _dragX = _dragX0 = e.x;
1693
                    _dragX = _dragX0 = e.x;
1739
                    _hitIdx = _timeProvider.getNameSpace();
1694
                    _hitIdx = _timeProvider.getNameSpace();
1740
                    ;
1695
                    ;
Lines 1748-1789 Link Here
1748
            idx = hitTest(e.x, e.y);
1703
            idx = hitTest(e.x, e.y);
1749
            if (idx >= 0) {
1704
            if (idx >= 0) {
1750
                if (_data._items[idx] instanceof TraceItem) {
1705
                if (_data._items[idx] instanceof TraceItem) {
1751
                    long hitTime = hitTimeTest(e.x, e.y);
1706
                    long hitTime = hitTimeTest(e.x);
1752
                    if (hitTime >= 0) {
1707
                    if (hitTime >= 0) {
1753
                        _timeProvider.setSelectedTimeInt(hitTime, false);
1708
                        // _timeProvider.setSelectedTimeInt(hitTime, false);
1754
                        setCapture(true);
1709
                        setCapture(true);
1755
                        _dragState = 1;
1710
                        _dragState = DRAG_TRACE_ITEM;
1756
                        _dragX = _dragX0 = e.x - _timeProvider.getNameSpace();
1711
                        _dragX = _dragX0 = e.x - _timeProvider.getNameSpace();
1712
                        _hitIdx = idx;
1757
                        _time0bak = _timeProvider.getTime0();
1713
                        _time0bak = _timeProvider.getTime0();
1758
                        _time1bak = _timeProvider.getTime1();
1714
                        _time1bak = _timeProvider.getTime1();
1715
                        return;
1759
                    }
1716
                    }
1760
                } else if (_data._items[idx] instanceof GroupItem) {
1717
                } else if (_data._items[idx] instanceof GroupItem) {
1761
                    _hitIdx = idx;
1718
                    _dragX0 = e.x;
1762
                    _dragState = 2;
1719
                    _dragState = DRAG_GROUP_ITEM;
1763
                }
1720
                }
1764
                selectItem(idx, false);
1721
                selectItem(idx, false);
1765
                fireSelectionChanged();
1722
                fireSelectionChanged();
1766
            } else {
1723
            } else {
1767
                selectItem(idx, false); // clear selection
1724
                selectItem(idx, false); // clear selection
1725
                redraw();
1768
            }
1726
            }
1769
        }
1727
        }
1770
    }
1728
    }
1771
1729
1772
    @Override
1730
    @Override
1773
    public void mouseUp(MouseEvent e) {
1731
    public void mouseUp(MouseEvent e) {
1774
        if (0 != _dragState) {
1732
        if (DRAG_NONE != _dragState) {
1775
            setCapture(false);
1733
            setCapture(false);
1776
            if (1 == _dragState) {
1734
            if (DRAG_TRACE_ITEM == _dragState) {
1777
                // Notify time provider to check the need for listener
1735
                // Notify time provider to check the need for listener
1778
                // notification
1736
                // notification
1779
                _timeProvider.notifyStartFinishTime();
1737
                _timeProvider.notifyStartFinishTime();
1780
            } else if (2 == _dragState) {
1738
                if (_dragX == _dragX0) { // click without drag
1781
                if (hitTest(e.x, e.y) == _hitIdx)
1739
                    long time = hitTimeTest(e.x);
1740
                    _timeProvider.setSelectedTimeInt(time, false);
1741
                    selectItem(_hitIdx, false);
1742
                    fireSelectionChanged();
1743
                }
1744
            } else if (DRAG_GROUP_ITEM == _dragState) {
1745
                if (e.x == _dragX0) // click without drag
1782
                    toggle(_hitIdx);
1746
                    toggle(_hitIdx);
1783
            } else if (3 == _dragState) {
1747
            } else if (DRAG_SPLIT_LINE == _dragState) {
1784
                redraw();
1748
                redraw();
1785
            }
1749
            }
1786
            _dragState = 0;
1750
            _dragState = DRAG_NONE;
1787
        }
1751
        }
1788
    }
1752
    }
1789
1753
Lines 1849-1855 Link Here
1849
1813
1850
    @Override
1814
    @Override
1851
    public void mouseScrolled(MouseEvent e) {
1815
    public void mouseScrolled(MouseEvent e) {
1852
        if (!_isInFocus)
1816
        if (!_isInFocus || _dragState != DRAG_NONE)
1853
            return;
1817
            return;
1854
        if (e.count > 0) {
1818
        if (e.count > 0) {
1855
            zoom(true);
1819
            zoom(true);
Lines 1895-1900 Link Here
1895
        this._itemHeight = rowHeight;
1859
        this._itemHeight = rowHeight;
1896
    }
1860
    }
1897
1861
1862
    public void setMinimumItemWidth(int width) {
1863
        this._minimumItemWidth = width;
1864
    }
1865
1898
    public Vector<ITmfTimeAnalysisEntry> getFilteredOut() {
1866
    public Vector<ITmfTimeAnalysisEntry> getFilteredOut() {
1899
        return _data.getFilteredOut();
1867
        return _data.getFilteredOut();
1900
    }
1868
    }
Lines 2033-2053 Link Here
2033
        if (trace == null)
2001
        if (trace == null)
2034
            return null;
2002
            return null;
2035
2003
2036
        int traceId = trace.getId();
2037
2038
        Integer idx = null;
2039
        for (int i = 0; i < _items.length; i++) {
2004
        for (int i = 0; i < _items.length; i++) {
2040
            idx = i;
2041
            Object item = _items[i];
2005
            Object item = _items[i];
2042
            if (item instanceof TraceItem) {
2006
            if (item instanceof TraceItem) {
2043
                TraceItem ti = (TraceItem) item;
2007
                TraceItem ti = (TraceItem) item;
2044
                if (ti._trace.getId() == traceId) {
2008
                if (ti._trace == trace) {
2045
                    break;
2009
                    return i;
2046
                }
2010
                }
2047
            }
2011
            }
2048
        }
2012
        }
2049
2013
2050
        return idx;
2014
        return null;
2051
    }
2015
    }
2052
2016
2053
    public void updateItems() {
2017
    public void updateItems() {
Lines 2142-2147 Link Here
2142
        // item = findTraceItem(parent);
2106
        // item = findTraceItem(parent);
2143
        // }
2107
        // }
2144
2108
2109
        /*
2110
         * Check if this is still needed!
2145
        ITmfTimeAnalysisEntry localTraceItem = item._trace;
2111
        ITmfTimeAnalysisEntry localTraceItem = item._trace;
2146
        // Local trace found
2112
        // Local trace found
2147
        Vector<TimeEvent> children = localTraceItem.getTraceEvents();
2113
        Vector<TimeEvent> children = localTraceItem.getTraceEvents();
Lines 2157-2162 Link Here
2157
        }
2123
        }
2158
        // Add the new item
2124
        // Add the new item
2159
        children.add(childItem);
2125
        children.add(childItem);
2126
        */
2160
2127
2161
    }
2128
    }
2162
2129

Return to bug 325016