1 /*******************************************************************************
2 * Copyright (c) 2011, 2012 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Moved from LTTng to TMF
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.histogram
;
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
;
21 * This control provides a group containing a text control.
24 * @author Francois Chouinard
26 public class HistogramCurrentTimeControl
extends HistogramTextControl
{
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
33 * Constructor with default group and text value.
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
40 public HistogramCurrentTimeControl(HistogramView parentView
, Composite parent
, int textStyle
, int groupStyle
) {
41 this(parentView
, parent
, textStyle
, groupStyle
, "", HistogramUtils
.nanosecondsToString(0L)); //$NON-NLS-1$
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
54 public HistogramCurrentTimeControl(HistogramView parentView
, Composite parent
, int textStyle
, int groupStyle
, String groupValue
, String textValue
) {
55 super(parentView
, parent
, textStyle
, groupStyle
, groupValue
, textValue
);
58 // ------------------------------------------------------------------------
60 // ------------------------------------------------------------------------
63 protected void updateValue() {
64 String stringValue
= fTextValue
.getText();
65 long value
= HistogramUtils
.stringToNanoseconds(stringValue
);
67 if (getValue() != value
) {
68 // Make sure that the new time is within range
69 TmfExperiment exp
= TmfExperiment
.getCurrentExperiment();
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
) {
76 } else if (value
> endTime
) {
83 fParentView
.updateCurrentEventTime(value
);