Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / common / AbsTimeUpdateView.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 * Bernd Hufmann - Bug fixes
12 *******************************************************************************/
13 package org.eclipse.linuxtools.lttng.ui.views.common;
14
15 import java.util.Arrays;
16
17 import org.eclipse.linuxtools.lttng.core.LttngConstants;
18 import org.eclipse.linuxtools.lttng.core.control.LttngCoreProviderFactory;
19 import org.eclipse.linuxtools.lttng.core.control.LttngSyntheticEventProvider;
20 import org.eclipse.linuxtools.lttng.core.event.LttngSyntheticEvent;
21 import org.eclipse.linuxtools.lttng.core.event.LttngTimestamp;
22 import org.eclipse.linuxtools.lttng.core.request.ILttngSyntEventRequest;
23 import org.eclipse.linuxtools.lttng.core.request.IRequestStatusListener;
24 import org.eclipse.linuxtools.lttng.core.request.LttngSyntEventRequest;
25 import org.eclipse.linuxtools.lttng.core.request.RequestCompletedSignal;
26 import org.eclipse.linuxtools.lttng.core.request.RequestStartedSignal;
27 import org.eclipse.linuxtools.lttng.core.state.evProcessor.ITransEventProcessor;
28 import org.eclipse.linuxtools.lttng.ui.TraceDebug;
29 import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer;
30 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
31 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
32 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
33 import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
34 import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
35 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
36 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
37 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
38 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
39 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
40 import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
41 import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer;
42 import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
43 import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent;
44 import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
45 import org.eclipse.linuxtools.tmf.ui.views.TmfView;
46 import org.eclipse.swt.widgets.Display;
47
48 /**
49 * <p>
50 * Abstract class used as a base for views handling specific time range data
51 * requests
52 * </p>
53 * <p>
54 * The class handles a single element queue of data requests, i.e. request can
55 * be triggered from different sources e.g. opening a file as well as a new
56 * selected time window
57 * </p>
58 *
59 * @author alvaro
60 *
61 */
62 public abstract class AbsTimeUpdateView extends TmfView implements IRequestStatusListener {
63
64 // ========================================================================
65 // Data
66 // ========================================================================
67
68 // private static final long INITIAL_WINDOW_OFFSET = (1L * 1 * 1000 * 1000); // .001sec
69 // private static final long INITIAL_WINDOW_OFFSET = (1L * 10 * 1000 * 1000); // .01sec
70 private static final long INITIAL_WINDOW_OFFSET = (1L * 100 * 1000 * 1000); // .1sec
71 // private static final long INITIAL_WINDOW_OFFSET = (1L * 1000 * 1000 * 1000); // 1sec
72
73 /**
74 * Number of events before a GUI refresh
75 */
76 protected static final Long INPUT_CHANGED_REFRESH = 75000L;
77 private static final long DEFAULT_OFFSET = 0;
78
79 protected boolean synch = true; // time synchronization, used to be an option
80 protected ITimeAnalysisViewer tsfviewer = null;
81
82 private LttngSyntEventRequest fCurrentRequest = null;
83
84 protected LttngSyntheticEventProvider fProvider = LttngCoreProviderFactory.getEventProvider(getProviderId());
85
86 // ========================================================================
87 // Constructor
88 // ========================================================================
89 public AbsTimeUpdateView(String viewID) {
90 super(viewID);
91 // freqState = UiCommonFactory.getQueue(this);
92 }
93
94 // ========================================================================
95 // Methods
96 // ========================================================================
97
98 /**
99 * Returns the number of events after which the relevant display will
100 * be refreshed
101 *
102 * @return
103 */
104 protected Long getInputChangedRefresh() {
105 return INPUT_CHANGED_REFRESH;
106 }
107
108 /**
109 * Cancel the ongoing request if another experiment is being selected
110 * @param experimentDisposedSignal
111 */
112 @TmfSignalHandler
113 public void experimentDisposed(TmfExperimentDisposedSignal<? extends TmfEvent> experimentDisposedSignal) {
114 fProvider.conditionallyCancelRequests();
115 }
116
117 /*
118 * (non-Javadoc)
119 *
120 * @seeorg.eclipse.linuxtools.lttng.state.IStateDataRequestListener#
121 * processingStarted(org.eclipse.linuxtools.lttng.state.StateDataRequest)
122 */
123 @Override
124 @TmfSignalHandler
125 public synchronized void processingStarted(RequestStartedSignal signal) {
126 LttngSyntEventRequest request = signal.getRequest();
127 if (request != null) {
128 // update queue with the id of the current request.
129 // freqState.requestStarted(request);
130
131 // if there was no new request then this one is still on
132 // prepare for the reception of new data
133 waitCursor(true);
134
135 // no new time range for zoom orders
136 TmfTimeRange trange = null;
137 // Time Range will be used to filter out events which are
138 // not visible in one pixel
139 trange = request.getRange();
140
141 // indicate if the data model needs to be cleared e.g. a new
142 // experiment is being selected
143 boolean clearData = request.isclearDataInd();
144 // Indicate if current data needs to be cleared and if so
145 // specify the new experiment time range that applies
146 ModelUpdatePrep(trange, clearData);
147 }
148 }
149
150 /*
151 * (non-Javadoc)
152 *
153 * @seeorg.eclipse.linuxtools.lttng.state.IStateDataRequestListener#
154 * processingCompleted(org.eclipse.linuxtools.lttng.state.StateDataRequest)
155 */
156 @Override
157 @TmfSignalHandler
158 public void processingCompleted(RequestCompletedSignal signal) {
159 ILttngSyntEventRequest request = signal.getRequest();
160
161 if (request == null) {
162 return;
163 }
164
165 // Update wait cursor
166 waitCursor(false);
167
168 // No data refresh actions for cancelled requests.
169 if (request.isCancelled() || request.isFailed()) {
170 if (TraceDebug.isDEBUG()) {
171 TmfTimeRange trange = request.getRange();
172 if (request.isCancelled()) {
173 TraceDebug.debug("Request cancelled " //$NON-NLS-1$
174 + trange.getStartTime() + "-" + trange.getEndTime() //$NON-NLS-1$
175 + " Handled Events: " + request.getSynEventCount() //$NON-NLS-1$
176 + " " + request.toString(), 15); //$NON-NLS-1$
177 } else if (request.isFailed()) {
178 TraceDebug.debug("Request Failed " + trange.getStartTime() //$NON-NLS-1$
179 + "-" + trange.getEndTime() + " Handled Events: " //$NON-NLS-1$ //$NON-NLS-2$
180 + request.getSynEventCount() + " " //$NON-NLS-1$
181 + request.toString());
182 }
183 }
184
185 return;
186 } else {
187 modelInputChanged(request, true);
188 }
189 }
190
191 /**
192 * Registers as listener of time selection from other views
193 *
194 * @param signal
195 */
196 public void synchToTime(TmfTimeSynchSignal signal) {
197 if (synch) {
198 Object source = signal.getSource();
199 if (signal != null && source != null && source != this) {
200
201 if ((tsfviewer != null) && (!tsfviewer.getControl().isDisposed())) {
202
203 // Check for GUI thread
204 if (Display.getCurrent() != null) {
205 // GUI thread - execute update right away.
206
207 // Internal value is expected in nano seconds.
208 long selectedTime = signal.getCurrentTime().getValue();
209 if (tsfviewer != null) {
210 tsfviewer.setSelectedTime(selectedTime, true, source);
211
212 ParamsUpdater paramUpdater = getParamsUpdater();
213 Long savedSelTime = paramUpdater.getSelectedTime();
214 if ((savedSelTime == null) || (savedSelTime != selectedTime)) {
215 // Update the parameter updater to save the selected time
216 paramUpdater.setSelectedTime(selectedTime);
217 }
218 }
219 } else {
220 // Perform the updates on the UI thread
221
222 // We need to clone the timestamp in the signal so that it won't be overwritten duo to multipe thread access
223 final TmfTimeSynchSignal savedSignal = new TmfTimeSynchSignal(signal.getSource(), signal.getCurrentTime().clone());
224 tsfviewer.getControl().getDisplay().asyncExec(new Runnable() {
225 @Override
226 public void run() {
227 if ((tsfviewer != null) && (!tsfviewer.getControl().isDisposed())) {
228 synchToTime(savedSignal);
229 }
230 }
231 });
232 }
233 }
234 }
235 }
236 }
237
238 /**
239 * Process the reception of time window adjustment in this view if the
240 * source of the update is not this view.
241 *
242 * @param signal
243 * @param clearingData
244 */
245 public void synchToTimeRange(TmfRangeSynchSignal signal, boolean clearingData) {
246 if (synch) {
247 Object source = signal.getSource();
248 if (signal != null && source != null && source != this) {
249 // Internal value is expected in nano seconds.
250 TmfTimeRange trange = signal.getCurrentRange();
251 TmfExperiment<?> experiment = TmfExperiment.getCurrentExperiment();
252 if (experiment == null) {
253 TraceDebug.debug("Current selected experiment is null"); //$NON-NLS-1$
254 return;
255 }
256
257 // Clearing of process data is configurable
258 eventRequest(trange, experiment.getTimeRange(), clearingData, ExecutionType.FOREGROUND);
259 }
260 }
261 }
262
263 /**
264 * Trigger time synchronisation to other views this method shall be called
265 * when a check has been performed to note that an actual change of time has
266 * been performed vs a pure re-selection of the same time
267 *
268 * @param time
269 * @param source
270 */
271 protected void synchTimeNotification(long time, Object source) {
272 // if synchronisation selected
273 if (synch) {
274 // Notify other views
275 TmfSignalManager.dispatchSignal(new TmfTimeSynchSignal(source, new LttngTimestamp(time)));
276 }
277 }
278
279 /**
280 * Common implementation of ITmfTimeSelectionListener, not used by all the
281 * views extending this abstract class
282 *
283 * @param event
284 */
285 protected void tsfTmProcessSelEvent(TmfTimeSelectionEvent event) {
286 Object source = event.getSource();
287 if (source == null) {
288 return;
289 }
290
291 ParamsUpdater paramUpdater = getParamsUpdater();
292 Long savedSelTime = paramUpdater.getSelectedTime();
293
294 long selTimens = event.getSelectedTime();
295
296 // make sure the new selected time is different than saved before
297 // executing update
298 if (savedSelTime == null || savedSelTime != selTimens) {
299 // Notify listener views.
300 synchTimeNotification(selTimens, source);
301
302 // Update the parameter updater to save the selected time
303 paramUpdater.setSelectedTime(selTimens);
304
305 if (TraceDebug.isDEBUG()) {
306 TraceDebug.debug("Selected Time: " + new LttngTimestamp(selTimens) + "\n\t\t" + getName()); //$NON-NLS-1$ //$NON-NLS-2$
307 }
308 }
309 }
310
311 /**
312 * Common implementation of ITmfTimeScaleSelectionListener, not used by all
313 * the views extending this abstract class
314 *
315 * @param event
316 */
317 protected void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event) {
318 // source needed to keep track of source values
319 Object source = event.getSource();
320
321 boolean newParams = false;
322 TmfTimeRange trange = null;
323 Long selectedTime = null;
324
325 // update all information and get relevant data
326 synchronized (this) {
327 if (source != null) {
328 // Update the parameter updater before carrying out a read request
329 ParamsUpdater paramUpdater = getParamsUpdater();
330 newParams = paramUpdater.processTimeScaleEvent(event);
331
332 if (newParams) {
333 // Read the updated time window
334 trange = paramUpdater.getTrange();
335 if (trange != null) {
336 selectedTime = paramUpdater.getSelectedTime();
337 }
338 }
339 }
340 }
341
342 // Check for selectedTime is sufficient since it is only set if
343 // newParams is true and trange is not null
344 if (selectedTime != null) {
345 // Notify listener views. to perform data requests
346 // upon this notification
347
348 // Note that this has to be done outside the synchronized statement
349 // because otherwise we could end-up in a deadlock if a ongoing
350 // request needs to be canceled.
351 synchTimeRangeNotification(trange, selectedTime, source);
352 }
353 }
354
355 /**
356 * Inform registered listeners about the new time range
357 *
358 * @param trange
359 * @param selectedTime
360 * @param source
361 */
362 protected void synchTimeRangeNotification(TmfTimeRange trange, Long selectedTime, Object source) {
363 // if synchronisation selected
364 if (synch) {
365 // Notify other views
366 TmfSignalManager.dispatchSignal(new TmfRangeSynchSignal(source, trange, new LttngTimestamp(selectedTime)));
367 }
368 }
369
370 /**
371 * @param zoomedTRange
372 * @param experimentTRange
373 * @param clearingData
374 * @param execType
375 */
376 public void eventRequest(TmfTimeRange zoomedTRange, TmfTimeRange experimentTRange, boolean clearingData, ExecutionType execType) {
377
378 // timeRange is the Experiment time range
379 boolean sent = processDataRequest(zoomedTRange, experimentTRange, DEFAULT_OFFSET, TmfDataRequest.ALL_DATA, clearingData, execType);
380
381 if (sent) {
382 waitCursor(true);
383 }
384 }
385
386 /**
387 * @param offset
388 * @param nbRequested
389 * @param startTime
390 * @param clearingData
391 * @param execType
392 */
393 public void eventRequest(long offset, TmfTimeRange range, boolean clearingData, ExecutionType execType) {
394
395 // timeRange is the Experiment time range
396 boolean sent = processDataRequest(range, null, offset, TmfDataRequest.ALL_DATA, clearingData, execType);
397
398 if (sent) {
399 waitCursor(true);
400 }
401 }
402
403 // /**
404 // * @param zoomedTRange
405 // * @param experimentTRange
406 // * @param execType
407 // */
408 // public void dataRequest(TmfTimeRange zoomedTRange,
409 // TmfTimeRange experimentTRange, boolean clearingData) {
410 //
411 // // timeRange is the Experiment time range
412 // boolean sent = processDataRequest(zoomedTRange, experimentTRange, clearingData);
413 //
414 // if (sent) {
415 // waitCursor(true);
416 // }
417 // }
418
419 /**
420 * send data request directly e.g. doesn't use a queue
421 *
422 * @param requestTrange
423 * @param listener
424 * @param experimentTRange
425 * @param execType
426 * @param processor
427 * @return
428 */
429 private boolean processDataRequest(TmfTimeRange requestTrange,
430 TmfTimeRange experimentTRange, long offset, int nbRequested, boolean clearingData, ExecutionType execType) {
431 // Validate input
432 if (requestTrange == null) {
433 TraceDebug.debug("Invalid input"); //$NON-NLS-1$
434 return false;
435 }
436
437 // Cancel the currently executing request before starting a new one
438 fProvider.conditionallyCancelRequests();
439 fCurrentRequest = new LttngSyntEventRequest(
440 requestTrange, offset, nbRequested,
441 LttngConstants.DEFAULT_BLOCK_SIZE, this, experimentTRange, getEventProcessor(),
442 TmfExperiment.getCurrentExperiment().getName(), execType) {
443
444 Long fCount = getSynEventCount();
445 ITransEventProcessor processor = getProcessor();
446 TmfTimestamp frunningTimeStamp;
447
448 /*
449 * (non-Javadoc)
450 *
451 * @see
452 * org.eclipse.linuxtools.lttng.request.LttngSyntEventRequest#handleData
453 * ()
454 */
455 //// int handleDataCount = 0;
456 //// int handleDataValidCount = 0;
457 // @Override
458 // public void handleData() {
459 // LttngSyntheticEvent[] result = getData();
460 //
461 // TmfEvent evt = (result.length > 0) ? result[0] : null;
462 //// handleDataCount++;
463
464 @Override
465 public void handleData(LttngSyntheticEvent event) {
466 super.handleData(event);
467 if (event != null) {
468 // handleDataValidCount++;
469 LttngSyntheticEvent synEvent = (LttngSyntheticEvent) event;
470 // process event
471 switch (synEvent.getSynType()) {
472
473 case STARTREQ: {
474 handleRequestStarted();
475 break;
476 }
477
478 case BEFORE: {
479 processor.process(event, synEvent.getTraceModel());
480 fCount++;
481 if ((fCount != 0) && (fCount % getInputChangedRefresh() == 0)) {
482 // send partial update
483 modelInputChanged(this, false);
484
485 if (TraceDebug.isDEBUG()) {
486 frunningTimeStamp = event.getTimestamp();
487 TraceDebug.debug("handled: " + fCount + " sequence: " + synEvent.getSynType()); //$NON-NLS-1$ //$NON-NLS-2$
488 }
489 }
490 break;
491 }
492
493 case AFTER:
494 // fall-through
495 case ENDREQ:{
496 processor.process(event, synEvent.getTraceModel());
497 break;
498 }
499
500 default:
501 // nothing to do
502 break;
503 }
504 }
505 }
506
507 public void handleRequestStarted() {
508 notifyStarting();
509 }
510
511 @Override
512 public void done() {
513 // if (TraceDebug.isDEBUG()) {
514 // TraceDebug.debug("AbsTimeUpdateView: Received=" + handleDataCount + ", Valid=" + handleDataCount + ", fCount=" + fCount);
515 // }
516 super.done();
517 }
518
519 @Override
520 public void handleCompleted() {
521 super.handleCompleted();
522
523 // Data is not complete and should be handled as such
524 if (isFailed() || isCancelled()) {
525 modelIncomplete(this);
526 }
527
528 if (TraceDebug.isDEBUG()) {
529 if (frunningTimeStamp != null) {
530 TraceDebug.debug("Last event time stamp: " + frunningTimeStamp.getValue()); //$NON-NLS-1$
531 }
532 }
533 }
534 };
535
536 // send the request to TMF
537 fCurrentRequest.startRequestInd(fProvider);
538 fCurrentRequest.setclearDataInd(clearingData);
539 return true;
540 }
541
542 /**
543 * Returns an initial smaller window to allow the user to select the area of
544 * interest
545 *
546 * @param experimentTRange
547 * @return
548 */
549 protected TmfTimeRange getInitTRange(TmfTimeRange experimentTRange) {
550 TmfTimestamp expStartTime = experimentTRange.getStartTime();
551 TmfTimestamp expEndTime = experimentTRange.getEndTime();
552 TmfTimestamp initialEndOfWindow = new LttngTimestamp(expStartTime
553 .getValue()
554 + INITIAL_WINDOW_OFFSET);
555 if (initialEndOfWindow.compareTo(expEndTime, false) < 0) {
556 return new TmfTimeRange(expStartTime, initialEndOfWindow);
557 }
558
559 // The original size of the experiment is smaller than proposed adjusted
560 // time
561 return experimentTRange;
562 }
563
564 /**
565 * Request the Time Analysis widget to enable or disable the wait cursor
566 * e.g. data request in progress or data request completed
567 *
568 * @param waitInd
569 */
570 protected void waitCursor(final boolean waitInd) {
571 if ((tsfviewer != null) && (!tsfviewer.getControl().isDisposed())) {
572 Display display = tsfviewer.getControl().getDisplay();
573
574 // Perform the updates on the UI thread
575 display.asyncExec(new Runnable() {
576 @Override
577 public void run() {
578 if ((tsfviewer != null) && (!tsfviewer.getControl().isDisposed())) {
579 tsfviewer.waitCursor(waitInd);
580 }
581 }
582 });
583 }
584 }
585
586 /**
587 * View preparation to override the current local information
588 *
589 * @param timeRange
590 * - new total time range e.g. Experiment level
591 * @param clearAllData
592 */
593 protected void ModelUpdatePrep(TmfTimeRange timeRange, boolean clearAllData) {
594 ItemContainer<?> itemContainer = getItemContainer();
595 if (clearAllData) {
596 // start fresh e.g. new experiment selected
597 itemContainer.clearItems();
598 } else {
599 // clear children but keep processes
600 itemContainer.clearChildren();
601 }
602
603 // Obtain the current resource array
604 ITmfTimeAnalysisEntry[] itemArr = itemContainer.readItems();
605
606 // clean up data and boundaries
607 displayModel(itemArr, -1, -1, false, -1, -1, null);
608
609 ParamsUpdater updater = getParamsUpdater();
610 if (updater != null) {
611 // Start over
612 updater.setEventsDiscarded(0);
613
614 // Update new visible time range if available
615 if (timeRange != null) {
616 updater.update(timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue());
617 }
618 }
619 }
620
621 /**
622 * Initialize the model and view before reloading items
623 *
624 * @param boundaryRange
625 * @param visibleRange
626 * @param source
627 */
628 protected void ModelUpdateInit(TmfTimeRange boundaryRange, TmfTimeRange visibleRange, Object source) {
629 // Update the view boundaries
630 if (boundaryRange != null) {
631 ItemContainer<?> itemContainer = getItemContainer();
632 if (itemContainer != null) {
633 itemContainer.clearItems();
634 // Obtain the current process array
635 ITmfTimeAnalysisEntry[] itemArr = itemContainer.readItems();
636
637 long startTime = boundaryRange.getStartTime().getValue();
638 long endTime = boundaryRange.getEndTime().getValue();
639
640 // Update the view part
641 displayModel(itemArr, startTime, endTime, true, visibleRange.getStartTime().getValue(), visibleRange
642 .getEndTime().getValue(), source);
643 }
644 }
645
646 // update the view filtering parameters
647 if (visibleRange != null) {
648 ParamsUpdater updater = getParamsUpdater();
649 if (updater != null) {
650 // Start over
651 updater.setEventsDiscarded(0);
652 // Update new visible time range if available
653 updater.update(visibleRange.getStartTime().getValue(), visibleRange.getEndTime().getValue());
654 }
655 }
656 }
657
658 /**
659 * Actions taken by the view to refresh its widget(s) with the updated data
660 * model
661 *
662 * @param request
663 * @param complete
664 * true: yes, false: partial update
665 */
666 @SuppressWarnings("deprecation")
667 protected void modelInputChanged(ILttngSyntEventRequest request, boolean complete) {
668 long experimentStartTime = -1;
669 long experimentEndTime = -1;
670 TmfTimeRange experimentTimeRange = request.getExperimentTimeRange();
671 if (experimentTimeRange != null) {
672 experimentStartTime = experimentTimeRange.getStartTime().getValue();
673 experimentEndTime = experimentTimeRange.getEndTime().getValue();
674 }
675
676 // Obtain the current resource list
677 ITmfTimeAnalysisEntry[] itemArr = getItemContainer().readItems();
678
679 if (itemArr != null) {
680 // Sort the array by pid
681 Arrays.sort(itemArr);
682
683 // Update the view part
684 displayModel(itemArr, experimentStartTime, experimentEndTime, false, request.getRange().getStartTime()
685 .getValue(), request.getRange().getEndTime().getValue(), request.getSource());
686 }
687
688 if (complete) {
689 // reselect to original time
690 ParamsUpdater paramUpdater = getParamsUpdater();
691 if ((paramUpdater != null) && (tsfviewer != null) && (!tsfviewer.getControl().isDisposed())) {
692 final Long selTime = paramUpdater.getSelectedTime();
693 if (selTime != null) {
694 TraceDebug.debug("View: " + getName() + "\n\t\tRestoring the selected time to: " + selTime); //$NON-NLS-1$ //$NON-NLS-2$
695 Display display = tsfviewer.getControl().getDisplay();
696 display.asyncExec(new Runnable() {
697 @Override
698 public void run() {
699 if ((tsfviewer != null) && (!tsfviewer.getControl().isDisposed())) {
700 tsfviewer.setSelectedTime(selTime, false, this);
701 }
702 }
703 });
704 }
705
706 // System.out.println(System.currentTimeMillis() + ": AbsTimeUpdate (" + getName() + ") completed");
707
708 if (TraceDebug.isDEBUG()) {
709 int eventCount = 0;
710 Long count = request.getSynEventCount();
711 for (int pos = 0; pos < itemArr.length; pos++) {
712 eventCount += itemArr[pos].getTraceEvents().size();
713 }
714
715 int discarded = paramUpdater.getEventsDiscarded();
716 int discardedOutofOrder = paramUpdater.getEventsDiscardedWrongOrder();
717 int discardedOutofViewRange = paramUpdater.getEventsDiscardedOutOfViewRange();
718 int dicardedNotVisible = paramUpdater.getEventsDiscardedNotVisible();
719
720 TmfTimeRange range = request.getRange();
721 StringBuilder sb = new StringBuilder("View: " + getName() + ", Events handled: " + count //$NON-NLS-1$ //$NON-NLS-2$
722 + ", Events loaded in view: " + eventCount + ", Number of events discarded: " + discarded //$NON-NLS-1$ //$NON-NLS-2$
723 + "\n\tNumber of events discarded with start time earlier than next good time: " //$NON-NLS-1$
724 + discardedOutofOrder + "\n\tDiscarded Not visible: " + dicardedNotVisible //$NON-NLS-1$
725 + "\n\tDiscarded out of view Range: " + discardedOutofViewRange); //$NON-NLS-1$
726
727 sb.append("\n\t\tRequested Time Range: " + range.getStartTime() + "-" + range.getEndTime()); //$NON-NLS-1$ //$NON-NLS-2$
728 sb.append("\n\t\tExperiment Time Range: " + experimentStartTime + "-" + experimentEndTime); //$NON-NLS-1$ //$NON-NLS-2$
729 TraceDebug.debug(sb.toString());
730 }
731 }
732
733 }
734 }
735
736 // /**
737 // * Obtains the remainder fraction on unit Seconds of the entered value in
738 // * nanoseconds. e.g. input: 1241207054171080214 ns The number of seconds
739 // can
740 // * be obtain by removing the last 9 digits: 1241207054 the fractional
741 // * portion of seconds, expressed in ns is: 171080214
742 // *
743 // * @param v
744 // * @return
745 // */
746 // protected String formatNs(long v) {
747 // StringBuffer str = new StringBuffer();
748 // boolean neg = v < 0;
749 // if (neg) {
750 // v = -v;
751 // str.append('-');
752 // }
753 //
754 // String strVal = String.valueOf(v);
755 // if (v < 1000000000) {
756 // return strVal;
757 // }
758 //
759 // // Extract the last nine digits (e.g. fraction of a S expressed in ns
760 // return strVal.substring(strVal.length() - 9);
761 // }
762
763 /**
764 * The request was stopped, the data is incomplete
765 *
766 * @param request
767 */
768 protected abstract void modelIncomplete(ILttngSyntEventRequest request);
769
770 /**
771 * Returns the Event processor instance related to a specific view
772 *
773 * @return
774 */
775 protected abstract ITransEventProcessor getEventProcessor();
776
777 /**
778 * To be overridden by some sub-classes although may not be needed in some
779 * e.g. statistics view
780 *
781 * @param items
782 * @param startBoundTime
783 * @param endBoundTime
784 * @param updateTimeBounds
785 * - Time bounds updated needed e.g. if a new Experiment or trace
786 * is selected
787 * @param startVisibleWindow
788 * @param endVisibleWindow
789 * @param source
790 */
791 protected abstract void displayModel(final ITmfTimeAnalysisEntry[] items, final long startBoundTime,
792 final long endBoundTime, final boolean updateTimeBounds, final long startVisibleWindow,
793 final long endVisibleWindow, final Object source);
794
795 /**
796 * To be overridden by some sub-classes although may not be needed in some
797 * e.g. statistics view
798 *
799 * @return
800 */
801 protected abstract ParamsUpdater getParamsUpdater();
802
803 /**
804 * Returns the model's item container
805 *
806 * @return
807 */
808 protected abstract ItemContainer<?> getItemContainer();
809
810 /**
811 * Returns LTTng Synthetic Provider ID used for current view
812 *
813 * @return
814 */
815 protected abstract int getProviderId();
816 }
This page took 0.103996 seconds and 5 git commands to generate.