1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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
.linuxtools
.tmf
.core
.util
.ReadOnlyTextPropertyDescriptor
;
17 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
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 // ------------------------------------------------------------------------
120 public IPropertyDescriptor
[] getPropertyDescriptors() {
121 return new IPropertyDescriptor
[] {
122 new ReadOnlyTextPropertyDescriptor(TRACE_CHANNEL_NAME_PROPERTY_ID
, TRACE_CHANNEL_NAME_PROPERTY_NAME
),
123 new ReadOnlyTextPropertyDescriptor(TRACE_CHANNEL_STATE_PROPERTY_ID
, TRACE_CHANNEL_STATE_PROPERTY_NAME
),
124 new ReadOnlyTextPropertyDescriptor(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID
, TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_NAME
),
125 new ReadOnlyTextPropertyDescriptor(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID
, TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_NAME
),
126 new ReadOnlyTextPropertyDescriptor(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID
, TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_NAME
),
127 new ReadOnlyTextPropertyDescriptor(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID
, TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_NAME
),
128 new ReadOnlyTextPropertyDescriptor(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID
, TRACE_CHANNEL_READ_TIMER_PROPERTY_NAME
),
129 new ReadOnlyTextPropertyDescriptor(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID
, TRACE_CHANNEL_OUTPUT_TYPEPROPERTY_NAME
)};
133 public Object
getPropertyValue(Object id
) {
134 if(TRACE_CHANNEL_NAME_PROPERTY_ID
.equals(id
)) {
135 return fChannel
.getName();
137 if (TRACE_CHANNEL_STATE_PROPERTY_ID
.equals(id
)) {
138 return fChannel
.getState().name();
140 if(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID
.equals(id
)) {
141 return String
.valueOf(fChannel
.isOverwriteMode());
143 if(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID
.equals(id
)) {
144 return String
.valueOf(fChannel
.getSubBufferSize());
146 if(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID
.equals(id
)) {
147 return String
.valueOf(fChannel
.getNumberOfSubBuffers());
149 if(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID
.equals(id
)) {
150 return String
.valueOf(fChannel
.getSwitchTimer());
152 if(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID
.equals(id
)) {
153 return String
.valueOf(fChannel
.getReadTimer());
155 if(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID
.equals(id
)) {
156 return fChannel
.getOutputType();