Remove unnecessary methods in LTTng Tracer Control model
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / model / impl / TraceEventComponent.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
14
15 import java.util.List;
16
17 import org.eclipse.core.commands.ExecutionException;
18 import org.eclipse.core.runtime.IProgressMonitor;
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;
30
31
32 /**
33 * <p>
34 * Implementation of the trace channel component.
35 * </p>
36 *
37 * @author Bernd Hufmann
38 */
39 public class TraceEventComponent extends TraceControlComponent {
40 // ------------------------------------------------------------------------
41 // Constants
42 // ------------------------------------------------------------------------
43 /**
44 * Path to icon file for this component (enabled state).
45 */
46 public static final String TRACE_EVENT_ICON_FILE_ENABLED = "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
47 /**
48 * Path to icon file for this component (disabled state).
49 */
50 public static final String TRACE_EVENT_ICON_FILE_DISABLED = "icons/obj16/event_disabled.gif"; //$NON-NLS-1$
51
52 // ------------------------------------------------------------------------
53 // Attributes
54 // ------------------------------------------------------------------------
55 /**
56 * The event information.
57 */
58 protected IEventInfo fEventInfo = null;
59 /**
60 * The image to be displayed when in disabled state.
61 */
62 private Image fDisabledImage = null;
63
64 // ------------------------------------------------------------------------
65 // Constructors
66 // ------------------------------------------------------------------------
67 /**
68 * Constructor
69 * @param name - the name of the component.
70 * @param parent - the parent of this component.
71 */
72 public TraceEventComponent(String name, ITraceControlComponent parent) {
73 super(name, 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);
78 }
79
80 // ------------------------------------------------------------------------
81 // Accessors
82 // ------------------------------------------------------------------------
83 /*
84 * (non-Javadoc)
85 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
86 */
87 @Override
88 public Image getImage() {
89 if (fEventInfo.getState() == TraceEnablement.DISABLED) {
90 return fDisabledImage;
91 }
92 return super.getImage();
93 }
94
95 /**
96 * Sets the event information.
97 * @param eventInfo - the event information to set.
98 */
99 public void setEventInfo(IEventInfo eventInfo) {
100 fEventInfo = eventInfo;
101 }
102
103 /**
104 * @return the trace event type
105 */
106 public TraceEventType getEventType() {
107 return fEventInfo.getEventType();
108 }
109
110 /**
111 * Sets the trace event type to the given type
112 * @param type - type to set
113 */
114 public void setEventType(TraceEventType type) {
115 fEventInfo.setEventType(type);
116 }
117
118 /**
119 * Sets the trace event type to the type specified by the given name.
120 * @param typeName - event type name
121 */
122 public void setEventType(String typeName) {
123 fEventInfo.setEventType(typeName);
124 }
125
126 /**
127 * @return the event state (enabled or disabled).
128 */
129 public TraceEnablement getState() {
130 return fEventInfo.getState();
131 }
132
133 /**
134 * Sets the event state (enablement) to the given value.
135 * @param state - state to set.
136 */
137 public void setState(TraceEnablement state) {
138 fEventInfo.setState(state);
139 }
140
141 /**
142 * Sets the event state (enablement) to the value specified by the given name.
143 * @param stateName - state to set.
144 */
145 public void setState(String stateName) {
146 fEventInfo.setState(stateName);
147 }
148
149 /**
150 * @return the trace event log level
151 */
152 public TraceLogLevel getLogLevel() {
153 return fEventInfo.getLogLevel();
154 }
155
156 /**
157 * Sets the trace event log level to the given level
158 * @param level - event log level to set
159 */
160 public void setLogLevel(TraceLogLevel level) {
161 fEventInfo.setLogLevel(level);
162 }
163
164 /**
165 * Sets the trace event log level to the level specified by the given name.
166 * @param levelName - event log level name
167 */
168 public void setLogLevel(String levelName) {
169 fEventInfo.setLogLevel(levelName);
170 }
171
172 /**
173 * Returns filter expression.
174 * @return filter expression
175 */
176 public String getFilterExpression() {
177 return fEventInfo.getFilterExpression();
178 }
179
180 /**
181 * Sets the filter expression.
182 * @param filter The filter expression to set
183 */
184 public void setFilterExpression(String filter) {
185 fEventInfo.setFilterExpression(filter);
186 }
187
188 /*
189 * (non-Javadoc)
190 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
191 */
192 @Override
193 public Object getAdapter(Class adapter) {
194 if (adapter == IPropertySource.class) {
195 return new TraceEventPropertySource(this);
196 }
197 return null;
198 }
199
200 /**
201 * @return session name from parent
202 */
203 public String getSessionName() {
204 return ((TraceChannelComponent)getParent()).getSessionName();
205 }
206
207 /**
208 * @return session from parent
209 */
210 public TraceSessionComponent getSession() {
211 return ((TraceChannelComponent)getParent()).getSession();
212 }
213
214 /**
215 * @return channel name from parent
216 */
217 public String getChannelName() {
218 return getParent().getName();
219 }
220
221 /**
222 * @return if domain is kernel or UST
223 */
224 public boolean isKernel() {
225 return ((TraceChannelComponent)getParent()).isKernel();
226 }
227
228 // ------------------------------------------------------------------------
229 // Operations
230 // ------------------------------------------------------------------------
231
232 /**
233 * Add contexts to given channels and or events
234 *
235 * @param contexts
236 * - a list of contexts to add
237 * @param monitor
238 * - a progress monitor
239 * @throws ExecutionException
240 * If the command fails
241 */
242 public void addContexts(List<String> contexts, IProgressMonitor monitor)
243 throws ExecutionException {
244 getControlService().addContexts(getSessionName(), getChannelName(),
245 getName(), isKernel(), contexts, monitor);
246 }
247 }
This page took 0.03738 seconds and 5 git commands to generate.