Fix for empty views that extend TmfView after restart (Bug 409345)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / histogram / HistogramView.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * 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 *******************************************************************************/
18
19 package org.eclipse.linuxtools.tmf.ui.views.histogram;
20
21 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
22 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
23 import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
24 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
25 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
26 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalThrottler;
27 import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
28 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
29 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
30 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceRangeUpdatedSignal;
31 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
32 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
33 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
34 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
35 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
36 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
37 import org.eclipse.linuxtools.tmf.ui.views.TmfView;
38 import org.eclipse.swt.SWT;
39 import org.eclipse.swt.events.MouseWheelListener;
40 import org.eclipse.swt.layout.GridData;
41 import org.eclipse.swt.layout.GridLayout;
42 import org.eclipse.swt.widgets.Composite;
43
44 /**
45 * The purpose of this view is to provide graphical time distribution statistics about the trace events.
46 * <p>
47 * The view is composed of two histograms and two controls:
48 * <ul>
49 * <li>an event distribution histogram for the whole trace;
50 * <li>an event distribution histogram for current time window (window span);
51 * <li>the timestamp of the currently selected event;
52 * <li>the window span (size of the time window of the smaller histogram).
53 * </ul>
54 * The histograms x-axis show their respective time range.
55 *
56 * @version 2.0
57 * @author Francois Chouinard
58 */
59 public class HistogramView extends TmfView {
60
61 // ------------------------------------------------------------------------
62 // Constants
63 // ------------------------------------------------------------------------
64
65 /**
66 * The view ID as defined in plugin.xml
67 */
68 public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.histogram"; //$NON-NLS-1$
69
70 // ------------------------------------------------------------------------
71 // Attributes
72 // ------------------------------------------------------------------------
73
74 // Parent widget
75 private Composite fParent;
76
77 // The current trace
78 private ITmfTrace fTrace;
79
80 // Current timestamp/time window - everything in the TIME_SCALE
81 private long fTraceStartTime;
82 private long fTraceEndTime;
83 private long fWindowStartTime;
84 private long fWindowEndTime;
85 private long fWindowSpan;
86 private long fCurrentTimestamp;
87
88 // Time controls
89 private HistogramTextControl fCurrentEventTimeControl;
90 private HistogramTextControl fTimeSpanControl;
91
92 // Histogram/request for the full trace range
93 private static FullTraceHistogram fFullTraceHistogram;
94 private HistogramRequest fFullTraceRequest;
95
96 // Histogram/request for the selected time range
97 private static TimeRangeHistogram fTimeRangeHistogram;
98 private HistogramRequest fTimeRangeRequest;
99
100 // Throttlers for the time sync and time-range sync signals
101 private final TmfSignalThrottler fTimeSyncThrottle;
102 private final TmfSignalThrottler fTimeRangeSyncThrottle;
103
104 // ------------------------------------------------------------------------
105 // Constructor
106 // ------------------------------------------------------------------------
107
108 /**
109 * Default constructor
110 */
111 public HistogramView() {
112 super(ID);
113 fTimeSyncThrottle = new TmfSignalThrottler(this, 200);
114 fTimeRangeSyncThrottle = new TmfSignalThrottler(this, 200);
115 }
116
117 @Override
118 public void dispose() {
119 if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
120 fTimeRangeRequest.cancel();
121 }
122 if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
123 fFullTraceRequest.cancel();
124 }
125 fFullTraceHistogram.dispose();
126 fTimeRangeHistogram.dispose();
127 fCurrentEventTimeControl.dispose();
128 fTimeSpanControl.dispose();
129 super.dispose();
130 }
131
132 // ------------------------------------------------------------------------
133 // TmfView
134 // ------------------------------------------------------------------------
135
136 @Override
137 public void createPartControl(Composite parent) {
138
139 fParent = parent;
140
141 // Control labels
142 final String currentEventLabel = Messages.HistogramView_currentEventLabel;
143 final String windowSpanLabel = Messages.HistogramView_windowSpanLabel;
144
145 // --------------------------------------------------------------------
146 // Set the HistogramView layout
147 // --------------------------------------------------------------------
148
149 Composite viewComposite = new Composite(fParent, SWT.FILL);
150 GridLayout gridLayout = new GridLayout();
151 gridLayout.numColumns = 2;
152 gridLayout.horizontalSpacing = 5;
153 gridLayout.verticalSpacing = 0;
154 gridLayout.marginHeight = 0;
155 gridLayout.marginWidth = 0;
156 viewComposite.setLayout(gridLayout);
157
158 // Use all available space
159 GridData gridData = new GridData();
160 gridData.horizontalAlignment = SWT.FILL;
161 gridData.verticalAlignment = SWT.FILL;
162 gridData.grabExcessHorizontalSpace = true;
163 viewComposite.setLayoutData(gridData);
164
165 // --------------------------------------------------------------------
166 // Time controls
167 // --------------------------------------------------------------------
168
169 Composite controlsComposite = new Composite(viewComposite, SWT.FILL);
170 gridLayout = new GridLayout();
171 gridLayout.numColumns = 2;
172 gridLayout.marginHeight = 0;
173 gridLayout.marginWidth = 0;
174 gridLayout.horizontalSpacing = 5;
175 gridLayout.verticalSpacing = 0;
176 gridLayout.makeColumnsEqualWidth = false;
177 gridLayout.marginLeft = 5;
178 gridLayout.marginRight = 5;
179 controlsComposite.setLayout(gridLayout);
180
181 // Current event time control
182 gridData = new GridData();
183 gridData.horizontalAlignment = SWT.CENTER;
184 gridData.verticalAlignment = SWT.CENTER;
185 fCurrentEventTimeControl = new HistogramCurrentTimeControl(this, controlsComposite, currentEventLabel, 0L);
186 fCurrentEventTimeControl.setLayoutData(gridData);
187 fCurrentEventTimeControl.setValue(Long.MIN_VALUE);
188
189 // Window span time control
190 gridData = new GridData();
191 gridData.horizontalAlignment = SWT.CENTER;
192 gridData.verticalAlignment = SWT.CENTER;
193 fTimeSpanControl = new HistogramTimeRangeControl(this, controlsComposite, windowSpanLabel, 0L);
194 fTimeSpanControl.setLayoutData(gridData);
195 fTimeSpanControl.setValue(Long.MIN_VALUE);
196
197 // --------------------------------------------------------------------
198 // Time range histogram
199 // --------------------------------------------------------------------
200
201 Composite timeRangeComposite = new Composite(viewComposite, SWT.FILL);
202 gridLayout = new GridLayout();
203 gridLayout.numColumns = 1;
204 gridLayout.marginHeight = 0;
205 gridLayout.marginWidth = 0;
206 gridLayout.marginTop = 5;
207 gridLayout.horizontalSpacing = 0;
208 gridLayout.verticalSpacing = 0;
209 gridLayout.marginLeft = 5;
210 gridLayout.marginRight = 5;
211 timeRangeComposite.setLayout(gridLayout);
212
213 // Use remaining horizontal space
214 gridData = new GridData();
215 gridData.horizontalAlignment = SWT.FILL;
216 gridData.verticalAlignment = SWT.FILL;
217 gridData.grabExcessHorizontalSpace = true;
218 timeRangeComposite.setLayoutData(gridData);
219
220 // Histogram
221 fTimeRangeHistogram = new TimeRangeHistogram(this, timeRangeComposite);
222
223 // --------------------------------------------------------------------
224 // Full range histogram
225 // --------------------------------------------------------------------
226
227 Composite fullRangeComposite = new Composite(viewComposite, SWT.FILL);
228 gridLayout = new GridLayout();
229 gridLayout.numColumns = 1;
230 gridLayout.marginHeight = 0;
231 gridLayout.marginWidth = 0;
232 gridLayout.marginTop = 5;
233 gridLayout.horizontalSpacing = 0;
234 gridLayout.verticalSpacing = 0;
235 gridLayout.marginLeft = 5;
236 gridLayout.marginRight = 5;
237 fullRangeComposite.setLayout(gridLayout);
238
239 // Use remaining horizontal space
240 gridData = new GridData();
241 gridData.horizontalAlignment = SWT.FILL;
242 gridData.verticalAlignment = SWT.FILL;
243 gridData.horizontalSpan = 2;
244 gridData.grabExcessHorizontalSpace = true;
245 fullRangeComposite.setLayoutData(gridData);
246
247 // Histogram
248 fFullTraceHistogram = new FullTraceHistogram(this, fullRangeComposite);
249
250 // Add mouse wheel listener to time span control
251 MouseWheelListener listener = fFullTraceHistogram.getZoom();
252 fTimeSpanControl.addMouseWheelListener(listener);
253
254 ITmfTrace trace = getActiveTrace();
255 if (trace != null) {
256 traceSelected(new TmfTraceSelectedSignal(this, trace));
257 }
258 }
259
260 @Override
261 public void setFocus() {
262 fFullTraceHistogram.fCanvas.setFocus();
263 }
264
265 void refresh() {
266 fParent.layout(true);
267 }
268
269 // ------------------------------------------------------------------------
270 // Accessors
271 // ------------------------------------------------------------------------
272
273 /**
274 * Returns the current trace handled by the view
275 *
276 * @return the current trace
277 * @since 2.0
278 */
279 public ITmfTrace getTrace() {
280 return fTrace;
281 }
282
283 /**
284 * Returns the time range of the current selected window (base on default time scale).
285 *
286 * @return the time range of current selected window.
287 * @since 2.0
288 */
289 public TmfTimeRange getTimeRange() {
290 return new TmfTimeRange(
291 new TmfTimestamp(fWindowStartTime, ITmfTimestamp.NANOSECOND_SCALE),
292 new TmfTimestamp(fWindowEndTime, ITmfTimestamp.NANOSECOND_SCALE));
293 }
294
295 // ------------------------------------------------------------------------
296 // Operations
297 // ------------------------------------------------------------------------
298
299 /**
300 * Broadcast TmfSignal about new current time value.
301 * @param newTime the new current time.
302 */
303 void updateCurrentEventTime(long newTime) {
304 if (fTrace != null) {
305 TmfTimeRange timeRange = new TmfTimeRange(new TmfTimestamp(newTime, ITmfTimestamp.NANOSECOND_SCALE), TmfTimestamp.BIG_CRUNCH);
306 HistogramRequest request = new HistogramRequest(fTimeRangeHistogram.getDataModel(), timeRange, 0, 1, 0, ExecutionType.FOREGROUND) {
307 @Override
308 public void handleData(ITmfEvent event) {
309 if (event != null) {
310 ITmfTimestamp ts = event.getTimestamp();
311 updateDisplayedCurrentTime(ts.normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
312 TmfTimeSynchSignal signal = new TmfTimeSynchSignal(this, ts);
313 fTimeSyncThrottle.queue(signal);
314 }
315 }
316 };
317 fTrace.sendRequest(request);
318 }
319 }
320
321 /**
322 * Broadcast TmfSignal about new selected time range.
323 * @param startTime the new start time
324 * @param endTime the new end time
325 */
326 void updateTimeRange(long startTime, long endTime) {
327 if (fTrace != null) {
328 // Build the new time range; keep the current time
329 TmfTimeRange timeRange = new TmfTimeRange(
330 new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE),
331 new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE));
332 ITmfTimestamp currentTime = new TmfTimestamp(fCurrentTimestamp, ITmfTimestamp.NANOSECOND_SCALE);
333 fTimeSpanControl.setValue(endTime - startTime);
334
335 updateDisplayedTimeRange(startTime, endTime);
336
337 // Send the FW signal
338 TmfRangeSynchSignal signal = new TmfRangeSynchSignal(this, timeRange, currentTime);
339 fTimeRangeSyncThrottle.queue(signal);
340 }
341 }
342
343 /**
344 * Broadcast TmfSignal about new selected time range.
345 * @param newDuration new duration (relative to current start time)
346 */
347 public synchronized void updateTimeRange(long newDuration) {
348 if (fTrace != null) {
349 long delta = newDuration - fWindowSpan;
350 long newStartTime = fWindowStartTime - (delta / 2);
351 setNewRange(newStartTime, newDuration);
352 }
353 }
354
355 private void setNewRange(long startTime, long duration) {
356 long realStart = startTime;
357
358 if (realStart < fTraceStartTime) {
359 realStart = fTraceStartTime;
360 }
361
362 long endTime = realStart + duration;
363 if (endTime > fTraceEndTime) {
364 endTime = fTraceEndTime;
365 if ((endTime - duration) > fTraceStartTime) {
366 realStart = endTime - duration;
367 } else {
368 realStart = fTraceStartTime;
369 }
370 }
371 updateTimeRange(realStart, endTime);
372 }
373
374 // ------------------------------------------------------------------------
375 // Signal handlers
376 // ------------------------------------------------------------------------
377
378 /**
379 * Handles trace opened signal. Loads histogram if new trace time range is not
380 * equal <code>TmfTimeRange.NULL_RANGE</code>
381 * @param signal the trace opened signal
382 * @since 2.0
383 */
384 @TmfSignalHandler
385 public void traceOpened(TmfTraceOpenedSignal signal) {
386 assert (signal != null);
387 fTrace = signal.getTrace();
388 loadTrace();
389 }
390
391 /**
392 * Handles trace selected signal. Loads histogram if new trace time range is not
393 * equal <code>TmfTimeRange.NULL_RANGE</code>
394 * @param signal the trace selected signal
395 * @since 2.0
396 */
397 @TmfSignalHandler
398 public void traceSelected(TmfTraceSelectedSignal signal) {
399 assert (signal != null);
400 if (fTrace != signal.getTrace()) {
401 fTrace = signal.getTrace();
402 loadTrace();
403 }
404 }
405
406 private void loadTrace() {
407 initializeHistograms();
408 fParent.redraw();
409 }
410
411 /**
412 * Handles trace closed signal. Clears the view and data model and cancels requests.
413 * @param signal the trace closed signal
414 * @since 2.0
415 */
416 @TmfSignalHandler
417 public void traceClosed(TmfTraceClosedSignal signal) {
418
419 if (signal.getTrace() != fTrace) {
420 return;
421 }
422
423 // Kill any running request
424 if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
425 fTimeRangeRequest.cancel();
426 }
427 if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
428 fFullTraceRequest.cancel();
429 }
430
431 // Initialize the internal data
432 fTrace = null;
433 fTraceStartTime = 0L;
434 fTraceEndTime = 0L;
435 fWindowStartTime = 0L;
436 fWindowEndTime = 0L;
437 fWindowSpan = 0L;
438 fCurrentTimestamp = 0L;
439
440 // Clear the UI widgets
441 fFullTraceHistogram.clear();
442 fTimeRangeHistogram.clear();
443 fCurrentEventTimeControl.setValue(Long.MIN_VALUE);
444
445 fTimeSpanControl.setValue(Long.MIN_VALUE);
446 }
447
448 /**
449 * Handles trace range updated signal. Extends histogram according to the new time range. If a
450 * HistogramRequest is already ongoing, it will be cancelled and a new request with the new range
451 * will be issued.
452 *
453 * @param signal the trace range updated signal
454 * @since 2.0
455 */
456 @TmfSignalHandler
457 public void traceRangeUpdated(TmfTraceRangeUpdatedSignal signal) {
458
459 if (signal.getTrace() != fTrace) {
460 return;
461 }
462
463 TmfTimeRange fullRange = signal.getRange();
464
465 fTraceStartTime = fullRange.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
466 fTraceEndTime = fullRange.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
467
468 fFullTraceHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
469 fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
470
471 sendFullRangeRequest(fullRange);
472 }
473
474 /**
475 * Handles the trace updated signal. Used to update time limits (start and end time)
476 * @param signal the trace updated signal
477 * @since 2.0
478 */
479 @TmfSignalHandler
480 public void traceUpdated(TmfTraceUpdatedSignal signal) {
481 if (signal.getTrace() != fTrace) {
482 return;
483 }
484 TmfTimeRange fullRange = signal.getTrace().getTimeRange();
485 fTraceStartTime = fullRange.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
486 fTraceEndTime = fullRange.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
487
488 fFullTraceHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
489 fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
490
491 fFullTraceHistogram.setTimeRange(fTimeRangeHistogram.getStartTime(), fWindowSpan);
492 fTimeRangeHistogram.setTimeRange(fTimeRangeHistogram.getStartTime(), fWindowSpan);
493
494 if ((fFullTraceRequest != null) && fFullTraceRequest.getRange().getEndTime().compareTo(signal.getRange().getEndTime()) < 0) {
495 sendFullRangeRequest(fullRange);
496 }
497 }
498
499 /**
500 * Handles the current time updated signal. Sets the current time in the time range
501 * histogram as well as the full histogram.
502 *
503 * @param signal the signal to process
504 */
505 @TmfSignalHandler
506 public void currentTimeUpdated(TmfTimeSynchSignal signal) {
507 // Because this can't happen :-)
508 assert (signal != null);
509
510 // Update the selected event time
511 ITmfTimestamp currentTime = signal.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
512 updateDisplayedCurrentTime(currentTime.getValue());
513 }
514
515 /**
516 * Updates the current time range in the time range histogram and full range histogram.
517 * @param signal the signal to process
518 */
519 @TmfSignalHandler
520 public void timeRangeUpdated(TmfRangeSynchSignal signal) {
521 // Because this can't happen :-)
522 assert (signal != null);
523
524 if (fTrace != null) {
525 // Validate the time range
526 TmfTimeRange range = signal.getCurrentRange().getIntersection(fTrace.getTimeRange());
527 if (range == null) {
528 return;
529 }
530
531 updateDisplayedTimeRange(
532 range.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(),
533 range.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue());
534
535 // Send the event request to populate the small histogram
536 sendTimeRangeRequest(fWindowStartTime, fWindowEndTime);
537
538 fTimeSpanControl.setValue(fWindowSpan);
539 }
540 }
541
542 // ------------------------------------------------------------------------
543 // Helper functions
544 // ------------------------------------------------------------------------
545
546 private void initializeHistograms() {
547 TmfTimeRange fullRange = updateTraceTimeRange();
548 long timestamp = fTraceManager.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
549 long startTime = fTraceManager.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
550 long duration = fTraceManager.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue() - startTime;
551
552 if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
553 fTimeRangeRequest.cancel();
554 }
555 fTimeRangeHistogram.clear();
556 fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
557 fTimeRangeHistogram.setTimeRange(startTime, duration);
558 fTimeRangeHistogram.setCurrentEvent(timestamp);
559
560 if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
561 fFullTraceRequest.cancel();
562 }
563 fFullTraceHistogram.clear();
564 fFullTraceHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
565 fFullTraceHistogram.setTimeRange(startTime, duration);
566 fFullTraceHistogram.setCurrentEvent(timestamp);
567
568 fWindowStartTime = startTime;
569 fWindowSpan = duration;
570 fWindowEndTime = startTime + duration;
571
572 fCurrentTimestamp = timestamp;
573 fCurrentEventTimeControl.setValue(fCurrentTimestamp);
574
575 fTimeSpanControl.setValue(duration);
576
577 if (!fullRange.equals(TmfTimeRange.NULL_RANGE)) {
578 sendTimeRangeRequest(startTime, startTime + duration);
579 sendFullRangeRequest(fullRange);
580 }
581 }
582
583 private void updateDisplayedCurrentTime(long time) {
584 fCurrentTimestamp = time;
585
586 fFullTraceHistogram.setCurrentEvent(fCurrentTimestamp);
587 fTimeRangeHistogram.setCurrentEvent(fCurrentTimestamp);
588 fCurrentEventTimeControl.setValue(fCurrentTimestamp);
589 }
590
591 private void updateDisplayedTimeRange(long start, long end) {
592 fWindowStartTime = start;
593 fWindowEndTime = end;
594 fWindowSpan = fWindowEndTime - fWindowStartTime;
595 fFullTraceHistogram.setTimeRange(fWindowStartTime, fWindowSpan);
596 }
597
598 private TmfTimeRange updateTraceTimeRange() {
599 fTraceStartTime = 0L;
600 fTraceEndTime = 0L;
601
602 TmfTimeRange timeRange = fTrace.getTimeRange();
603 if (!timeRange.equals(TmfTimeRange.NULL_RANGE)) {
604 fTraceStartTime = timeRange.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
605 fTraceEndTime = timeRange.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
606 }
607 return timeRange;
608 }
609
610 private void sendTimeRangeRequest(long startTime, long endTime) {
611 if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
612 fTimeRangeRequest.cancel();
613 }
614 TmfTimestamp startTS = new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE);
615 TmfTimestamp endTS = new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE);
616 TmfTimeRange timeRange = new TmfTimeRange(startTS, endTS);
617
618 fTimeRangeHistogram.clear();
619 fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
620 fTimeRangeHistogram.setTimeRange(startTime, endTime - startTime);
621
622 int cacheSize = fTrace.getCacheSize();
623 fTimeRangeRequest = new HistogramRequest(fTimeRangeHistogram.getDataModel(), timeRange, 0, TmfDataRequest.ALL_DATA, cacheSize, ExecutionType.FOREGROUND);
624 fTrace.sendRequest(fTimeRangeRequest);
625 }
626
627 private void sendFullRangeRequest(TmfTimeRange fullRange) {
628 if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
629 fFullTraceRequest.cancel();
630 }
631 int cacheSize = fTrace.getCacheSize();
632 fFullTraceRequest = new HistogramRequest(fFullTraceHistogram.getDataModel(), fullRange, (int) fFullTraceHistogram.fDataModel.getNbEvents(),
633 TmfDataRequest.ALL_DATA, cacheSize, ExecutionType.BACKGROUND);
634 fTrace.sendRequest(fFullTraceRequest);
635 }
636
637 }
This page took 0.047111 seconds and 5 git commands to generate.