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
CommitLineData
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 13package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl;
eb1bab5b 14
bbb3538a
BH
15import java.util.List;
16
17import org.eclipse.core.commands.ExecutionException;
18import org.eclipse.core.runtime.IProgressMonitor;
9bc60be7
AM
19import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo;
20import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo;
21import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
22import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
23import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.BufferType;
24import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.DomainInfo;
25import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
26import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
27import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TraceDomainPropertySource;
06b9339e 28import org.eclipse.ui.views.properties.IPropertySource;
eb1bab5b
BH
29
30/**
eb1bab5b
BH
31 * <p>
32 * Implementation of the trace domain component.
33 * </p>
cfdb727a 34 *
dbd4432d 35 * @author Bernd Hufmann
eb1bab5b
BH
36 */
37public 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 */
bbb3538a 52 private IDomainInfo fDomainInfo = null;
eb1bab5b
BH
53
54 // ------------------------------------------------------------------------
55 // Constructors
56 // ------------------------------------------------------------------------
57 /**
cfdb727a 58 * Constructor
eb1bab5b
BH
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
06b9339e 86 @Override
e58fe1d5 87 public <T> T getAdapter(Class<T> adapter) {
06b9339e 88 if (adapter == IPropertySource.class) {
e58fe1d5 89 return adapter.cast(new TraceDomainPropertySource(this));
06b9339e
BH
90 }
91 return null;
bbb3538a 92 }
cfdb727a 93
bbb3538a
BH
94 /**
95 * @return session name from parent
96 */
97 public String getSessionName() {
98 return ((TraceSessionComponent)getParent()).getName();
99 }
cfdb727a 100
6503ae0f
BH
101 /**
102 * @return session from parent
103 */
104 public TraceSessionComponent getSession() {
cfdb727a 105 return (TraceSessionComponent)getParent();
6503ae0f
BH
106 }
107
bbb3538a
BH
108 /**
109 * @return true if domain is kernel, false for UST
110 */
111 public boolean isKernel() {
112 return fDomainInfo.isKernel();
113 }
cfdb727a 114
bbb3538a 115 /**
cfdb727a 116 * Sets whether domain is Kernel domain or UST
bbb3538a
BH
117 * @param isKernel true for kernel, false for UST
118 */
119 public void setIsKernel(boolean isKernel) {
120 fDomainInfo.setIsKernel(isKernel);
121 }
cfdb727a 122
6503ae0f
BH
123 /**
124 * @return returns all available channels for this domain.
125 */
126 public TraceChannelComponent[] getChannels() {
127 List<ITraceControlComponent> channels = getChildren(TraceChannelComponent.class);
cfdb727a 128 return channels.toArray(new TraceChannelComponent[channels.size()]);
6503ae0f 129 }
cfdb727a 130
498704b3
BH
131 /**
132 * @return the parent target node
133 */
134 public TargetNodeComponent getTargetNode() {
135 return ((TraceSessionComponent)getParent()).getTargetNode();
136 }
bbb3538a 137
ca8c54b3
SD
138 /**
139 * @return the buffer type
140 */
83051fc3 141 public BufferType getBufferType(){
ca8c54b3
SD
142 return fDomainInfo.getBufferType();
143 }
144
eb1bab5b
BH
145 // ------------------------------------------------------------------------
146 // Operations
147 // ------------------------------------------------------------------------
cfdb727a 148
bbb3538a 149 /**
cfdb727a
AM
150 * Retrieves the session configuration from the node.
151 *
152 * @param monitor
153 * - a progress monitor
bbb3538a 154 * @throws ExecutionException
cfdb727a 155 * If the command fails
bbb3538a
BH
156 */
157 public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
158 TraceSessionComponent session = (TraceSessionComponent) getParent();
159 session.getConfigurationFromNode(monitor);
160 }
cfdb727a 161
bbb3538a 162 /**
cfdb727a
AM
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
bbb3538a 174 * @throws ExecutionException
cfdb727a 175 * If the command fails
bbb3538a 176 */
cfdb727a
AM
177 public void enableChannels(List<String> channelNames, IChannelInfo info,
178 IProgressMonitor monitor) throws ExecutionException {
179 getControlService().enableChannels(getParent().getName(), channelNames,
180 isKernel(), info, monitor);
bbb3538a 181 }
cfdb727a 182
bbb3538a 183 /**
cfdb727a
AM
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
bbb3538a 190 * @throws ExecutionException
cfdb727a 191 * If the command fails
bbb3538a 192 */
cfdb727a
AM
193 public void disableChannels(List<String> channelNames,
194 IProgressMonitor monitor) throws ExecutionException {
195 getControlService().disableChannels(getParent().getName(),
196 channelNames, isKernel(), monitor);
498704b3
BH
197 }
198
199 /**
200 * Enables a list of events with no additional parameters.
cfdb727a
AM
201 *
202 * @param eventNames
203 * - a list of event names to enabled.
a1fded88
BH
204 * @param filterExpression
205 * - a filter expression
cfdb727a
AM
206 * @param monitor
207 * - a progress monitor
498704b3 208 * @throws ExecutionException
cfdb727a 209 * If the command fails
498704b3 210 */
a1fded88 211 public void enableEvents(List<String> eventNames, String filterExpression, IProgressMonitor monitor)
cfdb727a
AM
212 throws ExecutionException {
213 getControlService().enableEvents(getSessionName(), null, eventNames,
a1fded88 214 isKernel(), filterExpression, monitor);
498704b3
BH
215 }
216
cfdb727a
AM
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 */
498704b3 225
cfdb727a
AM
226 public void enableSyscalls(IProgressMonitor monitor)
227 throws ExecutionException {
498704b3
BH
228 getControlService().enableSyscalls(getSessionName(), null, monitor);
229 }
230
498704b3
BH
231 /**
232 * Enables a dynamic probe (for kernel domain)
cfdb727a
AM
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
498704b3 242 * @throws ExecutionException
cfdb727a 243 * If the command fails
498704b3 244 */
cfdb727a
AM
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);
498704b3
BH
249 }
250
ccc66d01
BH
251 /**
252 * Enables events using log level.
cfdb727a
AM
253 *
254 * @param eventName
255 * - a event name
256 * @param logLevelType
257 * - a log level type
258 * @param level
259 * - a log level
d4514365
BH
260 * @param filterExpression
261 * - a filter expression
cfdb727a
AM
262 * @param monitor
263 * - a progress monitor
ccc66d01 264 * @throws ExecutionException
cfdb727a 265 * If the command fails
ccc66d01 266 */
cfdb727a 267 public void enableLogLevel(String eventName, LogLevelType logLevelType,
d4514365 268 TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
cfdb727a
AM
269 throws ExecutionException {
270 getControlService().enableLogLevel(getSessionName(), null, eventName,
d4514365 271 logLevelType, level, filterExpression, monitor);
ccc66d01
BH
272 }
273
b793fbe1
BH
274 /**
275 * Add contexts to given channels and or events
cfdb727a
AM
276 *
277 * @param contexts
278 * - a list of contexts to add
279 * @param monitor
280 * - a progress monitor
b793fbe1 281 * @throws ExecutionException
cfdb727a 282 * If the command fails
b793fbe1 283 */
cfdb727a
AM
284 public void addContexts(List<String> contexts, IProgressMonitor monitor)
285 throws ExecutionException {
286 getControlService().addContexts(getSessionName(), null, null,
287 isKernel(), contexts, monitor);
b793fbe1 288 }
b720ac44 289
eb1bab5b 290}
This page took 0.095035 seconds and 5 git commands to generate.