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 * Patrick Tasse - Update value handling
14 *******************************************************************************/
16 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.histogram
;
18 import java
.text
.ParseException
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalManager
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimestampFormatUpdateSignal
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimestamp
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimestampFormat
;
26 import org
.eclipse
.swt
.widgets
.Composite
;
29 * This control provides a group containing a text control.
32 * @author Francois Chouinard
34 public class HistogramTimeRangeControl
extends HistogramTextControl
{
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
41 * Constructor with given group and text values.
43 * @param parentView The parent histogram view.
44 * @param parent The parent composite
45 * @param groupLabel A group value
46 * @param value A text value
49 public HistogramTimeRangeControl(HistogramView parentView
, Composite parent
,
50 String groupLabel
, long value
)
52 super(parentView
, parent
, groupLabel
, value
);
53 TmfSignalManager
.register(this);
57 public void dispose() {
58 TmfSignalManager
.deregister(this);
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
66 protected void updateValue() {
67 if (getValue() == Long
.MIN_VALUE
) {
68 fTextValue
.setText(""); //$NON-NLS-1$
71 String string
= fTextValue
.getText();
72 long value
= getValue();
74 value
= TmfTimestampFormat
.getDefaulIntervalFormat().parseValue(string
);
75 } catch (ParseException e
) {
77 if (getValue() != value
) {
78 fParentView
.updateTimeRange(value
);
85 public void setValue(long time
) {
86 if (time
!= Long
.MIN_VALUE
) {
87 ITmfTimestamp ts
= new TmfTimestamp(time
, ITmfTimestamp
.NANOSECOND_SCALE
);
88 super.setValue(time
, ts
.toString(TmfTimestampFormat
.getDefaulIntervalFormat()));
90 super.setValue(time
, ""); //$NON-NLS-1$
94 // ------------------------------------------------------------------------
96 // ------------------------------------------------------------------------
99 * Format the interval and update the display. Compute the new text size,
100 * adjust the text and group widgets and then refresh the view layout.
102 * @param signal the incoming signal
106 public void intervalFormatUpdated(TmfTimestampFormatUpdateSignal signal
) {
107 setValue(getValue());