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