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
.ui
.Activator
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.Messages
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.IEventInfo
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceEnablement
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceEventType
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceLogLevel
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.TraceEventPropertySource
;
27 import org
.eclipse
.swt
.graphics
.Image
;
28 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
32 * <b><u>TraceEventComponent</u></b>
34 * Implementation of the trace channel component.
37 public class TraceEventComponent
extends TraceControlComponent
{
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
42 * Path to icon file for this component (enabled state).
44 public static final String TRACE_EVENT_ICON_FILE_ENABLED
= "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
46 * Path to icon file for this component (disabled state).
48 public static final String TRACE_EVENT_ICON_FILE_DISABLED
= "icons/obj16/event_disabled.gif"; //$NON-NLS-1$
50 // ------------------------------------------------------------------------
52 // ------------------------------------------------------------------------
54 * The event information.
56 protected IEventInfo fEventInfo
= null;
58 * The image to be displayed when in disabled state.
60 private Image fDisabledImage
= null;
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
67 * @param name - the name of the component.
68 * @param parent - the parent of this component.
70 public TraceEventComponent(String name
, ITraceControlComponent parent
) {
72 setImage(TRACE_EVENT_ICON_FILE_ENABLED
);
73 setToolTip(Messages
.TraceControl_EventDisplayName
);
74 fEventInfo
= new EventInfo(name
);
75 fDisabledImage
= Activator
.getDefault().loadIcon(TRACE_EVENT_ICON_FILE_DISABLED
);
78 // ------------------------------------------------------------------------
80 // ------------------------------------------------------------------------
83 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
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 type - 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
);
172 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
174 @SuppressWarnings("rawtypes")
176 public Object
getAdapter(Class adapter
) {
177 if (adapter
== IPropertySource
.class) {
178 return new TraceEventPropertySource(this);
184 * @return session name from parent
186 public String
getSessionName() {
187 return ((TraceChannelComponent
)getParent()).getSessionName();
191 * @return session from parent
193 public TraceSessionComponent
getSession() {
194 return ((TraceChannelComponent
)getParent()).getSession();
198 * @return channel name from parent
200 public String
getChannelName() {
201 return getParent().getName();
205 * @return if domain is kernel or UST
207 public boolean isKernel() {
208 return ((TraceChannelComponent
)getParent()).isKernel();
211 // ------------------------------------------------------------------------
213 // ------------------------------------------------------------------------
216 * Add contexts to given channels and or events
217 * @param contexts - a list of contexts to add
218 * @throws ExecutionException
220 public void addContexts(List
<String
> contexts
) throws ExecutionException
{
221 addContexts(contexts
, new NullProgressMonitor());
225 * Add contexts to given channels and or events
226 * @param contexts - a list of contexts to add
227 * @param monitor - a progress monitor
228 * @throws ExecutionException
230 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
) throws ExecutionException
{
231 getControlService().addContexts(getSessionName(),getChannelName(), getName(), isKernel(), contexts
, monitor
);