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