1 /*******************************************************************************
2 * Copyright (c) 2011, 2012 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 implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.statistics
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimeRange
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.request
.TmfDataRequest
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.request
.TmfEventRequest
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfExperiment
;
20 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.statistics
.ITmfExtraEventInfo
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.statistics
.Messages
;
22 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.statistics
.TmfStatisticsViewer
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.statistics
.model
.AbsTmfStatisticsTree
;
24 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.statistics
.model
.TmfStatisticsTreeRootFactory
;
27 * Class for the TMF event requests specific to the statistics view.
30 class TmfStatisticsRequest
extends TmfEventRequest
{
33 * Reference to the statistics viewer that sent the request
35 private final TmfStatisticsView fSender
;
38 * The viewer that displays the statistics data
40 private TmfStatisticsViewer fViewer
;
43 * The experiment for which to send the request
45 private final TmfExperiment fExperiment
;
48 * Tells if the request is for the whole trace or for a smaller time range
50 private final boolean fGlobal
;
53 * The statistics tree that will be updated from the requested data
55 private final AbsTmfStatisticsTree fStatisticsData
;
61 * Sender of this request
63 * Experiment targeted by this request
65 * The target time range
69 * The priority of the request
71 * Is this for a global statistics request (true), or a partial
74 TmfStatisticsRequest(TmfStatisticsView sender
, TmfStatisticsViewer viewer
, TmfExperiment experiment
, TmfTimeRange range
, long index
, ExecutionType prio
, boolean global
) {
75 super(ITmfEvent
.class, range
, index
, TmfDataRequest
.ALL_DATA
, sender
.getIndexPageSize(), prio
);
76 String treeID
= viewer
.getTreeID(experiment
.getName());
80 fExperiment
= experiment
;
82 fStatisticsData
= TmfStatisticsTreeRootFactory
.getStatTree(treeID
);
86 public void handleData(ITmfEvent data
) {
87 super.handleData(data
);
89 final String traceName
= data
.getTrace().getName();
90 ITmfExtraEventInfo extraInfo
= new ITmfExtraEventInfo() {
92 public String
getTraceName() {
93 if (traceName
== null) {
94 return Messages
.TmfStatisticsView_UnknownTraceName
;
100 fStatisticsData
.registerEvent(data
, extraInfo
);
102 fStatisticsData
.registerEventInTimeRange(data
, extraInfo
);
104 fStatisticsData
.increase(data
, extraInfo
, 1);
106 if ((getNbRead() % fViewer
.getInputChangedRefresh()) == 0) {
107 fSender
.modelInputChanged(false);
113 public void handleSuccess() {
114 super.handleSuccess();
115 fSender
.modelInputChanged(true);
117 fViewer
.waitCursor(false);
122 public void handleFailure() {
123 super.handleFailure();
124 fSender
.modelIncomplete(fExperiment
.getName());
128 public void handleCancel() {
129 super.handleCancel();
131 * The global request can be cancelled when another experiment is
132 * selected, but a time range request can also be cancelled when there is
133 * a time range update, which means the model must not be deleted.
136 fSender
.modelIncomplete(fExperiment
.getName());