Merge branch 'master' into lttng-kepler
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / histogram / HistogramCurrentTimeControl.java
1 /*******************************************************************************
2 * Copyright (c) 2011, 2012 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 * Francois Chouinard - Moved from LTTng to TMF
12 *******************************************************************************/
13
14 package org.eclipse.linuxtools.tmf.ui.views.histogram;
15
16 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
17 import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
18 import org.eclipse.swt.widgets.Composite;
19
20 /**
21 * This control provides a group containing a text control.
22 *
23 * @version 1.0
24 * @author Francois Chouinard
25 */
26 public class HistogramCurrentTimeControl extends HistogramTextControl {
27
28 // ------------------------------------------------------------------------
29 // Construction
30 // ------------------------------------------------------------------------
31
32 /**
33 * Constructor with default group and text value.
34 *
35 * @param parentView A parent histogram view
36 * @param parent A parent composite to draw in
37 * @param textStyle A test style
38 * @param groupStyle A group style
39 */
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
44 /**
45 *
46 * Constructor
47 * @param parentView A parent histogram view
48 * @param parent A parent composite to draw in
49 * @param textStyle A test style
50 * @param groupStyle A group style
51 * @param groupValue A group value
52 * @param textValue A text value
53 */
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) {
68 // Make sure that the new time is within range
69 TmfExperiment exp = TmfExperiment.getCurrentExperiment();
70 if (exp != null) {
71 TmfTimeRange range = exp.getTimeRange();
72 long startTime = range.getStartTime().normalize(0, -9).getValue();
73 long endTime = range.getEndTime().normalize(0, -9).getValue();
74 if (value < startTime) {
75 value = startTime;
76 } else if (value > endTime) {
77 value = endTime;
78 }
79 }
80
81 // Set and propagate
82 setValue(value);
83 fParentView.updateCurrentEventTime(value);
84 }
85 }
86
87 }
This page took 0.032804 seconds and 6 git commands to generate.