Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
ed902a2b | 2 | * Copyright (c) 2012, 2014 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 | |
bbb3538a BH |
15 | import java.util.List; |
16 | ||
17 | import org.eclipse.core.commands.ExecutionException; | |
18 | import org.eclipse.core.runtime.IProgressMonitor; | |
1bc37054 | 19 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType; |
9bc60be7 AM |
20 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo; |
21 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo; | |
a20452b1 BR |
22 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.ILoggerInfo; |
23 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.ITraceLogLevel; | |
9bc60be7 | 24 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType; |
9bc60be7 AM |
25 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.BufferType; |
26 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.DomainInfo; | |
27 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages; | |
28 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
29 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TraceDomainPropertySource; | |
06b9339e | 30 | import org.eclipse.ui.views.properties.IPropertySource; |
eb1bab5b BH |
31 | |
32 | /** | |
eb1bab5b BH |
33 | * <p> |
34 | * Implementation of the trace domain component. | |
35 | * </p> | |
cfdb727a | 36 | * |
dbd4432d | 37 | * @author Bernd Hufmann |
eb1bab5b BH |
38 | */ |
39 | public class TraceDomainComponent extends TraceControlComponent { | |
40 | // ------------------------------------------------------------------------ | |
41 | // Constants | |
42 | // ------------------------------------------------------------------------ | |
43 | /** | |
44 | * Path to icon file for this component. | |
45 | */ | |
46 | public static final String TRACE_DOMAIN_ICON_FILE = "icons/obj16/domain.gif"; //$NON-NLS-1$ | |
47 | ||
48 | // ------------------------------------------------------------------------ | |
49 | // Attributes | |
50 | // ------------------------------------------------------------------------ | |
51 | /** | |
52 | * The domain information. | |
53 | */ | |
bbb3538a | 54 | private IDomainInfo fDomainInfo = null; |
eb1bab5b BH |
55 | |
56 | // ------------------------------------------------------------------------ | |
57 | // Constructors | |
58 | // ------------------------------------------------------------------------ | |
59 | /** | |
cfdb727a | 60 | * Constructor |
eb1bab5b BH |
61 | * @param name - the name of the component. |
62 | * @param parent - the parent of this component. | |
63 | */ | |
64 | public TraceDomainComponent(String name, ITraceControlComponent parent) { | |
65 | super(name, parent); | |
66 | setImage(TRACE_DOMAIN_ICON_FILE); | |
67 | setToolTip(Messages.TraceControl_DomainDisplayName); | |
68 | fDomainInfo = new DomainInfo(name); | |
69 | } | |
70 | ||
71 | // ------------------------------------------------------------------------ | |
72 | // Accessors | |
73 | // ------------------------------------------------------------------------ | |
74 | /** | |
75 | * Sets the domain information. | |
76 | * @param domainInfo - the domain information to set. | |
77 | */ | |
78 | public void setDomainInfo(IDomainInfo domainInfo) { | |
79 | fDomainInfo = domainInfo; | |
80 | IChannelInfo[] channels = fDomainInfo.getChannels(); | |
81 | for (int i = 0; i < channels.length; i++) { | |
82 | TraceChannelComponent channel = new TraceChannelComponent(channels[i].getName(), this); | |
83 | channel.setChannelInfo(channels[i]); | |
84 | addChild(channel); | |
85 | } | |
a20452b1 | 86 | |
74fe9bdd | 87 | // Since the loggers are not in a channel, the loggers won't be added by the previous loop |
3d2d8c9f BR |
88 | if (TraceDomainType.JUL.equals(domainInfo.getDomain()) || |
89 | TraceDomainType.LOG4J.equals(domainInfo.getDomain()) || | |
90 | TraceDomainType.PYTHON.equals(domainInfo.getDomain())) { | |
a20452b1 BR |
91 | List<ILoggerInfo> loggers = fDomainInfo.getLoggers(); |
92 | for (ILoggerInfo loggerInfo : loggers) { | |
93 | TraceLoggerComponent logger = new TraceLoggerComponent(loggerInfo.getName(), this); | |
94 | logger.setLoggerInfo(loggerInfo); | |
95 | addChild(logger); | |
96 | } | |
97 | } | |
eb1bab5b BH |
98 | } |
99 | ||
06b9339e | 100 | @Override |
e58fe1d5 | 101 | public <T> T getAdapter(Class<T> adapter) { |
06b9339e | 102 | if (adapter == IPropertySource.class) { |
e58fe1d5 | 103 | return adapter.cast(new TraceDomainPropertySource(this)); |
06b9339e BH |
104 | } |
105 | return null; | |
bbb3538a | 106 | } |
cfdb727a | 107 | |
bbb3538a BH |
108 | /** |
109 | * @return session name from parent | |
110 | */ | |
111 | public String getSessionName() { | |
112 | return ((TraceSessionComponent)getParent()).getName(); | |
113 | } | |
cfdb727a | 114 | |
6503ae0f BH |
115 | /** |
116 | * @return session from parent | |
117 | */ | |
118 | public TraceSessionComponent getSession() { | |
cfdb727a | 119 | return (TraceSessionComponent)getParent(); |
6503ae0f BH |
120 | } |
121 | ||
bbb3538a | 122 | /** |
1bc37054 | 123 | * @return the domain type ({@link TraceDomainType}) |
bbb3538a | 124 | */ |
1bc37054 BR |
125 | public TraceDomainType getDomain() { |
126 | return fDomainInfo.getDomain(); | |
bbb3538a | 127 | } |
cfdb727a | 128 | |
bbb3538a | 129 | /** |
1bc37054 BR |
130 | * Sets the domain type |
131 | * | |
132 | * @param domain | |
133 | * the domain type ({@link TraceDomainType}) | |
bbb3538a | 134 | */ |
1bc37054 BR |
135 | public void setDomain(TraceDomainType domain) { |
136 | fDomainInfo.setDomain(domain); | |
bbb3538a | 137 | } |
cfdb727a | 138 | |
6503ae0f BH |
139 | /** |
140 | * @return returns all available channels for this domain. | |
141 | */ | |
142 | public TraceChannelComponent[] getChannels() { | |
143 | List<ITraceControlComponent> channels = getChildren(TraceChannelComponent.class); | |
cfdb727a | 144 | return channels.toArray(new TraceChannelComponent[channels.size()]); |
6503ae0f | 145 | } |
cfdb727a | 146 | |
498704b3 BH |
147 | /** |
148 | * @return the parent target node | |
149 | */ | |
150 | public TargetNodeComponent getTargetNode() { | |
151 | return ((TraceSessionComponent)getParent()).getTargetNode(); | |
152 | } | |
bbb3538a | 153 | |
ca8c54b3 SD |
154 | /** |
155 | * @return the buffer type | |
156 | */ | |
83051fc3 | 157 | public BufferType getBufferType(){ |
ca8c54b3 SD |
158 | return fDomainInfo.getBufferType(); |
159 | } | |
160 | ||
eb1bab5b BH |
161 | // ------------------------------------------------------------------------ |
162 | // Operations | |
163 | // ------------------------------------------------------------------------ | |
cfdb727a | 164 | |
bbb3538a | 165 | /** |
cfdb727a AM |
166 | * Retrieves the session configuration from the node. |
167 | * | |
168 | * @param monitor | |
169 | * - a progress monitor | |
bbb3538a | 170 | * @throws ExecutionException |
cfdb727a | 171 | * If the command fails |
bbb3538a BH |
172 | */ |
173 | public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException { | |
174 | TraceSessionComponent session = (TraceSessionComponent) getParent(); | |
175 | session.getConfigurationFromNode(monitor); | |
176 | } | |
cfdb727a | 177 | |
bbb3538a | 178 | /** |
cfdb727a AM |
179 | * Enables channels with given names which are part of this domain. If a |
180 | * given channel doesn't exists it creates a new channel with the given | |
181 | * parameters (or default values if given parameter is null). | |
182 | * | |
183 | * @param channelNames | |
184 | * - a list of channel names to enable on this domain | |
185 | * @param info | |
186 | * - channel information to set for the channel (use null for | |
187 | * default) | |
188 | * @param monitor | |
189 | * - a progress monitor | |
bbb3538a | 190 | * @throws ExecutionException |
cfdb727a | 191 | * If the command fails |
bbb3538a | 192 | */ |
cfdb727a AM |
193 | public void enableChannels(List<String> channelNames, IChannelInfo info, |
194 | IProgressMonitor monitor) throws ExecutionException { | |
195 | getControlService().enableChannels(getParent().getName(), channelNames, | |
1bc37054 | 196 | getDomain(), info, monitor); |
bbb3538a | 197 | } |
cfdb727a | 198 | |
bbb3538a | 199 | /** |
cfdb727a AM |
200 | * Disables channels with given names which are part of this domain. |
201 | * | |
202 | * @param channelNames | |
203 | * - a list of channel names to enable on this domain | |
204 | * @param monitor | |
205 | * - a progress monitor | |
bbb3538a | 206 | * @throws ExecutionException |
cfdb727a | 207 | * If the command fails |
bbb3538a | 208 | */ |
cfdb727a AM |
209 | public void disableChannels(List<String> channelNames, |
210 | IProgressMonitor monitor) throws ExecutionException { | |
211 | getControlService().disableChannels(getParent().getName(), | |
1bc37054 | 212 | channelNames, getDomain(), monitor); |
498704b3 BH |
213 | } |
214 | ||
215 | /** | |
216 | * Enables a list of events with no additional parameters. | |
cfdb727a AM |
217 | * |
218 | * @param eventNames | |
219 | * - a list of event names to enabled. | |
a1fded88 BH |
220 | * @param filterExpression |
221 | * - a filter expression | |
91dc1c3e BR |
222 | * @param excludedEvents |
223 | * - a list of events to exclude. | |
cfdb727a AM |
224 | * @param monitor |
225 | * - a progress monitor | |
498704b3 | 226 | * @throws ExecutionException |
cfdb727a | 227 | * If the command fails |
498704b3 | 228 | */ |
91dc1c3e | 229 | public void enableEvents(List<String> eventNames, String filterExpression, List<String> excludedEvents, IProgressMonitor monitor) |
cfdb727a AM |
230 | throws ExecutionException { |
231 | getControlService().enableEvents(getSessionName(), null, eventNames, | |
1bc37054 | 232 | getDomain(), filterExpression, excludedEvents, monitor); |
498704b3 BH |
233 | } |
234 | ||
a20452b1 BR |
235 | /** |
236 | * Disables events with given names which are part of this domain. | |
237 | * | |
238 | * @param loggerNames | |
239 | * - a list of logger names to disable | |
240 | * @param monitor | |
241 | * - a progress monitor | |
242 | * @throws ExecutionException | |
243 | * If the command fails | |
244 | */ | |
245 | public void disableLoggers(List<String> loggerNames, | |
246 | IProgressMonitor monitor) throws ExecutionException { | |
247 | getControlService().disableEvent(getSessionName(), null, loggerNames, getDomain(), monitor); | |
248 | } | |
249 | ||
cfdb727a AM |
250 | /** |
251 | * Enables all syscalls (for kernel domain) | |
207ff523 BR |
252 | * @param syscallNames |
253 | * - a list of syscall names | |
cfdb727a AM |
254 | * @param monitor |
255 | * - a progress monitor | |
256 | * @throws ExecutionException | |
257 | * If the command fails | |
258 | */ | |
498704b3 | 259 | |
207ff523 | 260 | public void enableSyscalls(List<String> syscallNames, IProgressMonitor monitor) |
cfdb727a | 261 | throws ExecutionException { |
207ff523 | 262 | getControlService().enableSyscalls(getSessionName(), null, syscallNames, monitor); |
498704b3 BH |
263 | } |
264 | ||
498704b3 BH |
265 | /** |
266 | * Enables a dynamic probe (for kernel domain) | |
cfdb727a AM |
267 | * |
268 | * @param eventName | |
269 | * - event name for probe | |
270 | * @param isFunction | |
271 | * - true for dynamic function entry/return probe else false | |
272 | * @param probe | |
273 | * - the actual probe | |
274 | * @param monitor | |
275 | * - a progress monitor | |
498704b3 | 276 | * @throws ExecutionException |
cfdb727a | 277 | * If the command fails |
498704b3 | 278 | */ |
cfdb727a AM |
279 | public void enableProbe(String eventName, boolean isFunction, String probe, |
280 | IProgressMonitor monitor) throws ExecutionException { | |
281 | getControlService().enableProbe(getSessionName(), null, eventName, | |
282 | isFunction, probe, monitor); | |
498704b3 BH |
283 | } |
284 | ||
ccc66d01 BH |
285 | /** |
286 | * Enables events using log level. | |
cfdb727a | 287 | * |
a20452b1 BR |
288 | * @param eventNames |
289 | * - a list of event names | |
cfdb727a AM |
290 | * @param logLevelType |
291 | * - a log level type | |
292 | * @param level | |
293 | * - a log level | |
d4514365 BH |
294 | * @param filterExpression |
295 | * - a filter expression | |
a20452b1 BR |
296 | * @param domain |
297 | * - the domain type ({@link TraceDomainType}) | |
cfdb727a AM |
298 | * @param monitor |
299 | * - a progress monitor | |
ccc66d01 | 300 | * @throws ExecutionException |
cfdb727a | 301 | * If the command fails |
ccc66d01 | 302 | */ |
a20452b1 BR |
303 | public void enableLogLevel(List<String> eventNames, LogLevelType logLevelType, |
304 | ITraceLogLevel level, String filterExpression, TraceDomainType domain, IProgressMonitor monitor) | |
cfdb727a | 305 | throws ExecutionException { |
a20452b1 BR |
306 | getControlService().enableLogLevel(getSessionName(), null, eventNames, |
307 | logLevelType, level, filterExpression, domain, monitor); | |
ccc66d01 BH |
308 | } |
309 | ||
b793fbe1 BH |
310 | /** |
311 | * Add contexts to given channels and or events | |
cfdb727a AM |
312 | * |
313 | * @param contexts | |
314 | * - a list of contexts to add | |
315 | * @param monitor | |
316 | * - a progress monitor | |
b793fbe1 | 317 | * @throws ExecutionException |
cfdb727a | 318 | * If the command fails |
b793fbe1 | 319 | */ |
cfdb727a AM |
320 | public void addContexts(List<String> contexts, IProgressMonitor monitor) |
321 | throws ExecutionException { | |
322 | getControlService().addContexts(getSessionName(), null, null, | |
1bc37054 | 323 | getDomain(), contexts, monitor); |
b793fbe1 | 324 | } |
b720ac44 | 325 | |
eb1bab5b | 326 | } |