1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 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
.tracecompass
.tmf
.ui
.views
.histogram
;
18 import java
.text
.ParseException
;
20 import org
.eclipse
.swt
.widgets
.Composite
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSignalHandler
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTimestampFormatUpdateSignal
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestamp
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestampFormat
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
30 * This control provides a group containing a text control.
32 * @author Francois Chouinard
34 public class HistogramCurrentTimeControl
extends HistogramTextControl
{
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
41 * Standard constructor
43 * @param parentView A parent histogram view
44 * @param parent A parent composite to draw in
45 * @param label A label
46 * @param value A value
48 public HistogramCurrentTimeControl(HistogramView parentView
, Composite parent
,
49 String label
, long value
)
51 super(parentView
, parent
, label
, value
);
54 // ------------------------------------------------------------------------
56 // ------------------------------------------------------------------------
59 protected void updateValue() {
60 if (getValue() == Long
.MIN_VALUE
) {
61 fTextValue
.setText(""); //$NON-NLS-1$
64 String string
= fTextValue
.getText();
65 long value
= getValue();
67 value
= TmfTimestampFormat
.getDefaulTimeFormat().parseValue(string
, getValue());
68 } catch (ParseException e
) {
70 if (getValue() != value
) {
71 // Make sure that the new time is within range
72 ITmfTrace trace
= fParentView
.getTrace();
74 TmfTimeRange range
= trace
.getTimeRange();
75 long startTime
= range
.getStartTime().toNanos();
76 long endTime
= range
.getEndTime().toNanos();
77 if (value
< startTime
) {
79 } else if (value
> endTime
) {
86 updateSelectionTime(value
);
93 * Update the selection time
96 * the new selected time
98 protected void updateSelectionTime(long time
) {
99 fParentView
.updateSelectionTime(time
, time
);
103 public void setValue(long time
) {
104 if (time
!= Long
.MIN_VALUE
) {
105 super.setValue(time
, new TmfTimestamp(time
, ITmfTimestamp
.NANOSECOND_SCALE
).toString());
107 super.setValue(time
, ""); //$NON-NLS-1$
111 // ------------------------------------------------------------------------
113 // ------------------------------------------------------------------------
116 * Format the timestamp and update the display. Compute the new text size,
117 * adjust the text and group widgets and then refresh the view layout.
119 * @param signal the incoming signal
122 public void timestampFormatUpdated(TmfTimestampFormatUpdateSignal signal
) {
123 setValue(getValue());