1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 Ericsson
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
10 * William Bourque - Initial API and implementation
11 * Yuriy Vashchuk - GUI reorganisation, simplification and some related code improvements.
12 * Yuriy Vashchuk - Histograms optimisation.
13 * Yuriy Vashchuk - Histogram Canvas Heritage correction
14 * Francois Chouinard - Cleanup and refactoring
15 * Francois Chouinard - Moved from LTTng to TMF
16 * Patrick Tasse - Update for mouse wheel zoom
17 *******************************************************************************/
19 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.histogram
;
21 import org
.eclipse
.jface
.action
.Action
;
22 import org
.eclipse
.jface
.action
.IAction
;
23 import org
.eclipse
.jface
.action
.Separator
;
24 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
25 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.ITmfImageConstants
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.request
.ITmfDataRequest
.ExecutionType
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.request
.TmfDataRequest
;
28 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfRangeSynchSignal
;
29 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
30 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalThrottler
;
31 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimeSynchSignal
;
32 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceClosedSignal
;
33 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
34 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceRangeUpdatedSignal
;
35 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceSelectedSignal
;
36 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceUpdatedSignal
;
37 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
38 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimeRange
;
39 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimestamp
;
40 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
41 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.TmfView
;
42 import org
.eclipse
.swt
.SWT
;
43 import org
.eclipse
.swt
.events
.MouseWheelListener
;
44 import org
.eclipse
.swt
.layout
.GridData
;
45 import org
.eclipse
.swt
.layout
.GridLayout
;
46 import org
.eclipse
.swt
.widgets
.Composite
;
47 import org
.eclipse
.ui
.IActionBars
;
50 * The purpose of this view is to provide graphical time distribution statistics about the trace events.
52 * The view is composed of two histograms and two controls:
54 * <li>an event distribution histogram for the whole trace;
55 * <li>an event distribution histogram for current time window (window span);
56 * <li>the timestamp of the currently selected event;
57 * <li>the window span (size of the time window of the smaller histogram).
59 * The histograms x-axis show their respective time range.
62 * @author Francois Chouinard
64 public class HistogramView
extends TmfView
{
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
71 * The view ID as defined in plugin.xml
73 public static final String ID
= "org.eclipse.linuxtools.tmf.ui.views.histogram"; //$NON-NLS-1$
75 // ------------------------------------------------------------------------
77 // ------------------------------------------------------------------------
80 private Composite fParent
;
83 private ITmfTrace fTrace
;
85 // Current timestamp/time window - everything in the TIME_SCALE
86 private long fTraceStartTime
;
87 private long fTraceEndTime
;
88 private long fWindowStartTime
;
89 private long fWindowEndTime
;
90 private long fWindowSpan
;
91 private long fSelectionBeginTime
;
92 private long fSelectionEndTime
;
95 private HistogramTextControl fCurrentEventTimeControl
;
96 private HistogramTextControl fTimeSpanControl
;
98 // Histogram/request for the full trace range
99 private static FullTraceHistogram fFullTraceHistogram
;
100 private HistogramRequest fFullTraceRequest
;
102 // Histogram/request for the selected time range
103 private static TimeRangeHistogram fTimeRangeHistogram
;
104 private HistogramRequest fTimeRangeRequest
;
106 // Throttlers for the time sync and time-range sync signals
107 private final TmfSignalThrottler fTimeSyncThrottle
;
108 private final TmfSignalThrottler fTimeRangeSyncThrottle
;
110 // Action for toggle showing the lost events
111 private Action hideLostEventsAction
;
113 // ------------------------------------------------------------------------
115 // ------------------------------------------------------------------------
118 * Default constructor
120 public HistogramView() {
122 fTimeSyncThrottle
= new TmfSignalThrottler(this, 200);
123 fTimeRangeSyncThrottle
= new TmfSignalThrottler(this, 200);
127 public void dispose() {
128 if ((fTimeRangeRequest
!= null) && !fTimeRangeRequest
.isCompleted()) {
129 fTimeRangeRequest
.cancel();
131 if ((fFullTraceRequest
!= null) && !fFullTraceRequest
.isCompleted()) {
132 fFullTraceRequest
.cancel();
134 fFullTraceHistogram
.dispose();
135 fTimeRangeHistogram
.dispose();
136 fCurrentEventTimeControl
.dispose();
137 fTimeSpanControl
.dispose();
141 // ------------------------------------------------------------------------
143 // ------------------------------------------------------------------------
146 public void createPartControl(Composite parent
) {
151 final String currentEventLabel
= Messages
.HistogramView_currentEventLabel
;
152 final String windowSpanLabel
= Messages
.HistogramView_windowSpanLabel
;
154 // --------------------------------------------------------------------
155 // Set the HistogramView layout
156 // --------------------------------------------------------------------
158 Composite viewComposite
= new Composite(fParent
, SWT
.FILL
);
159 GridLayout gridLayout
= new GridLayout();
160 gridLayout
.numColumns
= 2;
161 gridLayout
.horizontalSpacing
= 5;
162 gridLayout
.verticalSpacing
= 0;
163 gridLayout
.marginHeight
= 0;
164 gridLayout
.marginWidth
= 0;
165 viewComposite
.setLayout(gridLayout
);
167 // Use all available space
168 GridData gridData
= new GridData();
169 gridData
.horizontalAlignment
= SWT
.FILL
;
170 gridData
.verticalAlignment
= SWT
.FILL
;
171 gridData
.grabExcessHorizontalSpace
= true;
172 viewComposite
.setLayoutData(gridData
);
174 // --------------------------------------------------------------------
176 // --------------------------------------------------------------------
178 Composite controlsComposite
= new Composite(viewComposite
, SWT
.FILL
);
179 gridLayout
= new GridLayout();
180 gridLayout
.numColumns
= 2;
181 gridLayout
.marginHeight
= 0;
182 gridLayout
.marginWidth
= 0;
183 gridLayout
.horizontalSpacing
= 5;
184 gridLayout
.verticalSpacing
= 0;
185 gridLayout
.makeColumnsEqualWidth
= false;
186 gridLayout
.marginLeft
= 5;
187 gridLayout
.marginRight
= 5;
188 controlsComposite
.setLayout(gridLayout
);
190 // Current event time control
191 gridData
= new GridData();
192 gridData
.horizontalAlignment
= SWT
.CENTER
;
193 gridData
.verticalAlignment
= SWT
.CENTER
;
194 fCurrentEventTimeControl
= new HistogramCurrentTimeControl(this, controlsComposite
, currentEventLabel
, 0L);
195 fCurrentEventTimeControl
.setLayoutData(gridData
);
196 fCurrentEventTimeControl
.setValue(Long
.MIN_VALUE
);
198 // Window span time control
199 gridData
= new GridData();
200 gridData
.horizontalAlignment
= SWT
.CENTER
;
201 gridData
.verticalAlignment
= SWT
.CENTER
;
202 fTimeSpanControl
= new HistogramTimeRangeControl(this, controlsComposite
, windowSpanLabel
, 0L);
203 fTimeSpanControl
.setLayoutData(gridData
);
204 fTimeSpanControl
.setValue(Long
.MIN_VALUE
);
206 // --------------------------------------------------------------------
207 // Time range histogram
208 // --------------------------------------------------------------------
210 Composite timeRangeComposite
= new Composite(viewComposite
, SWT
.FILL
);
211 gridLayout
= new GridLayout();
212 gridLayout
.numColumns
= 1;
213 gridLayout
.marginHeight
= 0;
214 gridLayout
.marginWidth
= 0;
215 gridLayout
.marginTop
= 5;
216 gridLayout
.horizontalSpacing
= 0;
217 gridLayout
.verticalSpacing
= 0;
218 gridLayout
.marginLeft
= 5;
219 gridLayout
.marginRight
= 5;
220 timeRangeComposite
.setLayout(gridLayout
);
222 // Use remaining horizontal space
223 gridData
= new GridData();
224 gridData
.horizontalAlignment
= SWT
.FILL
;
225 gridData
.verticalAlignment
= SWT
.FILL
;
226 gridData
.grabExcessHorizontalSpace
= true;
227 timeRangeComposite
.setLayoutData(gridData
);
230 fTimeRangeHistogram
= new TimeRangeHistogram(this, timeRangeComposite
);
232 // --------------------------------------------------------------------
233 // Full range histogram
234 // --------------------------------------------------------------------
236 Composite fullRangeComposite
= new Composite(viewComposite
, SWT
.FILL
);
237 gridLayout
= new GridLayout();
238 gridLayout
.numColumns
= 1;
239 gridLayout
.marginHeight
= 0;
240 gridLayout
.marginWidth
= 0;
241 gridLayout
.marginTop
= 5;
242 gridLayout
.horizontalSpacing
= 0;
243 gridLayout
.verticalSpacing
= 0;
244 gridLayout
.marginLeft
= 5;
245 gridLayout
.marginRight
= 5;
246 fullRangeComposite
.setLayout(gridLayout
);
248 // Use remaining horizontal space
249 gridData
= new GridData();
250 gridData
.horizontalAlignment
= SWT
.FILL
;
251 gridData
.verticalAlignment
= SWT
.FILL
;
252 gridData
.horizontalSpan
= 2;
253 gridData
.grabExcessHorizontalSpace
= true;
254 fullRangeComposite
.setLayoutData(gridData
);
257 fFullTraceHistogram
= new FullTraceHistogram(this, fullRangeComposite
);
259 // Add mouse wheel listener to time span control
260 MouseWheelListener listener
= fFullTraceHistogram
.getZoom();
261 fTimeSpanControl
.addMouseWheelListener(listener
);
264 // View Action Handling
265 contributeToActionBars();
267 ITmfTrace trace
= getActiveTrace();
269 traceSelected(new TmfTraceSelectedSignal(this, trace
));
274 public void setFocus() {
275 fFullTraceHistogram
.fCanvas
.setFocus();
279 fParent
.layout(true);
282 // ------------------------------------------------------------------------
284 // ------------------------------------------------------------------------
287 * Returns the current trace handled by the view
289 * @return the current trace
292 public ITmfTrace
getTrace() {
297 * Returns the time range of the current selected window (base on default time scale).
299 * @return the time range of current selected window.
302 public TmfTimeRange
getTimeRange() {
303 return new TmfTimeRange(
304 new TmfTimestamp(fWindowStartTime
, ITmfTimestamp
.NANOSECOND_SCALE
),
305 new TmfTimestamp(fWindowEndTime
, ITmfTimestamp
.NANOSECOND_SCALE
));
309 * get the show lost events action
311 * @return The action object
314 public Action
getShowLostEventsAction() {
315 if (hideLostEventsAction
== null) {
316 /* show lost events */
317 hideLostEventsAction
= new Action(Messages
.HistogramView_hideLostEvents
, IAction
.AS_CHECK_BOX
) {
320 HistogramScaledData
.hideLostEvents
= hideLostEventsAction
.isChecked();
321 long maxNbEvents
= HistogramScaledData
.hideLostEvents ? fFullTraceHistogram
.fScaledData
.fMaxValue
: fFullTraceHistogram
.fScaledData
.fMaxCombinedValue
;
322 fFullTraceHistogram
.getMaxNbEventsText().setText(Long
.toString(maxNbEvents
));
323 fFullTraceHistogram
.getMaxNbEventsText().getParent().layout();
324 fFullTraceHistogram
.fCanvas
.redraw();
325 maxNbEvents
= HistogramScaledData
.hideLostEvents ? fTimeRangeHistogram
.fScaledData
.fMaxValue
: fTimeRangeHistogram
.fScaledData
.fMaxCombinedValue
;
326 fTimeRangeHistogram
.getMaxNbEventsText().setText(Long
.toString(maxNbEvents
));
327 fTimeRangeHistogram
.getMaxNbEventsText().getParent().layout();
328 fTimeRangeHistogram
.fCanvas
.redraw();
331 hideLostEventsAction
.setText(Messages
.HistogramView_hideLostEvents
);
332 hideLostEventsAction
.setToolTipText(Messages
.HistogramView_hideLostEvents
);
333 hideLostEventsAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SHOW_LOST_EVENTS
));
335 return hideLostEventsAction
;
338 // ------------------------------------------------------------------------
340 // ------------------------------------------------------------------------
343 * Broadcast TmfSignal about new current selection time range.
344 * @param beginTime the begin time of current selection.
345 * @param endTime the end time of current selection.
347 void updateSelectionTime(long beginTime
, long endTime
) {
348 updateDisplayedSelectionTime(beginTime
, endTime
);
349 TmfTimestamp beginTs
= new TmfTimestamp(beginTime
, ITmfTimestamp
.NANOSECOND_SCALE
);
350 TmfTimestamp endTs
= new TmfTimestamp(endTime
, ITmfTimestamp
.NANOSECOND_SCALE
);
351 TmfTimeSynchSignal signal
= new TmfTimeSynchSignal(this, beginTs
, endTs
);
352 fTimeSyncThrottle
.queue(signal
);
356 * Broadcast TmfSignal about new selection time range.
357 * @param startTime the new start time
358 * @param endTime the new end time
360 void updateTimeRange(long startTime
, long endTime
) {
361 if (fTrace
!= null) {
362 // Build the new time range; keep the current time
363 TmfTimeRange timeRange
= new TmfTimeRange(
364 new TmfTimestamp(startTime
, ITmfTimestamp
.NANOSECOND_SCALE
),
365 new TmfTimestamp(endTime
, ITmfTimestamp
.NANOSECOND_SCALE
));
366 fTimeSpanControl
.setValue(endTime
- startTime
);
368 updateDisplayedTimeRange(startTime
, endTime
);
370 // Send the FW signal
371 TmfRangeSynchSignal signal
= new TmfRangeSynchSignal(this, timeRange
);
372 fTimeRangeSyncThrottle
.queue(signal
);
377 * Broadcast TmfSignal about new selected time range.
378 * @param newDuration new duration (relative to current start time)
380 public synchronized void updateTimeRange(long newDuration
) {
381 if (fTrace
!= null) {
382 long delta
= newDuration
- fWindowSpan
;
383 long newStartTime
= fWindowStartTime
- (delta
/ 2);
384 setNewRange(newStartTime
, newDuration
);
388 private void setNewRange(long startTime
, long duration
) {
389 long realStart
= startTime
;
391 if (realStart
< fTraceStartTime
) {
392 realStart
= fTraceStartTime
;
395 long endTime
= realStart
+ duration
;
396 if (endTime
> fTraceEndTime
) {
397 endTime
= fTraceEndTime
;
398 if ((endTime
- duration
) > fTraceStartTime
) {
399 realStart
= endTime
- duration
;
401 realStart
= fTraceStartTime
;
404 updateTimeRange(realStart
, endTime
);
407 // ------------------------------------------------------------------------
409 // ------------------------------------------------------------------------
412 * Handles trace opened signal. Loads histogram if new trace time range is not
413 * equal <code>TmfTimeRange.NULL_RANGE</code>
414 * @param signal the trace opened signal
418 public void traceOpened(TmfTraceOpenedSignal signal
) {
419 assert (signal
!= null);
420 fTrace
= signal
.getTrace();
425 * Handles trace selected signal. Loads histogram if new trace time range is not
426 * equal <code>TmfTimeRange.NULL_RANGE</code>
427 * @param signal the trace selected signal
431 public void traceSelected(TmfTraceSelectedSignal signal
) {
432 assert (signal
!= null);
433 if (fTrace
!= signal
.getTrace()) {
434 fTrace
= signal
.getTrace();
439 private void loadTrace() {
440 initializeHistograms();
445 * Handles trace closed signal. Clears the view and data model and cancels requests.
446 * @param signal the trace closed signal
450 public void traceClosed(TmfTraceClosedSignal signal
) {
452 if (signal
.getTrace() != fTrace
) {
456 // Kill any running request
457 if ((fTimeRangeRequest
!= null) && !fTimeRangeRequest
.isCompleted()) {
458 fTimeRangeRequest
.cancel();
460 if ((fFullTraceRequest
!= null) && !fFullTraceRequest
.isCompleted()) {
461 fFullTraceRequest
.cancel();
464 // Initialize the internal data
466 fTraceStartTime
= 0L;
468 fWindowStartTime
= 0L;
471 fSelectionBeginTime
= 0L;
472 fSelectionEndTime
= 0L;
474 // Clear the UI widgets
475 fFullTraceHistogram
.clear();
476 fTimeRangeHistogram
.clear();
477 fCurrentEventTimeControl
.setValue(Long
.MIN_VALUE
);
479 fTimeSpanControl
.setValue(Long
.MIN_VALUE
);
483 * Handles trace range updated signal. Extends histogram according to the new time range. If a
484 * HistogramRequest is already ongoing, it will be cancelled and a new request with the new range
487 * @param signal the trace range updated signal
491 public void traceRangeUpdated(TmfTraceRangeUpdatedSignal signal
) {
493 if (signal
.getTrace() != fTrace
) {
497 TmfTimeRange fullRange
= signal
.getRange();
499 fTraceStartTime
= fullRange
.getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
500 fTraceEndTime
= fullRange
.getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
502 fFullTraceHistogram
.setFullRange(fTraceStartTime
, fTraceEndTime
);
503 fTimeRangeHistogram
.setFullRange(fTraceStartTime
, fTraceEndTime
);
505 sendFullRangeRequest(fullRange
);
509 * Handles the trace updated signal. Used to update time limits (start and end time)
510 * @param signal the trace updated signal
514 public void traceUpdated(TmfTraceUpdatedSignal signal
) {
515 if (signal
.getTrace() != fTrace
) {
518 TmfTimeRange fullRange
= signal
.getTrace().getTimeRange();
519 fTraceStartTime
= fullRange
.getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
520 fTraceEndTime
= fullRange
.getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
522 fFullTraceHistogram
.setFullRange(fTraceStartTime
, fTraceEndTime
);
523 fTimeRangeHistogram
.setFullRange(fTraceStartTime
, fTraceEndTime
);
525 fFullTraceHistogram
.setTimeRange(fTimeRangeHistogram
.getStartTime(), fWindowSpan
);
526 fTimeRangeHistogram
.setTimeRange(fTimeRangeHistogram
.getStartTime(), fWindowSpan
);
528 if ((fFullTraceRequest
!= null) && fFullTraceRequest
.getRange().getEndTime().compareTo(signal
.getRange().getEndTime()) < 0) {
529 sendFullRangeRequest(fullRange
);
534 * Handles the current time updated signal. Sets the current time in the time range
535 * histogram as well as the full histogram.
537 * @param signal the signal to process
540 public void currentTimeUpdated(TmfTimeSynchSignal signal
) {
541 // Because this can't happen :-)
542 assert (signal
!= null);
544 // Update the selected time range
545 ITmfTimestamp beginTime
= signal
.getBeginTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
);
546 ITmfTimestamp endTime
= signal
.getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
);
547 updateDisplayedSelectionTime(beginTime
.getValue(), endTime
.getValue());
551 * Updates the current time range in the time range histogram and full range histogram.
552 * @param signal the signal to process
555 public void timeRangeUpdated(TmfRangeSynchSignal signal
) {
556 // Because this can't happen :-)
557 assert (signal
!= null);
559 if (fTrace
!= null) {
560 // Validate the time range
561 TmfTimeRange range
= signal
.getCurrentRange().getIntersection(fTrace
.getTimeRange());
566 updateDisplayedTimeRange(
567 range
.getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue(),
568 range
.getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue());
570 // Send the event request to populate the small histogram
571 sendTimeRangeRequest(fWindowStartTime
, fWindowEndTime
);
573 fTimeSpanControl
.setValue(fWindowSpan
);
577 // ------------------------------------------------------------------------
579 // ------------------------------------------------------------------------
581 private void initializeHistograms() {
582 TmfTimeRange fullRange
= updateTraceTimeRange();
583 long selectionBeginTime
= fTraceManager
.getSelectionBeginTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
584 long selectionEndTime
= fTraceManager
.getSelectionEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
585 long startTime
= fTraceManager
.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
586 long duration
= fTraceManager
.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue() - startTime
;
588 if ((fTimeRangeRequest
!= null) && !fTimeRangeRequest
.isCompleted()) {
589 fTimeRangeRequest
.cancel();
591 fTimeRangeHistogram
.clear();
592 fTimeRangeHistogram
.setFullRange(fTraceStartTime
, fTraceEndTime
);
593 fTimeRangeHistogram
.setTimeRange(startTime
, duration
);
594 fTimeRangeHistogram
.setSelection(selectionBeginTime
, selectionEndTime
);
596 if ((fFullTraceRequest
!= null) && !fFullTraceRequest
.isCompleted()) {
597 fFullTraceRequest
.cancel();
599 fFullTraceHistogram
.clear();
600 fFullTraceHistogram
.setFullRange(fTraceStartTime
, fTraceEndTime
);
601 fFullTraceHistogram
.setTimeRange(startTime
, duration
);
602 fFullTraceHistogram
.setSelection(selectionBeginTime
, selectionEndTime
);
604 fWindowStartTime
= startTime
;
605 fWindowSpan
= duration
;
606 fWindowEndTime
= startTime
+ duration
;
608 fSelectionBeginTime
= selectionBeginTime
;
609 fSelectionEndTime
= selectionEndTime
;
610 fCurrentEventTimeControl
.setValue(fSelectionBeginTime
);
612 fTimeSpanControl
.setValue(duration
);
614 if (!fullRange
.equals(TmfTimeRange
.NULL_RANGE
)) {
615 sendTimeRangeRequest(startTime
, startTime
+ duration
);
616 sendFullRangeRequest(fullRange
);
620 private void updateDisplayedSelectionTime(long beginTime
, long endTime
) {
621 fSelectionBeginTime
= beginTime
;
622 fSelectionEndTime
= endTime
;
624 fFullTraceHistogram
.setSelection(fSelectionBeginTime
, fSelectionEndTime
);
625 fTimeRangeHistogram
.setSelection(fSelectionBeginTime
, fSelectionEndTime
);
626 fCurrentEventTimeControl
.setValue(fSelectionBeginTime
);
629 private void updateDisplayedTimeRange(long start
, long end
) {
630 fWindowStartTime
= start
;
631 fWindowEndTime
= end
;
632 fWindowSpan
= fWindowEndTime
- fWindowStartTime
;
633 fFullTraceHistogram
.setTimeRange(fWindowStartTime
, fWindowSpan
);
636 private TmfTimeRange
updateTraceTimeRange() {
637 fTraceStartTime
= 0L;
640 TmfTimeRange timeRange
= fTrace
.getTimeRange();
641 if (!timeRange
.equals(TmfTimeRange
.NULL_RANGE
)) {
642 fTraceStartTime
= timeRange
.getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
643 fTraceEndTime
= timeRange
.getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
648 private void sendTimeRangeRequest(long startTime
, long endTime
) {
649 if ((fTimeRangeRequest
!= null) && !fTimeRangeRequest
.isCompleted()) {
650 fTimeRangeRequest
.cancel();
652 TmfTimestamp startTS
= new TmfTimestamp(startTime
, ITmfTimestamp
.NANOSECOND_SCALE
);
653 TmfTimestamp endTS
= new TmfTimestamp(endTime
, ITmfTimestamp
.NANOSECOND_SCALE
);
654 TmfTimeRange timeRange
= new TmfTimeRange(startTS
, endTS
);
656 fTimeRangeHistogram
.clear();
657 fTimeRangeHistogram
.setFullRange(fTraceStartTime
, fTraceEndTime
);
658 fTimeRangeHistogram
.setTimeRange(startTime
, endTime
- startTime
);
660 int cacheSize
= fTrace
.getCacheSize();
661 fTimeRangeRequest
= new HistogramRequest(fTimeRangeHistogram
.getDataModel(), timeRange
, 0, TmfDataRequest
.ALL_DATA
, cacheSize
, ExecutionType
.FOREGROUND
, false);
662 fTrace
.sendRequest(fTimeRangeRequest
);
665 private void sendFullRangeRequest(TmfTimeRange fullRange
) {
666 if ((fFullTraceRequest
!= null) && !fFullTraceRequest
.isCompleted()) {
667 fFullTraceRequest
.cancel();
669 int cacheSize
= fTrace
.getCacheSize();
670 fFullTraceRequest
= new HistogramRequest(fFullTraceHistogram
.getDataModel(), fullRange
, (int) fFullTraceHistogram
.fDataModel
.getNbEvents(),
671 TmfDataRequest
.ALL_DATA
, cacheSize
, ExecutionType
.BACKGROUND
, true);
672 fTrace
.sendRequest(fFullTraceRequest
);
675 private void contributeToActionBars() {
676 IActionBars bars
= getViewSite().getActionBars();
677 bars
.getToolBarManager().add(getShowLostEventsAction());
678 bars
.getToolBarManager().add(new Separator());