2010-06-05 fchouinard@gmail.com Contributions for bugs 292965, 292963, 293102,...
[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
14import org.eclipse.linuxtools.lttng.event.LttngEvent;
15import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
550d787e 16import org.eclipse.linuxtools.tmf.event.TmfEvent;
b59134e1 17import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
833a21aa 18import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
b59134e1 19import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
550d787e
FC
20import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
21import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
ff4ed569
FC
22import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal;
23import org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal;
ed4b3b9f 24import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal;
b59134e1
WB
25import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
26import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
550d787e
FC
27import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
28import org.eclipse.linuxtools.tmf.trace.TmfContext;
b59134e1
WB
29import org.eclipse.linuxtools.tmf.ui.views.TmfView;
30import org.eclipse.swt.SWT;
7ef9ae3f
WB
31import org.eclipse.swt.events.ControlEvent;
32import org.eclipse.swt.events.ControlListener;
6cf16d22 33import org.eclipse.swt.graphics.Font;
833a21aa 34import org.eclipse.swt.graphics.FontData;
b59134e1 35import org.eclipse.swt.layout.GridData;
252ae4bd 36import org.eclipse.swt.layout.GridLayout;
6e512b93 37import org.eclipse.swt.widgets.Composite;
833a21aa 38import org.eclipse.swt.widgets.Text;
6e512b93 39
544fe9b7
WB
40/**
41 * <b><u>HistogramView</u></b>
42 * <p>
43 * View that contain an visual approach to the window that control the request.
44 * This is intended to replace the TimeFrameView
45 * <p>
46 * This view is composed of 2 canvas, one for the whole experiment and one for the selectionned window in the experiment.
47 * It also contain a certain number of controls to print or change informations about the experiment.
48 */
7ef9ae3f 49public class HistogramView extends TmfView implements ControlListener {
544fe9b7
WB
50
51 // *** TODO ***
52 // Here is what's left to do in this view
53 //
1155ca9f
WB
54 // 1- Make sure the interval time is small enought on very big trace (bug 311930)
55 // The interval time of the content is dynamically assigned from the screen width and trace duration.
56 // However, on very big trace (more than 1 hour), we could end up with time interval that are > 1 seconds,
57 // which is not very precise.
58 // An algorithm need to be implemented to make sure we "increase" the number of interval in the content if
59 // their precision is getting too bad.
60 //
61 // 2- Make sure all control are thread safe (bug 309348)
544fe9b7
WB
62 // Right now, all the basic controls (i.e. Text and Label) are sensible to "Thread Access Exception" if
63 // updated from different threads; we need to carefully decide when/where to redraw them.
64 // This is a real problem since there is a lot of thread going on in this view.
65 // All basic control should be subclassed to offer "Asynchronous" functions.
1155ca9f
WB
66 //
67 // 3- Implement a "preferences view" for the HistogramView (bug 311935)
68 // There is a lot of ajustable preferences in the view, however there is no way to ajust them right now
69 // at run time. There should be a view of some kind of "menu" to allow the user to change them while executing.
70 // Most of the pertinent values are in HistogramConstant.java or in this file.
544fe9b7 71
62d1696a 72 public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.histogram";
b59134e1 73
7c1540ab
WB
74 // "Minimum" screen width size. On smaller screen, we will apply several space saving technique
75 private static final int SCREEN_SMALL_IF_SMALLER_THAN = 1600;
76
544fe9b7 77 // Size of the "fulll trace" canvas
833a21aa
WB
78 private static final int FULL_TRACE_CANVAS_HEIGHT = 25;
79 private static final int FULL_TRACE_BAR_WIDTH = 1;
7ef9ae3f 80 private static final double FULL_TRACE_DIFFERENCE_TO_AVERAGE = 1.5;
833a21aa 81
544fe9b7
WB
82 // Size of the "Selected Window" canvas
83 private static final int SELECTED_WINDOW_CANVAS_WIDTH = 300;
7ef9ae3f 84 private static final int SMALL_SELECTED_WINDOW_CANVAS_WIDTH = 200;
544fe9b7 85 private static final int SELECTED_WINDOW_CANVAS_HEIGHT = 60;
833a21aa
WB
86 private static final int SELECTED_WINDOW_BAR_WIDTH = 1;
87 private static final double SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE = 10.0;
88
89 // For the two "events" label (Max and min number of events in the selection), we force a width
90 // This will prevent the control from moving horizontally if the number of events in the selection varies
3fda53ab 91 private static final int NB_EVENTS_FIXED_WIDTH = 50;
833a21aa
WB
92
93
94 // The "small font" height used to display time will be "default font" minus this constant
95 private static final int SMALL_FONT_MODIFIER = 2;
7c1540ab 96 private static final int VERY_SMALL_FONT_MODIFIER = 4;
ecfd1d41
WB
97
98 // *** TODO ***
99 // This need to be changed as soon the framework implement a "window"
1406f802 100 private static long DEFAULT_WINDOW_SIZE = (1L * 100 * 1000 * 1000); // 0.1sec
ecfd1d41 101
544fe9b7 102 // The last experiment received/used by the view
ecfd1d41 103 private TmfExperiment<LttngEvent> lastUsedExperiment = null;
b59134e1 104
7c1540ab
WB
105 // Parent of the view
106 private Composite parent = null;
107
544fe9b7 108 // Request and canvas for the "full trace" part
b59134e1 109 private HistogramRequest dataBackgroundFullRequest = null;
544fe9b7 110 private ParentHistogramCanvas fullExperimentCanvas = null;
b59134e1 111
544fe9b7 112 // Request and canvas for the "selected window"
ecfd1d41 113 private HistogramRequest selectedWindowRequest = null;
378e7718 114 private ChildrenHistogramCanvas selectedWindowCanvas = null;
b59134e1 115
544fe9b7
WB
116 // Content of the timeTextGroup
117 // Since the user can modify them with erroneous value,
118 // we will keep track of the value internally
1406f802
WB
119 private long selectedWindowTime = 0L;
120 private long selectedWindowTimerange = 0L;
121 private long currentEventTime = 0L;
7c1540ab 122
544fe9b7
WB
123 // *** All the UI control below
124 //
125 // NOTE : All textboxes will be READ_ONLY.
126 // So the user will be able to select/copy the value in them but not to change it
833a21aa
WB
127 private Text txtExperimentStartTime = null;
128 private Text txtExperimentStopTime = null;
129
130 private Text txtWindowStartTime = null;
131 private Text txtWindowStopTime = null;
7c1540ab
WB
132 private Text txtWindowMaxNbEvents = null;
133 private Text txtWindowMinNbEvents = null;
833a21aa
WB
134
135 private static final String WINDOW_TIMERANGE_LABEL_TEXT = "Window Timerange ";
544fe9b7
WB
136 private static final String WINDOW_CURRENT_TIME_LABEL_TEXT = "Cursor Centered on ";
137 private static final String EVENT_CURRENT_TIME_LABEL_TEXT = "Current Event Time ";
088c1d4e
WB
138 private TimeTextGroup ntgTimeRangeWindow = null;
139 private TimeTextGroup ntgCurrentWindowTime = null;
140 private TimeTextGroup ntgCurrentEventTime = null;
141
544fe9b7
WB
142 /**
143 * Default contructor of the view
144 */
6e512b93 145 public HistogramView() {
b59134e1 146 super(ID);
6e512b93 147 }
b59134e1 148
544fe9b7
WB
149 /**
150 * Create the UI controls of this view
151 *
152 * @param parent The composite parent of this view
153 */
6e512b93 154 @Override
7c1540ab
WB
155 public void createPartControl(Composite newParent) {
156 // Save the parent
157 parent = newParent;
b59134e1 158
833a21aa 159 // Default font
6cf16d22 160 Font font = parent.getFont();
833a21aa 161 FontData tmpFontData = font.getFontData()[0];
833a21aa
WB
162
163
7c1540ab
WB
164 Font smallFont = null;
165 int nbEventWidth = -1;
7ef9ae3f 166 int selectedCanvasWidth = -1;
7c1540ab
WB
167 boolean doesTimeTextGroupNeedAdjustment = false;
168
169 // Calculate if we need "small screen" fixes
170 if ( parent.getDisplay().getBounds().width < SCREEN_SMALL_IF_SMALLER_THAN ) {
171 // A lot smaller font for timstampe
172 smallFont = new Font(font.getDevice(), tmpFontData.getName(), tmpFontData.getHeight() - VERY_SMALL_FONT_MODIFIER, tmpFontData.getStyle());
173
7ef9ae3f
WB
174 // Smaller selection window canvas
175 selectedCanvasWidth = SMALL_SELECTED_WINDOW_CANVAS_WIDTH;
7c1540ab
WB
176 // Smaller event number text field
177 nbEventWidth = NB_EVENTS_FIXED_WIDTH/2;
178
179 // Tell the text group to ajust
180 doesTimeTextGroupNeedAdjustment = true;
7c1540ab
WB
181 }
182 else {
183 // Slightly smaller font for timestamp
184 smallFont = new Font(font.getDevice(), tmpFontData.getName(), tmpFontData.getHeight() - SMALL_FONT_MODIFIER, tmpFontData.getStyle());
185 // Usual size for selected window and event number text field
186 nbEventWidth = NB_EVENTS_FIXED_WIDTH;
187 selectedCanvasWidth = SELECTED_WINDOW_CANVAS_WIDTH;
188 // No ajustement needed by the text group
189 doesTimeTextGroupNeedAdjustment = false;
190 }
191
833a21aa
WB
192 // Layout for the whole view, other elements will be in a child composite of this one
193 // Contains :
194 // Composite layoutSelectionWindow
195 // Composite layoutTimesSpinner
196 // Composite layoutExperimentHistogram
197 Composite layoutFullView = new Composite(parent, SWT.NONE);
198 GridLayout gridFullView = new GridLayout();
199 gridFullView.numColumns = 2;
544fe9b7
WB
200 gridFullView.horizontalSpacing = 0;
201 gridFullView.verticalSpacing = 0;
833a21aa
WB
202 gridFullView.marginHeight = 0;
203 gridFullView.marginWidth = 0;
204 layoutFullView.setLayout(gridFullView);
833a21aa
WB
205
206
207 // Layout that contain the SelectionWindow
208 // Contains :
209 // Label lblWindowStartTime
210 // Label lblWindowStopTime
211 // Label lblWindowMaxNbEvents
212 // Label lblWindowMinNbEvents
213 // ChildrenHistogramCanvas selectedWindowCanvas
214 Composite layoutSelectionWindow = new Composite(layoutFullView, SWT.NONE);
215 GridLayout gridSelectionWindow = new GridLayout();
216 gridSelectionWindow.numColumns = 3;
217 gridSelectionWindow.marginHeight = 0;
218 gridSelectionWindow.marginWidth = 0;
544fe9b7
WB
219 gridSelectionWindow.horizontalSpacing = 0;
220 gridSelectionWindow.verticalSpacing = 0;
833a21aa
WB
221 layoutSelectionWindow.setLayout(gridSelectionWindow);
222 GridData gridDataSelectionWindow = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1);
223 layoutSelectionWindow.setLayoutData(gridDataSelectionWindow);
224
225
226 // Layout that contain the time spinner
227 // Contains :
228 // NanosecTextGroup spTimeRangeWindow
229 // NanosecTextGroup spCurrentWindowTime
230 // NanosecTextGroup spCurrentEventTime
231 Composite layoutTimesSpinner = new Composite(layoutFullView, SWT.NONE);
232 GridLayout gridTimesSpinner = new GridLayout();
544fe9b7 233 gridTimesSpinner.numColumns = 3;
833a21aa
WB
234 gridTimesSpinner.marginHeight = 0;
235 gridTimesSpinner.marginWidth = 0;
544fe9b7
WB
236 gridTimesSpinner.horizontalSpacing = 0;
237 gridTimesSpinner.verticalSpacing = 0;
833a21aa
WB
238 layoutTimesSpinner.setLayout(gridTimesSpinner);
239 GridData gridDataTimesSpinner = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
240 layoutTimesSpinner.setLayoutData(gridDataTimesSpinner);
241
242
243 // Layout that contain the complete experiment histogram and related controls.
244 // Contains :
245 // Label lblExperimentStartTime
246 // Label lblExperimentStopTime
247 // ParentHistogramCanvas fullTraceCanvas
248 Composite layoutExperimentHistogram = new Composite(layoutFullView, SWT.NONE);
249 GridLayout gridExperimentHistogram = new GridLayout();
250 gridExperimentHistogram.numColumns = 2;
251 gridExperimentHistogram.marginHeight = 0;
252 gridExperimentHistogram.marginWidth = 0;
544fe9b7
WB
253 gridExperimentHistogram.horizontalSpacing = 0;
254 gridExperimentHistogram.verticalSpacing = 0;
833a21aa
WB
255 layoutExperimentHistogram.setLayout(gridExperimentHistogram);
256 GridData gridDataExperimentHistogram = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
257 layoutExperimentHistogram.setLayoutData(gridDataExperimentHistogram);
258
259
260
261 // *** Everything related to the selection window is below
7c1540ab 262 GridData gridDataSelectionWindowCanvas = new GridData(SWT.LEFT, SWT.TOP, true, false, 2, 2);
833a21aa
WB
263 gridDataSelectionWindowCanvas.heightHint = SELECTED_WINDOW_CANVAS_HEIGHT;
264 gridDataSelectionWindowCanvas.minimumHeight = SELECTED_WINDOW_CANVAS_HEIGHT;
7c1540ab
WB
265 gridDataSelectionWindowCanvas.widthHint = selectedCanvasWidth;
266 gridDataSelectionWindowCanvas.minimumWidth = selectedCanvasWidth;
833a21aa
WB
267 selectedWindowCanvas = new ChildrenHistogramCanvas(this, layoutSelectionWindow, SWT.BORDER);
268 selectedWindowCanvas.setLayoutData(gridDataSelectionWindowCanvas);
269
7c1540ab 270 GridData gridDataWindowMaxEvents = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1);
833a21aa 271 // Force a width, to avoid the control to enlarge if the number of events change
7c1540ab
WB
272 gridDataWindowMaxEvents.minimumWidth = nbEventWidth;
273 txtWindowMaxNbEvents = new Text(layoutSelectionWindow, SWT.READ_ONLY);
274 txtWindowMaxNbEvents.setFont(smallFont);
275 txtWindowMaxNbEvents.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
276 txtWindowMaxNbEvents.setEditable(false);
277 txtWindowMaxNbEvents.setText("");
278 txtWindowMaxNbEvents.setLayoutData(gridDataWindowMaxEvents);
833a21aa
WB
279
280 GridData gridDataWindowMinEvents = new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1);
281 // Force a width, to avoid the control to enlarge if the number of events change
7c1540ab
WB
282 gridDataWindowMinEvents.minimumWidth = nbEventWidth;
283 txtWindowMinNbEvents = new Text(layoutSelectionWindow, SWT.READ_ONLY);
284 txtWindowMinNbEvents.setFont(smallFont);
285 txtWindowMinNbEvents.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
286 txtWindowMinNbEvents.setEditable(false);
287 txtWindowMinNbEvents.setText("");
288 txtWindowMinNbEvents.setLayoutData(gridDataWindowMinEvents);
833a21aa
WB
289
290 GridData gridDataWindowStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
291 txtWindowStartTime = new Text(layoutSelectionWindow, SWT.READ_ONLY);
292 txtWindowStartTime.setFont(smallFont);
293 txtWindowStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
294 txtWindowStartTime.setEditable(false);
295 txtWindowStartTime.setText("");
296 txtWindowStartTime.setLayoutData(gridDataWindowStart);
297
298 GridData gridDataWindowStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1);
299 txtWindowStopTime = new Text(layoutSelectionWindow, SWT.READ_ONLY);
300 txtWindowStopTime.setFont(smallFont);
301 txtWindowStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
302 txtWindowStopTime.setEditable(false);
303 txtWindowStopTime.setText("");
304 txtWindowStopTime.setLayoutData(gridDataWindowStop);
305
7ef9ae3f
WB
306 GridData gridDataSpacer = new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1);
307 gridDataSpacer.minimumWidth = nbEventWidth;
308 // *** HACK ***
309 // To align properly AND to make sure the canvas size is fixed, we NEED to make sure all "section" of the
310 // gridlayout are taken (and if possible of a fixed size).
311 // However, SWT is VERY VERY DUMB and won't consider griddata that contain no control.
312 // Since there will be missing a section, the SelectedWindowCanvas + NbEventsText will take 3 spaces, but
313 // startTimeText + stopTimeText will take only 2 (as if empty the other griddata of 1 will get ignored).
314 // StopTime will then take over the missing space; I want to align "stopTime" right on the end of canvas, so
315 // the added space to stop time would make it being aligned improperly
316 // So I NEED the empty griddata to be considered!
317 // Visually :
318 // |---------------|---------------|-----------|
319 // |SelectionCanvas SelectionCanvas|NbEventText|
320 // |SelectionCanvas SelectionCanvas|NbEventText|
321 // |---------------|---------------|-----------|
322 // |StartTime | StopTime| ??? |
323 // |---------------|---------------|-----------|
324 //
325 // So since SWT will only consider griddata with control,
326 // I need to create a totally useless control in the ??? section.
1155ca9f 327 // That's ugly, useless and it is generally a bad practice.
7ef9ae3f
WB
328 //
329 // *** SUB-HACK ***
330 // Other interesting fact about SWT : the way it draws (Fill/Expand control in grid) will change if
1406f802 331 // the control is a Text or a Label.
7ef9ae3f
WB
332 // A Label here will be "pushed" by startTime/stopTime Text and won't fill the full space as NbEventText.
333 // A Text here will NOT be "pushed" and would give a nice visual output.
334 // (NB : No, I am NOT kidding, try it for yourself!)
335 //
336 // Soooooo I guess I will use a Text here. Way to go SWT!
1155ca9f
WB
337 // Downside is that disabled textbox has a slightly different color (even if you force it yourself) so if I want
338 // to make the text "invisible", I have to keep it enabled (but read only), so it can be clicked on.
7ef9ae3f
WB
339 //
340 // Label uselessControlToByPassSWTStupidBug = new Label(layoutSelectionWindow, SWT.BORDER); // WON'T align correctly!!!
341 Text uselessControlToByPassSWTStupidBug = new Text(layoutSelectionWindow, SWT.READ_ONLY); // WILL align correctly!!!
342 uselessControlToByPassSWTStupidBug.setEditable(false);
343 uselessControlToByPassSWTStupidBug.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
344 uselessControlToByPassSWTStupidBug.setLayoutData(gridDataSpacer);
345
346
347
348 // *** Everything related to the time text group is below
3fda53ab 349 GridData gridDataCurrentEvent = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
7c1540ab 350 ntgCurrentEventTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, EVENT_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment);
3fda53ab 351 ntgCurrentEventTime.setLayoutData(gridDataCurrentEvent);
544fe9b7
WB
352
353 GridData gridDataTimeRange = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
7c1540ab 354 ntgTimeRangeWindow = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_TIMERANGE_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment);
544fe9b7
WB
355 ntgTimeRangeWindow.setLayoutData(gridDataTimeRange);
356
3fda53ab 357 GridData gridDataCurrentWindow = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
7c1540ab 358 ntgCurrentWindowTime = new TimeTextGroup(this, layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ), doesTimeTextGroupNeedAdjustment);
3fda53ab 359 ntgCurrentWindowTime.setLayoutData(gridDataCurrentWindow);
544fe9b7 360
833a21aa
WB
361
362
544fe9b7 363 // *** Everything related to the experiment canvas is below
833a21aa
WB
364 GridData gridDataExperimentCanvas = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
365 gridDataExperimentCanvas.heightHint = FULL_TRACE_CANVAS_HEIGHT;
366 gridDataExperimentCanvas.minimumHeight = FULL_TRACE_CANVAS_HEIGHT;
544fe9b7
WB
367 fullExperimentCanvas = new ParentHistogramCanvas(this, layoutExperimentHistogram, SWT.BORDER);
368 fullExperimentCanvas.setLayoutData(gridDataExperimentCanvas);
833a21aa
WB
369
370 GridData gridDataExperimentStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
371 txtExperimentStartTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY);
372 txtExperimentStartTime.setFont(smallFont);
373 txtExperimentStartTime.setText("");
374 txtExperimentStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
375 txtExperimentStartTime.setEditable(false);
376 txtExperimentStartTime.setLayoutData(gridDataExperimentStart);
377
378 GridData gridDataExperimentStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1);
379 txtExperimentStopTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY);
380 txtExperimentStopTime.setFont(smallFont);
381 txtExperimentStopTime.setText("");
382 txtExperimentStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
383 txtExperimentStopTime.setEditable(false);
384 txtExperimentStopTime.setLayoutData(gridDataExperimentStop);
6e512b93 385 }
b59134e1 386
544fe9b7
WB
387 // *** FIXME ***
388 // This is mainly used because of a because in the "experimentSelected()" notification, we shouldn't need this
389 /**
390 * Method called when the view receive the focus.<p>
391 * If ExperimentSelected didn't send us a request yet, get the current Experiment and fire requests
392 */
b59134e1 393 @SuppressWarnings("unchecked")
6e512b93
ASL
394 @Override
395 public void setFocus() {
544fe9b7 396 // WARNING : This does not seem to be thread safe
b59134e1
WB
397 TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)TmfExperiment.getCurrentExperiment();
398
399 if ( (dataBackgroundFullRequest == null) && (tmpExperiment != null) ) {
ecfd1d41 400 createCanvasAndRequests(tmpExperiment);
b59134e1 401 }
7ef9ae3f
WB
402
403 // Call a redraw for everything
404 parent.redraw();
6e512b93 405 }
b59134e1 406
544fe9b7
WB
407 /**
408 * Method called when the user select (double-click on) an experiment.<p>
409 * We will create the needed canvas and fire the requests.
410 *
411 * @param signal Signal received from the framework. Contain the experiment.
412 */
b59134e1
WB
413 @SuppressWarnings("unchecked")
414 @TmfSignalHandler
415 public void experimentSelected(TmfExperimentSelectedSignal<LttngEvent> signal) {
ecfd1d41
WB
416 TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)signal.getExperiment();
417 createCanvasAndRequests(tmpExperiment);
418 }
419
088c1d4e
WB
420 // *** VERIFY ***
421 // Not sure what this should do since I don't know when it will be called
422 // Let's do the same thing as experimentSelected for now
423 //
544fe9b7
WB
424 /**
425 * Method called when an experiment is updated (??).<p>
7c1540ab 426 * ...for now, do nothing, as udating an experiment running in the background might cause crash
544fe9b7
WB
427 *
428 * @param signal Signal received from the framework. Contain the experiment.
429 */
c1877796 430// @SuppressWarnings("unchecked")
088c1d4e 431 @TmfSignalHandler
833a21aa 432 public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
c1877796
WB
433//
434// TmfExperiment<LttngEvent> tmpExperiment = (TmfExperiment<LttngEvent>)signal.getExperiment();
435//
436// // Make sure the UI object are sane
437// resetControlsContent();
438//
439// // Redraw the canvas right away to have something "clean" as soon as we can
440// fullExperimentCanvas.redraw();
441// selectedWindowCanvas.redraw();
442//
443// // Recreate the request
444// createCanvasAndRequests(tmpExperiment);
833a21aa
WB
445 }
446
544fe9b7
WB
447 /**
448 * Method called when synchonization is active and that the user select an event.<p>
449 * We update the current event timeTextGroup and move the selected window if needed.
450 *
451 * @param signal Signal received from the framework. Contain the event.
452 */
833a21aa
WB
453 @TmfSignalHandler
454 public void currentTimeUpdated(TmfTimeSynchSignal signal) {
544fe9b7 455 // In case we received our own signal
833a21aa
WB
456 if (signal.getSource() != this) {
457 TmfTimestamp currentTime = signal.getCurrentTime();
833a21aa 458
544fe9b7 459 // Update the current event controls
088c1d4e
WB
460 currentEventTime = currentTime.getValue();
461 updateSelectedEventTime();
462
544fe9b7
WB
463 // If the given event is outside the selection window, recenter the window
464 if ( isGivenTimestampInSelectedWindow( currentEventTime ) == false) {
1406f802 465 fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(currentEventTime) );
544fe9b7 466 // Notify control that the window changed
833a21aa 467 windowChangedNotification();
1406f802
WB
468 // Send a broadcast to the framework about the window change
469 sendTmfRangeSynchSignalBroadcast();
833a21aa 470 }
833a21aa
WB
471 }
472 }
473
1406f802
WB
474 @TmfSignalHandler
475 public void synchToTimeRange(TmfRangeSynchSignal signal) {
476 if ( (signal != null) && (signal.getSource() != this) ) {
477 if ( lastUsedExperiment != null ) {
478 long currentTime = signal.getCurrentTime().getValue();
479 long windowStart = signal.getCurrentRange().getStartTime().getValue();
480 long windowEnd = signal.getCurrentRange().getEndTime().getValue();
481 long windowTimeWidth = (windowEnd - windowStart);
482
483 // Recenter the window
484 fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(windowStart + (windowTimeWidth/2)) );
485 fullExperimentCanvas.setSelectedWindowSize(windowTimeWidth);
486
487 // *** HACK ***
488 // Views could send us incorrect current event value (event outside the current window)
489 // Here we make sure the value is sane, otherwise, we force it as the left border of the window
490 if ( isGivenTimestampInSelectedWindow( currentTime ) == false ) {
491 currentTime = windowStart;
492 }
493 currentEventTime = currentTime;
494
495 // Notify control that the window changed
496 windowChangedNotification();
497
16511734 498 // Make sure we redraw the change
1406f802 499 fullExperimentCanvas.redraw();
1406f802
WB
500 }
501 }
502 }
503
504
544fe9b7
WB
505 /*
506 * Create the canvas needed and issue the requests
507 *
508 * @param newExperiment Experiment we will use for the request
509 */
510 private void createCanvasAndRequests(TmfExperiment<LttngEvent> newExperiment) {
16511734 511 // Save the experiment we are about to use
3cd34850
WB
512 lastUsedExperiment = newExperiment;
513
550d787e
FC
514// // Create a copy of the trace that will be use only by the full experiment request
515// TmfExperiment<LttngEvent> experimentCopy = newExperiment.createTraceCopy();
c1877796 516
3fda53ab
WB
517 // Create the content for the full experiment.
518 // This NEED to be created first, as we use it in the selectedWindowCanvas
7c1540ab
WB
519 fullExperimentCanvas.createNewHistogramContent(fullExperimentCanvas.getSize().x, FULL_TRACE_BAR_WIDTH, FULL_TRACE_CANVAS_HEIGHT, FULL_TRACE_DIFFERENCE_TO_AVERAGE);
520 fullExperimentCanvas.createNewSelectedWindow(DEFAULT_WINDOW_SIZE);
550d787e
FC
521
522 TmfTimeRange timeRange = getExperimentTimeRange(newExperiment);
523 currentEventTime = timeRange.getStartTime().getValue();
524
525 // Set the window of the fullTrace canvas visible.
7c1540ab 526 fullExperimentCanvas.getCurrentWindow().setSelectedWindowVisible(true);
550d787e 527 fullExperimentCanvas.getHistogramContent().resetTable(timeRange.getStartTime().getValue(), timeRange.getEndTime().getValue());
3fda53ab 528
7c1540ab 529 // Create the content for the selected window.
7ef9ae3f 530 selectedWindowCanvas.createNewHistogramContent(selectedWindowCanvas.getSize().x ,SELECTED_WINDOW_BAR_WIDTH, SELECTED_WINDOW_CANVAS_HEIGHT, SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE);
1155ca9f 531 selectedWindowCanvas.getHistogramContent().resetTable(fullExperimentCanvas.getCurrentWindow().getTimestampOfLeftPosition(), fullExperimentCanvas.getCurrentWindow().getTimestampOfRightPosition());
6cf16d22 532
1406f802 533 // Make sure the UI object are sane
544fe9b7 534 resetControlsContent();
833a21aa 535
6cf16d22
WB
536 // Redraw the canvas right away to have something "clean" as soon as we can
537 if ( dataBackgroundFullRequest != null ) {
544fe9b7 538 fullExperimentCanvas.redraw();
6cf16d22
WB
539 selectedWindowCanvas.redraw();
540 }
544fe9b7
WB
541 // Nullify the (possible) old request to be sure we start we something clean
542 // Note : this is very important for the order of the request below,
543 // see "TODO" in performSelectedWindowEventsRequest
544 dataBackgroundFullRequest = null;
545 selectedWindowRequest = null;
ecfd1d41 546
544fe9b7
WB
547 // Perform both request.
548 // Order is important here, the small/synchronous request for the selection window should go first
ecfd1d41 549 performSelectedWindowEventsRequest(newExperiment);
550d787e
FC
550// performAllTraceEventsRequest(experimentCopy);
551 performAllTraceEventsRequest(newExperiment);
ecfd1d41 552 }
550d787e
FC
553
554 // Before completing its indexing, the experiment doesn't know start/end time.
555 // However, LTTng individual traces have this knowledge so we should ask them
556 // directly.
557 private TmfTimeRange getExperimentTimeRange(TmfExperiment<LttngEvent> experiment) {
558 // Before completing its indexing, the experiment doesn't know start/end time.
559 // However, LTTng individual traces have this knowledge so we should ask them
560 // directly.
561 TmfTimestamp startTime = TmfTimestamp.BigCrunch;
562 TmfTimestamp endTime = TmfTimestamp.BigBang;
563 for (ITmfTrace trace : experiment.getTraces()) {
564 TmfContext context = trace.seekLocation(null);
565 context.setRank(0);
566 TmfEvent event = trace.getNextEvent(context);
567 TmfTimestamp traceStartTime = event.getTimestamp();
568 if (traceStartTime.compareTo(startTime, true) < 0)
569 startTime = traceStartTime;
570 TmfTimestamp traceEndTime = trace.getEndTime();
571 if (traceEndTime.compareTo(endTime, true) > 0)
572 endTime = traceEndTime;
573 }
574 TmfTimeRange tmpRange = new TmfTimeRange(startTime, endTime);
575 return tmpRange;
576 }
577
544fe9b7
WB
578 /**
579 * Perform a new request for the Selection window.<p>
580 * This assume the full experiment canvas has correct information about the selected window;
581 * we need the fullExperimentCanvas' HistogramContent to be created and a selection window to be set.
582 *
583 * @param experiment The experiment we will select from
584 */
ecfd1d41 585 public void performSelectedWindowEventsRequest(TmfExperiment<LttngEvent> experiment) {
252ae4bd 586
544fe9b7 587 HistogramSelectedWindow curSelectedWindow = fullExperimentCanvas.getCurrentWindow();
b59134e1 588
550d787e 589 // If no selection window exists, we will try to create one;
544fe9b7 590 // however this will most likely fail as the content is probably not created either
ecfd1d41 591 if ( curSelectedWindow == null ) {
544fe9b7
WB
592 fullExperimentCanvas.createNewSelectedWindow( DEFAULT_WINDOW_SIZE );
593 curSelectedWindow = fullExperimentCanvas.getCurrentWindow();
ecfd1d41
WB
594 }
595
544fe9b7
WB
596 // The request will go from the Left timestamp of the window to the Right timestamp
597 // This assume that out-of-bound value are handled by the SelectionWindow itself
1155ca9f
WB
598 LttngTimestamp ts1 = new LttngTimestamp( curSelectedWindow.getTimestampOfLeftPosition() );
599 LttngTimestamp ts2 = new LttngTimestamp( curSelectedWindow.getTimestampOfRightPosition() );
ecfd1d41
WB
600 TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
601
602 // Set a (dynamic) time interval
603 long intervalTime = ( (ts2.getValue() - ts1.getValue()) / selectedWindowCanvas.getHistogramContent().getNbElement() );
604
cb866e08 605 selectedWindowRequest = performRequest(experiment, selectedWindowCanvas, tmpRange, intervalTime, ExecutionType.LONG);
6cf16d22 606 selectedWindowCanvas.redrawAsynchronously();
ecfd1d41
WB
607 }
608
544fe9b7
WB
609 /**
610 * Perform a new request for the full experiment.<p>
611 * NOTE : this is very long, we need to implement a way to run this in parallel (see TODO)
612 *
613 * @param experiment The experiment we will select from
614 */
ecfd1d41 615 public void performAllTraceEventsRequest(TmfExperiment<LttngEvent> experiment) {
b59134e1
WB
616 // Create a new time range from "start" to "end"
617 // That way, we will get "everything" in the trace
550d787e
FC
618// LttngTimestamp ts1 = new LttngTimestamp( experiment.getStartTime() );
619// LttngTimestamp ts2 = new LttngTimestamp( experiment.getEndTime() );
620// TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
621
622 TmfTimeRange tmpRange = getExperimentTimeRange(experiment);
623 TmfTimestamp startTime = tmpRange.getStartTime();
624 TmfTimestamp endTime = tmpRange.getEndTime();
b59134e1 625
ecfd1d41 626 // Set a (dynamic) time interval
550d787e 627 long intervalTime = ( (endTime.getValue() - startTime.getValue()) / fullExperimentCanvas.getHistogramContent().getNbElement() );
b59134e1 628
544fe9b7
WB
629 // *** VERIFY ***
630 // This would enable "fixed interval" instead of dynamic one.
631 // ... we don't need it, do we?
632 //
633 // long intervalTime = ((long)(0.001 * (double)1000000000));
634
635 // *** TODO ***
636 // It would be interesting if there was a way to tell the framework to run the request "in parallel" here.
637 // Mean a completetly independant copy of the Expereiment would be done and we would proceed on that.
638 //
550d787e 639 dataBackgroundFullRequest = performRequest(experiment, fullExperimentCanvas, tmpRange, intervalTime, ExecutionType.LONG);
544fe9b7 640 fullExperimentCanvas.redrawAsynchronously();
b59134e1
WB
641 }
642
643 // *** VERIFY ***
544fe9b7
WB
644 // This function is synchronized, is it a good idea?
645 // Tis is done to make sure requests arrive somewhat in order,
646 // this is especially important when request are issued from different thread.
647 /**
648 * Create a new request from the given data and send it to the framework.<p>
649 * The request will be queued and processed later.
650 *
651 * @param experiment The experiment we will process the request on
652 * @param targetCanvas The canvas that will received the result
653 * @param newRange The range of the request
654 * @param newInterval The interval of time we use to store the result into the HistogramContent
655 */
550d787e 656 private synchronized HistogramRequest performRequest(TmfExperiment<LttngEvent> experiment, HistogramCanvas targetCanvas, TmfTimeRange newRange, long newInterval, ITmfDataRequest.ExecutionType execType) {
b59134e1
WB
657 HistogramRequest returnedRequest = null;
658
ecfd1d41
WB
659 // *** FIXME ***
660 // EVIL BUG!
1406f802 661 // We use int.MAX_VALUE because we want every events BUT we don't know the number inside the range.
ecfd1d41
WB
662 // HOWEVER, this would cause the request to run forever (or until it reach the end of trace).
663 // Seeting an EndTime does not seems to stop the request
550d787e 664 returnedRequest = new HistogramRequest(newRange, Integer.MAX_VALUE, targetCanvas, newInterval, execType );
544fe9b7
WB
665
666 // Send the request to the framework : it will be queued and processed later
b59134e1
WB
667 experiment.sendRequest(returnedRequest);
668
669 return returnedRequest;
670 }
088c1d4e 671
544fe9b7
WB
672 /**
673 * Function used to warn that the selection window changed.<p>
674 * This might be called because the window moved or because its size changed.<p>
675 *
676 * We will update the different control related to the selection window.
677 */
ecfd1d41 678 public void windowChangedNotification() {
833a21aa 679
ecfd1d41 680 if ( lastUsedExperiment != null ) {
544fe9b7 681 // If a request is ongoing, try to stop it
550d787e 682 if ( selectedWindowRequest != null && selectedWindowRequest.isCompleted() == false ) {
6cf16d22
WB
683 selectedWindowRequest.cancel();
684 }
833a21aa 685
544fe9b7 686 // Get the latest window information
1155ca9f 687 selectedWindowTime = fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition();
544fe9b7 688 selectedWindowTimerange = fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth();
088c1d4e 689
544fe9b7 690 // If the current event time is outside the new window, change the current event
1406f802 691 // The new current event will be the one closest to the LEFT side of the new window
544fe9b7 692 if ( isGivenTimestampInSelectedWindow(currentEventTime) == false ) {
1155ca9f 693 currentEventChangeNotification( fullExperimentCanvas.getCurrentWindow().getTimestampOfLeftPosition() );
088c1d4e
WB
694 }
695
544fe9b7 696 // Perform a new request to read data about the new window
ecfd1d41
WB
697 performSelectedWindowEventsRequest(lastUsedExperiment);
698 }
699 }
700
544fe9b7
WB
701 /**
702 * Function used to tell that the current event changed.<p>
703 * This might be called because the user changed the current event or
704 * because the last current event is now outside the selection window.<p>
705 *
706 * We update the related control and send a signal to notify other views of the new current event.
707 *
708 * @param newCurrentEventTime
709 */
1406f802
WB
710 public void currentEventChangeNotification(long newCurrentEventTime) {
711
088c1d4e
WB
712 // Notify other views in the framework
713 if (currentEventTime != newCurrentEventTime) {
714 currentEventTime = newCurrentEventTime;
715
544fe9b7 716 // Update the UI control
088c1d4e 717 updateSelectedEventTime();
088c1d4e
WB
718 }
719 }
720
1406f802
WB
721 public void sendTmfTimeSynchSignalBroadcast() {
722
723// System.out.println("sendTmfTimeSynchSignalBroadcast " + System.currentTimeMillis());
724
725 // Send a signal to the framework
726 LttngTimestamp tmpTimestamp = new LttngTimestamp(currentEventTime);
727 broadcast(new TmfTimeSynchSignal(this, tmpTimestamp));
728 }
729
ed4b3b9f
WB
730 /**
731 * Function used to tell that the timerange (window) changed.<p>
732 * This will most likely be called if the time window is resized.
733 *
734 * We send a signal to notify other views of the new timerange.
735 */
1406f802
WB
736 public void sendTmfRangeSynchSignalBroadcast() {
737
738// System.out.println("sendTmfRangeSynchSignalBroadcast " + System.currentTimeMillis());
739
740 // *** TODO ***
741 // Not very elegant... we need to chance this below.
742 //
1155ca9f 743 long centerTime = fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition();
1406f802
WB
744 long windowWidth = fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth();
745
746 long startTime = centerTime-windowWidth;
747 if ( startTime < fullExperimentCanvas.getHistogramContent().getStartTime() ) {
748 startTime = fullExperimentCanvas.getHistogramContent().getStartTime();
749 }
750 LttngTimestamp tmpStartTime = new LttngTimestamp(startTime);
751
752 long endTime = centerTime+windowWidth;
753 if ( endTime > fullExperimentCanvas.getHistogramContent().getEndTime() ) {
754 endTime = fullExperimentCanvas.getHistogramContent().getEndTime();
755 }
756 LttngTimestamp tmpEndTime = new LttngTimestamp(endTime);
1406f802 757
ed4b3b9f
WB
758 TmfTimeRange tmpTimeRange = new TmfTimeRange(tmpStartTime, tmpEndTime);
759 LttngTimestamp tmpEventTime = new LttngTimestamp(currentEventTime);
1406f802 760
ed4b3b9f
WB
761 // Send a signal to the framework
762 broadcast(new TmfRangeSynchSignal(this, tmpTimeRange, tmpEventTime));
763 }
764
544fe9b7
WB
765 /**
766 * Function that will be called when one of the time text group value is changed.<p>
767 * Since we don't (and can't unless we subclass them) know which one, we check them all.
768 */
088c1d4e
WB
769 public void timeTextGroupChangeNotification() {
770
544fe9b7 771 // Get all the time text group value
1406f802
WB
772 long newCurrentTime = ntgCurrentEventTime.getValue();
773 long newSelectedWindowTime = ntgCurrentWindowTime.getValue();
774 long newSelectedWindowTimeRange = ntgTimeRangeWindow.getValue();
088c1d4e 775
544fe9b7 776 // If the user changed the current event time, call the notification
088c1d4e
WB
777 if ( newCurrentTime != currentEventTime ) {
778 currentEventChangeNotification( newCurrentTime );
1406f802
WB
779 // Send a broadcast to the framework about the window change
780 sendTmfTimeSynchSignalBroadcast();
088c1d4e
WB
781 }
782
544fe9b7 783 // If the user changed the selected window time, recenter the window and call the notification
088c1d4e
WB
784 if ( newSelectedWindowTime != selectedWindowTime ) {
785 selectedWindowTime = newSelectedWindowTime;
1406f802 786 fullExperimentCanvas.setWindowCenterPosition( fullExperimentCanvas.getHistogramContent().getClosestXPositionFromTimestamp(selectedWindowTime) );
544fe9b7 787 windowChangedNotification();
1406f802
WB
788 // Send a broadcast to the framework about the window change
789 sendTmfRangeSynchSignalBroadcast();
088c1d4e
WB
790 }
791
544fe9b7 792 // If the user changed the selected window size, resize the window and call the notification
088c1d4e
WB
793 if ( newSelectedWindowTimeRange != selectedWindowTimerange ) {
794 selectedWindowTimerange = newSelectedWindowTimeRange;
544fe9b7
WB
795 fullExperimentCanvas.resizeWindowByAbsoluteTime(selectedWindowTimerange);
796 windowChangedNotification();
1406f802
WB
797 // Send a broadcast to the framework about the window change
798 sendTmfRangeSynchSignalBroadcast();
088c1d4e
WB
799 }
800
801 }
802
544fe9b7
WB
803 /**
804 * Getter for the last used experiment.<p>
805 * This might be different than the current experiment or even null.
806 *
807 * @return the last experiment we used in this view
808 */
ecfd1d41
WB
809 public TmfExperiment<LttngEvent> getLastUsedExperiment() {
810 return lastUsedExperiment;
811 }
812
544fe9b7
WB
813 /**
814 * Check if a given timestamp is inside the selection window.<p>
815 * This assume fullExperimentCanvas contain a valid HistogramContent
816 *
817 * @param timestamp the timestamp to check
818 *
819 * @return if the time is inside the selection window or not
820 */
1406f802 821 public boolean isGivenTimestampInSelectedWindow(long timestamp) {
088c1d4e
WB
822 boolean returnedValue = true;
823
544fe9b7 824 // If the content is not set correctly, this will return weird (or even null) result
1155ca9f
WB
825 if ( (timestamp < fullExperimentCanvas.getCurrentWindow().getTimestampOfLeftPosition() ) ||
826 (timestamp > fullExperimentCanvas.getCurrentWindow().getTimestampOfRightPosition() ) )
088c1d4e
WB
827 {
828 returnedValue = false;
829 }
830
831 return returnedValue;
832 }
833
544fe9b7
WB
834 /**
835 * Reset the content of all Controls.<p>
836 * WARNING : Calls in there are not thread safe and can't be called from different thread than "main"
837 */
838 public void resetControlsContent() {
833a21aa
WB
839
840 TmfExperiment<LttngEvent> tmpExperiment = getLastUsedExperiment();
841
544fe9b7 842 // Use the previous Start and End time, or default if they are not available
833a21aa
WB
843 String startTime = null;
844 String stopTime = null;
845 if ( tmpExperiment != null ) {
846 startTime = HistogramConstant.formatNanoSecondsTime( tmpExperiment.getStartTime().getValue() );
847 stopTime = HistogramConstant.formatNanoSecondsTime( tmpExperiment.getEndTime().getValue() );
6cf16d22 848 }
833a21aa
WB
849 else {
850 startTime = HistogramConstant.formatNanoSecondsTime( 0L );
851 stopTime = HistogramConstant.formatNanoSecondsTime( 0L );
852 }
853
854 txtExperimentStartTime.setText( startTime );
855 txtExperimentStopTime.setText( stopTime );
856 txtExperimentStartTime.getParent().layout();
857
7c1540ab
WB
858 txtWindowMaxNbEvents.setText("" + 0);
859 txtWindowMinNbEvents.setText("" + 0);
833a21aa
WB
860 txtWindowStartTime.setText( HistogramConstant.formatNanoSecondsTime( 0L ) );
861 txtWindowStopTime.setText( HistogramConstant.formatNanoSecondsTime( 0L ) );
862 txtWindowStartTime.getParent().layout();
378e7718 863
833a21aa
WB
864 ntgCurrentWindowTime.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
865 ntgTimeRangeWindow.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
16511734
WB
866
867 // Using "startTime" here can avoid an useless TmfTimeSynchSignal here
868 // However it look ugly to have only this time
833a21aa 869 ntgCurrentEventTime.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
378e7718
WB
870 }
871
544fe9b7
WB
872 /**
873 * Update the content of the controls related to the full experiment canvas<p>
874 * WARNING : Calls in there are not thread safe and can't be called from different thread than "main"
875 */
876 public void updateFullExperimentInformation() {
378e7718 877
544fe9b7
WB
878 String startTime = HistogramConstant.formatNanoSecondsTime( fullExperimentCanvas.getHistogramContent().getStartTime() );
879 String stopTime = HistogramConstant.formatNanoSecondsTime( fullExperimentCanvas.getHistogramContent().getEndTime() );
378e7718 880
833a21aa
WB
881 txtExperimentStartTime.setText( startTime );
882 txtExperimentStopTime.setText( stopTime );
883
884 // Take one of the parent and call its layout to update control size
885 // Since both control have the same parent, only one call is needed
886 txtExperimentStartTime.getParent().layout();
887
888 // Update the selected window, just in case
889 // This should give a better user experience and it is low cost
890 updateSelectedWindowInformation();
378e7718
WB
891 }
892
544fe9b7
WB
893 /**
894 * Update the content of the controls related to the selection window canvas<p>
895 * WARNING : Calls in there are not thread safe and can't be called from different thread than "main"
896 */
378e7718 897 public void updateSelectedWindowInformation() {
833a21aa
WB
898 // Update the timestamp as well
899 updateSelectedWindowTimestamp();
900
1406f802
WB
901 txtWindowMaxNbEvents.setText( Long.toString(selectedWindowCanvas.getHistogramContent().getHeighestEventCount()) );
902 txtWindowMinNbEvents.setText(Long.toString(0));
833a21aa
WB
903
904 // Refresh the layout
7c1540ab 905 txtWindowMaxNbEvents.getParent().layout();
ecfd1d41 906 }
6cf16d22 907
544fe9b7
WB
908 /**
909 * Update the content of the controls related to the timestamp of the selection window<p>
910 * WARNING : Calls in there are not thread safe and can't be called from different thread than "main"
911 */
833a21aa
WB
912 public void updateSelectedWindowTimestamp() {
913 String startTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getStartTime() );
914 String stopTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getEndTime() );
915 txtWindowStartTime.setText( startTime );
916 txtWindowStopTime.setText( stopTime );
917
1155ca9f 918 ntgCurrentWindowTime.setValue( fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition() );
544fe9b7 919 ntgTimeRangeWindow.setValue( fullExperimentCanvas.getCurrentWindow().getWindowTimeWidth() );
833a21aa 920
544fe9b7 921 // If the current event time is outside the selection window, recenter our window
088c1d4e 922 if ( isGivenTimestampInSelectedWindow(ntgCurrentEventTime.getValue()) == false ) {
1155ca9f 923 currentEventChangeNotification( fullExperimentCanvas.getCurrentWindow().getTimestampOfCenterPosition() );
088c1d4e
WB
924 }
925
833a21aa
WB
926 // Take one control in each group to call to refresh the layout
927 // Since both control have the same parent, only one call is needed
928 txtWindowStartTime.getParent().layout();
929 ntgCurrentWindowTime.getParent().layout();
930 }
378e7718 931
544fe9b7
WB
932 /**
933 * Update the controls related current event.<p>
934 * The call here SHOULD be thread safe and can be call from any threads.
935 */
088c1d4e
WB
936 public void updateSelectedEventTime() {
937 ntgCurrentEventTime.setValueAsynchronously(currentEventTime);
544fe9b7
WB
938 // Tell the selection canvas which event is currently selected
939 // This give a nice graphic output
088c1d4e
WB
940 selectedWindowCanvas.getHistogramContent().setSelectedEventTimeInWindow(currentEventTime);
941 selectedWindowCanvas.redrawAsynchronously();
942 }
943
7ef9ae3f
WB
944 /**
945 * Method called when the view is moved.<p>
946 *
947 * Just redraw everything...
948 *
949 * @param event The controle event generated by the move.
950 */
951 public void controlMoved(ControlEvent event) {
952 parent.redraw();
953 }
954
955 /**
956 * Method called when the view is resized.<p>
957 *
958 * We will make sure that the size didn't change more than the content size.<p>
959 * Otherwise we need to perform a new request for the full experiment because we are missing data).
960 *
961 * @param event The control event generated by the resize.
962 */
963 public void controlResized(ControlEvent event) {
964
965 // Ouch! The screen enlarged (screen resolution changed?) so far that we miss content to fill the space.
7ef9ae3f
WB
966 if ( parent.getDisplay().getBounds().width > fullExperimentCanvas.getHistogramContent().getNbElement() ) {
967 if ( lastUsedExperiment != null ) {
1406f802 968 createCanvasAndRequests(lastUsedExperiment);
7ef9ae3f
WB
969 }
970 }
971
972 }
6e512b93 973}
This page took 0.079434 seconds and 5 git commands to generate.