1 /*******************************************************************************
2 * Copyright (c) 2012, 2014 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 * Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and implementation
11 * Alexandre Montplaisir - Port to ITmfStatistics provider
12 * Patrick Tasse - Support selection range
13 *******************************************************************************/
15 package org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.statistics
;
17 import java
.util
.HashMap
;
18 import java
.util
.List
;
21 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
22 import org
.eclipse
.core
.runtime
.IStatus
;
23 import org
.eclipse
.core
.runtime
.Status
;
24 import org
.eclipse
.core
.runtime
.jobs
.Job
;
25 import org
.eclipse
.jface
.viewers
.TreeViewer
;
26 import org
.eclipse
.jface
.viewers
.TreeViewerColumn
;
27 import org
.eclipse
.jface
.viewers
.Viewer
;
28 import org
.eclipse
.jface
.viewers
.ViewerComparator
;
29 import org
.eclipse
.swt
.SWT
;
30 import org
.eclipse
.swt
.events
.SelectionAdapter
;
31 import org
.eclipse
.swt
.events
.SelectionEvent
;
32 import org
.eclipse
.swt
.graphics
.Color
;
33 import org
.eclipse
.swt
.graphics
.Cursor
;
34 import org
.eclipse
.swt
.widgets
.Composite
;
35 import org
.eclipse
.swt
.widgets
.Control
;
36 import org
.eclipse
.swt
.widgets
.Display
;
37 import org
.eclipse
.swt
.widgets
.Event
;
38 import org
.eclipse
.swt
.widgets
.Listener
;
39 import org
.eclipse
.tracecompass
.statesystem
.core
.ITmfStateSystem
;
40 import org
.eclipse
.tracecompass
.tmf
.core
.component
.TmfComponent
;
41 import org
.eclipse
.tracecompass
.tmf
.core
.request
.ITmfEventRequest
;
42 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSignalHandler
;
43 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTimeSynchSignal
;
44 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceRangeUpdatedSignal
;
45 import org
.eclipse
.tracecompass
.tmf
.core
.statistics
.ITmfStatistics
;
46 import org
.eclipse
.tracecompass
.tmf
.core
.statistics
.TmfStatisticsEventTypesModule
;
47 import org
.eclipse
.tracecompass
.tmf
.core
.statistics
.TmfStatisticsModule
;
48 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
49 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
50 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
51 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfExperiment
;
52 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
53 import org
.eclipse
.tracecompass
.tmf
.ui
.TmfUiRefreshHandler
;
54 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.TmfViewer
;
55 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.statistics
.model
.TmfBaseColumnData
;
56 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.statistics
.model
.TmfBaseColumnDataProvider
;
57 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.statistics
.model
.TmfStatisticsFormatter
;
58 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.statistics
.model
.TmfStatisticsTree
;
59 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.statistics
.model
.TmfStatisticsTreeManager
;
60 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.statistics
.model
.TmfStatisticsTreeNode
;
61 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.statistics
.model
.TmfTreeContentProvider
;
64 * A basic viewer to display statistics in the statistics view.
66 * It is linked to a single ITmfTrace until its disposal.
68 * @author Mathieu Denis
71 public class TmfStatisticsViewer
extends TmfViewer
{
73 /** Timestamp scale used for all statistics (nanosecond) */
74 private static final byte TIME_SCALE
= ITmfTimestamp
.NANOSECOND_SCALE
;
76 /** The delay (in ms) between each update in live-reading mode */
77 private static final long LIVE_UPDATE_DELAY
= 1000;
79 /** The actual tree viewer to display */
80 private TreeViewer fTreeViewer
;
82 /** The statistics tree linked to this viewer */
83 private TmfStatisticsTree fStatisticsData
;
85 /** Update range synchronization object */
86 private final Object fStatisticsRangeUpdateSyncObj
= new Object();
88 /** The trace that is displayed by this viewer */
89 private ITmfTrace fTrace
;
91 /** Indicates to process all events */
92 private boolean fProcessAll
;
94 /** View instance counter (for multiple statistics views) */
95 private static int fCountInstance
= 0;
97 /** Number of this instance. Used as an instance ID. */
98 private int fInstanceNb
;
100 /** Object to store the cursor while waiting for the trace to load */
101 private Cursor fWaitCursor
= null;
104 * Counts the number of times waitCursor() has been called. It avoids
105 * removing the waiting cursor, since there may be multiple requests running
108 private int fWaitCursorCount
= 0;
110 /** Tells to send a time range request when the trace gets updated. */
111 private boolean fSendRangeRequest
= true;
113 /** Reference to the trace manager */
114 private final TmfTraceManager fTraceManager
;
116 private final Map
<ITmfTrace
, Job
> fUpdateJobsPartial
= new HashMap
<>();
117 private final Map
<ITmfTrace
, Job
> fUpdateJobsGlobal
= new HashMap
<>();
119 private TmfTimeRange fTimeRange
;
121 private TmfTimeRange fTimeRangePartial
;
124 * Create a basic statistics viewer. To be used in conjunction with
125 * {@link TmfStatisticsViewer#init(Composite, String, ITmfTrace)}
128 * The parent composite that will hold the viewer
130 * The name that will be assigned to this viewer
132 * The trace that is displayed by this viewer
135 public TmfStatisticsViewer(Composite parent
, String viewerName
, ITmfTrace trace
) {
136 init(parent
, viewerName
, trace
);
137 fTraceManager
= TmfTraceManager
.getInstance();
141 * Initialize the statistics viewer.
144 * The parent component of the viewer.
146 * The name to give to the viewer.
148 * The trace that will be displayed by the viewer.
150 public void init(Composite parent
, String viewerName
, ITmfTrace trace
) {
151 super.init(parent
, viewerName
);
152 // Increment a counter to make sure the tree ID is unique.
154 fInstanceNb
= fCountInstance
;
157 // The viewer will process all events if he is assigned to an experiment
158 fProcessAll
= (trace
instanceof TmfExperiment
);
165 public void dispose() {
167 if (fWaitCursor
!= null) {
168 fWaitCursor
.dispose();
171 for (Job j
: fUpdateJobsGlobal
.values()) {
175 for (Job j
: fUpdateJobsPartial
.values()) {
179 // Clean the model for this viewer
180 TmfStatisticsTreeManager
.removeStatTreeRoot(getTreeID());
183 // ------------------------------------------------------------------------
185 // ------------------------------------------------------------------------
188 * Handles the signal about new trace range.
191 * The trace range updated signal
194 public void traceRangeUpdated(TmfTraceRangeUpdatedSignal signal
) {
195 ITmfTrace trace
= signal
.getTrace();
197 if (!isListeningTo(trace
)) {
201 synchronized (fStatisticsRangeUpdateSyncObj
) {
202 // Sends the time range request only once from this method.
203 if (fSendRangeRequest
) {
204 fSendRangeRequest
= false;
205 ITmfTimestamp begin
= fTraceManager
.getSelectionBeginTime();
206 ITmfTimestamp end
= fTraceManager
.getSelectionEndTime();
207 TmfTimeRange timeRange
= new TmfTimeRange(begin
, end
);
208 requestTimeRangeData(trace
, timeRange
);
211 requestData(trace
, signal
.getRange());
215 * Handles the time synch updated signal. It updates the time range
219 * Contains the information about the new selected time range.
223 public void timeSynchUpdated(TmfTimeSynchSignal signal
) {
224 if (fTrace
== null) {
227 ITmfTimestamp begin
= signal
.getBeginTime();
228 ITmfTimestamp end
= signal
.getEndTime();
229 TmfTimeRange timeRange
= new TmfTimeRange(begin
, end
);
230 requestTimeRangeData(fTrace
, timeRange
);
233 // ------------------------------------------------------------------------
235 // ------------------------------------------------------------------------
238 * Returns the primary control associated with this viewer.
240 * @return the SWT control which displays this viewer's content
243 public Control
getControl() {
244 return fTreeViewer
.getControl();
248 * Get the input of the viewer.
250 * @return an object representing the input of the statistics viewer.
252 public Object
getInput() {
253 return fTreeViewer
.getInput();
257 * This method can be overridden to implement another way of representing
258 * the statistics data and to retrieve the information for display.
260 * @return a TmfStatisticsData object.
262 public TmfStatisticsTree
getStatisticData() {
263 if (fStatisticsData
== null) {
264 fStatisticsData
= new TmfStatisticsTree();
266 return fStatisticsData
;
270 * Returns a unique ID based on name to be associated with the statistics
271 * tree for this viewer. For a same name, it will always return the same ID.
273 * @return a unique statistics tree ID.
275 public String
getTreeID() {
276 return getName() + fInstanceNb
;
280 public void refresh() {
281 final Control viewerControl
= getControl();
282 // Ignore update if disposed
283 if (viewerControl
.isDisposed()) {
287 TmfUiRefreshHandler
.getInstance().queueUpdate(this, new Runnable() {
290 if (!viewerControl
.isDisposed()) {
291 fTreeViewer
.refresh();
298 * Will force a request on the partial event count if one is needed.
300 public void sendPartialRequestOnNextUpdate() {
301 synchronized (fStatisticsRangeUpdateSyncObj
) {
302 fSendRangeRequest
= true;
307 * Focus on the statistics tree of the viewer
309 public void setFocus() {
310 fTreeViewer
.getTree().setFocus();
314 * Cancels the request if it is not already completed
317 * The request to be canceled
320 protected void cancelOngoingRequest(ITmfEventRequest request
) {
321 if (request
!= null && !request
.isCompleted()) {
327 * This method can be overridden to change the representation of the data in
330 * @return An object of type {@link TmfBaseColumnDataProvider}.
333 protected TmfBaseColumnDataProvider
getColumnDataProvider() {
334 return new TmfBaseColumnDataProvider();
338 * Initialize the content that will be drawn in this viewer
341 * The parent of the control to create
343 protected void initContent(Composite parent
) {
344 final List
<TmfBaseColumnData
> columnDataList
= getColumnDataProvider().getColumnData();
346 fTreeViewer
= new TreeViewer(parent
, SWT
.BORDER
| SWT
.H_SCROLL
| SWT
.V_SCROLL
);
347 fTreeViewer
.setContentProvider(new TmfTreeContentProvider());
348 fTreeViewer
.getTree().setHeaderVisible(true);
349 fTreeViewer
.setUseHashlookup(true);
351 // Creates the columns defined by the column data provider
352 for (final TmfBaseColumnData columnData
: columnDataList
) {
353 final TreeViewerColumn treeColumn
= new TreeViewerColumn(fTreeViewer
, columnData
.getAlignment());
354 treeColumn
.getColumn().setText(columnData
.getHeader());
355 treeColumn
.getColumn().setWidth(columnData
.getWidth());
356 treeColumn
.getColumn().setToolTipText(columnData
.getTooltip());
358 // If is dummy column
359 if (columnData
== columnDataList
.get(TmfBaseColumnDataProvider
.StatsColumn
.DUMMY
.getIndex())) {
360 treeColumn
.getColumn().setResizable(false);
363 // A comparator is defined.
364 if (columnData
.getComparator() != null) {
365 // Adds a listener on the columns header for sorting purpose.
366 treeColumn
.getColumn().addSelectionListener(new SelectionAdapter() {
368 private ViewerComparator reverseComparator
;
371 public void widgetSelected(SelectionEvent e
) {
372 // Initializes the reverse comparator once.
373 if (reverseComparator
== null) {
374 reverseComparator
= new ViewerComparator() {
376 public int compare(Viewer viewer
, Object e1
, Object e2
) {
377 return -1 * columnData
.getComparator().compare(viewer
, e1
, e2
);
382 if (fTreeViewer
.getTree().getSortDirection() == SWT
.UP
383 || fTreeViewer
.getTree().getSortColumn() != treeColumn
.getColumn()) {
385 * Puts the descendant order if the old order was up
386 * or if the selected column has changed.
388 fTreeViewer
.setComparator(columnData
.getComparator());
389 fTreeViewer
.getTree().setSortDirection(SWT
.DOWN
);
392 * Puts the ascendant ordering if the selected
393 * column hasn't changed.
395 fTreeViewer
.setComparator(reverseComparator
);
396 fTreeViewer
.getTree().setSortDirection(SWT
.UP
);
398 fTreeViewer
.getTree().setSortColumn(treeColumn
.getColumn());
402 treeColumn
.setLabelProvider(columnData
.getLabelProvider());
405 // Handler that will draw the percentages and the bar charts.
406 fTreeViewer
.getTree().addListener(SWT
.EraseItem
, new Listener() {
408 public void handleEvent(Event event
) {
409 if (columnDataList
.get(event
.index
).getPercentageProvider() != null) {
411 TmfStatisticsTreeNode node
= (TmfStatisticsTreeNode
) event
.item
.getData();
413 // If node is hidden, exit immediately.
414 if (TmfBaseColumnDataProvider
.HIDDEN_FOLDER_LEVELS
.contains(node
.getName())) {
418 // Otherwise, get percentage and draw bar and text if applicable.
419 double percentage
= columnDataList
.get(event
.index
).getPercentageProvider().getPercentage(node
);
421 // The item is selected.
422 if ((event
.detail
& SWT
.SELECTED
) > 0) {
423 // Draws our own background to avoid overwriting the bar.
424 event
.gc
.fillRectangle(event
.x
, event
.y
, event
.width
, event
.height
);
425 event
.detail
&= ~SWT
.SELECTED
;
428 // Drawing the percentage text
429 // if events are present in top node
430 // and the current node is not the top node
431 // and if is total or partial events column.
432 // If not, exit the method.
433 if (!((event
.index
== TmfBaseColumnDataProvider
.StatsColumn
.TOTAL
.getIndex() || event
.index
== TmfBaseColumnDataProvider
.StatsColumn
.PARTIAL
.getIndex())
434 && node
!= node
.getTop())) {
438 long eventValue
= event
.index
== TmfBaseColumnDataProvider
.StatsColumn
.TOTAL
.getIndex() ?
439 node
.getTop().getValues().getTotal() : node
.getTop().getValues().getPartial();
441 if (eventValue
!= 0) {
443 int oldAlpha
= event
.gc
.getAlpha();
444 Color oldForeground
= event
.gc
.getForeground();
445 Color oldBackground
= event
.gc
.getBackground();
448 if (percentage
!= 0) {
450 * Draws a transparent gradient rectangle from the
451 * color of foreground and background.
453 int barWidth
= (int) ((fTreeViewer
.getTree().getColumn(event
.index
).getWidth() - 8) * percentage
);
454 event
.gc
.setAlpha(64);
455 event
.gc
.setForeground(event
.item
.getDisplay().getSystemColor(SWT
.COLOR_BLUE
));
456 event
.gc
.setBackground(event
.item
.getDisplay().getSystemColor(SWT
.COLOR_LIST_BACKGROUND
));
457 event
.gc
.fillGradientRectangle(event
.x
, event
.y
, barWidth
, event
.height
, true);
458 event
.gc
.drawRectangle(event
.x
, event
.y
, barWidth
, event
.height
);
460 // Restore old values
461 event
.gc
.setBackground(oldBackground
);
462 event
.gc
.setAlpha(oldAlpha
);
463 event
.detail
&= ~SWT
.BACKGROUND
;
467 String percentageText
= TmfStatisticsFormatter
.toPercentageText(percentage
);
468 String absoluteNumberText
= TmfStatisticsFormatter
.toColumnData(node
, TmfBaseColumnDataProvider
.StatsColumn
.getColumn(event
.index
));
470 if (event
.width
> event
.gc
.stringExtent(percentageText
).x
+ event
.gc
.stringExtent(absoluteNumberText
).x
) {
471 int textHeight
= event
.gc
.stringExtent(percentageText
).y
;
472 event
.gc
.setForeground(event
.item
.getDisplay().getSystemColor(SWT
.COLOR_DARK_GRAY
));
473 event
.gc
.drawText(percentageText
, event
.x
, event
.y
+ (event
.height
- textHeight
) / 2, true);
476 // Restores old values
477 event
.gc
.setForeground(oldForeground
);
485 // Initializes the comparator parameters
486 fTreeViewer
.setComparator(columnDataList
.get(0).getComparator());
487 fTreeViewer
.getTree().setSortColumn(fTreeViewer
.getTree().getColumn(0));
488 fTreeViewer
.getTree().setSortDirection(SWT
.DOWN
);
492 * Initializes the input for the tree viewer.
494 protected void initInput() {
495 String treeID
= getTreeID();
496 TmfStatisticsTreeNode statisticsTreeNode
;
497 if (TmfStatisticsTreeManager
.containsTreeRoot(treeID
)) {
498 // The statistics root is already present
499 statisticsTreeNode
= TmfStatisticsTreeManager
.getStatTreeRoot(treeID
);
501 // Checks if the trace is already in the statistics tree.
502 int numNodeTraces
= statisticsTreeNode
.getNbChildren();
504 ITmfTrace
[] traces
= TmfTraceManager
.getTraceSet(fTrace
);
505 int numTraces
= traces
.length
;
507 if (numTraces
== numNodeTraces
) {
510 * Checks if the experiment contains the same traces as when
511 * previously selected.
513 for (int i
= 0; i
< numTraces
; i
++) {
514 String traceName
= traces
[i
].getName();
515 if (!statisticsTreeNode
.containsChild(traceName
)) {
522 // No need to reload data, all traces are already loaded
523 fTreeViewer
.setInput(statisticsTreeNode
);
526 // Clears the old content to start over
527 statisticsTreeNode
.reset();
530 // Creates a new tree
531 statisticsTreeNode
= TmfStatisticsTreeManager
.addStatsTreeRoot(treeID
, getStatisticData());
534 // Sets the input to a clean data model
535 fTreeViewer
.setInput(statisticsTreeNode
);
539 * Tells if the viewer is listening to a trace.
542 * The trace that the viewer may be listening
543 * @return true if the viewer is listening to the trace, false otherwise
545 protected boolean isListeningTo(ITmfTrace trace
) {
546 if (fProcessAll
|| trace
== fTrace
) {
553 * Called when an trace request has been completed successfully.
556 * Tells if the request is a global or time range (partial)
559 protected void modelComplete(boolean global
) {
565 * Called when an trace request has failed or has been cancelled.
567 * @param isGlobalRequest
568 * Tells if the request is a global or time range (partial)
571 protected void modelIncomplete(boolean isGlobalRequest
) {
572 if (isGlobalRequest
) { // Clean the global statistics
574 * No need to reset the global number of events, since the index of
575 * the last requested event is known.
577 } else { // Clean the partial statistics
578 resetTimeRangeValue();
585 * Sends the request to the trace for the whole trace
588 * The trace used to send the request
590 * The range to request to the trace
592 protected void requestData(final ITmfTrace trace
, final TmfTimeRange timeRange
) {
593 buildStatisticsTree(trace
, timeRange
, true);
597 * Sends the time range request from the trace
600 * The trace used to send the request
602 * The range to request to the trace
604 protected void requestTimeRangeData(final ITmfTrace trace
, final TmfTimeRange timeRange
) {
605 buildStatisticsTree(trace
, timeRange
, false);
609 * Requests all the data of the trace to the state system which contains
610 * information about the statistics.
612 * Since the viewer may be listening to multiple traces, it may receive an
613 * experiment rather than a single trace. The filtering is done with the
614 * method {@link #isListeningTo(String trace)}.
617 * The trace for which a request must be done
619 * The time range that will be requested to the state system
621 * Tells if the request is for the global event count or the
624 private void buildStatisticsTree(final ITmfTrace trace
, final TmfTimeRange timeRange
, final boolean isGlobal
) {
625 final TmfStatisticsTree statsData
= TmfStatisticsTreeManager
.getStatTree(getTreeID());
626 if (statsData
== null) {
630 Map
<ITmfTrace
, Job
> updateJobs
;
632 updateJobs
= fUpdateJobsGlobal
;
633 fTimeRange
= timeRange
;
635 updateJobs
= fUpdateJobsPartial
;
636 fTimeRangePartial
= timeRange
;
639 for (final ITmfTrace aTrace
: TmfTraceManager
.getTraceSet(trace
)) {
640 if (!isListeningTo(aTrace
)) {
644 /* Retrieve the statistics object */
645 final TmfStatisticsModule statsMod
= aTrace
.getAnalysisModuleOfClass(TmfStatisticsModule
.class, TmfStatisticsModule
.ID
);
646 if (statsMod
== null) {
647 /* No statistics module available for this trace */
651 Job job
= updateJobs
.get(aTrace
);
653 job
= new UpdateJob("Statistics update", aTrace
, isGlobal
, statsMod
); //$NON-NLS-1$
654 updateJobs
.put(aTrace
, job
);
661 private class UpdateJob
extends Job
{
663 private final ITmfTrace fJobTrace
;
664 private final boolean fIsGlobal
;
665 private final TmfStatisticsModule fStatsMod
;
667 private UpdateJob(String name
, ITmfTrace trace
, boolean isGlobal
, TmfStatisticsModule statsMod
) {
670 fIsGlobal
= isGlobal
;
671 fStatsMod
= statsMod
;
675 protected IStatus
run(IProgressMonitor monitor
) {
677 /* Wait until the analysis is ready to be queried */
678 fStatsMod
.waitForInitialization();
679 ITmfStatistics stats
= fStatsMod
.getStatistics();
681 /* It should have worked, but didn't */
682 throw new IllegalStateException();
686 * TODO Eventually this could be exposed through the
687 * TmfStateSystemAnalysisModule directly.
689 ITmfStateSystem ss
= fStatsMod
.getStateSystem(TmfStatisticsEventTypesModule
.ID
);
691 /* It should be instantiated after the
692 * statsMod.waitForInitialization() above. */
693 throw new IllegalStateException();
698 * Periodically update the statistics while they are
699 * being built (or, if the back-end is already completely
700 * built, it will skip over the while() immediately.
704 boolean finished
= false;
706 if (monitor
.isCanceled()) {
707 return Status
.CANCEL_STATUS
;
709 finished
= ss
.waitUntilBuilt(LIVE_UPDATE_DELAY
);
711 TmfTimeRange localtimeRange
= fIsGlobal ? fTimeRange
: fTimeRangePartial
;
713 * The generic statistics are stored in nanoseconds, so
714 * we must make sure the time range is scaled correctly.
716 start
= localtimeRange
.getStartTime().normalize(0, TIME_SCALE
).getValue();
717 end
= localtimeRange
.getEndTime().normalize(0, TIME_SCALE
).getValue();
719 Map
<String
, Long
> map
= stats
.getEventTypesInRange(start
, end
);
723 /* Query one last time for the final values */
724 Map
<String
, Long
> map
= stats
.getEventTypesInRange(start
, end
);
727 return Status
.OK_STATUS
;
731 * Update statistics for a given trace
733 private void updateStats(Map
<String
, Long
> eventsPerType
) {
735 final TmfStatisticsTree statsData
= TmfStatisticsTreeManager
.getStatTree(getTreeID());
736 if (statsData
== null) {
737 /* The stat tree has been disposed, abort mission. */
741 Map
<String
, Long
> map
= eventsPerType
;
742 String name
= fJobTrace
.getName();
746 * "Global", "partial", "total", etc., it's all very confusing...
748 * The base view shows the total count for the trace and for
749 * each even types, organized in columns like this:
751 * | Global | Time range |
752 * trace name | A | B |
754 * <event 1> | C | D |
755 * <event 2> | ... | ... |
758 * Here, we called the cells like this:
761 * C : GlobalTypeCount(s)
762 * D : TimeRangeTypeCount(s)
765 /* Fill in an the event counts (either cells C or D) */
766 for (Map
.Entry
<String
, Long
> entry
: map
.entrySet()) {
767 statsData
.setTypeCount(name
, entry
.getKey(), fIsGlobal
, entry
.getValue());
771 * Calculate the totals (cell A or B, depending if isGlobal). We will
772 * use the results of the previous request instead of sending another
775 long globalTotal
= 0;
776 for (long val
: map
.values()) {
779 statsData
.setTotal(name
, fIsGlobal
, globalTotal
);
781 modelComplete(fIsGlobal
);
786 * Resets the number of events within the time range
788 protected void resetTimeRangeValue() {
789 TmfStatisticsTreeNode treeModelRoot
= TmfStatisticsTreeManager
.getStatTreeRoot(getTreeID());
790 if (treeModelRoot
!= null && treeModelRoot
.hasChildren()) {
791 treeModelRoot
.resetTimeRangeValue();
796 * When the trace is loading the cursor will be different so the user knows
797 * that the processing is not finished yet.
799 * Calls to this method are stacked.
801 * @param waitRequested
802 * Indicates if we need to show the waiting cursor, or the
805 protected void waitCursor(final boolean waitRequested
) {
806 if ((fTreeViewer
== null) || (fTreeViewer
.getTree().isDisposed())) {
810 boolean needsUpdate
= false;
811 Display display
= fTreeViewer
.getControl().getDisplay();
814 if (fWaitCursor
== null) { // The cursor hasn't been initialized yet
815 fWaitCursor
= new Cursor(display
, SWT
.CURSOR_WAIT
);
817 if (fWaitCursorCount
== 1) { // The cursor is not in waiting mode
821 if (fWaitCursorCount
> 0) { // The cursor is in waiting mode
823 if (fWaitCursorCount
== 0) { // No more reason to wait
824 // Put back the default cursor
831 // Performs the updates on the UI thread
832 display
.asyncExec(new Runnable() {
835 if ((fTreeViewer
!= null)
836 && (!fTreeViewer
.getTree().isDisposed())) {
837 Cursor cursor
= null; // indicates default
839 cursor
= fWaitCursor
;
841 fTreeViewer
.getControl().setCursor(cursor
);