Fix tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / control / model / impl / TraceChannelComponent.java
CommitLineData
eb1bab5b
BH
1/**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
13
6503ae0f
BH
14import java.util.List;
15
16import org.eclipse.core.commands.ExecutionException;
17import org.eclipse.core.runtime.IProgressMonitor;
18import org.eclipse.core.runtime.NullProgressMonitor;
eb1bab5b
BH
19import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
20import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
21import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
22import org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo;
23import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
24import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
06b9339e 25import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceChannelPropertySource;
eb1bab5b 26import org.eclipse.swt.graphics.Image;
06b9339e 27import org.eclipse.ui.views.properties.IPropertySource;
eb1bab5b
BH
28
29
30/**
31 * <b><u>TraceChannelComponent</u></b>
32 * <p>
33 * Implementation of the trace channel component.
34 * </p>
35 */
36public class TraceChannelComponent extends TraceControlComponent {
37 // ------------------------------------------------------------------------
38 // Constants
39 // ------------------------------------------------------------------------
40 /**
41 * Path to icon file for this component (state enabled).
42 */
43 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED = "icons/obj16/channel.gif"; //$NON-NLS-1$
44 /**
45 * Path to icon file for this component (state disabled).
46 */
47 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED = "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
48
49 // ------------------------------------------------------------------------
50 // Attributes
51 // ------------------------------------------------------------------------
52 /**
53 * The channel information.
54 */
55 private IChannelInfo fChannelInfo = null;
56 /**
57 * The image to be displayed in disabled state.
58 */
59 private Image fDisabledImage = null;
60
61 // ------------------------------------------------------------------------
62 // Constructors
63 // ------------------------------------------------------------------------
64 /**
65 * Constructor
66 * @param name - the name of the component.
67 * @param parent - the parent of this component.
68 */
69 public TraceChannelComponent(String name, ITraceControlComponent parent) {
70 super(name, parent);
71 setImage(TRACE_CHANNEL_ICON_FILE_ENABLED);
72 setToolTip(Messages.TraceControl_ChannelDisplayName);
73 fChannelInfo = new ChannelInfo(name);
74 fDisabledImage = LTTngUiPlugin.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED);
75 }
76
77 // ------------------------------------------------------------------------
78 // Accessors
79 // ------------------------------------------------------------------------
80 /*
81 * (non-Javadoc)
82 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
83 */
84 @Override
85 public Image getImage() {
86 if (fChannelInfo.getState() == TraceEnablement.DISABLED) {
87 return fDisabledImage;
88 }
89 return super.getImage();
90 }
91
92 /**
93 * Sets the channel information.
94 * @param channelInfo
95 */
96 public void setChannelInfo(IChannelInfo channelInfo) {
97 fChannelInfo = channelInfo;
98 IEventInfo[] events = fChannelInfo.getEvents();
99 for (int i = 0; i < events.length; i++) {
100 TraceEventComponent event = new TraceEventComponent(events[i].getName(), this);
101 event.setEventInfo(events[i]);
102 addChild(event);
103 }
104 }
105
106 /**
107 * @return the overwrite mode value.
108 */
109 public boolean isOverwriteMode() {
110 return fChannelInfo.isOverwriteMode();
111 }
112 /**
113 * Sets the overwrite mode value to the given mode.
114 * @param mode - mode to set.
115 */
116 public void setOverwriteMode(boolean mode){
117 fChannelInfo.setOverwriteMode(mode);
118 }
119 /**
120 * @return the sub-buffer size.
121 */
122 public long getSubBufferSize() {
123 return fChannelInfo.getSubBufferSize();
124 }
125 /**
126 * Sets the sub-buffer size to the given value.
127 * @param bufferSize - size to set to set.
128 */
129 public void setSubBufferSize(long bufferSize) {
130 fChannelInfo.setSubBufferSize(bufferSize);
131 }
132 /**
133 * @return the number of sub-buffers.
134 */
135 public int getNumberOfSubBuffers() {
136 return fChannelInfo.getNumberOfSubBuffers();
137 }
138 /**
139 * Sets the number of sub-buffers to the given value.
140 * @param numberOfSubBuffers - value to set.
141 */
142 public void setNumberOfSubBuffers(int numberOfSubBuffers) {
143 fChannelInfo.setNumberOfSubBuffers(numberOfSubBuffers);
144 }
145 /**
146 * @return the switch timer interval.
147 */
148 public long getSwitchTimer() {
149 return fChannelInfo.getSwitchTimer();
150 }
151 /**
152 * Sets the switch timer interval to the given value.
153 * @param timer - timer value to set.
154 */
155 public void setSwitchTimer(long timer) {
156 fChannelInfo.setSwitchTimer(timer);
157 }
158 /**
159 * @return the read timer interval.
160 */
161 public long getReadTimer() {
162 return fChannelInfo.getReadTimer();
163 }
164 /**
165 * Sets the read timer interval to the given value.
166 * @param timer - timer value to set..
167 */
168 public void setReadTimer(long timer) {
169 fChannelInfo.setReadTimer(timer);
170 }
171 /**
172 * @return the output type.
173 */
174 public String getOutputType() {
175 return fChannelInfo.getOutputType();
176 }
177 /**
178 * Sets the output type to the given value.
179 * @param type - type to set.
180 */
181 public void setOutputType(String type) {
182 fChannelInfo.setOutputType(type);
183 }
184 /**
185 * @return the channel state (enabled or disabled).
186 */
187 public TraceEnablement getState() {
188 return fChannelInfo.getState();
189 }
190 /**
191 * Sets the channel state (enablement) to the given value.
192 * @param state - state to set.
193 */
194 public void setState(TraceEnablement state) {
195 fChannelInfo.setState(state);
196 }
197 /**
198 * Sets the channel state (enablement) to the value specified by the given name.
199 * @param stateName - state to set.
200 */
201 public void setState(String stateName) {
202 fChannelInfo.setState(stateName);
203 }
06b9339e
BH
204 /*
205 * (non-Javadoc)
206 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
207 */
208 @SuppressWarnings("rawtypes")
209 @Override
210 public Object getAdapter(Class adapter) {
211 if (adapter == IPropertySource.class) {
212 return new TraceChannelPropertySource(this);
213 }
214 return null;
215 }
bbb3538a
BH
216
217 /**
218 * @return session name from parent
219 */
220 public String getSessionName() {
221 return ((TraceDomainComponent)getParent()).getSessionName();
222 }
223
6503ae0f
BH
224 /**
225 * @return session from parent
226 */
227 public TraceSessionComponent getSession() {
228 return ((TraceDomainComponent)getParent()).getSession();
229 }
230
bbb3538a
BH
231 /**
232 * @return if domain is kernel or UST
233 */
234 public boolean isKernel() {
235 return ((TraceDomainComponent)getParent()).isKernel();
236 }
eb1bab5b
BH
237
238 // ------------------------------------------------------------------------
239 // Operations
240 // ------------------------------------------------------------------------
6503ae0f
BH
241 /**
242 * Enables a list of events with no additional parameters.
243 * @param eventNames - a list of event names to enabled.
244 * @throws ExecutionException
245 */
246 public void enableEvent(List<String> eventNames) throws ExecutionException {
247 enableEvent(eventNames, new NullProgressMonitor());
248 }
249
250 /**
251 * Enables a list of events with no additional parameters.
252 * @param eventNames - a list of event names to enabled.
253 * @param monitor - a progress monitor
254 * @throws ExecutionException
255 */
256 public void enableEvent(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
257 getControlService().enableEvent(getParent().getParent().getName(), getName(), eventNames, isKernel(), monitor);
258 }
259
260 /**
261 * Enables a list of events with no additional parameters.
262 * @param eventNames - a list of event names to enabled.
263 * @throws ExecutionException
264 */
265 public void disableEvent(List<String> eventNames) throws ExecutionException {
266 disableEvent(eventNames, new NullProgressMonitor());
267 }
268
269 /**
270 * Enables a list of events with no additional parameters.
271 * @param eventNames - a list of event names to enabled.
272 * @param monitor - a progress monitor
273 * @throws ExecutionException
274 */
275 public void disableEvent(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
276 getControlService().disableEvent(getParent().getParent().getName(), getName(), eventNames, isKernel(), monitor);
277 }
eb1bab5b 278}
This page took 0.034482 seconds and 5 git commands to generate.