1 /*******************************************************************************
2 * Copyright (c) 2011, 2013 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 * Francois Chouinard - Simplified constructor, handle interval format change
13 *******************************************************************************/
15 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.histogram
;
17 import java
.text
.ParseException
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalManager
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimestampFormatUpdateSignal
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimestamp
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimestampFormat
;
25 import org
.eclipse
.swt
.widgets
.Composite
;
28 * This control provides a group containing a text control.
31 * @author Francois Chouinard
33 public class HistogramTimeRangeControl
extends HistogramTextControl
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
40 * Constructor with given group and text values.
42 * @param parentView The parent histogram view.
43 * @param parent The parent composite
44 * @param groupLabel A group value
45 * @param value A text value
48 public HistogramTimeRangeControl(HistogramView parentView
, Composite parent
,
49 String groupLabel
, long value
)
51 super(parentView
, parent
, groupLabel
, value
);
52 TmfSignalManager
.register(this);
56 * @see org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramTextControl#dispose()
59 public void dispose() {
60 TmfSignalManager
.deregister(this);
63 // ------------------------------------------------------------------------
65 // ------------------------------------------------------------------------
69 * @see org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramTextControl#updateValue()
72 protected void updateValue() {
73 if (getValue() == Long
.MIN_VALUE
) {
74 fTextValue
.setText(""); //$NON-NLS-1$
77 String string
= fTextValue
.getText();
78 long value
= getValue();
80 value
= TmfTimestampFormat
.getDefaulIntervalFormat().parseValue(string
);
81 } catch (ParseException e
) {
83 fParentView
.updateTimeRange(value
);
87 public void setValue(long time
) {
88 if (time
!= Long
.MIN_VALUE
) {
89 ITmfTimestamp ts
= new TmfTimestamp(time
, ITmfTimestamp
.NANOSECOND_SCALE
);
90 super.setValue(time
, ts
.toString(TmfTimestampFormat
.getDefaulIntervalFormat()));
92 super.setValue(time
, ""); //$NON-NLS-1$
96 // ------------------------------------------------------------------------
98 // ------------------------------------------------------------------------
101 * Format the interval and update the display. Compute the new text size,
102 * adjust the text and group widgets and then refresh the view layout.
104 * @param signal the incoming signal
108 public void intervalFormatUpdated(TmfTimestampFormatUpdateSignal signal
) {
109 setValue(getValue());