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
.internal
.lttng2
.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
.internal
.lttng2
.core
.control
.model
.IEventInfo
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEnablement
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEventType
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.EventInfo
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.Activator
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.messages
.Messages
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.TraceEventPropertySource
;
28 import org
.eclipse
.swt
.graphics
.Image
;
29 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
34 * Implementation of the trace channel component.
37 * @author Bernd Hufmann
39 public class TraceEventComponent
extends TraceControlComponent
{
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
44 * Path to icon file for this component (enabled state).
46 public static final String TRACE_EVENT_ICON_FILE_ENABLED
= "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
48 * Path to icon file for this component (disabled state).
50 public static final String TRACE_EVENT_ICON_FILE_DISABLED
= "icons/obj16/event_disabled.gif"; //$NON-NLS-1$
52 // ------------------------------------------------------------------------
54 // ------------------------------------------------------------------------
56 * The event information.
58 protected IEventInfo fEventInfo
= null;
60 * The image to be displayed when in disabled state.
62 private Image fDisabledImage
= null;
64 // ------------------------------------------------------------------------
66 // ------------------------------------------------------------------------
69 * @param name - the name of the component.
70 * @param parent - the parent of this component.
72 public TraceEventComponent(String name
, ITraceControlComponent parent
) {
74 setImage(TRACE_EVENT_ICON_FILE_ENABLED
);
75 setToolTip(Messages
.TraceControl_EventDisplayName
);
76 fEventInfo
= new EventInfo(name
);
77 fDisabledImage
= Activator
.getDefault().loadIcon(TRACE_EVENT_ICON_FILE_DISABLED
);
80 // ------------------------------------------------------------------------
82 // ------------------------------------------------------------------------
85 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
88 public Image
getImage() {
89 if (fEventInfo
.getState() == TraceEnablement
.DISABLED
) {
90 return fDisabledImage
;
92 return super.getImage();
96 * Sets the event information.
97 * @param eventInfo - the event information to set.
99 public void setEventInfo(IEventInfo eventInfo
) {
100 fEventInfo
= eventInfo
;
104 * @return the trace event type
106 public TraceEventType
getEventType() {
107 return fEventInfo
.getEventType();
111 * Sets the trace event type to the given type
112 * @param type - type to set
114 public void setEventType(TraceEventType type
) {
115 fEventInfo
.setEventType(type
);
119 * Sets the trace event type to the type specified by the given name.
120 * @param type - event type name
122 public void setEventType(String typeName
) {
123 fEventInfo
.setEventType(typeName
);
127 * @return the event state (enabled or disabled).
129 public TraceEnablement
getState() {
130 return fEventInfo
.getState();
134 * Sets the event state (enablement) to the given value.
135 * @param state - state to set.
137 public void setState(TraceEnablement state
) {
138 fEventInfo
.setState(state
);
142 * Sets the event state (enablement) to the value specified by the given name.
143 * @param stateName - state to set.
145 public void setState(String stateName
) {
146 fEventInfo
.setState(stateName
);
150 * @return the trace event log level
152 public TraceLogLevel
getLogLevel() {
153 return fEventInfo
.getLogLevel();
157 * Sets the trace event log level to the given level
158 * @param level - event log level to set
160 public void setLogLevel(TraceLogLevel level
) {
161 fEventInfo
.setLogLevel(level
);
165 * Sets the trace event log level to the level specified by the given name.
166 * @param levelName - event log level name
168 public void setLogLevel(String levelName
) {
169 fEventInfo
.setLogLevel(levelName
);
174 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
176 @SuppressWarnings("rawtypes")
178 public Object
getAdapter(Class adapter
) {
179 if (adapter
== IPropertySource
.class) {
180 return new TraceEventPropertySource(this);
186 * @return session name from parent
188 public String
getSessionName() {
189 return ((TraceChannelComponent
)getParent()).getSessionName();
193 * @return session from parent
195 public TraceSessionComponent
getSession() {
196 return ((TraceChannelComponent
)getParent()).getSession();
200 * @return channel name from parent
202 public String
getChannelName() {
203 return getParent().getName();
207 * @return if domain is kernel or UST
209 public boolean isKernel() {
210 return ((TraceChannelComponent
)getParent()).isKernel();
213 // ------------------------------------------------------------------------
215 // ------------------------------------------------------------------------
218 * Add contexts to given channels and or events
219 * @param contexts - a list of contexts to add
220 * @throws ExecutionException
222 public void addContexts(List
<String
> contexts
) throws ExecutionException
{
223 addContexts(contexts
, new NullProgressMonitor());
227 * Add contexts to given channels and or events
228 * @param contexts - a list of contexts to add
229 * @param monitor - a progress monitor
230 * @throws ExecutionException
232 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
) throws ExecutionException
{
233 getControlService().addContexts(getSessionName(),getChannelName(), getName(), isKernel(), contexts
, monitor
);