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
.swt
.graphics
.Image
;
25 * <b><u>TraceChannelComponent</u></b>
27 * Implementation of the trace channel component.
30 public class TraceEventComponent
extends TraceControlComponent
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 * Path to icon file for this component (enabled state).
37 public static final String TRACE_EVENT_ICON_FILE_ENABLED
= "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
39 * Path to icon file for this component (disabled state).
41 public static final String TRACE_EVENT_ICON_FILE_DISABLED
= "icons/obj16/event_disabled.gif"; //$NON-NLS-1$
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
47 * The event information.
49 private IEventInfo fEventInfo
= null;
51 * The image to be displayed when in disabled state.
53 private Image fDisabledImage
= null;
55 // ------------------------------------------------------------------------
57 // ------------------------------------------------------------------------
60 * @param name - the name of the component.
61 * @param parent - the parent of this component.
63 public TraceEventComponent(String name
, ITraceControlComponent parent
) {
65 setImage(TRACE_EVENT_ICON_FILE_ENABLED
);
66 setToolTip(Messages
.TraceControl_EventDisplayName
);
67 fEventInfo
= new EventInfo(name
);
68 fDisabledImage
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_EVENT_ICON_FILE_DISABLED
);
71 // ------------------------------------------------------------------------
73 // ------------------------------------------------------------------------
76 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
79 public Image
getImage() {
80 if (fEventInfo
.getState() == TraceEnablement
.DISABLED
) {
81 return fDisabledImage
;
83 return super.getImage();
87 * Sets the event information.
88 * @param eventInfo - the event information to set.
90 public void setEventInfo(IEventInfo eventInfo
) {
91 fEventInfo
= eventInfo
;
95 * @return the trace event type
97 public TraceEventType
getEventType() {
98 return fEventInfo
.getEventType();
102 * Sets the trace event type to the given type
103 * @param type - type to set
105 public void setEventType(TraceEventType type
) {
106 fEventInfo
.setEventType(type
);
110 * Sets the trace event type to the type specified by the given name.
111 * @param type - event type name
113 public void setEventType(String typeName
) {
114 fEventInfo
.setEventType(typeName
);
118 * @return the event state (enabled or disabled).
120 public TraceEnablement
getState() {
121 return fEventInfo
.getState();
125 * Sets the event state (enablement) to the given value.
126 * @param state - state to set.
128 public void setState(TraceEnablement state
) {
129 fEventInfo
.setState(state
);
133 * Sets the event state (enablement) to the value specified by the given name.
134 * @param stateName - state to set.
136 public void setState(String stateName
) {
137 fEventInfo
.setState(stateName
);
141 * @return the trace event log level
143 public TraceLogLevel
getLogLevel() {
144 return fEventInfo
.getLogLevel();
148 * Sets the trace event log level to the given level
149 * @param level - event log level to set
151 public void setLogLevel(TraceLogLevel level
) {
152 fEventInfo
.setLogLevel(level
);
156 * Sets the trace event log level to the level specified by the given name.
157 * @param levelName - event log level name
159 public void setLogLevel(String levelName
) {
160 fEventInfo
.setLogLevel(levelName
);
163 // ------------------------------------------------------------------------
165 // ------------------------------------------------------------------------