Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
6f40b641 | 2 | * Copyright (c) 2012, 2015 Ericsson |
cfdb727a | 3 | * |
eb1bab5b BH |
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 | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
eb1bab5b | 10 | * Bernd Hufmann - Initial API and implementation |
ba3a9bd2 | 11 | * Bernd Hufmann - Updated for support of LTTng Tools 2.1 |
eb1bab5b | 12 | **********************************************************************/ |
9bc60be7 | 13 | package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl; |
eb1bab5b | 14 | |
b957fb8c | 15 | import java.util.ArrayList; |
6503ae0f BH |
16 | import java.util.List; |
17 | ||
18 | import org.eclipse.core.commands.ExecutionException; | |
19 | import org.eclipse.core.runtime.IProgressMonitor; | |
eb1bab5b | 20 | import org.eclipse.swt.graphics.Image; |
9bc60be7 AM |
21 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo; |
22 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IEventInfo; | |
23 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType; | |
24 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceChannelOutputType; | |
25 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement; | |
26 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel; | |
27 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.ChannelInfo; | |
28 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.ProbeEventInfo; | |
29 | import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator; | |
30 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages; | |
31 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
32 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TraceChannelPropertySource; | |
06b9339e | 33 | import org.eclipse.ui.views.properties.IPropertySource; |
eb1bab5b BH |
34 | |
35 | ||
36 | /** | |
eb1bab5b BH |
37 | * <p> |
38 | * Implementation of the trace channel component. | |
39 | * </p> | |
cfdb727a | 40 | * |
dbd4432d | 41 | * @author Bernd Hufmann |
eb1bab5b BH |
42 | */ |
43 | public class TraceChannelComponent extends TraceControlComponent { | |
11252342 | 44 | |
eb1bab5b BH |
45 | // ------------------------------------------------------------------------ |
46 | // Constants | |
47 | // ------------------------------------------------------------------------ | |
11252342 | 48 | |
eb1bab5b BH |
49 | /** |
50 | * Path to icon file for this component (state enabled). | |
51 | */ | |
52 | public static final String TRACE_CHANNEL_ICON_FILE_ENABLED = "icons/obj16/channel.gif"; //$NON-NLS-1$ | |
53 | /** | |
54 | * Path to icon file for this component (state disabled). | |
55 | */ | |
56 | public static final String TRACE_CHANNEL_ICON_FILE_DISABLED = "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$ | |
cfdb727a | 57 | |
eb1bab5b BH |
58 | // ------------------------------------------------------------------------ |
59 | // Attributes | |
60 | // ------------------------------------------------------------------------ | |
11252342 | 61 | |
eb1bab5b BH |
62 | /** |
63 | * The channel information. | |
64 | */ | |
65 | private IChannelInfo fChannelInfo = null; | |
66 | /** | |
67 | * The image to be displayed in disabled state. | |
68 | */ | |
69 | private Image fDisabledImage = null; | |
cfdb727a | 70 | |
eb1bab5b BH |
71 | // ------------------------------------------------------------------------ |
72 | // Constructors | |
73 | // ------------------------------------------------------------------------ | |
11252342 | 74 | |
eb1bab5b | 75 | /** |
cfdb727a | 76 | * Constructor |
eb1bab5b BH |
77 | * @param name - the name of the component. |
78 | * @param parent - the parent of this component. | |
79 | */ | |
80 | public TraceChannelComponent(String name, ITraceControlComponent parent) { | |
81 | super(name, parent); | |
82 | setImage(TRACE_CHANNEL_ICON_FILE_ENABLED); | |
83 | setToolTip(Messages.TraceControl_ChannelDisplayName); | |
84 | fChannelInfo = new ChannelInfo(name); | |
31a6a4e4 | 85 | fDisabledImage = Activator.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED); |
eb1bab5b | 86 | } |
cfdb727a | 87 | |
eb1bab5b BH |
88 | // ------------------------------------------------------------------------ |
89 | // Accessors | |
90 | // ------------------------------------------------------------------------ | |
11252342 | 91 | |
eb1bab5b BH |
92 | @Override |
93 | public Image getImage() { | |
94 | if (fChannelInfo.getState() == TraceEnablement.DISABLED) { | |
95 | return fDisabledImage; | |
96 | } | |
97 | return super.getImage(); | |
98 | } | |
99 | ||
100 | /** | |
101 | * Sets the channel information. | |
cfdb727a | 102 | * |
eb1bab5b | 103 | * @param channelInfo |
cfdb727a | 104 | * The channel info to assign to this component |
eb1bab5b BH |
105 | */ |
106 | public void setChannelInfo(IChannelInfo channelInfo) { | |
107 | fChannelInfo = channelInfo; | |
108 | IEventInfo[] events = fChannelInfo.getEvents(); | |
e0838ca1 | 109 | List<ITraceControlComponent> eventComponents = new ArrayList<>(); |
eb1bab5b | 110 | for (int i = 0; i < events.length; i++) { |
d132bcc7 BH |
111 | TraceEventComponent event = null; |
112 | if (events[i].getClass() == ProbeEventInfo.class) { | |
113 | event = new TraceProbeEventComponent(events[i].getName(), this); | |
114 | } else { | |
115 | event = new TraceEventComponent(events[i].getName(), this); | |
116 | } | |
117 | ||
b957fb8c | 118 | eventComponents.add(event); |
eb1bab5b | 119 | event.setEventInfo(events[i]); |
b957fb8c BH |
120 | } |
121 | if (!eventComponents.isEmpty()) { | |
122 | setChildren(eventComponents); | |
eb1bab5b BH |
123 | } |
124 | } | |
125 | ||
126 | /** | |
127 | * @return the overwrite mode value. | |
128 | */ | |
129 | public boolean isOverwriteMode() { | |
130 | return fChannelInfo.isOverwriteMode(); | |
131 | } | |
132 | /** | |
133 | * Sets the overwrite mode value to the given mode. | |
134 | * @param mode - mode to set. | |
135 | */ | |
136 | public void setOverwriteMode(boolean mode){ | |
137 | fChannelInfo.setOverwriteMode(mode); | |
138 | } | |
139 | /** | |
140 | * @return the sub-buffer size. | |
141 | */ | |
142 | public long getSubBufferSize() { | |
143 | return fChannelInfo.getSubBufferSize(); | |
144 | } | |
145 | /** | |
146 | * Sets the sub-buffer size to the given value. | |
147 | * @param bufferSize - size to set to set. | |
148 | */ | |
149 | public void setSubBufferSize(long bufferSize) { | |
150 | fChannelInfo.setSubBufferSize(bufferSize); | |
151 | } | |
152 | /** | |
153 | * @return the number of sub-buffers. | |
154 | */ | |
155 | public int getNumberOfSubBuffers() { | |
156 | return fChannelInfo.getNumberOfSubBuffers(); | |
157 | } | |
158 | /** | |
159 | * Sets the number of sub-buffers to the given value. | |
160 | * @param numberOfSubBuffers - value to set. | |
161 | */ | |
162 | public void setNumberOfSubBuffers(int numberOfSubBuffers) { | |
163 | fChannelInfo.setNumberOfSubBuffers(numberOfSubBuffers); | |
164 | } | |
165 | /** | |
166 | * @return the switch timer interval. | |
167 | */ | |
168 | public long getSwitchTimer() { | |
169 | return fChannelInfo.getSwitchTimer(); | |
170 | } | |
171 | /** | |
172 | * Sets the switch timer interval to the given value. | |
173 | * @param timer - timer value to set. | |
174 | */ | |
175 | public void setSwitchTimer(long timer) { | |
176 | fChannelInfo.setSwitchTimer(timer); | |
177 | } | |
178 | /** | |
179 | * @return the read timer interval. | |
180 | */ | |
181 | public long getReadTimer() { | |
cfdb727a | 182 | return fChannelInfo.getReadTimer(); |
eb1bab5b BH |
183 | } |
184 | /** | |
185 | * Sets the read timer interval to the given value. | |
186 | * @param timer - timer value to set.. | |
187 | */ | |
188 | public void setReadTimer(long timer) { | |
189 | fChannelInfo.setReadTimer(timer); | |
190 | } | |
191 | /** | |
192 | * @return the output type. | |
193 | */ | |
0ad9fc89 | 194 | public TraceChannelOutputType getOutputType() { |
eb1bab5b BH |
195 | return fChannelInfo.getOutputType(); |
196 | } | |
0ad9fc89 JRJ |
197 | /** |
198 | * Sets the output type to the given value. | |
199 | * @param type - type to set. | |
200 | */ | |
201 | public void setOutputType(TraceChannelOutputType type) { | |
202 | fChannelInfo.setOutputType(type); | |
203 | } | |
eb1bab5b BH |
204 | /** |
205 | * Sets the output type to the given value. | |
206 | * @param type - type to set. | |
207 | */ | |
208 | public void setOutputType(String type) { | |
209 | fChannelInfo.setOutputType(type); | |
210 | } | |
0ad9fc89 | 211 | |
eb1bab5b BH |
212 | /** |
213 | * @return the channel state (enabled or disabled). | |
214 | */ | |
215 | public TraceEnablement getState() { | |
216 | return fChannelInfo.getState(); | |
217 | } | |
218 | /** | |
219 | * Sets the channel state (enablement) to the given value. | |
220 | * @param state - state to set. | |
221 | */ | |
222 | public void setState(TraceEnablement state) { | |
223 | fChannelInfo.setState(state); | |
224 | } | |
225 | /** | |
226 | * Sets the channel state (enablement) to the value specified by the given name. | |
227 | * @param stateName - state to set. | |
228 | */ | |
229 | public void setState(String stateName) { | |
230 | fChannelInfo.setState(stateName); | |
231 | } | |
11252342 | 232 | |
6f40b641 BH |
233 | /** |
234 | * @return maximum size of trace files | |
235 | */ | |
236 | public long getMaxSizeTraceFiles() { | |
237 | return fChannelInfo.getMaxSizeTraceFiles(); | |
238 | } | |
239 | /** | |
240 | * @return maximum number of trace files | |
241 | */ | |
242 | public int getMaxNumberTraceFiles() { | |
243 | return fChannelInfo.getMaxNumberTraceFiles(); | |
244 | } | |
245 | ||
06b9339e BH |
246 | @Override |
247 | public Object getAdapter(Class adapter) { | |
248 | if (adapter == IPropertySource.class) { | |
249 | return new TraceChannelPropertySource(this); | |
250 | } | |
251 | return null; | |
cfdb727a | 252 | } |
bbb3538a BH |
253 | |
254 | /** | |
255 | * @return session name from parent | |
256 | */ | |
257 | public String getSessionName() { | |
cfdb727a | 258 | return ((TraceDomainComponent)getParent()).getSessionName(); |
bbb3538a BH |
259 | } |
260 | ||
6503ae0f BH |
261 | /** |
262 | * @return session from parent | |
263 | */ | |
264 | public TraceSessionComponent getSession() { | |
cfdb727a | 265 | return ((TraceDomainComponent)getParent()).getSession(); |
6503ae0f BH |
266 | } |
267 | ||
bbb3538a BH |
268 | /** |
269 | * @return if domain is kernel or UST | |
270 | */ | |
271 | public boolean isKernel() { | |
272 | return ((TraceDomainComponent)getParent()).isKernel(); | |
273 | } | |
cfdb727a | 274 | |
498704b3 BH |
275 | /** |
276 | * @return the parent target node | |
277 | */ | |
278 | public TargetNodeComponent getTargetNode() { | |
279 | return ((TraceDomainComponent)getParent()).getTargetNode(); | |
280 | } | |
cfdb727a | 281 | |
eb1bab5b BH |
282 | // ------------------------------------------------------------------------ |
283 | // Operations | |
284 | // ------------------------------------------------------------------------ | |
6503ae0f BH |
285 | |
286 | /** | |
287 | * Enables a list of events with no additional parameters. | |
cfdb727a AM |
288 | * |
289 | * @param eventNames | |
290 | * - a list of event names to enabled. | |
291 | * @param monitor | |
292 | * - a progress monitor | |
6503ae0f | 293 | * @throws ExecutionException |
cfdb727a | 294 | * If the command fails |
6503ae0f | 295 | */ |
498704b3 | 296 | public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException { |
d4514365 BH |
297 | enableEvents(eventNames, null, monitor); |
298 | } | |
299 | ||
300 | /** | |
301 | * Enables a list of events with no additional parameters. | |
302 | * | |
303 | * @param eventNames | |
304 | * - a list of event names to enabled. | |
305 | * @param filterExpression | |
306 | * - a filter expression | |
307 | * @param monitor | |
308 | * - a progress monitor | |
309 | * @throws ExecutionException | |
310 | * If the command fails | |
311 | */ | |
312 | public void enableEvents(List<String> eventNames, String filterExpression, IProgressMonitor monitor) throws ExecutionException { | |
313 | getControlService().enableEvents(getSessionName(), getName(), eventNames, isKernel(), filterExpression, monitor); | |
498704b3 | 314 | } |
cfdb727a | 315 | |
498704b3 BH |
316 | /** |
317 | * Enables all syscalls (for kernel domain) | |
cfdb727a AM |
318 | * |
319 | * @param monitor | |
320 | * - a progress monitor | |
498704b3 | 321 | * @throws ExecutionException |
cfdb727a | 322 | * If the command fails |
498704b3 BH |
323 | */ |
324 | public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException { | |
325 | getControlService().enableSyscalls(getSessionName(), getName(), monitor); | |
326 | } | |
327 | ||
498704b3 BH |
328 | /** |
329 | * Enables a dynamic probe (for kernel domain) | |
cfdb727a AM |
330 | * |
331 | * @param eventName | |
332 | * - event name for probe | |
333 | * @param isFunction | |
334 | * - true for dynamic function entry/return probe else false | |
335 | * @param probe | |
336 | * - the actual probe | |
337 | * @param monitor | |
338 | * - a progress monitor | |
498704b3 | 339 | * @throws ExecutionException |
cfdb727a | 340 | * If the command fails |
498704b3 | 341 | */ |
cfdb727a AM |
342 | public void enableProbe(String eventName, boolean isFunction, String probe, |
343 | IProgressMonitor monitor) throws ExecutionException { | |
d132bcc7 | 344 | getControlService().enableProbe(getSessionName(), getName(), eventName, isFunction, probe, monitor); |
498704b3 BH |
345 | } |
346 | ||
ccc66d01 BH |
347 | /** |
348 | * Enables events using log level. | |
cfdb727a AM |
349 | * |
350 | * @param eventName | |
351 | * - a event name | |
352 | * @param logLevelType | |
353 | * - a log level type | |
354 | * @param level | |
355 | * - a log level | |
d4514365 BH |
356 | * @param filterExpression |
357 | * - a filter expression | |
cfdb727a AM |
358 | * @param monitor |
359 | * - a progress monitor | |
ccc66d01 | 360 | * @throws ExecutionException |
cfdb727a | 361 | * If the command fails |
ccc66d01 | 362 | */ |
cfdb727a | 363 | public void enableLogLevel(String eventName, LogLevelType logLevelType, |
d4514365 | 364 | TraceLogLevel level, String filterExpression, IProgressMonitor monitor) |
cfdb727a | 365 | throws ExecutionException { |
d4514365 | 366 | getControlService().enableLogLevel(getSessionName(), getName(), eventName, logLevelType, level, filterExpression, monitor); |
ccc66d01 BH |
367 | } |
368 | ||
6503ae0f BH |
369 | /** |
370 | * Enables a list of events with no additional parameters. | |
cfdb727a AM |
371 | * |
372 | * @param eventNames | |
373 | * - a list of event names to enabled. | |
374 | * @param monitor | |
375 | * - a progress monitor | |
6503ae0f | 376 | * @throws ExecutionException |
cfdb727a | 377 | * If the command fails |
6503ae0f | 378 | */ |
cfdb727a AM |
379 | public void disableEvent(List<String> eventNames, IProgressMonitor monitor) |
380 | throws ExecutionException { | |
381 | getControlService().disableEvent(getParent().getParent().getName(), | |
382 | getName(), eventNames, isKernel(), monitor); | |
6503ae0f | 383 | } |
cfdb727a | 384 | |
b793fbe1 BH |
385 | /** |
386 | * Add contexts to given channels and or events | |
cfdb727a AM |
387 | * |
388 | * @param contexts | |
389 | * - a list of contexts to add | |
390 | * @param monitor | |
391 | * - a progress monitor | |
b793fbe1 | 392 | * @throws ExecutionException |
cfdb727a | 393 | * If the command fails |
b793fbe1 | 394 | */ |
cfdb727a AM |
395 | public void addContexts(List<String> contexts, IProgressMonitor monitor) |
396 | throws ExecutionException { | |
397 | getControlService().addContexts(getSessionName(), getName(), null, | |
398 | isKernel(), contexts, monitor); | |
b793fbe1 | 399 | } |
eb1bab5b | 400 | } |