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