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