1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
;
14 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.messages
.Messages
;
15 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceChannelComponent
;
16 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
17 import org
.eclipse
.ui
.views
.properties
.TextPropertyDescriptor
;
21 * Property source implementation for the trace channel component.
24 * @author Bernd Hufmann
26 public class TraceChannelPropertySource
extends BasePropertySource
{
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
32 * The trace channel 'name' property ID.
34 public static final String TRACE_CHANNEL_NAME_PROPERTY_ID
= "trace.channel.name"; //$NON-NLS-1$
36 * The trace channel 'state' ID.
38 public static final String TRACE_CHANNEL_STATE_PROPERTY_ID
= "trace.channel.state"; //$NON-NLS-1$
40 * The trace channel 'overwrite mode' property ID.
42 public static final String TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID
= "trace.channel.overwrite.mode"; //$NON-NLS-1$
44 * The trace channel 'sub-buffer size' property ID.
46 public static final String TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID
= "trace.channel.subbuffer.size"; //$NON-NLS-1$
48 * The trace channel 'number of sub-buffers' property ID.
50 public static final String TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID
= "trace.channel.no.subbuffers"; //$NON-NLS-1$
52 * The trace channel 'switch timer interval' property ID.
54 public static final String TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID
= "trace.channel.switch.timer"; //$NON-NLS-1$
56 * The trace channel 'read timer interval' property ID.
58 public static final String TRACE_CHANNEL_READ_TIMER_PROPERTY_ID
= "trace.channel.read.timer"; //$NON-NLS-1$
60 * The trace channel 'output type' property ID.
62 public static final String TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID
= "trace.channel.output.type"; //$NON-NLS-1$
64 * The trace channel 'name' property name.
66 public static final String TRACE_CHANNEL_NAME_PROPERTY_NAME
= Messages
.TraceControl_ChannelNamePropertyName
;
68 * The trace channel 'state' property name.
70 public static final String TRACE_CHANNEL_STATE_PROPERTY_NAME
= Messages
.TraceControl_StatePropertyName
;
72 * The trace channel 'overwrite mode' property name.
74 public static final String TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_NAME
= Messages
.TraceControl_OverwriteModePropertyName
;
76 * The trace channel 'sub-buffer size' property name.
78 public static final String TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_NAME
= Messages
.TraceControl_SubBufferSizePropertyName
;
80 * The trace channel 'sub-buffer size' property name.
82 public static final String TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_NAME
= Messages
.TraceControl_NbSubBuffersPropertyName
;
84 * The trace channel 'switch timer interval' property name.
86 public static final String TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_NAME
= Messages
.TraceControl_SwitchTimerPropertyName
;
88 * The trace channel 'read timer interval' property name.
90 public static final String TRACE_CHANNEL_READ_TIMER_PROPERTY_NAME
= Messages
.TraceControl_ReadTimerPropertyName
;
92 * The trace channel 'output type' property name.
94 public static final String TRACE_CHANNEL_OUTPUT_TYPEPROPERTY_NAME
= Messages
.TraceControl_OutputTypePropertyName
;
96 // ------------------------------------------------------------------------
98 // ------------------------------------------------------------------------
100 * The channel component which this property source is for.
102 private final TraceChannelComponent fChannel
;
104 // ------------------------------------------------------------------------
106 // ------------------------------------------------------------------------
109 * @param component - the channel component
111 public TraceChannelPropertySource(TraceChannelComponent component
) {
112 fChannel
= component
;
115 // ------------------------------------------------------------------------
117 // ------------------------------------------------------------------------
121 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
124 public IPropertyDescriptor
[] getPropertyDescriptors() {
125 return new IPropertyDescriptor
[] {
126 new TextPropertyDescriptor(TRACE_CHANNEL_NAME_PROPERTY_ID
, TRACE_CHANNEL_NAME_PROPERTY_NAME
),
127 new TextPropertyDescriptor(TRACE_CHANNEL_STATE_PROPERTY_ID
, TRACE_CHANNEL_STATE_PROPERTY_NAME
),
128 new TextPropertyDescriptor(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID
, TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_NAME
),
129 new TextPropertyDescriptor(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID
, TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_NAME
),
130 new TextPropertyDescriptor(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID
, TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_NAME
),
131 new TextPropertyDescriptor(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID
, TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_NAME
),
132 new TextPropertyDescriptor(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID
, TRACE_CHANNEL_READ_TIMER_PROPERTY_NAME
),
133 new TextPropertyDescriptor(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID
, TRACE_CHANNEL_OUTPUT_TYPEPROPERTY_NAME
)};
138 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
141 public Object
getPropertyValue(Object id
) {
142 if(TRACE_CHANNEL_NAME_PROPERTY_ID
.equals(id
)) {
143 return fChannel
.getName();
145 if (TRACE_CHANNEL_STATE_PROPERTY_ID
.equals(id
)) {
146 return fChannel
.getState().name();
148 if(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID
.equals(id
)) {
149 return String
.valueOf(fChannel
.isOverwriteMode());
151 if(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID
.equals(id
)) {
152 return String
.valueOf(fChannel
.getSubBufferSize());
154 if(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID
.equals(id
)) {
155 return String
.valueOf(fChannel
.getNumberOfSubBuffers());
157 if(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID
.equals(id
)) {
158 return String
.valueOf(fChannel
.getSwitchTimer());
160 if(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID
.equals(id
)) {
161 return String
.valueOf(fChannel
.getReadTimer());
163 if(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID
.equals(id
)) {
164 return fChannel
.getOutputType();