Commit | Line | Data |
---|---|---|
c392540b | 1 | /******************************************************************************* |
e0752744 | 2 | * Copyright (c) 2011, 2012 Ericsson |
6256d8ad | 3 | * |
c392540b FC |
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 | |
6256d8ad | 8 | * |
c392540b FC |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
e0752744 | 11 | * Francois Chouinard - Moved from LTTng to TMF |
c392540b FC |
12 | *******************************************************************************/ |
13 | ||
e0752744 | 14 | package org.eclipse.linuxtools.tmf.ui.views.histogram; |
c392540b | 15 | |
e0fce55b FC |
16 | import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; |
17 | import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment; | |
c392540b FC |
18 | import org.eclipse.swt.widgets.Composite; |
19 | ||
20 | /** | |
c392540b | 21 | * This control provides a group containing a text control. |
6256d8ad | 22 | * |
b544077e BH |
23 | * @version 1.0 |
24 | * @author Francois Chouinard | |
c392540b FC |
25 | */ |
26 | public class HistogramCurrentTimeControl extends HistogramTextControl { | |
27 | ||
28 | // ------------------------------------------------------------------------ | |
29 | // Construction | |
30 | // ------------------------------------------------------------------------ | |
31 | ||
b544077e BH |
32 | /** |
33 | * Constructor with default group and text value. | |
6256d8ad | 34 | * |
b544077e BH |
35 | * @param parentView A parent histogram view |
36 | * @param parent A parent composite to draw in | |
6256d8ad | 37 | * @param textStyle A test style |
b544077e BH |
38 | * @param groupStyle A group style |
39 | */ | |
c392540b FC |
40 | public HistogramCurrentTimeControl(HistogramView parentView, Composite parent, int textStyle, int groupStyle) { |
41 | this(parentView, parent, textStyle, groupStyle, "", HistogramUtils.nanosecondsToString(0L)); //$NON-NLS-1$ | |
42 | } | |
43 | ||
b544077e | 44 | /** |
6256d8ad | 45 | * |
b544077e BH |
46 | * Constructor |
47 | * @param parentView A parent histogram view | |
48 | * @param parent A parent composite to draw in | |
6256d8ad | 49 | * @param textStyle A test style |
b544077e BH |
50 | * @param groupStyle A group style |
51 | * @param groupValue A group value | |
52 | * @param textValue A text value | |
53 | */ | |
c392540b FC |
54 | public HistogramCurrentTimeControl(HistogramView parentView, Composite parent, int textStyle, int groupStyle, String groupValue, String textValue) { |
55 | super(parentView, parent, textStyle, groupStyle, groupValue, textValue); | |
56 | } | |
57 | ||
58 | // ------------------------------------------------------------------------ | |
59 | // Operations | |
60 | // ------------------------------------------------------------------------ | |
61 | ||
62 | @Override | |
63 | protected void updateValue() { | |
64 | String stringValue = fTextValue.getText(); | |
65 | long value = HistogramUtils.stringToNanoseconds(stringValue); | |
66 | ||
67 | if (getValue() != value) { | |
e0fce55b | 68 | // Make sure that the new time is within range |
6256d8ad | 69 | TmfExperiment exp = TmfExperiment.getCurrentExperiment(); |
e0fce55b FC |
70 | if (exp != null) { |
71 | TmfTimeRange range = exp.getTimeRange(); | |
2d2bfd1f FC |
72 | long startTime = range.getStartTime().normalize(0, -9).getValue(); |
73 | long endTime = range.getEndTime().normalize(0, -9).getValue(); | |
e0fce55b FC |
74 | if (value < startTime) { |
75 | value = startTime; | |
76 | } else if (value > endTime) { | |
77 | value = endTime; | |
78 | } | |
79 | } | |
80 | ||
81 | // Set and propagate | |
c392540b FC |
82 | setValue(value); |
83 | fParentView.updateCurrentEventTime(value); | |
84 | } | |
85 | } | |
86 | ||
87 | } |