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