Added properties implementation
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / control / model / impl / TraceChannelComponent.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 **********************************************************************/
12package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
13
14import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
15import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
16import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
17import org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo;
18import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
19import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
06b9339e 20import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceChannelPropertySource;
eb1bab5b 21import org.eclipse.swt.graphics.Image;
06b9339e 22import org.eclipse.ui.views.properties.IPropertySource;
eb1bab5b
BH
23
24
25/**
26 * <b><u>TraceChannelComponent</u></b>
27 * <p>
28 * Implementation of the trace channel component.
29 * </p>
30 */
31public class TraceChannelComponent extends TraceControlComponent {
32 // ------------------------------------------------------------------------
33 // Constants
34 // ------------------------------------------------------------------------
35 /**
36 * Path to icon file for this component (state enabled).
37 */
38 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED = "icons/obj16/channel.gif"; //$NON-NLS-1$
39 /**
40 * Path to icon file for this component (state disabled).
41 */
42 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED = "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
43
44 // ------------------------------------------------------------------------
45 // Attributes
46 // ------------------------------------------------------------------------
47 /**
48 * The channel information.
49 */
50 private IChannelInfo fChannelInfo = null;
51 /**
52 * The image to be displayed in disabled state.
53 */
54 private Image fDisabledImage = null;
55
56 // ------------------------------------------------------------------------
57 // Constructors
58 // ------------------------------------------------------------------------
59 /**
60 * Constructor
61 * @param name - the name of the component.
62 * @param parent - the parent of this component.
63 */
64 public TraceChannelComponent(String name, ITraceControlComponent parent) {
65 super(name, parent);
66 setImage(TRACE_CHANNEL_ICON_FILE_ENABLED);
67 setToolTip(Messages.TraceControl_ChannelDisplayName);
68 fChannelInfo = new ChannelInfo(name);
69 fDisabledImage = LTTngUiPlugin.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED);
70 }
71
72 // ------------------------------------------------------------------------
73 // Accessors
74 // ------------------------------------------------------------------------
75 /*
76 * (non-Javadoc)
77 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
78 */
79 @Override
80 public Image getImage() {
81 if (fChannelInfo.getState() == TraceEnablement.DISABLED) {
82 return fDisabledImage;
83 }
84 return super.getImage();
85 }
86
87 /**
88 * Sets the channel information.
89 * @param channelInfo
90 */
91 public void setChannelInfo(IChannelInfo channelInfo) {
92 fChannelInfo = channelInfo;
93 IEventInfo[] events = fChannelInfo.getEvents();
94 for (int i = 0; i < events.length; i++) {
95 TraceEventComponent event = new TraceEventComponent(events[i].getName(), this);
96 event.setEventInfo(events[i]);
97 addChild(event);
98 }
99 }
100
101 /**
102 * @return the overwrite mode value.
103 */
104 public boolean isOverwriteMode() {
105 return fChannelInfo.isOverwriteMode();
106 }
107 /**
108 * Sets the overwrite mode value to the given mode.
109 * @param mode - mode to set.
110 */
111 public void setOverwriteMode(boolean mode){
112 fChannelInfo.setOverwriteMode(mode);
113 }
114 /**
115 * @return the sub-buffer size.
116 */
117 public long getSubBufferSize() {
118 return fChannelInfo.getSubBufferSize();
119 }
120 /**
121 * Sets the sub-buffer size to the given value.
122 * @param bufferSize - size to set to set.
123 */
124 public void setSubBufferSize(long bufferSize) {
125 fChannelInfo.setSubBufferSize(bufferSize);
126 }
127 /**
128 * @return the number of sub-buffers.
129 */
130 public int getNumberOfSubBuffers() {
131 return fChannelInfo.getNumberOfSubBuffers();
132 }
133 /**
134 * Sets the number of sub-buffers to the given value.
135 * @param numberOfSubBuffers - value to set.
136 */
137 public void setNumberOfSubBuffers(int numberOfSubBuffers) {
138 fChannelInfo.setNumberOfSubBuffers(numberOfSubBuffers);
139 }
140 /**
141 * @return the switch timer interval.
142 */
143 public long getSwitchTimer() {
144 return fChannelInfo.getSwitchTimer();
145 }
146 /**
147 * Sets the switch timer interval to the given value.
148 * @param timer - timer value to set.
149 */
150 public void setSwitchTimer(long timer) {
151 fChannelInfo.setSwitchTimer(timer);
152 }
153 /**
154 * @return the read timer interval.
155 */
156 public long getReadTimer() {
157 return fChannelInfo.getReadTimer();
158 }
159 /**
160 * Sets the read timer interval to the given value.
161 * @param timer - timer value to set..
162 */
163 public void setReadTimer(long timer) {
164 fChannelInfo.setReadTimer(timer);
165 }
166 /**
167 * @return the output type.
168 */
169 public String getOutputType() {
170 return fChannelInfo.getOutputType();
171 }
172 /**
173 * Sets the output type to the given value.
174 * @param type - type to set.
175 */
176 public void setOutputType(String type) {
177 fChannelInfo.setOutputType(type);
178 }
179 /**
180 * @return the channel state (enabled or disabled).
181 */
182 public TraceEnablement getState() {
183 return fChannelInfo.getState();
184 }
185 /**
186 * Sets the channel state (enablement) to the given value.
187 * @param state - state to set.
188 */
189 public void setState(TraceEnablement state) {
190 fChannelInfo.setState(state);
191 }
192 /**
193 * Sets the channel state (enablement) to the value specified by the given name.
194 * @param stateName - state to set.
195 */
196 public void setState(String stateName) {
197 fChannelInfo.setState(stateName);
198 }
06b9339e
BH
199 /*
200 * (non-Javadoc)
201 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
202 */
203 @SuppressWarnings("rawtypes")
204 @Override
205 public Object getAdapter(Class adapter) {
206 if (adapter == IPropertySource.class) {
207 return new TraceChannelPropertySource(this);
208 }
209 return null;
210 }
211
eb1bab5b
BH
212
213 // ------------------------------------------------------------------------
214 // Operations
215 // ------------------------------------------------------------------------
216}
This page took 0.031506 seconds and 5 git commands to generate.