lttng: Add a diagram showing the dependencies between plugins
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / model / impl / BaseEventComponent.java
CommitLineData
eb1bab5b 1/**********************************************************************
ba3a9bd2 2 * Copyright (c) 2012, 2013 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 10 * Bernd Hufmann - Initial API and implementation
ba3a9bd2 11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
eb1bab5b 12 **********************************************************************/
115b4a01 13package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
eb1bab5b 14
9315aeee 15import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo;
d4514365 16import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
9315aeee
BH
17import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType;
18import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
19import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo;
115b4a01 20import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
115b4a01 21import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BaseEventPropertySource;
06b9339e 22import org.eclipse.ui.views.properties.IPropertySource;
eb1bab5b
BH
23
24/**
eb1bab5b
BH
25 * <p>
26 * Implementation of the base trace event component.
27 * </p>
ea21cd65 28 *
dbd4432d 29 * @author Bernd Hufmann
eb1bab5b
BH
30 */
31public 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$
ea21cd65 39
eb1bab5b
BH
40 // ------------------------------------------------------------------------
41 // Attributes
42 // ------------------------------------------------------------------------
43 /**
ea21cd65 44 * The Event information implementation.
eb1bab5b
BH
45 */
46 private IBaseEventInfo fEventInfo;
ea21cd65 47
eb1bab5b
BH
48 // ------------------------------------------------------------------------
49 // Constructors
50 // ------------------------------------------------------------------------
ea21cd65 51
eb1bab5b 52 /**
ea21cd65 53 * Constructor
eb1bab5b
BH
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 }
ea21cd65 62
eb1bab5b
BH
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 }
ea21cd65 73
eb1bab5b
BH
74 /**
75 * @return the event type.
76 */
77 public TraceEventType getEventType() {
78 return fEventInfo.getEventType();
79 }
ea21cd65 80
eb1bab5b
BH
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 }
ea21cd65 88
eb1bab5b
BH
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 }
ea21cd65 103
eb1bab5b 104 /**
ea21cd65 105 * Sets the trace event log level to the given level
eb1bab5b
BH
106 * @param level - event log level to set
107 */
108 public void setLogLevel(TraceLogLevel level) {
109 fEventInfo.setLogLevel(level);
110 }
ea21cd65 111
eb1bab5b
BH
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
d4514365
BH
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
06b9339e
BH
140 @Override
141 public Object getAdapter(Class adapter) {
142 if (adapter == IPropertySource.class) {
143 return new BaseEventPropertySource(this);
144 }
145 return null;
ea21cd65 146 }
6503ae0f
BH
147
148 /**
ea21cd65 149 * @return target node component.
6503ae0f
BH
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
eb1bab5b
BH
162 // ------------------------------------------------------------------------
163 // Operations
164 // ------------------------------------------------------------------------
165}
This page took 0.065094 seconds and 5 git commands to generate.