First part of LTTng 2.0 support
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / control / model / impl / TraceEventComponent.java
1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
13
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;
22
23
24 /**
25 * <b><u>TraceChannelComponent</u></b>
26 * <p>
27 * Implementation of the trace channel component.
28 * </p>
29 */
30 public class TraceEventComponent extends TraceControlComponent {
31 // ------------------------------------------------------------------------
32 // Constants
33 // ------------------------------------------------------------------------
34 /**
35 * Path to icon file for this component (enabled state).
36 */
37 public static final String TRACE_EVENT_ICON_FILE_ENABLED = "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
38 /**
39 * Path to icon file for this component (disabled state).
40 */
41 public static final String TRACE_EVENT_ICON_FILE_DISABLED = "icons/obj16/event_disabled.gif"; //$NON-NLS-1$
42
43 // ------------------------------------------------------------------------
44 // Attributes
45 // ------------------------------------------------------------------------
46 /**
47 * The event information.
48 */
49 private IEventInfo fEventInfo = null;
50 /**
51 * The image to be displayed when in disabled state.
52 */
53 private Image fDisabledImage = null;
54
55 // ------------------------------------------------------------------------
56 // Constructors
57 // ------------------------------------------------------------------------
58 /**
59 * Constructor
60 * @param name - the name of the component.
61 * @param parent - the parent of this component.
62 */
63 public TraceEventComponent(String name, ITraceControlComponent parent) {
64 super(name, 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);
69 }
70
71 // ------------------------------------------------------------------------
72 // Accessors
73 // ------------------------------------------------------------------------
74 /*
75 * (non-Javadoc)
76 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
77 */
78 @Override
79 public Image getImage() {
80 if (fEventInfo.getState() == TraceEnablement.DISABLED) {
81 return fDisabledImage;
82 }
83 return super.getImage();
84 }
85
86 /**
87 * Sets the event information.
88 * @param eventInfo - the event information to set.
89 */
90 public void setEventInfo(IEventInfo eventInfo) {
91 fEventInfo = eventInfo;
92 }
93
94 /**
95 * @return the trace event type
96 */
97 public TraceEventType getEventType() {
98 return fEventInfo.getEventType();
99 }
100
101 /**
102 * Sets the trace event type to the given type
103 * @param type - type to set
104 */
105 public void setEventType(TraceEventType type) {
106 fEventInfo.setEventType(type);
107 }
108
109 /**
110 * Sets the trace event type to the type specified by the given name.
111 * @param type - event type name
112 */
113 public void setEventType(String typeName) {
114 fEventInfo.setEventType(typeName);
115 }
116
117 /**
118 * @return the event state (enabled or disabled).
119 */
120 public TraceEnablement getState() {
121 return fEventInfo.getState();
122 }
123
124 /**
125 * Sets the event state (enablement) to the given value.
126 * @param state - state to set.
127 */
128 public void setState(TraceEnablement state) {
129 fEventInfo.setState(state);
130 }
131
132 /**
133 * Sets the event state (enablement) to the value specified by the given name.
134 * @param stateName - state to set.
135 */
136 public void setState(String stateName) {
137 fEventInfo.setState(stateName);
138 }
139
140 /**
141 * @return the trace event log level
142 */
143 public TraceLogLevel getLogLevel() {
144 return fEventInfo.getLogLevel();
145 }
146
147 /**
148 * Sets the trace event log level to the given level
149 * @param level - event log level to set
150 */
151 public void setLogLevel(TraceLogLevel level) {
152 fEventInfo.setLogLevel(level);
153 }
154
155 /**
156 * Sets the trace event log level to the level specified by the given name.
157 * @param levelName - event log level name
158 */
159 public void setLogLevel(String levelName) {
160 fEventInfo.setLogLevel(levelName);
161 }
162
163 // ------------------------------------------------------------------------
164 // Operations
165 // ------------------------------------------------------------------------
166 }
This page took 0.035068 seconds and 6 git commands to generate.