1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
;
15 import java
.util
.List
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
19 import org
.eclipse
.swt
.graphics
.Image
;
20 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IEventInfo
;
21 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
22 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEnablement
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEventType
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.EventInfo
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.Activator
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
28 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
29 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.property
.TraceEventPropertySource
;
30 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
35 * Implementation of the trace channel component.
38 * @author Bernd Hufmann
40 public class TraceEventComponent
extends TraceControlComponent
{
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
45 * Path to icon file for this component (enabled state).
47 public static final String TRACE_EVENT_ICON_FILE_ENABLED
= "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
49 * Path to icon file for this component (disabled state).
51 public static final String TRACE_EVENT_ICON_FILE_DISABLED
= "icons/obj16/event_disabled.gif"; //$NON-NLS-1$
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
57 * The event information.
59 protected IEventInfo fEventInfo
= null;
61 * The image to be displayed when in disabled state.
63 private Image fDisabledImage
= null;
65 // ------------------------------------------------------------------------
67 // ------------------------------------------------------------------------
70 * @param name - the name of the component.
71 * @param parent - the parent of this component.
73 public TraceEventComponent(String name
, ITraceControlComponent parent
) {
75 setImage(TRACE_EVENT_ICON_FILE_ENABLED
);
76 setToolTip(Messages
.TraceControl_EventDisplayName
);
77 fEventInfo
= new EventInfo(name
);
78 fDisabledImage
= Activator
.getDefault().loadIcon(TRACE_EVENT_ICON_FILE_DISABLED
);
81 // ------------------------------------------------------------------------
83 // ------------------------------------------------------------------------
86 public Image
getImage() {
87 if (fEventInfo
.getState() == TraceEnablement
.DISABLED
) {
88 return fDisabledImage
;
90 return super.getImage();
94 * Sets the event information.
95 * @param eventInfo - the event information to set.
97 public void setEventInfo(IEventInfo eventInfo
) {
98 fEventInfo
= eventInfo
;
102 * @return the trace event type
104 public TraceEventType
getEventType() {
105 return fEventInfo
.getEventType();
109 * Sets the trace event type to the given type
110 * @param type - type to set
112 public void setEventType(TraceEventType type
) {
113 fEventInfo
.setEventType(type
);
117 * Sets the trace event type to the type specified by the given name.
118 * @param typeName - event type name
120 public void setEventType(String typeName
) {
121 fEventInfo
.setEventType(typeName
);
125 * @return the event state (enabled or disabled).
127 public TraceEnablement
getState() {
128 return fEventInfo
.getState();
132 * Sets the event state (enablement) to the given value.
133 * @param state - state to set.
135 public void setState(TraceEnablement state
) {
136 fEventInfo
.setState(state
);
140 * Sets the event state (enablement) to the value specified by the given name.
141 * @param stateName - state to set.
143 public void setState(String stateName
) {
144 fEventInfo
.setState(stateName
);
148 * @return the trace event log level
150 public TraceLogLevel
getLogLevel() {
151 return fEventInfo
.getLogLevel();
155 * Sets the trace event log level to the given level
156 * @param level - event log level to set
158 public void setLogLevel(TraceLogLevel level
) {
159 fEventInfo
.setLogLevel(level
);
163 * Sets the trace event log level to the level specified by the given name.
164 * @param levelName - event log level name
166 public void setLogLevel(String levelName
) {
167 fEventInfo
.setLogLevel(levelName
);
171 * Returns filter expression.
172 * @return filter expression
174 public String
getFilterExpression() {
175 return fEventInfo
.getFilterExpression();
179 * Sets the filter expression.
180 * @param filter The filter expression to set
182 public void setFilterExpression(String filter
) {
183 fEventInfo
.setFilterExpression(filter
);
187 * Returns the log level type
188 * @return event log level type
190 public LogLevelType
getLogLevelType() {
191 return fEventInfo
.getLogLevelType();
195 * Sets the trace event log level type to the given level type
196 * @param levelType - event log level type to set
198 public void setLogLevelType(LogLevelType levelType
) {
199 fEventInfo
.setLogLevelType(levelType
);
203 public Object
getAdapter(Class adapter
) {
204 if (adapter
== IPropertySource
.class) {
205 return new TraceEventPropertySource(this);
211 * @return target node component.
213 public TargetNodeComponent
getTargetNode() {
214 return ((TraceChannelComponent
)getParent()).getTargetNode();
218 * @return session name from parent
220 public String
getSessionName() {
221 return ((TraceChannelComponent
)getParent()).getSessionName();
225 * @return session from parent
227 public TraceSessionComponent
getSession() {
228 return ((TraceChannelComponent
)getParent()).getSession();
232 * @return channel name from parent
234 public String
getChannelName() {
235 return getParent().getName();
239 * @return if domain is kernel or UST
241 public boolean isKernel() {
242 return ((TraceChannelComponent
)getParent()).isKernel();
245 // ------------------------------------------------------------------------
247 // ------------------------------------------------------------------------
250 * Add contexts to given channels and or events
253 * - a list of contexts to add
255 * - a progress monitor
256 * @throws ExecutionException
257 * If the command fails
259 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
260 throws ExecutionException
{
261 getControlService().addContexts(getSessionName(), getChannelName(),
262 getName(), isKernel(), contexts
, monitor
);