Remove unnecessary methods in LTTng Tracer Control model
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / model / impl / TraceDomainComponent.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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.linuxtools.internal.lttng2.ui.views.control.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.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;
25 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
26 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceDomainPropertySource;
27 import org.eclipse.ui.views.properties.IPropertySource;
28
29 /**
30 * <p>
31 * Implementation of the trace domain component.
32 * </p>
33 *
34 * @author Bernd Hufmann
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 */
51 private IDomainInfo fDomainInfo = null;
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
85 /*
86 * (non-Javadoc)
87 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
88 */
89 @Override
90 public Object getAdapter(Class adapter) {
91 if (adapter == IPropertySource.class) {
92 return new TraceDomainPropertySource(this);
93 }
94 return null;
95 }
96
97 /**
98 * @return session name from parent
99 */
100 public String getSessionName() {
101 return ((TraceSessionComponent)getParent()).getName();
102 }
103
104 /**
105 * @return session from parent
106 */
107 public TraceSessionComponent getSession() {
108 return (TraceSessionComponent)getParent();
109 }
110
111 /**
112 * @return true if domain is kernel, false for UST
113 */
114 public boolean isKernel() {
115 return fDomainInfo.isKernel();
116 }
117
118 /**
119 * Sets whether domain is Kernel domain or UST
120 * @param isKernel true for kernel, false for UST
121 */
122 public void setIsKernel(boolean isKernel) {
123 fDomainInfo.setIsKernel(isKernel);
124 }
125
126 /**
127 * @return returns all available channels for this domain.
128 */
129 public TraceChannelComponent[] getChannels() {
130 List<ITraceControlComponent> channels = getChildren(TraceChannelComponent.class);
131 return channels.toArray(new TraceChannelComponent[channels.size()]);
132 }
133
134 /**
135 * @return the parent target node
136 */
137 public TargetNodeComponent getTargetNode() {
138 return ((TraceSessionComponent)getParent()).getTargetNode();
139 }
140
141 // ------------------------------------------------------------------------
142 // Operations
143 // ------------------------------------------------------------------------
144
145 /**
146 * Retrieves the session configuration from the node.
147 *
148 * @param monitor
149 * - a progress monitor
150 * @throws ExecutionException
151 * If the command fails
152 */
153 public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
154 TraceSessionComponent session = (TraceSessionComponent) getParent();
155 session.getConfigurationFromNode(monitor);
156 }
157
158 /**
159 * Enables channels with given names which are part of this domain. If a
160 * given channel doesn't exists it creates a new channel with the given
161 * parameters (or default values if given parameter is null).
162 *
163 * @param channelNames
164 * - a list of channel names to enable on this domain
165 * @param info
166 * - channel information to set for the channel (use null for
167 * default)
168 * @param monitor
169 * - a progress monitor
170 * @throws ExecutionException
171 * If the command fails
172 */
173 public void enableChannels(List<String> channelNames, IChannelInfo info,
174 IProgressMonitor monitor) throws ExecutionException {
175 getControlService().enableChannels(getParent().getName(), channelNames,
176 isKernel(), info, monitor);
177 }
178
179 /**
180 * Disables channels with given names which are part of this domain.
181 *
182 * @param channelNames
183 * - a list of channel names to enable on this domain
184 * @param monitor
185 * - a progress monitor
186 * @throws ExecutionException
187 * If the command fails
188 */
189 public void disableChannels(List<String> channelNames,
190 IProgressMonitor monitor) throws ExecutionException {
191 getControlService().disableChannels(getParent().getName(),
192 channelNames, isKernel(), monitor);
193 }
194
195 /**
196 * Enables a list of events with no additional parameters.
197 *
198 * @param eventNames
199 * - a list of event names to enabled.
200 * @param monitor
201 * - a progress monitor
202 * @throws ExecutionException
203 * If the command fails
204 */
205 public void enableEvents(List<String> eventNames, IProgressMonitor monitor)
206 throws ExecutionException {
207 getControlService().enableEvents(getSessionName(), null, eventNames,
208 isKernel(), null, monitor);
209 }
210
211 /**
212 * Enables all syscalls (for kernel domain)
213 *
214 * @param monitor
215 * - a progress monitor
216 * @throws ExecutionException
217 * If the command fails
218 */
219
220 public void enableSyscalls(IProgressMonitor monitor)
221 throws ExecutionException {
222 getControlService().enableSyscalls(getSessionName(), null, monitor);
223 }
224
225 /**
226 * Enables a dynamic probe (for kernel domain)
227 *
228 * @param eventName
229 * - event name for probe
230 * @param isFunction
231 * - true for dynamic function entry/return probe else false
232 * @param probe
233 * - the actual probe
234 * @param monitor
235 * - a progress monitor
236 * @throws ExecutionException
237 * If the command fails
238 */
239 public void enableProbe(String eventName, boolean isFunction, String probe,
240 IProgressMonitor monitor) throws ExecutionException {
241 getControlService().enableProbe(getSessionName(), null, eventName,
242 isFunction, probe, monitor);
243 }
244
245 /**
246 * Enables events using log level.
247 *
248 * @param eventName
249 * - a event name
250 * @param logLevelType
251 * - a log level type
252 * @param level
253 * - a log level
254 * @param filterExpression
255 * - a filter expression
256 * @param monitor
257 * - a progress monitor
258 * @throws ExecutionException
259 * If the command fails
260 */
261 public void enableLogLevel(String eventName, LogLevelType logLevelType,
262 TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
263 throws ExecutionException {
264 getControlService().enableLogLevel(getSessionName(), null, eventName,
265 logLevelType, level, filterExpression, monitor);
266 }
267
268 /**
269 * Add contexts to given channels and or events
270 *
271 * @param contexts
272 * - a list of contexts to add
273 * @param monitor
274 * - a progress monitor
275 * @throws ExecutionException
276 * If the command fails
277 */
278 public void addContexts(List<String> contexts, IProgressMonitor monitor)
279 throws ExecutionException {
280 getControlService().addContexts(getSessionName(), null, null,
281 isKernel(), contexts, monitor);
282 }
283
284 /**
285 * Executes calibrate command to quantify LTTng overhead.
286 *
287 * @param monitor
288 * - a progress monitor
289 * @throws ExecutionException
290 * If the command fails
291 */
292 public void calibrate(IProgressMonitor monitor) throws ExecutionException {
293 getControlService().calibrate(isKernel(), monitor);
294 }
295 }
This page took 0.039258 seconds and 5 git commands to generate.