lttng: Fix Javadoc in lttng2.core
[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 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.internal.lttng2.ui.views.control.model.impl;
13
14 import java.util.List;
15
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.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 type - 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 * (non-Javadoc)
174 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
175 */
176 @SuppressWarnings("rawtypes")
177 @Override
178 public Object getAdapter(Class adapter) {
179 if (adapter == IPropertySource.class) {
180 return new TraceEventPropertySource(this);
181 }
182 return null;
183 }
184
185 /**
186 * @return session name from parent
187 */
188 public String getSessionName() {
189 return ((TraceChannelComponent)getParent()).getSessionName();
190 }
191
192 /**
193 * @return session from parent
194 */
195 public TraceSessionComponent getSession() {
196 return ((TraceChannelComponent)getParent()).getSession();
197 }
198
199 /**
200 * @return channel name from parent
201 */
202 public String getChannelName() {
203 return getParent().getName();
204 }
205
206 /**
207 * @return if domain is kernel or UST
208 */
209 public boolean isKernel() {
210 return ((TraceChannelComponent)getParent()).isKernel();
211 }
212
213 // ------------------------------------------------------------------------
214 // Operations
215 // ------------------------------------------------------------------------
216
217 /**
218 * Add contexts to given channels and or events
219 * @param contexts - a list of contexts to add
220 * @throws ExecutionException
221 */
222 public void addContexts(List<String> contexts) throws ExecutionException {
223 addContexts(contexts, new NullProgressMonitor());
224 }
225
226 /**
227 * Add contexts to given channels and or events
228 * @param contexts - a list of contexts to add
229 * @param monitor - a progress monitor
230 * @throws ExecutionException
231 */
232 public void addContexts(List<String> contexts, IProgressMonitor monitor) throws ExecutionException {
233 getControlService().addContexts(getSessionName(),getChannelName(), getName(), isKernel(), contexts, monitor);
234 }
235 }
This page took 0.046333 seconds and 6 git commands to generate.