Commit | Line | Data |
---|---|---|
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: | |
10 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.lttng.ui.views.timeframe; | |
14 | ||
8b29a712 | 15 | import org.eclipse.linuxtools.lttng.ui.views.Labels; |
6e512b93 ASL |
16 | import org.eclipse.linuxtools.tmf.event.TmfTimeRange; |
17 | import org.eclipse.linuxtools.tmf.event.TmfTimestamp; | |
18 | import org.eclipse.swt.SWT; | |
19 | import org.eclipse.swt.events.ModifyEvent; | |
20 | import org.eclipse.swt.events.ModifyListener; | |
21 | import org.eclipse.swt.layout.GridData; | |
22 | import org.eclipse.swt.widgets.Composite; | |
23 | import org.eclipse.swt.widgets.Group; | |
24 | import org.eclipse.swt.widgets.Label; | |
25 | import org.eclipse.swt.widgets.Spinner; | |
26 | ||
27 | // ======================================================================== | |
28 | // SpinnerGroup | |
29 | // ======================================================================== | |
30 | ||
31 | /** | |
32 | * <b><u>SpinnerGroup</u></b> | |
33 | * <p> | |
34 | * A SpinnerGroup holds two coordinated spinners (for seconds and | |
35 | * nanoseconds) representing the current time within the trace. | |
36 | * <p> | |
37 | * The current time can take any value anything within the time range (start | |
38 | * and end time). | |
39 | */ | |
40 | public class SpinnerGroup { | |
41 | ||
42 | // The nanosecond scale (10^9) | |
8b29a712 FC |
43 | private static final int NANOSECOND_SCALE = 1000 * 1000 * 1000; |
44 | private static final byte SCALE = -9; | |
6e512b93 ASL |
45 | |
46 | // Widgets | |
47 | private Group group; | |
48 | private Spinner seconds; | |
49 | private Spinner nanosec; | |
50 | ||
51 | // The valid time range - start time | |
52 | private TmfTimestamp startTime; | |
53 | private int startSeconds; | |
54 | private int startNanosec; | |
55 | ||
56 | // The valid time range - end time | |
57 | private TmfTimestamp endTime; | |
58 | private int endSeconds; | |
59 | private int endNanosec; | |
60 | ||
61 | // The current time value | |
62 | private TmfTimestamp currentTime; | |
63 | private int currentSeconds; | |
64 | private int currentNanosec; | |
65 | ||
6e512b93 ASL |
66 | private TimeFrameView fOwner; |
67 | ||
68 | /** | |
69 | * <b><u>Constructor</u></b> | |
70 | * <p> | |
71 | * <li>Creates the display group and formats it for the grid cell | |
72 | * <li>Sets the initial values for Start/End/Current time | |
73 | * </li> | |
74 | * <p> | |
75 | * @param parent - the parent Composite | |
76 | * @param groupName - the group name | |
77 | * @param range - the valid time range (start/end time) | |
78 | * @param current - the current time | |
79 | */ | |
80 | public SpinnerGroup(TimeFrameView owner, Composite parent, String groupName, TmfTimeRange range, TmfTimestamp current) { | |
81 | ||
82 | fOwner = owner; | |
83 | ||
84 | // Create the group | |
85 | group = new Group(parent, SWT.BORDER); | |
86 | group.setText(groupName); | |
87 | ||
88 | // Make it use the whole grid cell | |
89 | GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false); | |
90 | gridData.horizontalAlignment = SWT.FILL; | |
91 | group.setLayoutData(gridData); | |
92 | ||
93 | // Create and position the widgets | |
94 | seconds = new Spinner(group, SWT.BORDER); | |
95 | seconds.addModifyListener(new ModifyListener() { | |
96 | public void modifyText(ModifyEvent e) { | |
97 | currentSeconds = seconds.getSelection(); | |
98 | refreshCurrentTime(); | |
99 | } | |
100 | }); | |
101 | seconds.setBounds(5, 25, 110, 25); | |
102 | ||
103 | Label label = new Label(group, SWT.LEFT); | |
8b29a712 | 104 | label.setText(Labels.TimeFrameView_Seconds); |
6e512b93 ASL |
105 | label.setBounds(120, 28, 25, 22); |
106 | ||
107 | nanosec = new Spinner(group, SWT.BORDER); | |
108 | nanosec.addModifyListener(new ModifyListener() { | |
109 | public void modifyText(ModifyEvent e) { | |
110 | currentNanosec = nanosec.getSelection(); | |
111 | // Correct for nanosec underflow | |
112 | if (currentNanosec < 0) { | |
113 | currentSeconds--; | |
8b29a712 | 114 | currentNanosec = NANOSECOND_SCALE - 1; |
6e512b93 ASL |
115 | } |
116 | // Correct for nanosec overflow | |
8b29a712 | 117 | if (currentNanosec >= NANOSECOND_SCALE) { |
6e512b93 ASL |
118 | currentSeconds++; |
119 | currentNanosec = 0; | |
120 | } | |
121 | refreshCurrentTime(); | |
122 | } | |
123 | }); | |
124 | nanosec.setBounds(150, 25, 110, 25); | |
125 | ||
126 | label = new Label(group, SWT.LEFT); | |
8b29a712 | 127 | label.setText(Labels.TimeFrameView_Nanosec); |
6e512b93 ASL |
128 | label.setBounds(265, 28, 25, 22); |
129 | ||
130 | setContent(range, current); | |
131 | } | |
132 | ||
133 | private void refreshCurrentTime() { | |
8b29a712 FC |
134 | long newCurrentTime = (long) currentSeconds * NANOSECOND_SCALE + currentNanosec; |
135 | TmfTimestamp ts = new TmfTimestamp(newCurrentTime, SCALE, 0); | |
6e512b93 | 136 | currentTime = ts; |
8035003b | 137 | fOwner.synchTimeFrameWidgets(this); |
6e512b93 ASL |
138 | } |
139 | ||
140 | // ==================================================================== | |
141 | // Get/Set | |
142 | // ==================================================================== | |
143 | ||
144 | public TmfTimestamp getStartTime() { | |
145 | return startTime; | |
146 | } | |
147 | ||
148 | public TmfTimestamp getEndTime() { | |
149 | return endTime; | |
150 | } | |
151 | ||
152 | public TmfTimestamp getCurrentTime() { | |
153 | return currentTime; | |
154 | } | |
155 | ||
156 | public TmfTimestamp getSpan() { | |
8b29a712 | 157 | TmfTimestamp span = new TmfTimestamp(startTime.getAdjustment(endTime), SCALE, 0); |
6e512b93 ASL |
158 | return span; |
159 | } | |
160 | ||
161 | public TmfTimeRange getTimeRange() { | |
162 | TmfTimeRange range = new TmfTimeRange(startTime, endTime); | |
163 | return range; | |
164 | } | |
165 | ||
166 | public void setStartTime(TmfTimestamp ts) { | |
8b29a712 FC |
167 | startTime = ts.synchronize(0, SCALE); |
168 | startSeconds = (int) (startTime.getValue() / NANOSECOND_SCALE); | |
169 | startNanosec = (int) (startTime.getValue() % NANOSECOND_SCALE); | |
6e512b93 ASL |
170 | } |
171 | ||
172 | public void setEndTime(TmfTimestamp ts) { | |
8b29a712 FC |
173 | endTime = ts.synchronize(0, SCALE); |
174 | endSeconds = (int) (endTime.getValue() / NANOSECOND_SCALE); | |
175 | endNanosec = (int) (endTime.getValue() % NANOSECOND_SCALE); | |
6e512b93 ASL |
176 | } |
177 | ||
178 | public void setCurrentTime(TmfTimestamp ts) { | |
8b29a712 FC |
179 | currentTime = ts.synchronize(0, SCALE); |
180 | currentSeconds = (int) (currentTime.getValue() / NANOSECOND_SCALE); | |
181 | currentNanosec = (int) (currentTime.getValue() % NANOSECOND_SCALE); | |
6e512b93 ASL |
182 | } |
183 | ||
184 | // ==================================================================== | |
185 | // Operators | |
186 | // ==================================================================== | |
187 | ||
188 | /** | |
189 | * <b><u>setContent</u></b> | |
190 | * <p> | |
191 | * <li>validates that [startTime <= currentTime <= endTime] is respected | |
192 | * <li>sets the start/current/end time and update the spinners | |
193 | * </li> | |
194 | * <p> | |
195 | * | |
196 | * @param range | |
197 | * @param current | |
198 | */ | |
199 | public void setContent(TmfTimeRange range, TmfTimestamp current) { | |
200 | ||
201 | if (range != null) { | |
202 | // Extract the time range | |
203 | TmfTimestamp start = range.getStartTime(); | |
8035003b | 204 | TmfTimestamp end = range.getEndTime(); |
6e512b93 ASL |
205 | |
206 | // Assume start time is OK | |
207 | setStartTime(start); | |
208 | ||
209 | // Make sure end time >= start time | |
210 | if (end.compareTo(start, false) < 0) { | |
211 | end = start; | |
212 | } | |
213 | setEndTime(end); | |
214 | ||
215 | // Make sure [start time <= current time <= end time] | |
216 | // If not: current = min(max(start, current), end); | |
217 | if (current.compareTo(start, false) < 0) { | |
218 | current = start; | |
219 | } | |
220 | if (current.compareTo(end, false) > 0) { | |
221 | current = end; | |
222 | } | |
223 | } | |
224 | setCurrentTime(current); | |
225 | ||
226 | // And configure the spinners | |
227 | updateSpinners(); | |
228 | } | |
229 | ||
230 | /** | |
231 | * <b><u>setValue</u></b> | |
232 | * <p> | |
233 | * <li>validates that [startTime <= currentTime <= endTime] is respected | |
234 | * <li>sets the current time and the spinners | |
235 | * </li> | |
236 | * <p> | |
237 | * | |
238 | * @param range | |
239 | * @param current | |
240 | */ | |
241 | public void setValue(TmfTimestamp current) { | |
242 | ||
243 | // Make sure [start time <= current time <= end time] | |
244 | // If not: current = min(max(start, current), end); | |
245 | if (current.compareTo(startTime, false) < 0) { | |
246 | current = startTime; | |
247 | } | |
248 | if (current.compareTo(endTime, false) > 0) { | |
249 | current = endTime; | |
250 | } | |
251 | setCurrentTime(current); | |
252 | ||
253 | // And configure the spinners | |
254 | updateSpinners(); | |
255 | } | |
256 | ||
257 | /** | |
258 | * Update the spinners with the new current time value | |
259 | * Perform the update on the UI thread | |
260 | */ | |
261 | public void updateSpinners() { | |
262 | ||
263 | seconds.getDisplay().asyncExec(new Runnable() { | |
264 | public void run() { | |
265 | if (!seconds.isDisposed() && !nanosec.isDisposed()) { | |
266 | // If we are on the start second, ensure that [currentNS >= startNS] | |
267 | // If the currentSeconds > startSeconds, set startns to -1 so we can | |
268 | // "underflow" | |
269 | int startns = -1; | |
270 | if (currentSeconds <= startSeconds) { | |
271 | currentSeconds = startSeconds; | |
272 | startns = startNanosec; | |
273 | if (currentNanosec < startns) { | |
274 | currentNanosec = startns; | |
275 | } | |
276 | } | |
277 | ||
278 | // If we are on the end second, ensure that [currentNS <= endNS] | |
279 | // If the currentSeconds < endSeconds, set endns to MAX so we can | |
280 | // "overflow" | |
8b29a712 | 281 | int endns = NANOSECOND_SCALE; |
6e512b93 ASL |
282 | if (currentSeconds >= endSeconds) { |
283 | currentSeconds = endSeconds; | |
284 | endns = endNanosec; | |
285 | if (currentNanosec > endns) { | |
286 | currentNanosec = endns; | |
287 | } | |
288 | } | |
289 | ||
290 | // Refresh the spinners (value, range, increments, ...) | |
291 | // To ensure that the spinners are properly set, the range has to be > 0 | |
8035003b ASL |
292 | seconds.setValues(currentSeconds, startSeconds - 1, endSeconds + 1, 0, 1, 10); |
293 | nanosec.setValues(currentNanosec, startns - 1, endns + 1, 0, 1, 1000000); | |
6e512b93 ASL |
294 | |
295 | // If start == end (i.e. no range), disable the spinner | |
296 | // (if start == end, the spinner widget range is set to [0..100] by default) | |
297 | seconds.setEnabled(startSeconds != endSeconds); | |
298 | nanosec.setEnabled(startns != endns); | |
299 | } | |
300 | } | |
301 | }); | |
302 | } | |
8b29a712 FC |
303 | }; |
304 | ///** | |
305 | // * <b><u>LTTngTimeFrameView</u></b> | |
306 | // * <p> | |
307 | // * The TimeFrameView provides a set of spinners to monitor and set the start | |
308 | // * time, end time, the current time interval and current time of the event log | |
309 | // * set at the nanosecond level. | |
310 | // * <p> | |
311 | // * It ensures that the following relations are always true: | |
312 | // * <p> | |
313 | // * <li>[ startTime >= start time of the log set ] | |
314 | // * <li>[ endTime <= end time of the log set ] | |
315 | // * <li>[ startTime <= currentTime <= endTime ] | |
316 | // * <li>[ interval == (endTime - startTime) ] | |
317 | // * </li> | |
318 | // * <p> | |
319 | // * It provides a slider to rapidly set the current time within the time range | |
320 | // * (i.e. between startTime and endTime). | |
321 | // * <p> | |
322 | // * Finally, it allows modification of the time range and the current time. This | |
323 | // * triggers notifications to the other LTTng views. | |
324 | // * <p> | |
325 | // * TODO: View synchronization | |
326 | // */ | |
327 | //public class SpinnerGroup { | |
328 | // | |
329 | //// public static final String ID = Labels.TimeFrameView_ID; | |
330 | //// | |
331 | //// // ======================================================================== | |
332 | //// // SpinnerGroup | |
333 | //// // ======================================================================== | |
334 | // | |
335 | // /** | |
336 | // * <b><u>SpinnerGroup</u></b> | |
337 | // * <p> | |
338 | // * A SpinnerGroup holds two coordinated spinners (for seconds and | |
339 | // * nanoseconds) representing the current time within the trace. | |
340 | // * <p> | |
341 | // * The current time can take any value anything within the time range (start | |
342 | // * and end time). | |
343 | // */ | |
344 | //// private class SpinnerGroup { | |
345 | // | |
346 | // // The nanosecond scale (10^9) | |
347 | // private static final int NANOSECOND_SCALE = 1000 * 1000 * 1000; | |
348 | // private static final byte SCALE = -9; | |
349 | // | |
350 | // // Widgets | |
351 | // private Group group; | |
352 | // private Spinner seconds; | |
353 | // private Spinner nanosec; | |
354 | // | |
355 | // // The valid time range - start time | |
356 | // private TmfTimestamp startTime; | |
357 | // private int startSeconds; | |
358 | // private int startNanosec; | |
359 | // | |
360 | // // The valid time range - end time | |
361 | // private TmfTimestamp endTime; | |
362 | // private int endSeconds; | |
363 | // private int endNanosec; | |
364 | // | |
365 | // // The current time value | |
366 | // private TmfTimestamp currentTime; | |
367 | // private int currentSeconds; | |
368 | // private int currentNanosec; | |
369 | // | |
370 | // private final TimeFrameView fOwner; | |
371 | // | |
372 | // /** | |
373 | // * <b><u>Constructor</u></b> | |
374 | // * <p> | |
375 | // * <li>Creates the display group and formats it for the grid cell | |
376 | // * <li>Sets the initial values for Start/End/Current time | |
377 | // * </li> | |
378 | // * <p> | |
379 | // * @param parent - the parent Composite | |
380 | // * @param groupName - the group name | |
381 | // * @param range - the valid time range (start/end time) | |
382 | // * @param current - the current time | |
383 | // */ | |
384 | // public SpinnerGroup(TimeFrameView owner, Composite parent, String groupName, TmfTimeRange range, TmfTimestamp current) { | |
385 | // | |
386 | // fOwner = owner; | |
387 | // | |
388 | // // Create the group | |
389 | // group = new Group(parent, SWT.BORDER); | |
390 | // group.setText(groupName); | |
391 | // | |
392 | // // Make it use the whole grid cell | |
393 | // GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false); | |
394 | // gridData.horizontalAlignment = SWT.FILL; | |
395 | // group.setLayoutData(gridData); | |
396 | // | |
397 | // // Create and position the widgets | |
398 | // seconds = new Spinner(group, SWT.BORDER); | |
399 | // seconds.addModifyListener(new ModifyListener() { | |
400 | // public void modifyText(ModifyEvent e) { | |
401 | // currentSeconds = seconds.getSelection(); | |
402 | // refreshCurrentTime(); | |
403 | // } | |
404 | // }); | |
405 | // seconds.setBounds(5, 25, 110, 25); | |
406 | // | |
407 | // Label label = new Label(group, SWT.LEFT); | |
408 | // label.setText(Labels.TimeFrameView_Seconds); | |
409 | // label.setBounds(120, 28, 25, 22); | |
410 | // | |
411 | // nanosec = new Spinner(group, SWT.BORDER); | |
412 | // nanosec.addModifyListener(new ModifyListener() { | |
413 | // public void modifyText(ModifyEvent e) { | |
414 | // currentNanosec = nanosec.getSelection(); | |
415 | // // Correct for nanosec underflow | |
416 | // if (currentNanosec < 0) { | |
417 | // currentSeconds--; | |
418 | // currentNanosec = NANOSECOND_SCALE - 1; | |
419 | // } | |
420 | // // Correct for nanosec overflow | |
421 | // if (currentNanosec >= NANOSECOND_SCALE) { | |
422 | // currentSeconds++; | |
423 | // currentNanosec = 0; | |
424 | // } | |
425 | // refreshCurrentTime(); | |
426 | // } | |
427 | // }); | |
428 | // nanosec.setBounds(150, 25, 110, 25); | |
429 | // | |
430 | // label = new Label(group, SWT.LEFT); | |
431 | // label.setText(Labels.TimeFrameView_Nanosec); | |
432 | // label.setBounds(265, 28, 25, 22); | |
433 | // | |
434 | // setContent(range, current); | |
435 | // } | |
436 | // | |
437 | // private void refreshCurrentTime() { | |
438 | // long newCurrentTime = (long) currentSeconds * NANOSECOND_SCALE + currentNanosec; | |
439 | // TmfTimestamp ts = new TmfTimestamp(newCurrentTime, SCALE, 0); | |
440 | // currentTime = ts; | |
441 | // fOwner.synchTimeFrameWidgets(this); | |
442 | // } | |
443 | // | |
444 | // // ==================================================================== | |
445 | // // Get/Set | |
446 | // // ==================================================================== | |
447 | // | |
448 | // public TmfTimestamp getStartTime() { | |
449 | // return startTime; | |
450 | // } | |
451 | // | |
452 | // public TmfTimestamp getEndTime() { | |
453 | // return endTime; | |
454 | // } | |
455 | // | |
456 | // public TmfTimestamp getCurrentTime() { | |
457 | // return currentTime; | |
458 | // } | |
459 | // | |
460 | // public TmfTimestamp getSpan() { | |
461 | // TmfTimestamp span = new TmfTimestamp(startTime.getAdjustment(endTime), SCALE, 0); | |
462 | // return span; | |
463 | // } | |
464 | // | |
465 | // public void setStartTime(TmfTimestamp ts) { | |
466 | // startTime = ts.synchronize(0, SCALE); | |
467 | // startSeconds = (int) (startTime.getValue() / NANOSECOND_SCALE); | |
468 | // startNanosec = (int) (startTime.getValue() % NANOSECOND_SCALE); | |
469 | // } | |
470 | // | |
471 | // public void setEndTime(TmfTimestamp ts) { | |
472 | // endTime = ts.synchronize(0, SCALE); | |
473 | // endSeconds = (int) (endTime.getValue() / NANOSECOND_SCALE); | |
474 | // endNanosec = (int) (endTime.getValue() % NANOSECOND_SCALE); | |
475 | // } | |
476 | // | |
477 | // public void setCurrentTime(TmfTimestamp ts) { | |
478 | // currentTime = ts.synchronize(0, SCALE); | |
479 | // currentSeconds = (int) (currentTime.getValue() / NANOSECOND_SCALE); | |
480 | // currentNanosec = (int) (currentTime.getValue() % NANOSECOND_SCALE); | |
481 | // } | |
482 | // | |
483 | // // ==================================================================== | |
484 | // // Operators | |
485 | // // ==================================================================== | |
486 | // | |
487 | // /** | |
488 | // * <b><u>setContent</u></b> | |
489 | // * <p> | |
490 | // * <li>validates that [startTime <= currentTime <= endTime] is respected | |
491 | // * <li>sets the start/current/end time and update the spinners | |
492 | // * </li> | |
493 | // * <p> | |
494 | // * | |
495 | // * @param range | |
496 | // * @param current | |
497 | // */ | |
498 | // public void setContent(TmfTimeRange range, TmfTimestamp current) { | |
499 | // | |
500 | // // Extract the time range | |
501 | // TmfTimestamp start = range.getStartTime(); | |
502 | // TmfTimestamp end = range.getEndTime(); | |
503 | // | |
504 | // // Assume start time is OK | |
505 | // setStartTime(start); | |
506 | // | |
507 | // // Make sure end time >= start time | |
508 | // if (end.compareTo(start, false) < 0) { | |
509 | // end = start; | |
510 | // } | |
511 | // setEndTime(end); | |
512 | // | |
513 | // // Make sure [start time <= current time <= end time] | |
514 | // // If not: current = min(max(start, current), end); | |
515 | // if (current.compareTo(start, false) < 0) { | |
516 | // current = start; | |
517 | // } | |
518 | // if (current.compareTo(end, false) > 0) { | |
519 | // current = end; | |
520 | // } | |
521 | // setCurrentTime(current); | |
522 | // | |
523 | // // And configure the spinners | |
524 | // updateSpinners(); | |
525 | // } | |
526 | // | |
527 | // /** | |
528 | // * <b><u>setValue</u></b> | |
529 | // * <p> | |
530 | // * <li>validates that [startTime <= currentTime <= endTime] is respected | |
531 | // * <li>sets the current time and the spinners | |
532 | // * </li> | |
533 | // * <p> | |
534 | // * | |
535 | // * @param range | |
536 | // * @param current | |
537 | // */ | |
538 | // public void setValue(TmfTimestamp current) { | |
539 | // | |
540 | // // Make sure [start time <= current time <= end time] | |
541 | // // If not: current = min(max(start, current), end); | |
542 | // if (current.compareTo(startTime, false) < 0) { | |
543 | // current = startTime; | |
544 | // } | |
545 | // if (current.compareTo(endTime, false) > 0) { | |
546 | // current = endTime; | |
547 | // } | |
548 | // setCurrentTime(current); | |
549 | // | |
550 | // // And configure the spinners | |
551 | // updateSpinners(); | |
552 | // } | |
553 | // | |
554 | // /** | |
555 | // * Update the spinners with the new current time value | |
556 | // * Perform the update on the UI thread | |
557 | // */ | |
558 | // public void updateSpinners() { | |
559 | // | |
560 | // seconds.getDisplay().asyncExec(new Runnable() { | |
561 | // public void run() { | |
562 | // if (!seconds.isDisposed() && !nanosec.isDisposed()) { | |
563 | // // If we are on the start second, ensure that [currentNS >= startNS] | |
564 | // // If the currentSeconds > startSeconds, set startns to -1 so we can | |
565 | // // "underflow" | |
566 | // int startns = -1; | |
567 | // if (currentSeconds <= startSeconds) { | |
568 | // currentSeconds = startSeconds; | |
569 | // startns = startNanosec; | |
570 | // if (currentNanosec < startns) { | |
571 | // currentNanosec = startns; | |
572 | // } | |
573 | // } | |
574 | // | |
575 | // // If we are on the end second, ensure that [currentNS <= endNS] | |
576 | // // If the currentSeconds < endSeconds, set endns to MAX so we can | |
577 | // // "overflow" | |
578 | // int endns = NANOSECOND_SCALE; | |
579 | // if (currentSeconds >= endSeconds) { | |
580 | // currentSeconds = endSeconds; | |
581 | // endns = endNanosec; | |
582 | // if (currentNanosec > endns) { | |
583 | // currentNanosec = endns; | |
584 | // } | |
585 | // } | |
586 | // | |
587 | // // Refresh the spinners (value, range, increments, ...) | |
588 | // // To ensure that the spinners are properly set, the range has to be > 0 | |
589 | // seconds.setValues(currentSeconds, startSeconds - 1, endSeconds + 1, 0, 1, 10); | |
590 | // nanosec.setValues(currentNanosec, startns - 1, endns + 1, 0, 1, 1000000); | |
591 | // | |
592 | // // If start == end (i.e. no range), disable the spinner | |
593 | // // (if start == end, the spinner widget range is set to [0..100] by default) | |
594 | // seconds.setEnabled(startSeconds != endSeconds); | |
595 | // nanosec.setEnabled(startns != endns); | |
596 | // } | |
597 | // } | |
598 | // }); | |
599 | // } | |
600 | //// }; | |
601 | //// | |
602 | //// // ======================================================================== | |
603 | //// // LTTngTimeFrameView | |
604 | //// // ======================================================================== | |
605 | //// | |
606 | //// // The event log timestamp characteristics | |
607 | //// private TmfTimestamp fLogStartTime = new TmfTimestamp(); | |
608 | //// private TmfTimestamp fLogEndTime = new TmfTimestamp(); | |
609 | //// | |
610 | //// @SuppressWarnings("unused") | |
611 | //// private TmfTimestamp fCurrentTime = new TmfTimestamp(); | |
612 | //// | |
613 | //// private TmfTimeRange fLogTimeRange = new TmfTimeRange(fLogStartTime, fLogEndTime); | |
614 | //// private TmfTimeRange fLogSpan = new TmfTimeRange(fLogStartTime, fLogEndTime); | |
615 | //// private byte fScale = 0; | |
616 | //// | |
617 | //// private static final int SLIDER_RANGE = 10000; | |
618 | //// | |
619 | //// private SpinnerGroup fStartGroup; | |
620 | //// private SpinnerGroup fEndGroup; | |
621 | //// private SpinnerGroup fRangeGroup; | |
622 | //// private SpinnerGroup fCurrentGroup; | |
623 | //// | |
624 | //// // The slider | |
625 | //// private Slider fSlider; | |
626 | //// | |
627 | //// // The event log | |
628 | //// TmfTrace fEventLog; | |
629 | //// | |
630 | //// /** | |
631 | //// * Constructor | |
632 | //// */ | |
633 | //// public TimeFrameView() { | |
634 | //// | |
635 | //// } | |
636 | //// | |
637 | //// /* (non-Javadoc) | |
638 | //// * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) | |
639 | //// */ | |
640 | //// public void createPartControl(Composite parent) { | |
641 | //// | |
642 | //// // Set the view layout | |
643 | //// GridLayout layout = new GridLayout(4, true); | |
644 | //// parent.setLayout(layout); | |
645 | //// | |
646 | //// fStartGroup = new SpinnerGroup(parent, Labels.TimeFrameView_StartTime, fLogTimeRange, fLogStartTime); | |
647 | //// fEndGroup = new SpinnerGroup(parent, Labels.TimeFrameView_EndTime, fLogTimeRange, fLogEndTime); | |
648 | //// fRangeGroup = new SpinnerGroup(parent, Labels.TimeFrameView_TimeRange, fLogTimeRange, fLogEndTime); | |
649 | //// fCurrentGroup = new SpinnerGroup(parent, Labels.TimeFrameView_CurrentTime, fLogTimeRange, fLogStartTime); | |
650 | //// | |
651 | //// // Create the slider | |
652 | //// createSlider(parent); | |
653 | //// } | |
654 | //// | |
655 | //// /* (non-Javadoc) | |
656 | //// * @see org.eclipse.ui.part.WorkbenchPart#setFocus() | |
657 | //// */ | |
658 | //// public void setFocus() { | |
659 | //// // TODO Auto-generated method stub | |
660 | //// } | |
661 | //// | |
662 | //// // ======================================================================== | |
663 | //// // Slider Handling | |
664 | //// // ======================================================================== | |
665 | //// | |
666 | //// /** | |
667 | //// * @param parent | |
668 | //// */ | |
669 | //// private void createSlider(Composite parent) { | |
670 | //// fSlider = new Slider(parent, SWT.FILL); | |
671 | //// fSlider.setMaximum(SLIDER_RANGE + fSlider.getThumb()); | |
672 | //// | |
673 | //// GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false); | |
674 | //// gridData.horizontalAlignment = SWT.FILL; | |
675 | //// gridData.horizontalSpan = 4; | |
676 | //// fSlider.setLayoutData(gridData); | |
677 | //// | |
678 | //// fSlider.addSelectionListener(this); | |
679 | //// } | |
680 | //// | |
681 | //// /** | |
682 | //// * @param range | |
683 | //// * @param current | |
684 | //// */ | |
685 | //// private void updateSlider(TmfTimeRange range, TmfTimestamp current) { | |
686 | //// | |
687 | //// // Determine the new relative position | |
688 | //// long total = range.getStartTime().getAdjustment(range.getEndTime()); | |
689 | //// long relative = range.getStartTime().getAdjustment(current); | |
690 | //// | |
691 | //// // Set the slider value | |
692 | //// long position = (total > 0) ? (relative * SLIDER_RANGE / total) : 0; | |
693 | //// fSlider.setSelection((int) position); | |
694 | //// } | |
695 | //// | |
696 | //// /* (non-Javadoc) | |
697 | //// * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) | |
698 | //// */ | |
699 | //// public void widgetDefaultSelected(SelectionEvent e) { | |
700 | //// // TODO Auto-generated method stub | |
701 | //// } | |
702 | //// | |
703 | //// /* (non-Javadoc) | |
704 | //// * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) | |
705 | //// */ | |
706 | //// public void widgetSelected(SelectionEvent e) { | |
707 | //// | |
708 | //// // Get the relative position | |
709 | //// int ratio = fSlider.getSelection(); | |
710 | //// | |
711 | //// TmfTimestamp span = fCurrentGroup.getSpan(); | |
712 | //// long value = span.getValue() * ratio / SLIDER_RANGE; | |
713 | //// | |
714 | //// TmfTimestamp start = fCurrentGroup.getStartTime(); | |
715 | //// TmfTimestamp current = new TmfTimestamp(start.getValue() + value, start.getScale(), 0); | |
716 | //// | |
717 | //// fCurrentGroup.setValue(current); | |
718 | //// } | |
719 | //// | |
720 | //// // ======================================================================== | |
721 | //// // TMF Signal Handling | |
722 | //// // ======================================================================== | |
723 | //// | |
724 | //// /** | |
725 | //// * @param signal | |
726 | //// */ | |
727 | //// @TmfSignalHandler | |
728 | //// public void traceSelected(TmfTraceSelectedSignal signal) { | |
729 | //// | |
730 | //// // Update the trace reference | |
731 | //// fEventLog = signal.getTrace(); | |
732 | //// | |
733 | //// // Update the time frame | |
734 | //// fLogTimeRange = fEventLog.getTimeRange(); | |
735 | //// fLogStartTime = fLogTimeRange.getStartTime(); | |
736 | //// fLogEndTime = fLogTimeRange.getEndTime(); | |
737 | //// fScale = fLogStartTime.getScale(); | |
738 | //// | |
739 | //// // Update the widgets | |
740 | //// fStartGroup.setContent(fLogTimeRange, fLogStartTime); | |
741 | //// fEndGroup.setContent(fLogTimeRange, fLogEndTime); | |
742 | //// fCurrentGroup.setContent(fLogTimeRange, fLogStartTime); | |
743 | //// | |
744 | //// fCurrentTime = fLogStartTime; | |
745 | //// | |
746 | //// TmfTimestamp delta = new TmfTimestamp(fLogStartTime.getAdjustment(fLogEndTime), fScale, 0); | |
747 | //// fLogSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta); | |
748 | //// fRangeGroup.setContent(fLogSpan, delta); | |
749 | //// } | |
750 | //// | |
751 | //// /** | |
752 | //// * @param signal | |
753 | //// */ | |
754 | //// @TmfSignalHandler | |
755 | //// public void traceUpdated(TmfTraceUpdatedSignal signal) { | |
756 | //// | |
757 | //// // Update the time frame | |
758 | //// fLogTimeRange = signal.getTrace().getTimeRange(); | |
759 | //// fLogStartTime = fLogTimeRange.getStartTime(); | |
760 | //// fLogEndTime = fLogTimeRange.getEndTime(); | |
761 | //// fScale = fLogStartTime.getScale(); | |
762 | //// | |
763 | //// // Update the widgets | |
764 | //// fStartGroup.setContent(fLogTimeRange, fStartGroup.getCurrentTime()); | |
765 | //// fEndGroup.setContent(fLogTimeRange, fLogEndTime); // fEndGroup.getCurrentTime()); | |
766 | //// fCurrentGroup.setContent(fLogTimeRange, fCurrentGroup.getCurrentTime()); | |
767 | //// | |
768 | //// TmfTimestamp delta = new TmfTimestamp(fLogStartTime.getAdjustment(fLogEndTime), fScale, 0); | |
769 | //// fLogSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta); | |
770 | //// fRangeGroup.setContent(fLogSpan, delta); | |
771 | //// } | |
772 | //// | |
773 | ////// /** | |
774 | ////// * @param signal | |
775 | ////// */ | |
776 | ////// @TmfSignalHandler | |
777 | ////// public void currentTimeUpdated(TmfCurrentTimeSignal signal) { | |
778 | ////// | |
779 | ////// // Update the time frame | |
780 | ////// fLogTimeRange = signal.getTrace().getTimeRange(); | |
781 | ////// fLogStartTime = fLogTimeRange.getStartTime(); | |
782 | ////// fLogEndTime = fLogTimeRange.getEndTime(); | |
783 | ////// fScale = fLogStartTime.getScale(); | |
784 | ////// | |
785 | ////// // Update the widgets | |
786 | ////// fStartGroup.setContent(fLogTimeRange, fStartGroup.getCurrentTime()); | |
787 | ////// fEndGroup.setContent(fLogTimeRange, fLogEndTime); // fEndGroup.getCurrentTime()); | |
788 | ////// fCurrentGroup.setContent(fLogTimeRange, fCurrentGroup.getCurrentTime()); | |
789 | ////// | |
790 | ////// TmfTimestamp delta = new TmfTimestamp(fLogStartTime.getAdjustment(fLogEndTime), fScale, 0); | |
791 | ////// fLogSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta); | |
792 | ////// fRangeGroup.setContent(fLogSpan, delta); | |
793 | ////// } | |
794 | //// | |
795 | ////// /* (non-Javadoc) | |
796 | ////// * @see org.eclipse.linuxtools.tmf.ui.viewer.TmfViewer#handleEvent(org.eclipse.linuxtools.tmf.ui.viewer.TmfViewerEvent) | |
797 | ////// */ | |
798 | ////// public void handleEvent(ITmfEventLogEvent event) { | |
799 | ////// | |
800 | ////// // A new trace has been selected | |
801 | ////// if (event instanceof TmfTraceSelectedEvent) { | |
802 | ////// TmfTraceSelectedEvent e = (TmfTraceSelectedEvent) event; | |
803 | ////// traceSelected(e.getEventLog()); | |
804 | ////// return; | |
805 | ////// } | |
806 | ////// | |
807 | ////// // The trace time range has been updated | |
808 | ////// if (event instanceof TmfLogUpdateEvent) { | |
809 | ////// TmfLogUpdateEvent e = (TmfLogUpdateEvent) event; | |
810 | ////// traceUpdated(e.getEventLog()); | |
811 | ////// return; | |
812 | ////// } | |
813 | ////// | |
814 | //////// if (event instanceof TmfCurrentTimeEvent) { | |
815 | //////// TmfCurrentTimeEvent e = (TmfCurrentTimeEvent) event; | |
816 | //////// fCurrentGroup.setContent(fLogTimeRange, e.getCurrentTime()); | |
817 | //////// } | |
818 | ////// } | |
819 | //// | |
820 | //// /** | |
821 | //// * One of the spinners has been updated. Synchronize the other widgets. | |
822 | //// */ | |
823 | //// private void synchTimeFrameWidgets(SpinnerGroup trigger) { | |
824 | //// | |
825 | //// // Collect the data | |
826 | //// TmfTimestamp startTime = fStartGroup.getCurrentTime(); | |
827 | //// TmfTimestamp endTime = fEndGroup.getCurrentTime(); | |
828 | //// TmfTimestamp timeRange = fRangeGroup.getCurrentTime(); | |
829 | //// TmfTimestamp currentTime = fCurrentGroup.getCurrentTime(); | |
830 | //// | |
831 | //// // If startTime was set beyond endTime, adjust endTime and interval | |
832 | //// if (trigger == fStartGroup) { | |
833 | //// if (startTime.compareTo(endTime, false) > 0) { | |
834 | //// endTime = startTime; | |
835 | //// } | |
836 | //// } | |
837 | //// | |
838 | //// // If endTime was set beyond startTime, adjust startTime and interval | |
839 | //// if (trigger == fEndGroup) { | |
840 | //// if (endTime.compareTo(startTime, false) < 0) { | |
841 | //// startTime = endTime; | |
842 | //// } | |
843 | //// } | |
844 | //// | |
845 | //// // If timeRange was set, adjust endTime | |
846 | //// if (trigger == fRangeGroup) { | |
847 | //// long start = startTime.getValue(); | |
848 | //// long span = timeRange.getValue(); | |
849 | //// TmfTimestamp ts = new TmfTimestamp(start + span, startTime.getScale(), 0); | |
850 | //// if (ts.compareTo(fLogEndTime, false) > 0) { | |
851 | //// ts = fLogEndTime.synchronize(fLogEndTime.getValue(), startTime.getScale()); | |
852 | //// } | |
853 | //// endTime = ts; | |
854 | //// } | |
855 | //// | |
856 | //// // Compute the new time range | |
857 | //// TmfTimeRange subrange = new TmfTimeRange(startTime, endTime); | |
858 | //// TmfTimestamp interval = new TmfTimestamp(startTime.getAdjustment(endTime), startTime.getScale(), 0); | |
859 | //// | |
860 | //// // Update the spinner groups | |
861 | //// fStartGroup.setContent(fLogTimeRange, startTime); | |
862 | //// fEndGroup.setContent(fLogTimeRange, endTime); | |
863 | //// fRangeGroup.setContent(fLogSpan, interval); | |
864 | //// fCurrentGroup.setContent(subrange, currentTime); | |
865 | //// | |
866 | //// updateSlider(subrange, currentTime); | |
867 | //// | |
868 | ////// // Notify other views | |
869 | ////// if (!fCurrentTime.equals(currentTime)) { | |
870 | ////// fCurrentTime = currentTime; | |
871 | ////// dispatchEvent(new TmfCurrentTimeEvent(currentTime)); | |
872 | ////// } | |
873 | //// } | |
874 | // | |
875 | //} |