lttng: Fix ControlViewTest
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / model / impl / TraceDomainComponent.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl;
14
15 import java.util.List;
16
17 import org.eclipse.core.commands.ExecutionException;
18 import org.eclipse.core.runtime.IProgressMonitor;
19 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType;
20 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo;
21 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo;
22 import org.eclipse.tracecompass.internal.lttng2.control.core.model.ILoggerInfo;
23 import org.eclipse.tracecompass.internal.lttng2.control.core.model.ITraceLogLevel;
24 import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
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;
30 import org.eclipse.ui.views.properties.IPropertySource;
31
32 /**
33 * <p>
34 * Implementation of the trace domain component.
35 * </p>
36 *
37 * @author Bernd Hufmann
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 */
54 private IDomainInfo fDomainInfo = null;
55
56 // ------------------------------------------------------------------------
57 // Constructors
58 // ------------------------------------------------------------------------
59 /**
60 * Constructor
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 }
86
87 // Since the loggers are not in a channel, the loggers won't be added by the previous loop
88 if (TraceDomainType.JUL.equals(domainInfo.getDomain()) ||
89 TraceDomainType.LOG4J.equals(domainInfo.getDomain()) ||
90 TraceDomainType.PYTHON.equals(domainInfo.getDomain())) {
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 }
98 }
99
100 @Override
101 public <T> T getAdapter(Class<T> adapter) {
102 if (adapter == IPropertySource.class) {
103 return adapter.cast(new TraceDomainPropertySource(this));
104 }
105 return null;
106 }
107
108 /**
109 * @return session name from parent
110 */
111 public String getSessionName() {
112 return ((TraceSessionComponent)getParent()).getName();
113 }
114
115 /**
116 * @return session from parent
117 */
118 public TraceSessionComponent getSession() {
119 return (TraceSessionComponent)getParent();
120 }
121
122 /**
123 * @return the domain type ({@link TraceDomainType})
124 */
125 public TraceDomainType getDomain() {
126 return fDomainInfo.getDomain();
127 }
128
129 /**
130 * Sets the domain type
131 *
132 * @param domain
133 * the domain type ({@link TraceDomainType})
134 */
135 public void setDomain(TraceDomainType domain) {
136 fDomainInfo.setDomain(domain);
137 }
138
139 /**
140 * @return returns all available channels for this domain.
141 */
142 public TraceChannelComponent[] getChannels() {
143 List<ITraceControlComponent> channels = getChildren(TraceChannelComponent.class);
144 return channels.toArray(new TraceChannelComponent[channels.size()]);
145 }
146
147 /**
148 * @return the parent target node
149 */
150 public TargetNodeComponent getTargetNode() {
151 return ((TraceSessionComponent)getParent()).getTargetNode();
152 }
153
154 /**
155 * @return the buffer type
156 */
157 public BufferType getBufferType(){
158 return fDomainInfo.getBufferType();
159 }
160
161 // ------------------------------------------------------------------------
162 // Operations
163 // ------------------------------------------------------------------------
164
165 /**
166 * Retrieves the session configuration from the node.
167 *
168 * @param monitor
169 * - a progress monitor
170 * @throws ExecutionException
171 * If the command fails
172 */
173 public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
174 TraceSessionComponent session = (TraceSessionComponent) getParent();
175 session.getConfigurationFromNode(monitor);
176 }
177
178 /**
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
190 * @throws ExecutionException
191 * If the command fails
192 */
193 public void enableChannels(List<String> channelNames, IChannelInfo info,
194 IProgressMonitor monitor) throws ExecutionException {
195 getControlService().enableChannels(getParent().getName(), channelNames,
196 getDomain(), info, monitor);
197 }
198
199 /**
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
206 * @throws ExecutionException
207 * If the command fails
208 */
209 public void disableChannels(List<String> channelNames,
210 IProgressMonitor monitor) throws ExecutionException {
211 getControlService().disableChannels(getParent().getName(),
212 channelNames, getDomain(), monitor);
213 }
214
215 /**
216 * Enables a list of events with no additional parameters.
217 *
218 * @param eventNames
219 * - a list of event names to enabled.
220 * @param filterExpression
221 * - a filter expression
222 * @param excludedEvents
223 * - a list of events to exclude.
224 * @param monitor
225 * - a progress monitor
226 * @throws ExecutionException
227 * If the command fails
228 */
229 public void enableEvents(List<String> eventNames, String filterExpression, List<String> excludedEvents, IProgressMonitor monitor)
230 throws ExecutionException {
231 getControlService().enableEvents(getSessionName(), null, eventNames,
232 getDomain(), filterExpression, excludedEvents, monitor);
233 }
234
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
250 /**
251 * Enables all syscalls (for kernel domain)
252 * @param syscallNames
253 * - a list of syscall names
254 * @param monitor
255 * - a progress monitor
256 * @throws ExecutionException
257 * If the command fails
258 */
259
260 public void enableSyscalls(List<String> syscallNames, IProgressMonitor monitor)
261 throws ExecutionException {
262 getControlService().enableSyscalls(getSessionName(), null, syscallNames, monitor);
263 }
264
265 /**
266 * Enables a dynamic probe (for kernel domain)
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
276 * @throws ExecutionException
277 * If the command fails
278 */
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);
283 }
284
285 /**
286 * Enables events using log level.
287 *
288 * @param eventNames
289 * - a list of event names
290 * @param logLevelType
291 * - a log level type
292 * @param level
293 * - a log level
294 * @param filterExpression
295 * - a filter expression
296 * @param domain
297 * - the domain type ({@link TraceDomainType})
298 * @param monitor
299 * - a progress monitor
300 * @throws ExecutionException
301 * If the command fails
302 */
303 public void enableLogLevel(List<String> eventNames, LogLevelType logLevelType,
304 ITraceLogLevel level, String filterExpression, TraceDomainType domain, IProgressMonitor monitor)
305 throws ExecutionException {
306 getControlService().enableLogLevel(getSessionName(), null, eventNames,
307 logLevelType, level, filterExpression, domain, monitor);
308 }
309
310 /**
311 * Add contexts to given channels and or events
312 *
313 * @param contexts
314 * - a list of contexts to add
315 * @param monitor
316 * - a progress monitor
317 * @throws ExecutionException
318 * If the command fails
319 */
320 public void addContexts(List<String> contexts, IProgressMonitor monitor)
321 throws ExecutionException {
322 getControlService().addContexts(getSessionName(), null, null,
323 getDomain(), contexts, monitor);
324 }
325
326 }
This page took 0.053442 seconds and 5 git commands to generate.