Commit | Line | Data |
---|---|---|
eb1bab5b BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 Ericsson | |
ea21cd65 | 3 | * |
eb1bab5b BH |
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 | |
ea21cd65 AM |
8 | * |
9 | * Contributors: | |
eb1bab5b BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl; |
eb1bab5b | 13 | |
9315aeee BH |
14 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo; |
15 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType; | |
16 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel; | |
17 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo; | |
115b4a01 | 18 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; |
115b4a01 | 19 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BaseEventPropertySource; |
06b9339e | 20 | import org.eclipse.ui.views.properties.IPropertySource; |
eb1bab5b BH |
21 | |
22 | /** | |
eb1bab5b BH |
23 | * <p> |
24 | * Implementation of the base trace event component. | |
25 | * </p> | |
ea21cd65 | 26 | * |
dbd4432d | 27 | * @author Bernd Hufmann |
eb1bab5b BH |
28 | */ |
29 | public class BaseEventComponent extends TraceControlComponent { | |
30 | // ------------------------------------------------------------------------ | |
31 | // Constants | |
32 | // ------------------------------------------------------------------------ | |
33 | /** | |
34 | * Path to icon file for this component. | |
35 | */ | |
36 | public static final String TRACE_EVENT_ICON_FILE_ENABLED = "icons/obj16/event_enabled.gif"; //$NON-NLS-1$ | |
ea21cd65 | 37 | |
eb1bab5b BH |
38 | // ------------------------------------------------------------------------ |
39 | // Attributes | |
40 | // ------------------------------------------------------------------------ | |
41 | /** | |
ea21cd65 | 42 | * The Event information implementation. |
eb1bab5b BH |
43 | */ |
44 | private IBaseEventInfo fEventInfo; | |
ea21cd65 | 45 | |
eb1bab5b BH |
46 | // ------------------------------------------------------------------------ |
47 | // Constructors | |
48 | // ------------------------------------------------------------------------ | |
ea21cd65 | 49 | |
eb1bab5b | 50 | /** |
ea21cd65 | 51 | * Constructor |
eb1bab5b BH |
52 | * @param name - the name of the component. |
53 | * @param parent - the parent of this component. | |
54 | */ | |
55 | public BaseEventComponent(String name, ITraceControlComponent parent) { | |
56 | super(name, parent); | |
57 | setImage(TRACE_EVENT_ICON_FILE_ENABLED); | |
58 | fEventInfo = new EventInfo(name); | |
59 | } | |
ea21cd65 | 60 | |
eb1bab5b BH |
61 | // ------------------------------------------------------------------------ |
62 | // Accessors | |
63 | // ------------------------------------------------------------------------ | |
64 | /** | |
65 | * Sets the event information. | |
66 | * @param eventInfo - the event info to set. | |
67 | */ | |
68 | public void setEventInfo(IBaseEventInfo eventInfo) { | |
69 | fEventInfo = eventInfo; | |
70 | } | |
ea21cd65 | 71 | |
eb1bab5b BH |
72 | /** |
73 | * @return the event type. | |
74 | */ | |
75 | public TraceEventType getEventType() { | |
76 | return fEventInfo.getEventType(); | |
77 | } | |
ea21cd65 | 78 | |
eb1bab5b BH |
79 | /** |
80 | * Sets the event type to the given value. | |
81 | * @param type - type to set. | |
82 | */ | |
83 | public void setEventType(TraceEventType type) { | |
84 | fEventInfo.setEventType(type); | |
85 | } | |
ea21cd65 | 86 | |
eb1bab5b BH |
87 | /** |
88 | * Sets the event type to the value specified by the give name. | |
89 | * @param typeName - the type name. | |
90 | */ | |
91 | public void setEventType(String typeName) { | |
92 | fEventInfo.setEventType(typeName); | |
93 | } | |
94 | ||
95 | /** | |
96 | * @return the trace event log level | |
97 | */ | |
98 | public TraceLogLevel getLogLevel() { | |
99 | return fEventInfo.getLogLevel(); | |
100 | } | |
ea21cd65 | 101 | |
eb1bab5b | 102 | /** |
ea21cd65 | 103 | * Sets the trace event log level to the given level |
eb1bab5b BH |
104 | * @param level - event log level to set |
105 | */ | |
106 | public void setLogLevel(TraceLogLevel level) { | |
107 | fEventInfo.setLogLevel(level); | |
108 | } | |
ea21cd65 | 109 | |
eb1bab5b BH |
110 | /** |
111 | * Sets the trace event log level to the level specified by the given name. | |
112 | * @param levelName - event log level name | |
113 | */ | |
114 | public void setLogLevel(String levelName) { | |
115 | fEventInfo.setLogLevel(levelName); | |
116 | } | |
117 | ||
06b9339e BH |
118 | /* |
119 | * (non-Javadoc) | |
115b4a01 | 120 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class) |
06b9339e | 121 | */ |
06b9339e BH |
122 | @Override |
123 | public Object getAdapter(Class adapter) { | |
124 | if (adapter == IPropertySource.class) { | |
125 | return new BaseEventPropertySource(this); | |
126 | } | |
127 | return null; | |
ea21cd65 | 128 | } |
6503ae0f BH |
129 | |
130 | /** | |
ea21cd65 | 131 | * @return target node component. |
6503ae0f BH |
132 | */ |
133 | public TargetNodeComponent getTargetNode() { | |
134 | return (TargetNodeComponent) getParent().getParent(); | |
135 | } | |
136 | ||
137 | /** | |
138 | * @return if provider kernel or UST | |
139 | */ | |
140 | public boolean isKernel() { | |
141 | return getParent() instanceof KernelProviderComponent; | |
142 | } | |
143 | ||
eb1bab5b BH |
144 | // ------------------------------------------------------------------------ |
145 | // Operations | |
146 | // ------------------------------------------------------------------------ | |
147 | } |