1 /**********************************************************************
2 * Copyright (c) 2012 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 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
;
14 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IBaseEventInfo
;
15 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IFieldInfo
;
16 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEventType
;
17 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.EventInfo
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.BaseEventPropertySource
;
21 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
25 * Implementation of the base trace event component.
28 * @author Bernd Hufmann
30 public class BaseEventComponent
extends TraceControlComponent
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 * Path to icon file for this component.
37 public static final String TRACE_EVENT_ICON_FILE_ENABLED
= "icons/obj16/event_enabled.gif"; //$NON-NLS-1$
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
43 * The Event information implementation.
45 private IBaseEventInfo fEventInfo
;
47 // ------------------------------------------------------------------------
49 // ------------------------------------------------------------------------
53 * @param name - the name of the component.
54 * @param parent - the parent of this component.
56 public BaseEventComponent(String name
, ITraceControlComponent parent
) {
58 setImage(TRACE_EVENT_ICON_FILE_ENABLED
);
59 fEventInfo
= new EventInfo(name
);
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
66 * Sets the event information.
67 * @param eventInfo - the event info to set.
69 public void setEventInfo(IBaseEventInfo eventInfo
) {
70 fEventInfo
= eventInfo
;
74 * @return the event type.
76 public TraceEventType
getEventType() {
77 return fEventInfo
.getEventType();
81 * Sets the event type to the given value.
82 * @param type - type to set.
84 public void setEventType(TraceEventType type
) {
85 fEventInfo
.setEventType(type
);
89 * Sets the event type to the value specified by the give name.
90 * @param typeName - the type name.
92 public void setEventType(String typeName
) {
93 fEventInfo
.setEventType(typeName
);
97 * @return the trace event log level
99 public TraceLogLevel
getLogLevel() {
100 return fEventInfo
.getLogLevel();
104 * Sets the trace event log level to the given level
105 * @param level - event log level to set
107 public void setLogLevel(TraceLogLevel level
) {
108 fEventInfo
.setLogLevel(level
);
112 * Sets the trace event log level to the level specified by the given name.
113 * @param levelName - event log level name
115 public void setLogLevel(String levelName
) {
116 fEventInfo
.setLogLevel(levelName
);
120 * @return a String containing pairs if field name and data type
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$
134 return buffer
.toString();
141 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
144 public Object
getAdapter(Class adapter
) {
145 if (adapter
== IPropertySource
.class) {
146 return new BaseEventPropertySource(this);
152 * @return target node component.
154 public TargetNodeComponent
getTargetNode() {
155 return (TargetNodeComponent
) getParent().getParent();
159 * @return if provider kernel or UST
161 public boolean isKernel() {
162 return getParent() instanceof KernelProviderComponent
;
165 // ------------------------------------------------------------------------
167 // ------------------------------------------------------------------------