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