1 /**********************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
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
.ui
.views
.control
.model
.impl
;
15 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IBaseEventInfo
;
16 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IFieldInfo
;
17 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEventType
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.EventInfo
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.BaseEventPropertySource
;
22 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
26 * Implementation of the base trace event component.
29 * @author Bernd Hufmann
31 public class BaseEventComponent
extends TraceControlComponent
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 * Path to icon file for this component.
38 public static final String TRACE_EVENT_ICON_FILE_ENABLED
= "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
44 * The Event information implementation.
46 private IBaseEventInfo fEventInfo
;
48 // ------------------------------------------------------------------------
50 // ------------------------------------------------------------------------
54 * @param name - the name of the component.
55 * @param parent - the parent of this component.
57 public BaseEventComponent(String name
, ITraceControlComponent parent
) {
59 setImage(TRACE_EVENT_ICON_FILE_ENABLED
);
60 fEventInfo
= new EventInfo(name
);
63 // ------------------------------------------------------------------------
65 // ------------------------------------------------------------------------
67 * Sets the event information.
68 * @param eventInfo - the event info to set.
70 public void setEventInfo(IBaseEventInfo eventInfo
) {
71 fEventInfo
= eventInfo
;
75 * @return the event type.
77 public TraceEventType
getEventType() {
78 return fEventInfo
.getEventType();
82 * Sets the event type to the given value.
83 * @param type - type to set.
85 public void setEventType(TraceEventType type
) {
86 fEventInfo
.setEventType(type
);
90 * Sets the event type to the value specified by the give name.
91 * @param typeName - the type name.
93 public void setEventType(String typeName
) {
94 fEventInfo
.setEventType(typeName
);
98 * @return the trace event log level
100 public TraceLogLevel
getLogLevel() {
101 return fEventInfo
.getLogLevel();
105 * Sets the trace event log level to the given level
106 * @param level - event log level to set
108 public void setLogLevel(TraceLogLevel level
) {
109 fEventInfo
.setLogLevel(level
);
113 * Sets the trace event log level to the level specified by the given name.
114 * @param levelName - event log level name
116 public void setLogLevel(String levelName
) {
117 fEventInfo
.setLogLevel(levelName
);
121 * @return a String containing pairs if field name and data type
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$
135 return buffer
.toString();
142 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
145 public Object
getAdapter(Class adapter
) {
146 if (adapter
== IPropertySource
.class) {
147 return new BaseEventPropertySource(this);
153 * @return target node component.
155 public TargetNodeComponent
getTargetNode() {
156 return (TargetNodeComponent
) getParent().getParent();
160 * @return if provider kernel or UST
162 public boolean isKernel() {
163 return getParent() instanceof KernelProviderComponent
;
166 // ------------------------------------------------------------------------
168 // ------------------------------------------------------------------------