lttng: Temporary lttng-luna annotation update
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / histogram / HistogramTimeRangeControl.java
CommitLineData
c392540b 1/*******************************************************************************
c8422608 2 * Copyright (c) 2011, 2013 Ericsson
f8177ba2 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
f8177ba2 8 *
c392540b
FC
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
e0752744 11 * Francois Chouinard - Moved from LTTng to TMF
f8177ba2 12 * Francois Chouinard - Simplified constructor, handle interval format change
65cdf787 13 * Patrick Tasse - Update value handling
c392540b
FC
14 *******************************************************************************/
15
e0752744 16package org.eclipse.linuxtools.tmf.ui.views.histogram;
c392540b 17
f8177ba2
FC
18import java.text.ParseException;
19
f8177ba2
FC
20import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
21import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
22import org.eclipse.linuxtools.tmf.core.signal.TmfTimestampFormatUpdateSignal;
3bd46eef
AM
23import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
24import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
25import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampFormat;
c392540b
FC
26import org.eclipse.swt.widgets.Composite;
27
28/**
c392540b 29 * This control provides a group containing a text control.
f8177ba2
FC
30 *
31 * @version 2.0
b544077e 32 * @author Francois Chouinard
c392540b
FC
33 */
34public class HistogramTimeRangeControl extends HistogramTextControl {
35
36 // ------------------------------------------------------------------------
37 // Construction
38 // ------------------------------------------------------------------------
f8177ba2 39
b544077e 40 /**
f8177ba2
FC
41 * Constructor with given group and text values.
42 *
b544077e
BH
43 * @param parentView The parent histogram view.
44 * @param parent The parent composite
f8177ba2
FC
45 * @param groupLabel A group value
46 * @param value A text value
47 * @since 2.0
b544077e 48 */
f8177ba2
FC
49 public HistogramTimeRangeControl(HistogramView parentView, Composite parent,
50 String groupLabel, long value)
51 {
52 super(parentView, parent, groupLabel, value);
53 TmfSignalManager.register(this);
c392540b
FC
54 }
55
f8177ba2
FC
56 @Override
57 public void dispose() {
58 TmfSignalManager.deregister(this);
c392540b
FC
59 }
60
61 // ------------------------------------------------------------------------
62 // Operations
63 // ------------------------------------------------------------------------
64
65 @Override
66 protected void updateValue() {
da7bdcbc
PT
67 if (getValue() == Long.MIN_VALUE) {
68 fTextValue.setText(""); //$NON-NLS-1$
69 return;
70 }
f8177ba2
FC
71 String string = fTextValue.getText();
72 long value = getValue();
73 try {
74 value = TmfTimestampFormat.getDefaulIntervalFormat().parseValue(string);
75 } catch (ParseException e) {
c392540b 76 }
65cdf787
PT
77 if (getValue() != value) {
78 fParentView.updateTimeRange(value);
79 } else {
80 setValue(value);
81 }
f8177ba2
FC
82 }
83
84 @Override
85 public void setValue(long time) {
da7bdcbc
PT
86 if (time != Long.MIN_VALUE) {
87 ITmfTimestamp ts = new TmfTimestamp(time, ITmfTimestamp.NANOSECOND_SCALE);
88 super.setValue(time, ts.toString(TmfTimestampFormat.getDefaulIntervalFormat()));
89 } else {
90 super.setValue(time, ""); //$NON-NLS-1$
91 }
f8177ba2
FC
92 }
93
94 // ------------------------------------------------------------------------
95 // Signal Handlers
96 // ------------------------------------------------------------------------
97
98 /**
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.
101 *
102 * @param signal the incoming signal
103 * @since 2.0
104 */
105 @TmfSignalHandler
106 public void intervalFormatUpdated(TmfTimestampFormatUpdateSignal signal) {
107 setValue(getValue());
c392540b
FC
108 }
109
110}
This page took 0.043987 seconds and 5 git commands to generate.