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 * 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
.event
.ITmfTimestamp
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimeRange
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimestamp
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimestampFormat
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalManager
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimestampFormatUpdateSignal
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
27 import org
.eclipse
.swt
.widgets
.Composite
;
30 * This control provides a group containing a text control.
33 * @author Francois Chouinard
35 public class HistogramCurrentTimeControl
extends HistogramTextControl
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
42 * Standard constructor
44 * @param parentView A parent histogram view
45 * @param parent A parent composite to draw in
46 * @param groupLabel A group value
47 * @param value A value
50 public HistogramCurrentTimeControl(HistogramView parentView
, Composite parent
,
51 String groupLabel
, long value
)
53 super(parentView
, parent
, groupLabel
, value
);
54 TmfSignalManager
.register(this);
58 * @see org.eclipse.linuxtools.tmf.ui.views.histogram.HistogramTextControl#dispose()
61 public void dispose() {
62 TmfSignalManager
.deregister(this);
65 // ------------------------------------------------------------------------
67 // ------------------------------------------------------------------------
70 protected void updateValue() {
71 if (getValue() == Long
.MIN_VALUE
) {
72 fTextValue
.setText(""); //$NON-NLS-1$
75 String string
= fTextValue
.getText();
78 value
= TmfTimestampFormat
.getDefaulTimeFormat().parseValue(string
, getValue());
79 } catch (ParseException e
) {
81 if (getValue() != value
) {
82 // Make sure that the new time is within range
83 ITmfTrace trace
= fParentView
.getTrace();
85 TmfTimeRange range
= trace
.getTimeRange();
86 long startTime
= range
.getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
87 long endTime
= range
.getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
88 if (value
< startTime
) {
90 } else if (value
> endTime
) {
97 fParentView
.updateCurrentEventTime(value
);
102 public void setValue(long time
) {
103 if (time
!= Long
.MIN_VALUE
) {
104 super.setValue(time
, new TmfTimestamp(time
, ITmfTimestamp
.NANOSECOND_SCALE
).toString());
106 super.setValue(time
, ""); //$NON-NLS-1$
110 // ------------------------------------------------------------------------
112 // ------------------------------------------------------------------------
115 * Format the timestamp and update the display. Compute the new text size,
116 * adjust the text and group widgets and then refresh the view layout.
118 * @param signal the incoming signal
122 public void timestampFormatUpdated(TmfTimestampFormatUpdateSignal signal
) {
123 setValue(getValue());