Commit | Line | Data |
---|---|---|
a20452b1 BR |
1 | /********************************************************************** |
2 | * Copyright (c) 2016 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 | * Bruno Roy - Initial API and implementation | |
11 | **********************************************************************/ | |
12 | package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl; | |
13 | ||
14 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseLoggerInfo; | |
15 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.ILoggerInfo; | |
74fe9bdd | 16 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.ITraceLogLevel; |
a20452b1 | 17 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType; |
a20452b1 BR |
18 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.LoggerInfo; |
19 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
20 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.BaseLoggerPropertySource; | |
21 | import org.eclipse.ui.views.properties.IPropertySource; | |
22 | ||
23 | /** | |
24 | * Implementation of the base trace logger component. | |
25 | * | |
26 | * @author Bruno Roy | |
27 | */ | |
28 | public class BaseLoggerComponent extends TraceControlComponent { | |
29 | // ------------------------------------------------------------------------ | |
30 | // Constants | |
31 | // ------------------------------------------------------------------------ | |
32 | /** | |
33 | * Path to icon file for this component. | |
34 | */ | |
35 | public static final String TRACE_LOGGER_ICON_FILE_ENABLED = "icons/obj16/logger_enabled.gif"; //$NON-NLS-1$ | |
36 | ||
37 | // ------------------------------------------------------------------------ | |
38 | // Attributes | |
39 | // ------------------------------------------------------------------------ | |
40 | /** | |
41 | * The logger information implementation. | |
42 | */ | |
43 | private IBaseLoggerInfo fLoggerInfo; | |
44 | ||
45 | // ------------------------------------------------------------------------ | |
46 | // Constructors | |
47 | // ------------------------------------------------------------------------ | |
48 | ||
49 | /** | |
50 | * Constructor | |
51 | * | |
52 | * @param name | |
53 | * the name of the component. | |
54 | * @param parent | |
55 | * the parent of this component. | |
56 | */ | |
57 | public BaseLoggerComponent(String name, ITraceControlComponent parent) { | |
58 | super(name, parent); | |
59 | setImage(TRACE_LOGGER_ICON_FILE_ENABLED); | |
60 | fLoggerInfo = new LoggerInfo(name); | |
61 | } | |
62 | ||
63 | ||
64 | // ------------------------------------------------------------------------ | |
65 | // Accessors | |
66 | // ------------------------------------------------------------------------ | |
67 | /** | |
68 | * Sets the logger information. | |
69 | * | |
70 | * @param loggerInfo | |
71 | * the logger info to set. | |
72 | */ | |
73 | public void setLoggerInfo(IBaseLoggerInfo loggerInfo) { | |
74 | fLoggerInfo = loggerInfo; | |
75 | } | |
76 | ||
77 | /** | |
78 | * @return the trace logger log level | |
79 | */ | |
74fe9bdd | 80 | public ITraceLogLevel getLogLevel() { |
a20452b1 BR |
81 | return fLoggerInfo.getLogLevel(); |
82 | } | |
83 | ||
84 | /** | |
85 | * Sets the trace logger log level to the given level | |
86 | * | |
87 | * @param level | |
88 | * event log level to set | |
89 | */ | |
74fe9bdd | 90 | public void setLogLevel(ITraceLogLevel level) { |
a20452b1 BR |
91 | fLoggerInfo.setLogLevel(level); |
92 | } | |
93 | ||
94 | /** | |
95 | * Sets the trace logger log level to the level specified by the given name. | |
96 | * | |
97 | * @param levelName | |
98 | * logger log level name | |
99 | */ | |
100 | public void setLogLevel(String levelName) { | |
101 | fLoggerInfo.setLogLevel(levelName); | |
102 | } | |
103 | ||
104 | @Override | |
105 | public <T> T getAdapter(Class<T> adapter) { | |
106 | if (adapter == IPropertySource.class) { | |
107 | return adapter.cast(new BaseLoggerPropertySource(this)); | |
108 | } | |
109 | return null; | |
110 | } | |
111 | ||
112 | /** | |
113 | * @return target node component. | |
114 | */ | |
115 | public TargetNodeComponent getTargetNode() { | |
116 | return (TargetNodeComponent) getParent().getParent(); | |
117 | } | |
118 | ||
119 | /** | |
120 | * @return the domain type ({@link TraceDomainType}) | |
121 | */ | |
122 | public TraceDomainType getDomain() { | |
123 | return fLoggerInfo.getDomain(); | |
124 | } | |
125 | ||
126 | /** | |
127 | * Sets the logger information. | |
128 | * @param loggerInfo - the logger information to set. | |
129 | */ | |
130 | public void setLoggerInfo(ILoggerInfo loggerInfo) { | |
131 | fLoggerInfo = loggerInfo; | |
132 | } | |
133 | } |