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
;
33 * <b><u>TraceEventComponent</u></b>
35 * Implementation of the trace channel component.
38 public class TraceEventComponent
extends TraceControlComponent
{
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
43 * Path to icon file for this component (enabled state).
45 public static final String TRACE_EVENT_ICON_FILE_ENABLED
= "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
47 * Path to icon file for this component (disabled state).
49 public static final String TRACE_EVENT_ICON_FILE_DISABLED
= "icons/obj16/event_disabled.gif"; //$NON-NLS-1$
51 // ------------------------------------------------------------------------
53 // ------------------------------------------------------------------------
55 * The event information.
57 protected IEventInfo fEventInfo
= null;
59 * The image to be displayed when in disabled state.
61 private Image fDisabledImage
= null;
63 // ------------------------------------------------------------------------
65 // ------------------------------------------------------------------------
68 * @param name - the name of the component.
69 * @param parent - the parent of this component.
71 public TraceEventComponent(String name
, ITraceControlComponent parent
) {
73 setImage(TRACE_EVENT_ICON_FILE_ENABLED
);
74 setToolTip(Messages
.TraceControl_EventDisplayName
);
75 fEventInfo
= new EventInfo(name
);
76 fDisabledImage
= Activator
.getDefault().loadIcon(TRACE_EVENT_ICON_FILE_DISABLED
);
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
84 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
87 public Image
getImage() {
88 if (fEventInfo
.getState() == TraceEnablement
.DISABLED
) {
89 return fDisabledImage
;
91 return super.getImage();
95 * Sets the event information.
96 * @param eventInfo - the event information to set.
98 public void setEventInfo(IEventInfo eventInfo
) {
99 fEventInfo
= eventInfo
;
103 * @return the trace event type
105 public TraceEventType
getEventType() {
106 return fEventInfo
.getEventType();
110 * Sets the trace event type to the given type
111 * @param type - type to set
113 public void setEventType(TraceEventType type
) {
114 fEventInfo
.setEventType(type
);
118 * Sets the trace event type to the type specified by the given name.
119 * @param type - event type name
121 public void setEventType(String typeName
) {
122 fEventInfo
.setEventType(typeName
);
126 * @return the event state (enabled or disabled).
128 public TraceEnablement
getState() {
129 return fEventInfo
.getState();
133 * Sets the event state (enablement) to the given value.
134 * @param state - state to set.
136 public void setState(TraceEnablement state
) {
137 fEventInfo
.setState(state
);
141 * Sets the event state (enablement) to the value specified by the given name.
142 * @param stateName - state to set.
144 public void setState(String stateName
) {
145 fEventInfo
.setState(stateName
);
149 * @return the trace event log level
151 public TraceLogLevel
getLogLevel() {
152 return fEventInfo
.getLogLevel();
156 * Sets the trace event log level to the given level
157 * @param level - event log level to set
159 public void setLogLevel(TraceLogLevel level
) {
160 fEventInfo
.setLogLevel(level
);
164 * Sets the trace event log level to the level specified by the given name.
165 * @param levelName - event log level name
167 public void setLogLevel(String levelName
) {
168 fEventInfo
.setLogLevel(levelName
);
173 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
175 @SuppressWarnings("rawtypes")
177 public Object
getAdapter(Class adapter
) {
178 if (adapter
== IPropertySource
.class) {
179 return new TraceEventPropertySource(this);
185 * @return session name from parent
187 public String
getSessionName() {
188 return ((TraceChannelComponent
)getParent()).getSessionName();
192 * @return session from parent
194 public TraceSessionComponent
getSession() {
195 return ((TraceChannelComponent
)getParent()).getSession();
199 * @return channel name from parent
201 public String
getChannelName() {
202 return getParent().getName();
206 * @return if domain is kernel or UST
208 public boolean isKernel() {
209 return ((TraceChannelComponent
)getParent()).isKernel();
212 // ------------------------------------------------------------------------
214 // ------------------------------------------------------------------------
217 * Add contexts to given channels and or events
218 * @param contexts - a list of contexts to add
219 * @throws ExecutionException
221 public void addContexts(List
<String
> contexts
) throws ExecutionException
{
222 addContexts(contexts
, new NullProgressMonitor());
226 * Add contexts to given channels and or events
227 * @param contexts - a list of contexts to add
228 * @param monitor - a progress monitor
229 * @throws ExecutionException
231 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
) throws ExecutionException
{
232 getControlService().addContexts(getSessionName(),getChannelName(), getName(), isKernel(), contexts
, monitor
);