control: allow filters for when enabling events on domain level
[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.IChannelInfo;
20 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo;
21 import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
22 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
23 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.BufferType;
24 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.DomainInfo;
25 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
26 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
27 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TraceDomainPropertySource;
28 import org.eclipse.ui.views.properties.IPropertySource;
29
30 /**
31 * <p>
32 * Implementation of the trace domain component.
33 * </p>
34 *
35 * @author Bernd Hufmann
36 */
37 public class TraceDomainComponent extends TraceControlComponent {
38 // ------------------------------------------------------------------------
39 // Constants
40 // ------------------------------------------------------------------------
41 /**
42 * Path to icon file for this component.
43 */
44 public static final String TRACE_DOMAIN_ICON_FILE = "icons/obj16/domain.gif"; //$NON-NLS-1$
45
46 // ------------------------------------------------------------------------
47 // Attributes
48 // ------------------------------------------------------------------------
49 /**
50 * The domain information.
51 */
52 private IDomainInfo fDomainInfo = null;
53
54 // ------------------------------------------------------------------------
55 // Constructors
56 // ------------------------------------------------------------------------
57 /**
58 * Constructor
59 * @param name - the name of the component.
60 * @param parent - the parent of this component.
61 */
62 public TraceDomainComponent(String name, ITraceControlComponent parent) {
63 super(name, parent);
64 setImage(TRACE_DOMAIN_ICON_FILE);
65 setToolTip(Messages.TraceControl_DomainDisplayName);
66 fDomainInfo = new DomainInfo(name);
67 }
68
69 // ------------------------------------------------------------------------
70 // Accessors
71 // ------------------------------------------------------------------------
72 /**
73 * Sets the domain information.
74 * @param domainInfo - the domain information to set.
75 */
76 public void setDomainInfo(IDomainInfo domainInfo) {
77 fDomainInfo = domainInfo;
78 IChannelInfo[] channels = fDomainInfo.getChannels();
79 for (int i = 0; i < channels.length; i++) {
80 TraceChannelComponent channel = new TraceChannelComponent(channels[i].getName(), this);
81 channel.setChannelInfo(channels[i]);
82 addChild(channel);
83 }
84 }
85
86 @Override
87 public <T> T getAdapter(Class<T> adapter) {
88 if (adapter == IPropertySource.class) {
89 return adapter.cast(new TraceDomainPropertySource(this));
90 }
91 return null;
92 }
93
94 /**
95 * @return session name from parent
96 */
97 public String getSessionName() {
98 return ((TraceSessionComponent)getParent()).getName();
99 }
100
101 /**
102 * @return session from parent
103 */
104 public TraceSessionComponent getSession() {
105 return (TraceSessionComponent)getParent();
106 }
107
108 /**
109 * @return true if domain is kernel, false for UST
110 */
111 public boolean isKernel() {
112 return fDomainInfo.isKernel();
113 }
114
115 /**
116 * Sets whether domain is Kernel domain or UST
117 * @param isKernel true for kernel, false for UST
118 */
119 public void setIsKernel(boolean isKernel) {
120 fDomainInfo.setIsKernel(isKernel);
121 }
122
123 /**
124 * @return returns all available channels for this domain.
125 */
126 public TraceChannelComponent[] getChannels() {
127 List<ITraceControlComponent> channels = getChildren(TraceChannelComponent.class);
128 return channels.toArray(new TraceChannelComponent[channels.size()]);
129 }
130
131 /**
132 * @return the parent target node
133 */
134 public TargetNodeComponent getTargetNode() {
135 return ((TraceSessionComponent)getParent()).getTargetNode();
136 }
137
138 /**
139 * @return the buffer type
140 */
141 public BufferType getBufferType(){
142 return fDomainInfo.getBufferType();
143 }
144
145 // ------------------------------------------------------------------------
146 // Operations
147 // ------------------------------------------------------------------------
148
149 /**
150 * Retrieves the session configuration from the node.
151 *
152 * @param monitor
153 * - a progress monitor
154 * @throws ExecutionException
155 * If the command fails
156 */
157 public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
158 TraceSessionComponent session = (TraceSessionComponent) getParent();
159 session.getConfigurationFromNode(monitor);
160 }
161
162 /**
163 * Enables channels with given names which are part of this domain. If a
164 * given channel doesn't exists it creates a new channel with the given
165 * parameters (or default values if given parameter is null).
166 *
167 * @param channelNames
168 * - a list of channel names to enable on this domain
169 * @param info
170 * - channel information to set for the channel (use null for
171 * default)
172 * @param monitor
173 * - a progress monitor
174 * @throws ExecutionException
175 * If the command fails
176 */
177 public void enableChannels(List<String> channelNames, IChannelInfo info,
178 IProgressMonitor monitor) throws ExecutionException {
179 getControlService().enableChannels(getParent().getName(), channelNames,
180 isKernel(), info, monitor);
181 }
182
183 /**
184 * Disables channels with given names which are part of this domain.
185 *
186 * @param channelNames
187 * - a list of channel names to enable on this domain
188 * @param monitor
189 * - a progress monitor
190 * @throws ExecutionException
191 * If the command fails
192 */
193 public void disableChannels(List<String> channelNames,
194 IProgressMonitor monitor) throws ExecutionException {
195 getControlService().disableChannels(getParent().getName(),
196 channelNames, isKernel(), monitor);
197 }
198
199 /**
200 * Enables a list of events with no additional parameters.
201 *
202 * @param eventNames
203 * - a list of event names to enabled.
204 * @param filterExpression
205 * - a filter expression
206 * @param monitor
207 * - a progress monitor
208 * @throws ExecutionException
209 * If the command fails
210 */
211 public void enableEvents(List<String> eventNames, String filterExpression, IProgressMonitor monitor)
212 throws ExecutionException {
213 getControlService().enableEvents(getSessionName(), null, eventNames,
214 isKernel(), filterExpression, monitor);
215 }
216
217 /**
218 * Enables all syscalls (for kernel domain)
219 *
220 * @param monitor
221 * - a progress monitor
222 * @throws ExecutionException
223 * If the command fails
224 */
225
226 public void enableSyscalls(IProgressMonitor monitor)
227 throws ExecutionException {
228 getControlService().enableSyscalls(getSessionName(), null, monitor);
229 }
230
231 /**
232 * Enables a dynamic probe (for kernel domain)
233 *
234 * @param eventName
235 * - event name for probe
236 * @param isFunction
237 * - true for dynamic function entry/return probe else false
238 * @param probe
239 * - the actual probe
240 * @param monitor
241 * - a progress monitor
242 * @throws ExecutionException
243 * If the command fails
244 */
245 public void enableProbe(String eventName, boolean isFunction, String probe,
246 IProgressMonitor monitor) throws ExecutionException {
247 getControlService().enableProbe(getSessionName(), null, eventName,
248 isFunction, probe, monitor);
249 }
250
251 /**
252 * Enables events using log level.
253 *
254 * @param eventName
255 * - a event name
256 * @param logLevelType
257 * - a log level type
258 * @param level
259 * - a log level
260 * @param filterExpression
261 * - a filter expression
262 * @param monitor
263 * - a progress monitor
264 * @throws ExecutionException
265 * If the command fails
266 */
267 public void enableLogLevel(String eventName, LogLevelType logLevelType,
268 TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
269 throws ExecutionException {
270 getControlService().enableLogLevel(getSessionName(), null, eventName,
271 logLevelType, level, filterExpression, monitor);
272 }
273
274 /**
275 * Add contexts to given channels and or events
276 *
277 * @param contexts
278 * - a list of contexts to add
279 * @param monitor
280 * - a progress monitor
281 * @throws ExecutionException
282 * If the command fails
283 */
284 public void addContexts(List<String> contexts, IProgressMonitor monitor)
285 throws ExecutionException {
286 getControlService().addContexts(getSessionName(), null, null,
287 isKernel(), contexts, monitor);
288 }
289
290 }
This page took 0.03859 seconds and 5 git commands to generate.