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