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
;
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
;
20 * <b><u>TraceChannelPropertySource</u></b>
22 * Property source implementation for the trace channel component.
25 public class TraceChannelPropertySource
extends BasePropertySource
{
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
31 * The trace channel 'name' property ID.
33 public static final String TRACE_CHANNEL_NAME_PROPERTY_ID
= "trace.channel.name"; //$NON-NLS-1$
35 * The trace channel 'state' ID.
37 public static final String TRACE_CHANNEL_STATE_PROPERTY_ID
= "trace.channel.state"; //$NON-NLS-1$
39 * The trace channel 'overwrite mode' property ID.
41 public static final String TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID
= "trace.channel.overwrite.mode"; //$NON-NLS-1$
43 * The trace channel 'sub-buffer size' property ID.
45 public static final String TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID
= "trace.channel.subbuffer.size"; //$NON-NLS-1$
47 * The trace channel 'number of sub-buffers' property ID.
49 public static final String TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID
= "trace.channel.no.subbuffers"; //$NON-NLS-1$
51 * The trace channel 'switch timer interval' property ID.
53 public static final String TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID
= "trace.channel.switch.timer"; //$NON-NLS-1$
55 * The trace channel 'read timer interval' property ID.
57 public static final String TRACE_CHANNEL_READ_TIMER_PROPERTY_ID
= "trace.channel.read.timer"; //$NON-NLS-1$
59 * The trace channel 'output type' property ID.
61 public static final String TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID
= "trace.channel.output.type"; //$NON-NLS-1$
63 * The trace channel 'name' property name.
65 public static final String TRACE_CHANNEL_NAME_PROPERTY_NAME
= Messages
.TraceControl_ChannelNamePropertyName
;
67 * The trace channel 'state' property name.
69 public static final String TRACE_CHANNEL_STATE_PROPERTY_NAME
= Messages
.TraceControl_StatePropertyName
;
71 * The trace channel 'overwrite mode' property name.
73 public static final String TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_NAME
= Messages
.TraceControl_OverwriteModePropertyName
;
75 * The trace channel 'sub-buffer size' property name.
77 public static final String TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_NAME
= Messages
.TraceControl_SubBufferSizePropertyName
;
79 * The trace channel 'sub-buffer size' property name.
81 public static final String TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_NAME
= Messages
.TraceControl_NbSubBuffersPropertyName
;
83 * The trace channel 'switch timer interval' property name.
85 public static final String TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_NAME
= Messages
.TraceControl_SwitchTimerPropertyName
;
87 * The trace channel 'read timer interval' property name.
89 public static final String TRACE_CHANNEL_READ_TIMER_PROPERTY_NAME
= Messages
.TraceControl_ReadTimerPropertyName
;
91 * The trace channel 'output type' property name.
93 public static final String TRACE_CHANNEL_OUTPUT_TYPEPROPERTY_NAME
= Messages
.TraceControl_OutputTypePropertyName
;
95 // ------------------------------------------------------------------------
97 // ------------------------------------------------------------------------
99 * The channel component which this property source is for.
101 private final TraceChannelComponent fChannel
;
103 // ------------------------------------------------------------------------
105 // ------------------------------------------------------------------------
108 * @param component - the channel component
110 public TraceChannelPropertySource(TraceChannelComponent component
) {
111 fChannel
= component
;
114 // ------------------------------------------------------------------------
116 // ------------------------------------------------------------------------
120 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
123 public IPropertyDescriptor
[] getPropertyDescriptors() {
124 return new IPropertyDescriptor
[] {
125 new TextPropertyDescriptor(TRACE_CHANNEL_NAME_PROPERTY_ID
, TRACE_CHANNEL_NAME_PROPERTY_NAME
),
126 new TextPropertyDescriptor(TRACE_CHANNEL_STATE_PROPERTY_ID
, TRACE_CHANNEL_STATE_PROPERTY_NAME
),
127 new TextPropertyDescriptor(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID
, TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_NAME
),
128 new TextPropertyDescriptor(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID
, TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_NAME
),
129 new TextPropertyDescriptor(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID
, TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_NAME
),
130 new TextPropertyDescriptor(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID
, TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_NAME
),
131 new TextPropertyDescriptor(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID
, TRACE_CHANNEL_READ_TIMER_PROPERTY_NAME
),
132 new TextPropertyDescriptor(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID
, TRACE_CHANNEL_OUTPUT_TYPEPROPERTY_NAME
)};
137 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
140 public Object
getPropertyValue(Object id
) {
141 if(TRACE_CHANNEL_NAME_PROPERTY_ID
.equals(id
)) {
142 return fChannel
.getName();
144 if (TRACE_CHANNEL_STATE_PROPERTY_ID
.equals(id
)) {
145 return fChannel
.getState().name();
147 if(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID
.equals(id
)) {
148 return String
.valueOf(fChannel
.isOverwriteMode());
150 if(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID
.equals(id
)) {
151 return String
.valueOf(fChannel
.getSubBufferSize());
153 if(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID
.equals(id
)) {
154 return String
.valueOf(fChannel
.getNumberOfSubBuffers());
156 if(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID
.equals(id
)) {
157 return String
.valueOf(fChannel
.getSwitchTimer());
159 if(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID
.equals(id
)) {
160 return String
.valueOf(fChannel
.getReadTimer());
162 if(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID
.equals(id
)) {
163 return fChannel
.getOutputType();