[Bug309042] Improved test code coverage and other mundane issues.
[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
088c1d4e 64
ecfd1d41 65 private TmfExperiment<LttngEvent> lastUsedExperiment = null;
b59134e1
WB
66
67 private HistogramRequest dataBackgroundFullRequest = null;
378e7718 68 private ParentHistogramCanvas fullTraceCanvas = null;
b59134e1 69
ecfd1d41 70 private HistogramRequest selectedWindowRequest = null;
378e7718 71 private ChildrenHistogramCanvas selectedWindowCanvas = null;
b59134e1 72
6cf16d22 73
833a21aa
WB
74 private Text txtExperimentStartTime = null;
75 private Text txtExperimentStopTime = null;
76
77 private Text txtWindowStartTime = null;
78 private Text txtWindowStopTime = null;
79 private Label lblWindowMaxNbEvents = null;
80 private Label lblWindowMinNbEvents = null;
81
82 private static final String WINDOW_TIMERANGE_LABEL_TEXT = "Window Timerange ";
83 private static final String WINDOW_CURRENT_TIME_LABEL_TEXT = "Window Current Time";
84 private static final String EVENT_CURRENT_TIME_LABEL_TEXT = "Event Current Time ";
088c1d4e
WB
85 private TimeTextGroup ntgTimeRangeWindow = null;
86 private TimeTextGroup ntgCurrentWindowTime = null;
87 private TimeTextGroup ntgCurrentEventTime = null;
88
89 private Long selectedWindowTime = 0L;
90 private Long selectedWindowTimerange = 0L;
91 private Long currentEventTime = 0L;
833a21aa 92
6e512b93 93 public HistogramView() {
b59134e1 94 super(ID);
6e512b93 95 }
b59134e1 96
6e512b93 97 @Override
8035003b 98 public void createPartControl(Composite parent) {
b59134e1 99
833a21aa 100 // Default font
6cf16d22 101 Font font = parent.getFont();
833a21aa
WB
102 FontData tmpFontData = font.getFontData()[0];
103 // Slightly smaller font for time
104 Font smallFont = new Font(font.getDevice(), tmpFontData.getName(), tmpFontData.getHeight() - SMALL_FONT_MODIFIER, tmpFontData.getStyle());
105
106
107 // Layout for the whole view, other elements will be in a child composite of this one
108 // Contains :
109 // Composite layoutSelectionWindow
110 // Composite layoutTimesSpinner
111 // Composite layoutExperimentHistogram
112 Composite layoutFullView = new Composite(parent, SWT.NONE);
113 GridLayout gridFullView = new GridLayout();
114 gridFullView.numColumns = 2;
115 gridFullView.marginHeight = 0;
116 gridFullView.marginWidth = 0;
117 layoutFullView.setLayout(gridFullView);
118 //layoutFullView.setSize(parent.getDisplay().getBounds().width, parent.getDisplay().getBounds().height);
119
120
121 // Layout that contain the SelectionWindow
122 // Contains :
123 // Label lblWindowStartTime
124 // Label lblWindowStopTime
125 // Label lblWindowMaxNbEvents
126 // Label lblWindowMinNbEvents
127 // ChildrenHistogramCanvas selectedWindowCanvas
128 Composite layoutSelectionWindow = new Composite(layoutFullView, SWT.NONE);
129 GridLayout gridSelectionWindow = new GridLayout();
130 gridSelectionWindow.numColumns = 3;
131 gridSelectionWindow.marginHeight = 0;
132 gridSelectionWindow.marginWidth = 0;
133 layoutSelectionWindow.setLayout(gridSelectionWindow);
134 GridData gridDataSelectionWindow = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1);
135 layoutSelectionWindow.setLayoutData(gridDataSelectionWindow);
136
137
138 // Layout that contain the time spinner
139 // Contains :
140 // NanosecTextGroup spTimeRangeWindow
141 // NanosecTextGroup spCurrentWindowTime
142 // NanosecTextGroup spCurrentEventTime
143 Composite layoutTimesSpinner = new Composite(layoutFullView, SWT.NONE);
144 GridLayout gridTimesSpinner = new GridLayout();
145
146 if ( TEST_UI ) {
147 gridTimesSpinner.numColumns = 3;
148 }
149 else {
150 gridTimesSpinner.numColumns = 2;
151 }
152 gridTimesSpinner.marginHeight = 0;
153 gridTimesSpinner.marginWidth = 0;
154 layoutTimesSpinner.setLayout(gridTimesSpinner);
155 GridData gridDataTimesSpinner = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
156 layoutTimesSpinner.setLayoutData(gridDataTimesSpinner);
157
158
159 // Layout that contain the complete experiment histogram and related controls.
160 // Contains :
161 // Label lblExperimentStartTime
162 // Label lblExperimentStopTime
163 // ParentHistogramCanvas fullTraceCanvas
164 Composite layoutExperimentHistogram = new Composite(layoutFullView, SWT.NONE);
165 GridLayout gridExperimentHistogram = new GridLayout();
166 gridExperimentHistogram.numColumns = 2;
167 gridExperimentHistogram.marginHeight = 0;
168 gridExperimentHistogram.marginWidth = 0;
169 layoutExperimentHistogram.setLayout(gridExperimentHistogram);
170 GridData gridDataExperimentHistogram = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
171 layoutExperimentHistogram.setLayoutData(gridDataExperimentHistogram);
172
173
174
175 // *** Everything related to the selection window is below
176 GridData gridDataSelectionWindowCanvas = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 2);
177 gridDataSelectionWindowCanvas.heightHint = SELECTED_WINDOW_CANVAS_HEIGHT;
178 gridDataSelectionWindowCanvas.minimumHeight = SELECTED_WINDOW_CANVAS_HEIGHT;
179
180 int size = 0;
181 if ( TEST_UI ) {
182 size = SELECTED_WINDOW_CANVAS_WIDTH/2;
183 }
184 else {
185 size = SELECTED_WINDOW_CANVAS_WIDTH;
186 }
187
188 gridDataSelectionWindowCanvas.widthHint = size;
189 gridDataSelectionWindowCanvas.minimumWidth = size;
190
191
192 selectedWindowCanvas = new ChildrenHistogramCanvas(this, layoutSelectionWindow, SWT.BORDER);
193 selectedWindowCanvas.setLayoutData(gridDataSelectionWindowCanvas);
194
195 GridData gridDataWindowMaxEvents = new GridData(SWT.LEFT, SWT.TOP, true, false, 1, 1);
196 // Force a width, to avoid the control to enlarge if the number of events change
197 gridDataWindowMaxEvents.minimumWidth = NB_EVENTS_FIXED_WIDTH;
198 gridDataWindowMaxEvents.widthHint = NB_EVENTS_FIXED_WIDTH;
199 lblWindowMaxNbEvents = new Label(layoutSelectionWindow, SWT.NONE);
200 lblWindowMaxNbEvents.setFont(smallFont);
201 lblWindowMaxNbEvents.setText("");
202 lblWindowMaxNbEvents.setLayoutData(gridDataWindowMaxEvents);
203
204 GridData gridDataWindowMinEvents = new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1);
205 // Force a width, to avoid the control to enlarge if the number of events change
206 gridDataWindowMinEvents.minimumWidth = NB_EVENTS_FIXED_WIDTH;
207 gridDataWindowMinEvents.widthHint = NB_EVENTS_FIXED_WIDTH;
208 lblWindowMinNbEvents = new Label(layoutSelectionWindow, SWT.NONE);
209 lblWindowMinNbEvents.setFont(smallFont);
210 lblWindowMinNbEvents.setText("");
211 lblWindowMinNbEvents.setLayoutData(gridDataWindowMinEvents);
212
213 GridData gridDataWindowStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
214 txtWindowStartTime = new Text(layoutSelectionWindow, SWT.READ_ONLY);
215 txtWindowStartTime.setFont(smallFont);
216 txtWindowStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
217 txtWindowStartTime.setEditable(false);
218 txtWindowStartTime.setText("");
219 txtWindowStartTime.setLayoutData(gridDataWindowStart);
220
221 GridData gridDataWindowStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1);
222 txtWindowStopTime = new Text(layoutSelectionWindow, SWT.READ_ONLY);
223 txtWindowStopTime.setFont(smallFont);
224 txtWindowStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
225 txtWindowStopTime.setEditable(false);
226 txtWindowStopTime.setText("");
227 txtWindowStopTime.setLayoutData(gridDataWindowStop);
228
229
230
231 // *** Everything related to the spinner is below
232 if ( TEST_UI ) {
233 GridData gridDataCurrentWindow = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
088c1d4e 234 ntgCurrentWindowTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
833a21aa
WB
235 ntgCurrentWindowTime.setLayoutData(gridDataCurrentWindow);
236
237 GridData gridDataTimeRange = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
088c1d4e 238 ntgTimeRangeWindow = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_TIMERANGE_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
833a21aa
WB
239 ntgTimeRangeWindow.setLayoutData(gridDataTimeRange);
240
241 GridData gridDataCurrentEvent = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
088c1d4e 242 ntgCurrentEventTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, EVENT_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
833a21aa
WB
243 ntgCurrentEventTime.setLayoutData(gridDataCurrentEvent);
244 }
245 else {
246 GridData gridDataTimeRange = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
088c1d4e 247 ntgTimeRangeWindow = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_TIMERANGE_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
833a21aa
WB
248 ntgTimeRangeWindow.setLayoutData(gridDataTimeRange);
249
250 GridData gridDataCurrentEvent = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 2);
088c1d4e 251 ntgCurrentEventTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, EVENT_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
833a21aa
WB
252 ntgCurrentEventTime.setLayoutData(gridDataCurrentEvent);
253
254 GridData gridDataCurrentWindow = new GridData(SWT.CENTER, SWT.BOTTOM, true, false, 1, 1);
088c1d4e 255 ntgCurrentWindowTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
833a21aa
WB
256 ntgCurrentWindowTime.setLayoutData(gridDataCurrentWindow);
257 }
258
259
260 // Everything related to the experiment canvas is below
261 GridData gridDataExperimentCanvas = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
262 gridDataExperimentCanvas.heightHint = FULL_TRACE_CANVAS_HEIGHT;
263 gridDataExperimentCanvas.minimumHeight = FULL_TRACE_CANVAS_HEIGHT;
264 fullTraceCanvas = new ParentHistogramCanvas(this, layoutExperimentHistogram, SWT.BORDER);
265 fullTraceCanvas.setLayoutData(gridDataExperimentCanvas);
266
267 GridData gridDataExperimentStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
268 txtExperimentStartTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY);
269 txtExperimentStartTime.setFont(smallFont);
270 txtExperimentStartTime.setText("");
271 txtExperimentStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
272 txtExperimentStartTime.setEditable(false);
273 txtExperimentStartTime.setLayoutData(gridDataExperimentStart);
274
275 GridData gridDataExperimentStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1);
276 txtExperimentStopTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY);
277 txtExperimentStopTime.setFont(smallFont);
278 txtExperimentStopTime.setText("");
279 txtExperimentStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
280 txtExperimentStopTime.setEditable(false);
281 txtExperimentStopTime.setLayoutData(gridDataExperimentStop);
6e512b93 282 }
b59134e1 283
ecfd1d41 284
b59134e1 285 @SuppressWarnings("unchecked")
6e512b93
ASL
286 @Override
287 public void setFocus() {
b59134e1
WB
288
289 TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)TmfExperiment.getCurrentExperiment();
290
291 if ( (dataBackgroundFullRequest == null) && (tmpExperiment != null) ) {
ecfd1d41 292 createCanvasAndRequests(tmpExperiment);
b59134e1 293 }
6e512b93 294 }
b59134e1
WB
295
296
297 @SuppressWarnings("unchecked")
298 @TmfSignalHandler
299 public void experimentSelected(TmfExperimentSelectedSignal<LttngEvent> signal) {
ecfd1d41
WB
300 TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)signal.getExperiment();
301 createCanvasAndRequests(tmpExperiment);
302 }
303
088c1d4e
WB
304 // *** VERIFY ***
305 // Not sure what this should do since I don't know when it will be called
306 // Let's do the same thing as experimentSelected for now
307 //
308 @SuppressWarnings("unchecked")
309 @TmfSignalHandler
833a21aa 310 public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
088c1d4e 311 TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)signal.getExperiment();
833a21aa 312
088c1d4e
WB
313 // Make sure the UI object are sane
314 resetLabelContent();
315
316 // Redraw the canvas right away to have something "clean" as soon as we can
317 fullTraceCanvas.redraw();
318 selectedWindowCanvas.redraw();
319
320 performAllTraceEventsRequest(tmpExperiment);
321 performSelectedWindowEventsRequest(tmpExperiment);
833a21aa
WB
322 }
323
324 @TmfSignalHandler
325 public void currentTimeUpdated(TmfTimeSynchSignal signal) {
326 if (signal.getSource() != this) {
327 TmfTimestamp currentTime = signal.getCurrentTime();
833a21aa 328
088c1d4e
WB
329 currentEventTime = currentTime.getValue();
330 updateSelectedEventTime();
331
332 if ( isGivenTimestampInSelectedWindow( currentEventTime ) == false)
833a21aa 333 {
088c1d4e 334 fullTraceCanvas.centerWindow( fullTraceCanvas.getHistogramContent().getClosestXPositionFromTimestamp(currentEventTime) );
833a21aa
WB
335 windowChangedNotification();
336 }
833a21aa
WB
337 }
338 }
339
ecfd1d41
WB
340 public void createCanvasAndRequests(TmfExperiment<LttngEvent> newExperiment) {
341 lastUsedExperiment = newExperiment;
6cf16d22 342
378e7718
WB
343 fullTraceCanvas.createNewHistogramContent( DEFAULT_WINDOW_SIZE, FULL_TRACE_BAR_WIDTH, FULL_TRACE_CANVAS_HEIGHT, FULL_TRACE_DIFFERENCE_TO_AVERAGE);
344 selectedWindowCanvas.createNewHistogramContent(0, SELECTED_WINDOW_BAR_WIDTH, SELECTED_WINDOW_CANVAS_HEIGHT, SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE);
6cf16d22 345
833a21aa
WB
346 // Make sure the UI object are sane
347 resetLabelContent();
348
6cf16d22
WB
349 // Redraw the canvas right away to have something "clean" as soon as we can
350 if ( dataBackgroundFullRequest != null ) {
351 fullTraceCanvas.redraw();
352 selectedWindowCanvas.redraw();
353 }
ecfd1d41 354
ecfd1d41 355 fullTraceCanvas.getCurrentWindow().setSelectedWindowVisible(true);
ecfd1d41 356
6cf16d22 357 performAllTraceEventsRequest(newExperiment);
ecfd1d41
WB
358 performSelectedWindowEventsRequest(newExperiment);
359 }
360
361 public void performSelectedWindowEventsRequest(TmfExperiment<LttngEvent> experiment) {
252ae4bd 362
ecfd1d41 363 HistogramSelectedWindow curSelectedWindow = fullTraceCanvas.getCurrentWindow();
b59134e1 364
ecfd1d41 365 if ( curSelectedWindow == null ) {
378e7718
WB
366 fullTraceCanvas.createNewSelectedWindow( getTimeWindowSize() );
367 curSelectedWindow = fullTraceCanvas.getCurrentWindow();
ecfd1d41
WB
368 }
369
370 LttngTimestamp ts1 = new LttngTimestamp( curSelectedWindow.getTimestampLeft() );
371 LttngTimestamp ts2 = new LttngTimestamp( curSelectedWindow.getTimestampRight() );
b59134e1 372
ecfd1d41
WB
373 if ( ts2.getValue() > experiment.getEndTime().getValue() ) {
374 ts2 = new LttngTimestamp( experiment.getEndTime().getValue() );
833a21aa 375 }
ecfd1d41
WB
376
377 TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
378
379 // Set a (dynamic) time interval
380 long intervalTime = ( (ts2.getValue() - ts1.getValue()) / selectedWindowCanvas.getHistogramContent().getNbElement() );
381
382 // *** VERIFY ***
383 // This would enable "fixed interval" instead of dynamic one.
384 // ... we don't need it, do we?
385 //
386 // long intervalTime = ((long)(0.001 * (double)1000000000));
387 selectedWindowRequest = performRequest(experiment, selectedWindowCanvas, tmpRange, intervalTime);
6cf16d22 388 selectedWindowCanvas.redrawAsynchronously();
ecfd1d41
WB
389 }
390
391 public void performAllTraceEventsRequest(TmfExperiment<LttngEvent> experiment) {
b59134e1
WB
392 // Create a new time range from "start" to "end"
393 // That way, we will get "everything" in the trace
ecfd1d41
WB
394 LttngTimestamp ts1 = new LttngTimestamp( experiment.getStartTime() );
395 LttngTimestamp ts2 = new LttngTimestamp( experiment.getEndTime() );
b59134e1
WB
396 TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
397
ecfd1d41
WB
398 // Set a (dynamic) time interval
399 long intervalTime = ( (ts2.getValue() - ts1.getValue()) / fullTraceCanvas.getHistogramContent().getNbElement() );
b59134e1 400
ecfd1d41 401 dataBackgroundFullRequest = performRequest(experiment, fullTraceCanvas, tmpRange, intervalTime);
6cf16d22 402 fullTraceCanvas.redrawAsynchronously();
b59134e1
WB
403 }
404
405 // *** VERIFY ***
406 // this function is synchronized, is it a good idea?
378e7718 407 public synchronized HistogramRequest performRequest(TmfExperiment<LttngEvent> experiment, HistogramCanvas targetCanvas, TmfTimeRange newRange, long newInterval) {
b59134e1
WB
408 HistogramRequest returnedRequest = null;
409
ecfd1d41
WB
410 // *** FIXME ***
411 // EVIL BUG!
412 // We use integer.MAX_VALUE because we want every events BUT we don't know the number inside the range.
413 // HOWEVER, this would cause the request to run forever (or until it reach the end of trace).
414 // Seeting an EndTime does not seems to stop the request
378e7718 415 returnedRequest = new HistogramRequest(newRange, Integer.MAX_VALUE, targetCanvas, newInterval );
b59134e1
WB
416 experiment.sendRequest(returnedRequest);
417
418 return returnedRequest;
419 }
088c1d4e 420
b59134e1 421
ecfd1d41 422 public void windowChangedNotification() {
833a21aa 423
ecfd1d41 424 if ( lastUsedExperiment != null ) {
6cf16d22
WB
425 if ( selectedWindowRequest.isCompleted() == false ) {
426 selectedWindowRequest.cancel();
427 }
833a21aa 428
088c1d4e
WB
429 selectedWindowTime = fullTraceCanvas.getCurrentWindow().getTimestampCenter();
430 selectedWindowTimerange = fullTraceCanvas.getCurrentWindow().getWindowTimeWidth();
431
432 if ( isGivenTimestampInSelectedWindow(ntgCurrentEventTime.getValue()) == false ) {
433 currentEventChangeNotification( selectedWindowTime );
434 }
435
ecfd1d41
WB
436 performSelectedWindowEventsRequest(lastUsedExperiment);
437 }
438 }
439
088c1d4e
WB
440
441 public void currentEventChangeNotification(Long newCurrentEventTime) {
442 // Notify other views in the framework
443 if (currentEventTime != newCurrentEventTime) {
444 currentEventTime = newCurrentEventTime;
445
446 updateSelectedEventTime();
447
448 LttngTimestamp tmpTimestamp = new LttngTimestamp(newCurrentEventTime);
449 broadcast(new TmfTimeSynchSignal(this, tmpTimestamp));
450 }
451 }
452
453 public void timeTextGroupChangeNotification() {
454
455 Long newCurrentTime = ntgCurrentEventTime.getValue();
456 Long newSelectedWindowTime = ntgCurrentWindowTime.getValue();
457 Long newSelectedWindowTimeRange = ntgTimeRangeWindow.getValue();
458
459 if ( newCurrentTime != currentEventTime ) {
460 currentEventChangeNotification( newCurrentTime );
461 }
462
463 if ( newSelectedWindowTime != selectedWindowTime ) {
464 selectedWindowTime = newSelectedWindowTime;
465 fullTraceCanvas.centerWindow( fullTraceCanvas.getHistogramContent().getClosestXPositionFromTimestamp(selectedWindowTime) );
466 }
467
468 if ( newSelectedWindowTimeRange != selectedWindowTimerange ) {
469 selectedWindowTimerange = newSelectedWindowTimeRange;
470 fullTraceCanvas.resizeWindowByAbsoluteTime(selectedWindowTimerange);
471 }
472
473 }
474
6cf16d22
WB
475 public boolean isRequestRunning() {
476 boolean returnedValue = true;
ecfd1d41 477
6cf16d22
WB
478 if ( ( dataBackgroundFullRequest.isCompleted() == true ) && ( selectedWindowRequest.isCompleted() == true ) ) {
479 returnedValue = false;
ecfd1d41
WB
480 }
481
482 return returnedValue;
483 }
484
485
ecfd1d41
WB
486 public TmfExperiment<LttngEvent> getLastUsedExperiment() {
487 return lastUsedExperiment;
488 }
489
490 public Long getTimeWindowSize() {
6cf16d22 491 return fullTraceCanvas.getSelectedWindowSize();
ecfd1d41
WB
492 }
493
494 public void setTimeWindowSize(long newTimeWidth) {
6cf16d22 495 fullTraceCanvas.setSelectedWindowSize(newTimeWidth);
ecfd1d41
WB
496 }
497
088c1d4e
WB
498 public boolean isGivenTimestampInSelectedWindow(Long timestamp) {
499 boolean returnedValue = true;
500
501 if ( (timestamp < fullTraceCanvas.getCurrentWindow().getTimestampLeft() ) ||
502 (timestamp > fullTraceCanvas.getCurrentWindow().getTimestampRight() ) )
503 {
504 returnedValue = false;
505 }
506
507 return returnedValue;
508 }
509
833a21aa
WB
510 public void resetLabelContent() {
511
512 TmfExperiment<LttngEvent> tmpExperiment = getLastUsedExperiment();
513
514 String startTime = null;
515 String stopTime = null;
516 if ( tmpExperiment != null ) {
517 startTime = HistogramConstant.formatNanoSecondsTime( tmpExperiment.getStartTime().getValue() );
518 stopTime = HistogramConstant.formatNanoSecondsTime( tmpExperiment.getEndTime().getValue() );
6cf16d22 519 }
833a21aa
WB
520 else {
521 startTime = HistogramConstant.formatNanoSecondsTime( 0L );
522 stopTime = HistogramConstant.formatNanoSecondsTime( 0L );
523 }
524
525 txtExperimentStartTime.setText( startTime );
526 txtExperimentStopTime.setText( stopTime );
527 txtExperimentStartTime.getParent().layout();
528
529 lblWindowMaxNbEvents.setText("" + 0);
530 lblWindowMinNbEvents.setText("" + 0);
531 txtWindowStartTime.setText( HistogramConstant.formatNanoSecondsTime( 0L ) );
532 txtWindowStopTime.setText( HistogramConstant.formatNanoSecondsTime( 0L ) );
533 txtWindowStartTime.getParent().layout();
378e7718 534
833a21aa
WB
535 ntgCurrentWindowTime.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
536 ntgTimeRangeWindow.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
537 ntgCurrentEventTime.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
378e7718
WB
538 }
539
540 public void updateFullTraceInformation() {
541
833a21aa
WB
542 String startTime = HistogramConstant.formatNanoSecondsTime( fullTraceCanvas.getHistogramContent().getStartTime() );
543 String stopTime = HistogramConstant.formatNanoSecondsTime( fullTraceCanvas.getHistogramContent().getEndTime() );
378e7718 544
833a21aa
WB
545 txtExperimentStartTime.setText( startTime );
546 txtExperimentStopTime.setText( stopTime );
547
548 // Take one of the parent and call its layout to update control size
549 // Since both control have the same parent, only one call is needed
550 txtExperimentStartTime.getParent().layout();
551
552 // Update the selected window, just in case
553 // This should give a better user experience and it is low cost
554 updateSelectedWindowInformation();
378e7718
WB
555 }
556
557 public void updateSelectedWindowInformation() {
833a21aa
WB
558 // Update the timestamp as well
559 updateSelectedWindowTimestamp();
560
561 lblWindowMaxNbEvents.setText( selectedWindowCanvas.getHistogramContent().getHeighestEventCount().toString() );
562 lblWindowMinNbEvents.setText("0");
563
564 // Refresh the layout
565 lblWindowMaxNbEvents.getParent().layout();
ecfd1d41 566 }
6cf16d22 567
833a21aa
WB
568 public void updateSelectedWindowTimestamp() {
569 String startTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getStartTime() );
570 String stopTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getEndTime() );
571 txtWindowStartTime.setText( startTime );
572 txtWindowStopTime.setText( stopTime );
573
574 ntgCurrentWindowTime.setValue( fullTraceCanvas.getCurrentWindow().getTimestampCenter() );
575 ntgTimeRangeWindow.setValue( fullTraceCanvas.getCurrentWindow().getWindowTimeWidth() );
576
088c1d4e
WB
577 if ( isGivenTimestampInSelectedWindow(ntgCurrentEventTime.getValue()) == false ) {
578 currentEventChangeNotification( fullTraceCanvas.getCurrentWindow().getTimestampCenter() );
579 }
580
833a21aa
WB
581 // Take one control in each group to call to refresh the layout
582 // Since both control have the same parent, only one call is needed
583 txtWindowStartTime.getParent().layout();
584 ntgCurrentWindowTime.getParent().layout();
585 }
378e7718 586
088c1d4e
WB
587 public void updateSelectedEventTime() {
588 ntgCurrentEventTime.setValueAsynchronously(currentEventTime);
589 selectedWindowCanvas.getHistogramContent().setSelectedEventTimeInWindow(currentEventTime);
590 selectedWindowCanvas.redrawAsynchronously();
591 }
592
6e512b93 593}
This page took 0.055161 seconds and 5 git commands to generate.