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
.linuxtools
.lttng
.ui
.views
.control
.property
.TraceChannelPropertySource
;
21 import org
.eclipse
.swt
.graphics
.Image
;
22 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
26 * <b><u>TraceChannelComponent</u></b>
28 * Implementation of the trace channel component.
31 public class TraceChannelComponent
extends TraceControlComponent
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 * Path to icon file for this component (state enabled).
38 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED
= "icons/obj16/channel.gif"; //$NON-NLS-1$
40 * Path to icon file for this component (state disabled).
42 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED
= "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
48 * The channel information.
50 private IChannelInfo fChannelInfo
= null;
52 * The image to be displayed in disabled state.
54 private Image fDisabledImage
= null;
56 // ------------------------------------------------------------------------
58 // ------------------------------------------------------------------------
61 * @param name - the name of the component.
62 * @param parent - the parent of this component.
64 public TraceChannelComponent(String name
, ITraceControlComponent parent
) {
66 setImage(TRACE_CHANNEL_ICON_FILE_ENABLED
);
67 setToolTip(Messages
.TraceControl_ChannelDisplayName
);
68 fChannelInfo
= new ChannelInfo(name
);
69 fDisabledImage
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED
);
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
77 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
80 public Image
getImage() {
81 if (fChannelInfo
.getState() == TraceEnablement
.DISABLED
) {
82 return fDisabledImage
;
84 return super.getImage();
88 * Sets the channel information.
91 public void setChannelInfo(IChannelInfo channelInfo
) {
92 fChannelInfo
= channelInfo
;
93 IEventInfo
[] events
= fChannelInfo
.getEvents();
94 for (int i
= 0; i
< events
.length
; i
++) {
95 TraceEventComponent event
= new TraceEventComponent(events
[i
].getName(), this);
96 event
.setEventInfo(events
[i
]);
102 * @return the overwrite mode value.
104 public boolean isOverwriteMode() {
105 return fChannelInfo
.isOverwriteMode();
108 * Sets the overwrite mode value to the given mode.
109 * @param mode - mode to set.
111 public void setOverwriteMode(boolean mode
){
112 fChannelInfo
.setOverwriteMode(mode
);
115 * @return the sub-buffer size.
117 public long getSubBufferSize() {
118 return fChannelInfo
.getSubBufferSize();
121 * Sets the sub-buffer size to the given value.
122 * @param bufferSize - size to set to set.
124 public void setSubBufferSize(long bufferSize
) {
125 fChannelInfo
.setSubBufferSize(bufferSize
);
128 * @return the number of sub-buffers.
130 public int getNumberOfSubBuffers() {
131 return fChannelInfo
.getNumberOfSubBuffers();
134 * Sets the number of sub-buffers to the given value.
135 * @param numberOfSubBuffers - value to set.
137 public void setNumberOfSubBuffers(int numberOfSubBuffers
) {
138 fChannelInfo
.setNumberOfSubBuffers(numberOfSubBuffers
);
141 * @return the switch timer interval.
143 public long getSwitchTimer() {
144 return fChannelInfo
.getSwitchTimer();
147 * Sets the switch timer interval to the given value.
148 * @param timer - timer value to set.
150 public void setSwitchTimer(long timer
) {
151 fChannelInfo
.setSwitchTimer(timer
);
154 * @return the read timer interval.
156 public long getReadTimer() {
157 return fChannelInfo
.getReadTimer();
160 * Sets the read timer interval to the given value.
161 * @param timer - timer value to set..
163 public void setReadTimer(long timer
) {
164 fChannelInfo
.setReadTimer(timer
);
167 * @return the output type.
169 public String
getOutputType() {
170 return fChannelInfo
.getOutputType();
173 * Sets the output type to the given value.
174 * @param type - type to set.
176 public void setOutputType(String type
) {
177 fChannelInfo
.setOutputType(type
);
180 * @return the channel state (enabled or disabled).
182 public TraceEnablement
getState() {
183 return fChannelInfo
.getState();
186 * Sets the channel state (enablement) to the given value.
187 * @param state - state to set.
189 public void setState(TraceEnablement state
) {
190 fChannelInfo
.setState(state
);
193 * Sets the channel state (enablement) to the value specified by the given name.
194 * @param stateName - state to set.
196 public void setState(String stateName
) {
197 fChannelInfo
.setState(stateName
);
201 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
203 @SuppressWarnings("rawtypes")
205 public Object
getAdapter(Class adapter
) {
206 if (adapter
== IPropertySource
.class) {
207 return new TraceChannelPropertySource(this);
213 * @return session name from parent
215 public String
getSessionName() {
216 return ((TraceDomainComponent
)getParent()).getSessionName();
220 * @return if domain is kernel or UST
222 public boolean isKernel() {
223 return ((TraceDomainComponent
)getParent()).isKernel();
226 // ------------------------------------------------------------------------
228 // ------------------------------------------------------------------------