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