1 /*******************************************************************************
2 * Copyright (c) 2009 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 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.common
;
14 import org
.eclipse
.linuxtools
.lttng
.state
.IStateDataRequestListener
;
15 import org
.eclipse
.linuxtools
.lttng
.state
.RequestCompletedSignal
;
16 import org
.eclipse
.linuxtools
.lttng
.state
.RequestStartedSignal
;
17 import org
.eclipse
.linuxtools
.lttng
.state
.StateDataRequest
;
18 import org
.eclipse
.linuxtools
.lttng
.state
.StateManager
;
19 import org
.eclipse
.linuxtools
.lttng
.state
.experiment
.StateManagerFactory
;
20 import org
.eclipse
.linuxtools
.lttng
.ui
.TraceDebug
;
21 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
22 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfSignalHandler
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.TmfView
;
27 * Abstract class used as a base for views handling specific time range data
31 * The class handles a single element queue of data requests, and a list of
32 * requests in progress i.e. request can be triggered from different sources
33 * e.g. opening a file as well as a new selected time window
39 public abstract class AbsTimeUpdateView
extends TmfView
implements
40 IStateDataRequestListener
{
42 // ========================================================================
44 // ========================================================================
45 private DataRequestQueue reqState
= UiCommonFactory
.getQueue();
46 private String viewID
= "";
48 // ========================================================================
50 // ========================================================================
51 public AbsTimeUpdateView(String viewID
) {
55 // ========================================================================
57 // ========================================================================
61 * @seeorg.eclipse.linuxtools.lttng.state.IStateDataRequestListener#
62 * processingStarted(org.eclipse.linuxtools.lttng.state.StateDataRequest)
65 public synchronized void processingStarted(RequestStartedSignal signal
) {
66 StateDataRequest request
= signal
.getRequest();
67 if (request
!= null) {
68 // update queue with the id of the current request.
69 reqState
.requestStarted(request
);
70 // if there was no new request then this one is still on
71 // prepare for the reception of new data
75 StateManager smanager
= request
.getStateManager();
76 // Clear the children on the Processes related to this
78 // Leave the GUI in charge of the updated data.
79 String traceId
= smanager
.getEventLog().getName();
81 // indicate if the data model needs to be cleared e.g. a new
82 // experiment is being selected
83 boolean clearData
= request
.isclearDataInd();
84 // no new time range for zoom orders
85 TmfTimeRange trange
= null;
87 // Time Range will be used to filter out events which are
88 // not visible in one pixel
89 trange
= StateManagerFactory
.getExperimentManager()
90 .getExperimentTimeRange();
93 // Indicate if current data needs to be cleared and if so
94 // specify the new experiment time range that applies
95 ModelUpdatePrep(traceId
, clearData
, trange
);
102 * @seeorg.eclipse.linuxtools.lttng.state.IStateDataRequestListener#
103 * processingCompleted(org.eclipse.linuxtools.lttng.state.StateDataRequest)
106 public synchronized void processingCompleted(RequestCompletedSignal signal
) {
107 StateDataRequest request
= signal
.getRequest();
109 if (request
== null) {
112 reqState
.requestCompleted(request
);
116 // Update wait cursor
117 requestStateUpdate();
118 // No data refresh actions for cancelled requests.
119 if (request
.isCancelled() || request
.isFailed()) {
120 if (TraceDebug
.isDEBUG()) {
121 TmfTimeRange trange
= request
.getRange();
122 if (request
.isCancelled()) {
123 TraceDebug
.debug("Request cancelled "
124 + trange
.getStartTime() + "-" + trange
.getEndTime()
125 + " Handled Events: " + request
.getNumOfEvents());
126 } else if (request
.isFailed()) {
127 TraceDebug
.debug("Request Failed " + trange
.getStartTime()
128 + "-" + trange
.getEndTime() + " Handled Events: "
129 + request
.getNumOfEvents());
135 ModelUpdateComplete(request
);
140 * Evaluates the need to either send a new data request or queue the request
141 * till next available opportunity. One element queue to keep the latest
146 public synchronized void dataRequest(TmfTimeRange trange
) {
147 boolean sent
= reqState
.processDataRequest(trange
, viewID
, this);
155 * Disable the wait cursor if the state is back to idle
157 private synchronized void requestStateUpdate() {
158 // disable the wait cursor if the state is back to idle
159 if (reqState
.isIdle()) {
160 // no more in the queue
166 * Request the Time Analysis widget to enable or disable the wait cursor
167 * e.g. data request in progress or data request completed
171 protected abstract void waitCursor(boolean waitInd
);
174 * View preparation to override the current local information related to the
178 * @param clearAllData
179 * - reset all data e.g when a new experiment is selected
181 * - new total time range e.g. Experiment level
183 public abstract void ModelUpdatePrep(String traceId
, boolean clearAllData
,
184 TmfTimeRange timeRange
);
187 * Actions taken by the view to refresh its widget(s) with the updated data
192 public abstract void ModelUpdateComplete(StateDataRequest request
);