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 typeName - 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
);
173 * Returns filter expression.
174 * @return filter expression
176 public String
getFilterExpression() {
177 return fEventInfo
.getFilterExpression();
181 * Sets the filter expression.
182 * @param filter The filter expression to set
184 public void setFilterExpression(String filter
) {
185 fEventInfo
.setFilterExpression(filter
);
190 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
193 public Object
getAdapter(Class adapter
) {
194 if (adapter
== IPropertySource
.class) {
195 return new TraceEventPropertySource(this);
201 * @return session name from parent
203 public String
getSessionName() {
204 return ((TraceChannelComponent
)getParent()).getSessionName();
208 * @return session from parent
210 public TraceSessionComponent
getSession() {
211 return ((TraceChannelComponent
)getParent()).getSession();
215 * @return channel name from parent
217 public String
getChannelName() {
218 return getParent().getName();
222 * @return if domain is kernel or UST
224 public boolean isKernel() {
225 return ((TraceChannelComponent
)getParent()).isKernel();
228 // ------------------------------------------------------------------------
230 // ------------------------------------------------------------------------
233 * Add contexts to given channels and or events
236 * - a list of contexts to add
237 * @throws ExecutionException
238 * If the command fails
240 public void addContexts(List
<String
> contexts
) throws ExecutionException
{
241 addContexts(contexts
, new NullProgressMonitor());
245 * Add contexts to given channels and or events
248 * - a list of contexts to add
250 * - a progress monitor
251 * @throws ExecutionException
252 * If the command fails
254 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
255 throws ExecutionException
{
256 getControlService().addContexts(getSessionName(), getChannelName(),
257 getName(), isKernel(), contexts
, monitor
);