1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.impl
;
14 import java
.util
.List
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
18 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
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
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.TraceDomainPropertySource
;
24 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
27 * <b><u>TraceDomainComponent</u></b>
29 * Implementation of the trace domain component.
32 public class TraceDomainComponent
extends TraceControlComponent
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
37 * Path to icon file for this component.
39 public static final String TRACE_DOMAIN_ICON_FILE
= "icons/obj16/domain.gif"; //$NON-NLS-1$
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
45 * The domain information.
47 private IDomainInfo fDomainInfo
= null;
49 // ------------------------------------------------------------------------
51 // ------------------------------------------------------------------------
54 * @param name - the name of the component.
55 * @param parent - the parent of this component.
57 public TraceDomainComponent(String name
, ITraceControlComponent parent
) {
59 setImage(TRACE_DOMAIN_ICON_FILE
);
60 setToolTip(Messages
.TraceControl_DomainDisplayName
);
61 fDomainInfo
= new DomainInfo(name
);
64 // ------------------------------------------------------------------------
66 // ------------------------------------------------------------------------
68 * Sets the domain information.
69 * @param domainInfo - the domain information to set.
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
]);
83 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
85 @SuppressWarnings("rawtypes")
87 public Object
getAdapter(Class adapter
) {
88 if (adapter
== IPropertySource
.class) {
89 return new TraceDomainPropertySource(this);
95 * @return session name from parent
97 public String
getSessionName() {
98 return ((TraceSessionComponent
)getParent()).getName();
102 * @return session from parent
104 public TraceSessionComponent
getSession() {
105 return (TraceSessionComponent
)getParent();
109 * @return true if domain is kernel, false for UST
111 public boolean isKernel() {
112 return fDomainInfo
.isKernel();
116 * Sets whether domain is Kernel domain or UST
117 * @param isKernel true for kernel, false for UST
119 public void setIsKernel(boolean isKernel
) {
120 fDomainInfo
.setIsKernel(isKernel
);
124 * @return returns all available channels for this domain.
126 public TraceChannelComponent
[] getChannels() {
127 List
<ITraceControlComponent
> channels
= getChildren(TraceChannelComponent
.class);
128 return (TraceChannelComponent
[])channels
.toArray(new TraceChannelComponent
[channels
.size()]);
131 // ------------------------------------------------------------------------
133 // ------------------------------------------------------------------------
135 * Retrieves the session configuration from the node.
136 * @throws ExecutionException
138 public void getConfigurationFromNode() throws ExecutionException
{
139 getConfigurationFromNode(new NullProgressMonitor());
142 * Retrieves the session configuration from the node.
143 * @param monitor - a progress monitor
144 * @throws ExecutionException
146 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
147 TraceSessionComponent session
= (TraceSessionComponent
) getParent();
148 session
.getConfigurationFromNode(monitor
);
151 * Enables channels with given names which are part of this domain. If a given channel
152 * doesn't exists it creates a new channel with the given parameters (or default values
153 * if given parameter is null).
154 * @param channelNames - a list of channel names to enable on this domain
155 * @param info - channel information to set for the channel (use null for default)
156 * @throws ExecutionException
158 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
) throws ExecutionException
{
159 enableChannels(channelNames
, info
, new NullProgressMonitor());
162 * Enables channels with given names which are part of this domain. If a given channel
163 * doesn't exists it creates a new channel with the given parameters (or default values
164 * if given parameter is null).
165 * @param channelNames - a list of channel names to enable on this domain
166 * @param info - channel information to set for the channel (use null for default)
167 * @param monitor - a progress monitor
168 * @throws ExecutionException
170 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
, IProgressMonitor monitor
) throws ExecutionException
{
171 getControlService().enableChannel(getParent().getName(), channelNames
, isKernel(), info
, monitor
);
174 * Disables channels with given names which are part of this domain.
175 * @param channelNames - a list of channel names to enable on this domain
176 * @throws ExecutionException
178 public void disableChannels(List
<String
> channelNames
) throws ExecutionException
{
179 disableChannels(channelNames
, new NullProgressMonitor());
182 * Disables channels with given names which are part of this domain.
183 * @param channelNames - a list of channel names to enable on this domain
184 * @param monitor - a progress monitor
185 * @throws ExecutionException
187 public void disableChannels(List
<String
> channelNames
, IProgressMonitor monitor
) throws ExecutionException
{
188 getControlService().disableChannel(getParent().getName(), channelNames
, isKernel(), monitor
);