gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.ui / src / org / eclipse / linuxtools / internal / lttng2 / control / ui / views / model / impl / BaseEventComponent.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.control.ui.views.model.impl;
14
15 import org.eclipse.linuxtools.internal.lttng2.control.core.model.IBaseEventInfo;
16 import org.eclipse.linuxtools.internal.lttng2.control.core.model.IFieldInfo;
17 import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEventType;
18 import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceLogLevel;
19 import org.eclipse.linuxtools.internal.lttng2.control.core.model.impl.EventInfo;
20 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.ITraceControlComponent;
21 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.property.BaseEventPropertySource;
22 import org.eclipse.ui.views.properties.IPropertySource;
23
24 /**
25 * <p>
26 * Implementation of the base trace event component.
27 * </p>
28 *
29 * @author Bernd Hufmann
30 */
31 public class BaseEventComponent extends TraceControlComponent {
32 // ------------------------------------------------------------------------
33 // Constants
34 // ------------------------------------------------------------------------
35 /**
36 * Path to icon file for this component.
37 */
38 public static final String TRACE_EVENT_ICON_FILE_ENABLED = "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
39
40 // ------------------------------------------------------------------------
41 // Attributes
42 // ------------------------------------------------------------------------
43 /**
44 * The Event information implementation.
45 */
46 private IBaseEventInfo fEventInfo;
47
48 // ------------------------------------------------------------------------
49 // Constructors
50 // ------------------------------------------------------------------------
51
52 /**
53 * Constructor
54 * @param name - the name of the component.
55 * @param parent - the parent of this component.
56 */
57 public BaseEventComponent(String name, ITraceControlComponent parent) {
58 super(name, parent);
59 setImage(TRACE_EVENT_ICON_FILE_ENABLED);
60 fEventInfo = new EventInfo(name);
61 }
62
63 // ------------------------------------------------------------------------
64 // Accessors
65 // ------------------------------------------------------------------------
66 /**
67 * Sets the event information.
68 * @param eventInfo - the event info to set.
69 */
70 public void setEventInfo(IBaseEventInfo eventInfo) {
71 fEventInfo = eventInfo;
72 }
73
74 /**
75 * @return the event type.
76 */
77 public TraceEventType getEventType() {
78 return fEventInfo.getEventType();
79 }
80
81 /**
82 * Sets the event type to the given value.
83 * @param type - type to set.
84 */
85 public void setEventType(TraceEventType type) {
86 fEventInfo.setEventType(type);
87 }
88
89 /**
90 * Sets the event type to the value specified by the give name.
91 * @param typeName - the type name.
92 */
93 public void setEventType(String typeName) {
94 fEventInfo.setEventType(typeName);
95 }
96
97 /**
98 * @return the trace event log level
99 */
100 public TraceLogLevel getLogLevel() {
101 return fEventInfo.getLogLevel();
102 }
103
104 /**
105 * Sets the trace event log level to the given level
106 * @param level - event log level to set
107 */
108 public void setLogLevel(TraceLogLevel level) {
109 fEventInfo.setLogLevel(level);
110 }
111
112 /**
113 * Sets the trace event log level to the level specified by the given name.
114 * @param levelName - event log level name
115 */
116 public void setLogLevel(String levelName) {
117 fEventInfo.setLogLevel(levelName);
118 }
119
120 /**
121 * @return a String containing pairs if field name and data type
122 */
123 public String getFieldString() {
124 IFieldInfo[] fields = fEventInfo.getFields();
125 if ((fields != null) && (fields.length > 0)) {
126 StringBuffer buffer = new StringBuffer();
127 for (int i = 0; i < fields.length; i++) {
128 buffer.append(fields[i].getName());
129 buffer.append("="); //$NON-NLS-1$
130 buffer.append(fields[i].getFieldType());
131 if (i != fields.length-1) {
132 buffer.append(";"); //$NON-NLS-1$
133 }
134 }
135 return buffer.toString();
136 }
137 return null;
138 }
139
140 @Override
141 public Object getAdapter(Class adapter) {
142 if (adapter == IPropertySource.class) {
143 return new BaseEventPropertySource(this);
144 }
145 return null;
146 }
147
148 /**
149 * @return target node component.
150 */
151 public TargetNodeComponent getTargetNode() {
152 return (TargetNodeComponent) getParent().getParent();
153 }
154
155 /**
156 * @return if provider kernel or UST
157 */
158 public boolean isKernel() {
159 return getParent() instanceof KernelProviderComponent;
160 }
161
162 // ------------------------------------------------------------------------
163 // Operations
164 // ------------------------------------------------------------------------
165 }
This page took 0.04656 seconds and 5 git commands to generate.