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
.lttng
.ui
.views
.control
.model
.impl
;
14 import org
.eclipse
.linuxtools
.lttng
.ui
.LTTngUiPlugin
;
15 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.Messages
;
16 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IEventInfo
;
17 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.ITraceControlComponent
;
18 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceEnablement
;
19 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceEventType
;
20 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceLogLevel
;
21 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.TraceEventPropertySource
;
22 import org
.eclipse
.swt
.graphics
.Image
;
23 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
27 * <b><u>TraceEventComponent</u></b>
29 * Implementation of the trace channel component.
32 public class TraceEventComponent
extends TraceControlComponent
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
37 * Path to icon file for this component (enabled state).
39 public static final String TRACE_EVENT_ICON_FILE_ENABLED
= "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
41 * Path to icon file for this component (disabled state).
43 public static final String TRACE_EVENT_ICON_FILE_DISABLED
= "icons/obj16/event_disabled.gif"; //$NON-NLS-1$
45 // ------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
49 * The event information.
51 protected IEventInfo fEventInfo
= null;
53 * The image to be displayed when in disabled state.
55 private Image fDisabledImage
= null;
57 // ------------------------------------------------------------------------
59 // ------------------------------------------------------------------------
62 * @param name - the name of the component.
63 * @param parent - the parent of this component.
65 public TraceEventComponent(String name
, ITraceControlComponent parent
) {
67 setImage(TRACE_EVENT_ICON_FILE_ENABLED
);
68 setToolTip(Messages
.TraceControl_EventDisplayName
);
69 fEventInfo
= new EventInfo(name
);
70 fDisabledImage
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_EVENT_ICON_FILE_DISABLED
);
73 // ------------------------------------------------------------------------
75 // ------------------------------------------------------------------------
78 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
81 public Image
getImage() {
82 if (fEventInfo
.getState() == TraceEnablement
.DISABLED
) {
83 return fDisabledImage
;
85 return super.getImage();
89 * Sets the event information.
90 * @param eventInfo - the event information to set.
92 public void setEventInfo(IEventInfo eventInfo
) {
93 fEventInfo
= eventInfo
;
97 * @return the trace event type
99 public TraceEventType
getEventType() {
100 return fEventInfo
.getEventType();
104 * Sets the trace event type to the given type
105 * @param type - type to set
107 public void setEventType(TraceEventType type
) {
108 fEventInfo
.setEventType(type
);
112 * Sets the trace event type to the type specified by the given name.
113 * @param type - event type name
115 public void setEventType(String typeName
) {
116 fEventInfo
.setEventType(typeName
);
120 * @return the event state (enabled or disabled).
122 public TraceEnablement
getState() {
123 return fEventInfo
.getState();
127 * Sets the event state (enablement) to the given value.
128 * @param state - state to set.
130 public void setState(TraceEnablement state
) {
131 fEventInfo
.setState(state
);
135 * Sets the event state (enablement) to the value specified by the given name.
136 * @param stateName - state to set.
138 public void setState(String stateName
) {
139 fEventInfo
.setState(stateName
);
143 * @return the trace event log level
145 public TraceLogLevel
getLogLevel() {
146 return fEventInfo
.getLogLevel();
150 * Sets the trace event log level to the given level
151 * @param level - event log level to set
153 public void setLogLevel(TraceLogLevel level
) {
154 fEventInfo
.setLogLevel(level
);
158 * Sets the trace event log level to the level specified by the given name.
159 * @param levelName - event log level name
161 public void setLogLevel(String levelName
) {
162 fEventInfo
.setLogLevel(levelName
);
167 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
169 @SuppressWarnings("rawtypes")
171 public Object
getAdapter(Class adapter
) {
172 if (adapter
== IPropertySource
.class) {
173 return new TraceEventPropertySource(this);
179 * @return session name from parent
181 public String
getSessionName() {
182 return ((TraceChannelComponent
)getParent()).getSessionName();
186 * @return channel name from parent
188 public String
getChannelName() {
189 return getParent().getName();
193 * @return if domain is kernel or UST
195 public boolean isKernel() {
196 return ((TraceChannelComponent
)getParent()).isKernel();
199 // ------------------------------------------------------------------------
201 // ------------------------------------------------------------------------