New generation of HistogramView : first draft of what will replace TimeFrameView
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / histogram / HistogramView.java
CommitLineData
6e512b93
ASL
1/*******************************************************************************
2 * Copyright (c) 2009 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:
b59134e1 10 * William Bourque - Initial API and implementation
6e512b93
ASL
11 *******************************************************************************/
12package org.eclipse.linuxtools.lttng.ui.views.histogram;
13
b59134e1
WB
14
15import org.eclipse.linuxtools.lttng.event.LttngEvent;
16import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
17import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
833a21aa 18import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
b59134e1
WB
19import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
20import org.eclipse.linuxtools.tmf.experiment.TmfExperimentSelectedSignal;
21import org.eclipse.linuxtools.tmf.experiment.TmfExperimentUpdatedSignal;
22import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
23import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
24import org.eclipse.linuxtools.tmf.ui.views.TmfView;
25import org.eclipse.swt.SWT;
6cf16d22 26import org.eclipse.swt.graphics.Font;
833a21aa 27import org.eclipse.swt.graphics.FontData;
b59134e1 28import org.eclipse.swt.layout.GridData;
252ae4bd 29import org.eclipse.swt.layout.GridLayout;
6e512b93 30import org.eclipse.swt.widgets.Composite;
6cf16d22 31import org.eclipse.swt.widgets.Label;
833a21aa 32import org.eclipse.swt.widgets.Text;
6e512b93 33
b59134e1 34public class HistogramView extends TmfView {
8035003b 35
62d1696a 36 public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.histogram";
b59134e1 37
ecfd1d41 38
833a21aa
WB
39 private static final boolean TEST_UI = true;
40
41
42 private static final int FULL_TRACE_CANVAS_HEIGHT = 25;
43 private static final int FULL_TRACE_BAR_WIDTH = 1;
44 private static final double FULL_TRACE_DIFFERENCE_TO_AVERAGE = 2.0;
45
46 private static final int SELECTED_WINDOW_CANVAS_WIDTH = 600;
47 private static final int SELECTED_WINDOW_CANVAS_HEIGHT = 75;
48 private static final int SELECTED_WINDOW_BAR_WIDTH = 1;
49 private static final double SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE = 10.0;
50
51 // For the two "events" label (Max and min number of events in the selection), we force a width
52 // This will prevent the control from moving horizontally if the number of events in the selection varies
53 private static final int NB_EVENTS_FIXED_WIDTH = 75;
54
55
56 // The "small font" height used to display time will be "default font" minus this constant
57 private static final int SMALL_FONT_MODIFIER = 2;
ecfd1d41
WB
58
59 // *** TODO ***
60 // This need to be changed as soon the framework implement a "window"
6cf16d22 61 private static long DEFAULT_WINDOW_SIZE = (1L * 1000000000);
ecfd1d41 62
833a21aa 63
ecfd1d41 64 private TmfExperiment<LttngEvent> lastUsedExperiment = null;
b59134e1
WB
65
66 private HistogramRequest dataBackgroundFullRequest = null;
378e7718 67 private ParentHistogramCanvas fullTraceCanvas = null;
b59134e1 68
ecfd1d41 69 private HistogramRequest selectedWindowRequest = null;
378e7718 70 private ChildrenHistogramCanvas selectedWindowCanvas = null;
b59134e1 71
6cf16d22 72
833a21aa
WB
73
74
75 private Text txtExperimentStartTime = null;
76 private Text txtExperimentStopTime = null;
77
78 private Text txtWindowStartTime = null;
79 private Text txtWindowStopTime = null;
80 private Label lblWindowMaxNbEvents = null;
81 private Label lblWindowMinNbEvents = null;
82
83 private static final String WINDOW_TIMERANGE_LABEL_TEXT = "Window Timerange ";
84 private static final String WINDOW_CURRENT_TIME_LABEL_TEXT = "Window Current Time";
85 private static final String EVENT_CURRENT_TIME_LABEL_TEXT = "Event Current Time ";
86 private NanosecTextGroup ntgTimeRangeWindow = null;
87 private NanosecTextGroup ntgCurrentWindowTime = null;
88 private NanosecTextGroup ntgCurrentEventTime = null;
89
6e512b93 90 public HistogramView() {
b59134e1 91 super(ID);
6e512b93 92 }
b59134e1 93
6e512b93 94 @Override
8035003b 95 public void createPartControl(Composite parent) {
b59134e1 96
833a21aa 97 // Default font
6cf16d22 98 Font font = parent.getFont();
833a21aa
WB
99 FontData tmpFontData = font.getFontData()[0];
100 // Slightly smaller font for time
101 Font smallFont = new Font(font.getDevice(), tmpFontData.getName(), tmpFontData.getHeight() - SMALL_FONT_MODIFIER, tmpFontData.getStyle());
102
103
104 // Layout for the whole view, other elements will be in a child composite of this one
105 // Contains :
106 // Composite layoutSelectionWindow
107 // Composite layoutTimesSpinner
108 // Composite layoutExperimentHistogram
109 Composite layoutFullView = new Composite(parent, SWT.NONE);
110 GridLayout gridFullView = new GridLayout();
111 gridFullView.numColumns = 2;
112 gridFullView.marginHeight = 0;
113 gridFullView.marginWidth = 0;
114 layoutFullView.setLayout(gridFullView);
115 //layoutFullView.setSize(parent.getDisplay().getBounds().width, parent.getDisplay().getBounds().height);
116
117
118 // Layout that contain the SelectionWindow
119 // Contains :
120 // Label lblWindowStartTime
121 // Label lblWindowStopTime
122 // Label lblWindowMaxNbEvents
123 // Label lblWindowMinNbEvents
124 // ChildrenHistogramCanvas selectedWindowCanvas
125 Composite layoutSelectionWindow = new Composite(layoutFullView, SWT.NONE);
126 GridLayout gridSelectionWindow = new GridLayout();
127 gridSelectionWindow.numColumns = 3;
128 gridSelectionWindow.marginHeight = 0;
129 gridSelectionWindow.marginWidth = 0;
130 layoutSelectionWindow.setLayout(gridSelectionWindow);
131 GridData gridDataSelectionWindow = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1);
132 layoutSelectionWindow.setLayoutData(gridDataSelectionWindow);
133
134
135 // Layout that contain the time spinner
136 // Contains :
137 // NanosecTextGroup spTimeRangeWindow
138 // NanosecTextGroup spCurrentWindowTime
139 // NanosecTextGroup spCurrentEventTime
140 Composite layoutTimesSpinner = new Composite(layoutFullView, SWT.NONE);
141 GridLayout gridTimesSpinner = new GridLayout();
142
143 if ( TEST_UI ) {
144 gridTimesSpinner.numColumns = 3;
145 }
146 else {
147 gridTimesSpinner.numColumns = 2;
148 }
149 gridTimesSpinner.marginHeight = 0;
150 gridTimesSpinner.marginWidth = 0;
151 layoutTimesSpinner.setLayout(gridTimesSpinner);
152 GridData gridDataTimesSpinner = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
153 layoutTimesSpinner.setLayoutData(gridDataTimesSpinner);
154
155
156 // Layout that contain the complete experiment histogram and related controls.
157 // Contains :
158 // Label lblExperimentStartTime
159 // Label lblExperimentStopTime
160 // ParentHistogramCanvas fullTraceCanvas
161 Composite layoutExperimentHistogram = new Composite(layoutFullView, SWT.NONE);
162 GridLayout gridExperimentHistogram = new GridLayout();
163 gridExperimentHistogram.numColumns = 2;
164 gridExperimentHistogram.marginHeight = 0;
165 gridExperimentHistogram.marginWidth = 0;
166 layoutExperimentHistogram.setLayout(gridExperimentHistogram);
167 GridData gridDataExperimentHistogram = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
168 layoutExperimentHistogram.setLayoutData(gridDataExperimentHistogram);
169
170
171
172 // *** Everything related to the selection window is below
173 GridData gridDataSelectionWindowCanvas = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 2);
174 gridDataSelectionWindowCanvas.heightHint = SELECTED_WINDOW_CANVAS_HEIGHT;
175 gridDataSelectionWindowCanvas.minimumHeight = SELECTED_WINDOW_CANVAS_HEIGHT;
176
177 int size = 0;
178 if ( TEST_UI ) {
179 size = SELECTED_WINDOW_CANVAS_WIDTH/2;
180 }
181 else {
182 size = SELECTED_WINDOW_CANVAS_WIDTH;
183 }
184
185 gridDataSelectionWindowCanvas.widthHint = size;
186 gridDataSelectionWindowCanvas.minimumWidth = size;
187
188
189 selectedWindowCanvas = new ChildrenHistogramCanvas(this, layoutSelectionWindow, SWT.BORDER);
190 selectedWindowCanvas.setLayoutData(gridDataSelectionWindowCanvas);
191
192 GridData gridDataWindowMaxEvents = new GridData(SWT.LEFT, SWT.TOP, true, false, 1, 1);
193 // Force a width, to avoid the control to enlarge if the number of events change
194 gridDataWindowMaxEvents.minimumWidth = NB_EVENTS_FIXED_WIDTH;
195 gridDataWindowMaxEvents.widthHint = NB_EVENTS_FIXED_WIDTH;
196 lblWindowMaxNbEvents = new Label(layoutSelectionWindow, SWT.NONE);
197 lblWindowMaxNbEvents.setFont(smallFont);
198 lblWindowMaxNbEvents.setText("");
199 lblWindowMaxNbEvents.setLayoutData(gridDataWindowMaxEvents);
200
201 GridData gridDataWindowMinEvents = new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1);
202 // Force a width, to avoid the control to enlarge if the number of events change
203 gridDataWindowMinEvents.minimumWidth = NB_EVENTS_FIXED_WIDTH;
204 gridDataWindowMinEvents.widthHint = NB_EVENTS_FIXED_WIDTH;
205 lblWindowMinNbEvents = new Label(layoutSelectionWindow, SWT.NONE);
206 lblWindowMinNbEvents.setFont(smallFont);
207 lblWindowMinNbEvents.setText("");
208 lblWindowMinNbEvents.setLayoutData(gridDataWindowMinEvents);
209
210 GridData gridDataWindowStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
211 txtWindowStartTime = new Text(layoutSelectionWindow, SWT.READ_ONLY);
212 txtWindowStartTime.setFont(smallFont);
213 txtWindowStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
214 txtWindowStartTime.setEditable(false);
215 txtWindowStartTime.setText("");
216 txtWindowStartTime.setLayoutData(gridDataWindowStart);
217
218 GridData gridDataWindowStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1);
219 txtWindowStopTime = new Text(layoutSelectionWindow, SWT.READ_ONLY);
220 txtWindowStopTime.setFont(smallFont);
221 txtWindowStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
222 txtWindowStopTime.setEditable(false);
223 txtWindowStopTime.setText("");
224 txtWindowStopTime.setLayoutData(gridDataWindowStop);
225
226
227
228 // *** Everything related to the spinner is below
229 if ( TEST_UI ) {
230 GridData gridDataCurrentWindow = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
231 ntgCurrentWindowTime = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
232 ntgCurrentWindowTime.setLayoutData(gridDataCurrentWindow);
233
234 GridData gridDataTimeRange = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
235 ntgTimeRangeWindow = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_TIMERANGE_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
236 ntgTimeRangeWindow.setLayoutData(gridDataTimeRange);
237
238 GridData gridDataCurrentEvent = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
239 ntgCurrentEventTime = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, EVENT_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
240 ntgCurrentEventTime.setLayoutData(gridDataCurrentEvent);
241 }
242 else {
243 GridData gridDataTimeRange = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
244 ntgTimeRangeWindow = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_TIMERANGE_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
245 ntgTimeRangeWindow.setLayoutData(gridDataTimeRange);
246
247 GridData gridDataCurrentEvent = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 2);
248 ntgCurrentEventTime = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, EVENT_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
249 ntgCurrentEventTime.setLayoutData(gridDataCurrentEvent);
250
251 GridData gridDataCurrentWindow = new GridData(SWT.CENTER, SWT.BOTTOM, true, false, 1, 1);
252 ntgCurrentWindowTime = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
253 ntgCurrentWindowTime.setLayoutData(gridDataCurrentWindow);
254 }
255
256
257 // Everything related to the experiment canvas is below
258 GridData gridDataExperimentCanvas = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
259 gridDataExperimentCanvas.heightHint = FULL_TRACE_CANVAS_HEIGHT;
260 gridDataExperimentCanvas.minimumHeight = FULL_TRACE_CANVAS_HEIGHT;
261 fullTraceCanvas = new ParentHistogramCanvas(this, layoutExperimentHistogram, SWT.BORDER);
262 fullTraceCanvas.setLayoutData(gridDataExperimentCanvas);
263
264 GridData gridDataExperimentStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
265 txtExperimentStartTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY);
266 txtExperimentStartTime.setFont(smallFont);
267 txtExperimentStartTime.setText("");
268 txtExperimentStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
269 txtExperimentStartTime.setEditable(false);
270 txtExperimentStartTime.setLayoutData(gridDataExperimentStart);
271
272 GridData gridDataExperimentStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1);
273 txtExperimentStopTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY);
274 txtExperimentStopTime.setFont(smallFont);
275 txtExperimentStopTime.setText("");
276 txtExperimentStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
277 txtExperimentStopTime.setEditable(false);
278 txtExperimentStopTime.setLayoutData(gridDataExperimentStop);
6e512b93 279 }
b59134e1 280
ecfd1d41 281
b59134e1 282 @SuppressWarnings("unchecked")
6e512b93
ASL
283 @Override
284 public void setFocus() {
b59134e1
WB
285
286 TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)TmfExperiment.getCurrentExperiment();
287
288 if ( (dataBackgroundFullRequest == null) && (tmpExperiment != null) ) {
ecfd1d41 289 createCanvasAndRequests(tmpExperiment);
b59134e1 290 }
6e512b93 291 }
b59134e1
WB
292
293
294 @SuppressWarnings("unchecked")
295 @TmfSignalHandler
296 public void experimentSelected(TmfExperimentSelectedSignal<LttngEvent> signal) {
252ae4bd 297
ecfd1d41
WB
298 TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)signal.getExperiment();
299 createCanvasAndRequests(tmpExperiment);
300 }
301
833a21aa
WB
302 @TmfSignalHandler
303 public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
304 System.out.println("experimentUpdated");
305
306 // *** TODO ***
307 // Update the histogram if the time changed
308 //
309 }
310
311 @TmfSignalHandler
312 public void currentTimeUpdated(TmfTimeSynchSignal signal) {
313 if (signal.getSource() != this) {
314 TmfTimestamp currentTime = signal.getCurrentTime();
315 ntgCurrentEventTime.setValue(currentTime.getValue());
316
317 if ( (currentTime.getValue() < fullTraceCanvas.getCurrentWindow().getTimestampLeft() ) ||
318 (currentTime.getValue() > fullTraceCanvas.getCurrentWindow().getTimestampRight() ) )
319 {
320 fullTraceCanvas.centerWindow( fullTraceCanvas.getHistogramContent().getClosestXPositionFromTimestamp(currentTime.getValue()) );
321 windowChangedNotification();
322 }
323
324 }
325 }
326
ecfd1d41
WB
327 public void createCanvasAndRequests(TmfExperiment<LttngEvent> newExperiment) {
328 lastUsedExperiment = newExperiment;
6cf16d22 329
378e7718
WB
330 fullTraceCanvas.createNewHistogramContent( DEFAULT_WINDOW_SIZE, FULL_TRACE_BAR_WIDTH, FULL_TRACE_CANVAS_HEIGHT, FULL_TRACE_DIFFERENCE_TO_AVERAGE);
331 selectedWindowCanvas.createNewHistogramContent(0, SELECTED_WINDOW_BAR_WIDTH, SELECTED_WINDOW_CANVAS_HEIGHT, SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE);
6cf16d22 332
833a21aa
WB
333 // Make sure the UI object are sane
334 resetLabelContent();
335
6cf16d22
WB
336 // Redraw the canvas right away to have something "clean" as soon as we can
337 if ( dataBackgroundFullRequest != null ) {
338 fullTraceCanvas.redraw();
339 selectedWindowCanvas.redraw();
340 }
ecfd1d41 341
ecfd1d41 342 fullTraceCanvas.getCurrentWindow().setSelectedWindowVisible(true);
ecfd1d41 343
6cf16d22 344 performAllTraceEventsRequest(newExperiment);
ecfd1d41
WB
345 performSelectedWindowEventsRequest(newExperiment);
346 }
347
348 public void performSelectedWindowEventsRequest(TmfExperiment<LttngEvent> experiment) {
252ae4bd 349
ecfd1d41 350 HistogramSelectedWindow curSelectedWindow = fullTraceCanvas.getCurrentWindow();
b59134e1 351
ecfd1d41 352 if ( curSelectedWindow == null ) {
378e7718
WB
353 fullTraceCanvas.createNewSelectedWindow( getTimeWindowSize() );
354 curSelectedWindow = fullTraceCanvas.getCurrentWindow();
ecfd1d41
WB
355 }
356
357 LttngTimestamp ts1 = new LttngTimestamp( curSelectedWindow.getTimestampLeft() );
358 LttngTimestamp ts2 = new LttngTimestamp( curSelectedWindow.getTimestampRight() );
b59134e1 359
ecfd1d41
WB
360 if ( ts2.getValue() > experiment.getEndTime().getValue() ) {
361 ts2 = new LttngTimestamp( experiment.getEndTime().getValue() );
833a21aa 362 }
ecfd1d41
WB
363
364 TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
365
366 // Set a (dynamic) time interval
367 long intervalTime = ( (ts2.getValue() - ts1.getValue()) / selectedWindowCanvas.getHistogramContent().getNbElement() );
368
369 // *** VERIFY ***
370 // This would enable "fixed interval" instead of dynamic one.
371 // ... we don't need it, do we?
372 //
373 // long intervalTime = ((long)(0.001 * (double)1000000000));
374 selectedWindowRequest = performRequest(experiment, selectedWindowCanvas, tmpRange, intervalTime);
6cf16d22 375 selectedWindowCanvas.redrawAsynchronously();
ecfd1d41
WB
376 }
377
378 public void performAllTraceEventsRequest(TmfExperiment<LttngEvent> experiment) {
b59134e1
WB
379 // Create a new time range from "start" to "end"
380 // That way, we will get "everything" in the trace
ecfd1d41
WB
381 LttngTimestamp ts1 = new LttngTimestamp( experiment.getStartTime() );
382 LttngTimestamp ts2 = new LttngTimestamp( experiment.getEndTime() );
b59134e1
WB
383 TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
384
ecfd1d41
WB
385 // Set a (dynamic) time interval
386 long intervalTime = ( (ts2.getValue() - ts1.getValue()) / fullTraceCanvas.getHistogramContent().getNbElement() );
b59134e1 387
ecfd1d41 388 dataBackgroundFullRequest = performRequest(experiment, fullTraceCanvas, tmpRange, intervalTime);
6cf16d22 389 fullTraceCanvas.redrawAsynchronously();
b59134e1
WB
390 }
391
392 // *** VERIFY ***
393 // this function is synchronized, is it a good idea?
378e7718 394 public synchronized HistogramRequest performRequest(TmfExperiment<LttngEvent> experiment, HistogramCanvas targetCanvas, TmfTimeRange newRange, long newInterval) {
b59134e1
WB
395 HistogramRequest returnedRequest = null;
396
ecfd1d41
WB
397 // *** FIXME ***
398 // EVIL BUG!
399 // We use integer.MAX_VALUE because we want every events BUT we don't know the number inside the range.
400 // HOWEVER, this would cause the request to run forever (or until it reach the end of trace).
401 // Seeting an EndTime does not seems to stop the request
378e7718 402 returnedRequest = new HistogramRequest(newRange, Integer.MAX_VALUE, targetCanvas, newInterval );
b59134e1
WB
403 experiment.sendRequest(returnedRequest);
404
405 return returnedRequest;
406 }
8035003b 407
b59134e1 408
ecfd1d41 409 public void windowChangedNotification() {
833a21aa
WB
410 // *** NO GUI UPDATE SHOULD BE DONE IN HERE !! ***
411
ecfd1d41 412 if ( lastUsedExperiment != null ) {
6cf16d22
WB
413 if ( selectedWindowRequest.isCompleted() == false ) {
414 selectedWindowRequest.cancel();
415 }
833a21aa 416
ecfd1d41
WB
417 performSelectedWindowEventsRequest(lastUsedExperiment);
418 }
419 }
420
6cf16d22
WB
421 public boolean isRequestRunning() {
422 boolean returnedValue = true;
ecfd1d41 423
6cf16d22
WB
424 if ( ( dataBackgroundFullRequest.isCompleted() == true ) && ( selectedWindowRequest.isCompleted() == true ) ) {
425 returnedValue = false;
ecfd1d41
WB
426 }
427
428 return returnedValue;
429 }
430
431
ecfd1d41
WB
432 public TmfExperiment<LttngEvent> getLastUsedExperiment() {
433 return lastUsedExperiment;
434 }
435
436 public Long getTimeWindowSize() {
6cf16d22 437 return fullTraceCanvas.getSelectedWindowSize();
ecfd1d41
WB
438 }
439
440 public void setTimeWindowSize(long newTimeWidth) {
6cf16d22 441 fullTraceCanvas.setSelectedWindowSize(newTimeWidth);
ecfd1d41
WB
442 }
443
833a21aa
WB
444 public void resetLabelContent() {
445
446 TmfExperiment<LttngEvent> tmpExperiment = getLastUsedExperiment();
447
448 String startTime = null;
449 String stopTime = null;
450 if ( tmpExperiment != null ) {
451 startTime = HistogramConstant.formatNanoSecondsTime( tmpExperiment.getStartTime().getValue() );
452 stopTime = HistogramConstant.formatNanoSecondsTime( tmpExperiment.getEndTime().getValue() );
6cf16d22 453 }
833a21aa
WB
454 else {
455 startTime = HistogramConstant.formatNanoSecondsTime( 0L );
456 stopTime = HistogramConstant.formatNanoSecondsTime( 0L );
457 }
458
459 txtExperimentStartTime.setText( startTime );
460 txtExperimentStopTime.setText( stopTime );
461 txtExperimentStartTime.getParent().layout();
462
463 lblWindowMaxNbEvents.setText("" + 0);
464 lblWindowMinNbEvents.setText("" + 0);
465 txtWindowStartTime.setText( HistogramConstant.formatNanoSecondsTime( 0L ) );
466 txtWindowStopTime.setText( HistogramConstant.formatNanoSecondsTime( 0L ) );
467 txtWindowStartTime.getParent().layout();
378e7718 468
833a21aa
WB
469 ntgCurrentWindowTime.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
470 ntgTimeRangeWindow.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
471 ntgCurrentEventTime.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
378e7718
WB
472 }
473
474 public void updateFullTraceInformation() {
475
833a21aa
WB
476 String startTime = HistogramConstant.formatNanoSecondsTime( fullTraceCanvas.getHistogramContent().getStartTime() );
477 String stopTime = HistogramConstant.formatNanoSecondsTime( fullTraceCanvas.getHistogramContent().getEndTime() );
378e7718 478
833a21aa
WB
479 txtExperimentStartTime.setText( startTime );
480 txtExperimentStopTime.setText( stopTime );
481
482 // Take one of the parent and call its layout to update control size
483 // Since both control have the same parent, only one call is needed
484 txtExperimentStartTime.getParent().layout();
485
486 // Update the selected window, just in case
487 // This should give a better user experience and it is low cost
488 updateSelectedWindowInformation();
378e7718
WB
489 }
490
491 public void updateSelectedWindowInformation() {
833a21aa
WB
492 // Update the timestamp as well
493 updateSelectedWindowTimestamp();
494
495 lblWindowMaxNbEvents.setText( selectedWindowCanvas.getHistogramContent().getHeighestEventCount().toString() );
496 lblWindowMinNbEvents.setText("0");
497
498 // Refresh the layout
499 lblWindowMaxNbEvents.getParent().layout();
ecfd1d41 500 }
6cf16d22 501
833a21aa
WB
502 public void updateSelectedWindowTimestamp() {
503 String startTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getStartTime() );
504 String stopTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getEndTime() );
505 txtWindowStartTime.setText( startTime );
506 txtWindowStopTime.setText( stopTime );
507
508 ntgCurrentWindowTime.setValue( fullTraceCanvas.getCurrentWindow().getTimestampCenter() );
509 ntgTimeRangeWindow.setValue( fullTraceCanvas.getCurrentWindow().getWindowTimeWidth() );
510
511 // Take one control in each group to call to refresh the layout
512 // Since both control have the same parent, only one call is needed
513 txtWindowStartTime.getParent().layout();
514 ntgCurrentWindowTime.getParent().layout();
515 }
378e7718 516
6e512b93 517}
This page took 0.055183 seconds and 5 git commands to generate.