1 /**********************************************************************
2 * Copyright (c) 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 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.impl
;
14 import org
.eclipse
.linuxtools
.lttng
.ui
.LTTngUiPlugin
;
15 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.Messages
;
16 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IChannelInfo
;
17 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IEventInfo
;
18 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.ITraceControlComponent
;
19 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceEnablement
;
20 import org
.eclipse
.swt
.graphics
.Image
;
24 * <b><u>TraceChannelComponent</u></b>
26 * Implementation of the trace channel component.
29 public class TraceChannelComponent
extends TraceControlComponent
{
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
34 * Path to icon file for this component (state enabled).
36 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED
= "icons/obj16/channel.gif"; //$NON-NLS-1$
38 * Path to icon file for this component (state disabled).
40 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED
= "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
46 * The channel information.
48 private IChannelInfo fChannelInfo
= null;
50 * The image to be displayed in disabled state.
52 private Image fDisabledImage
= null;
54 // ------------------------------------------------------------------------
56 // ------------------------------------------------------------------------
59 * @param name - the name of the component.
60 * @param parent - the parent of this component.
62 public TraceChannelComponent(String name
, ITraceControlComponent parent
) {
64 setImage(TRACE_CHANNEL_ICON_FILE_ENABLED
);
65 setToolTip(Messages
.TraceControl_ChannelDisplayName
);
66 fChannelInfo
= new ChannelInfo(name
);
67 fDisabledImage
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED
);
70 // ------------------------------------------------------------------------
72 // ------------------------------------------------------------------------
75 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
78 public Image
getImage() {
79 if (fChannelInfo
.getState() == TraceEnablement
.DISABLED
) {
80 return fDisabledImage
;
82 return super.getImage();
86 * Sets the channel information.
89 public void setChannelInfo(IChannelInfo channelInfo
) {
90 fChannelInfo
= channelInfo
;
91 IEventInfo
[] events
= fChannelInfo
.getEvents();
92 for (int i
= 0; i
< events
.length
; i
++) {
93 TraceEventComponent event
= new TraceEventComponent(events
[i
].getName(), this);
94 event
.setEventInfo(events
[i
]);
100 * @return the overwrite mode value.
102 public boolean isOverwriteMode() {
103 return fChannelInfo
.isOverwriteMode();
106 * Sets the overwrite mode value to the given mode.
107 * @param mode - mode to set.
109 public void setOverwriteMode(boolean mode
){
110 fChannelInfo
.setOverwriteMode(mode
);
113 * @return the sub-buffer size.
115 public long getSubBufferSize() {
116 return fChannelInfo
.getSubBufferSize();
119 * Sets the sub-buffer size to the given value.
120 * @param bufferSize - size to set to set.
122 public void setSubBufferSize(long bufferSize
) {
123 fChannelInfo
.setSubBufferSize(bufferSize
);
126 * @return the number of sub-buffers.
128 public int getNumberOfSubBuffers() {
129 return fChannelInfo
.getNumberOfSubBuffers();
132 * Sets the number of sub-buffers to the given value.
133 * @param numberOfSubBuffers - value to set.
135 public void setNumberOfSubBuffers(int numberOfSubBuffers
) {
136 fChannelInfo
.setNumberOfSubBuffers(numberOfSubBuffers
);
139 * @return the switch timer interval.
141 public long getSwitchTimer() {
142 return fChannelInfo
.getSwitchTimer();
145 * Sets the switch timer interval to the given value.
146 * @param timer - timer value to set.
148 public void setSwitchTimer(long timer
) {
149 fChannelInfo
.setSwitchTimer(timer
);
152 * @return the read timer interval.
154 public long getReadTimer() {
155 return fChannelInfo
.getReadTimer();
158 * Sets the read timer interval to the given value.
159 * @param timer - timer value to set..
161 public void setReadTimer(long timer
) {
162 fChannelInfo
.setReadTimer(timer
);
165 * @return the output type.
167 public String
getOutputType() {
168 return fChannelInfo
.getOutputType();
171 * Sets the output type to the given value.
172 * @param type - type to set.
174 public void setOutputType(String type
) {
175 fChannelInfo
.setOutputType(type
);
178 * @return the channel state (enabled or disabled).
180 public TraceEnablement
getState() {
181 return fChannelInfo
.getState();
184 * Sets the channel state (enablement) to the given value.
185 * @param state - state to set.
187 public void setState(TraceEnablement state
) {
188 fChannelInfo
.setState(state
);
191 * Sets the channel state (enablement) to the value specified by the given name.
192 * @param stateName - state to set.
194 public void setState(String stateName
) {
195 fChannelInfo
.setState(stateName
);
198 // ------------------------------------------------------------------------
200 // ------------------------------------------------------------------------