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