Commit | Line | Data |
---|---|---|
06b9339e 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 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property; |
06b9339e | 13 | |
115b4a01 BH |
14 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages; |
15 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent; | |
06b9339e BH |
16 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
17 | import org.eclipse.ui.views.properties.TextPropertyDescriptor; | |
18 | ||
19 | /** | |
20 | * <b><u>TraceChannelPropertySource</u></b> | |
21 | * <p> | |
22 | * Property source implementation for the trace channel component. | |
23 | * </p> | |
24 | */ | |
25 | public class TraceChannelPropertySource extends BasePropertySource { | |
26 | ||
27 | // ------------------------------------------------------------------------ | |
28 | // Constants | |
29 | // ------------------------------------------------------------------------ | |
30 | /** | |
31 | * The trace channel 'name' property ID. | |
32 | */ | |
33 | public static final String TRACE_CHANNEL_NAME_PROPERTY_ID = "trace.channel.name"; //$NON-NLS-1$ | |
34 | /** | |
35 | * The trace channel 'state' ID. | |
36 | */ | |
37 | public static final String TRACE_CHANNEL_STATE_PROPERTY_ID = "trace.channel.state"; //$NON-NLS-1$ | |
38 | /** | |
39 | * The trace channel 'overwrite mode' property ID. | |
40 | */ | |
41 | public static final String TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID = "trace.channel.overwrite.mode"; //$NON-NLS-1$ | |
42 | /** | |
43 | * The trace channel 'sub-buffer size' property ID. | |
44 | */ | |
45 | public static final String TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID = "trace.channel.subbuffer.size"; //$NON-NLS-1$ | |
46 | /** | |
47 | * The trace channel 'number of sub-buffers' property ID. | |
48 | */ | |
49 | public static final String TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID = "trace.channel.no.subbuffers"; //$NON-NLS-1$ | |
50 | /** | |
51 | * The trace channel 'switch timer interval' property ID. | |
52 | */ | |
53 | public static final String TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID = "trace.channel.switch.timer"; //$NON-NLS-1$ | |
54 | /** | |
55 | * The trace channel 'read timer interval' property ID. | |
56 | */ | |
57 | public static final String TRACE_CHANNEL_READ_TIMER_PROPERTY_ID = "trace.channel.read.timer"; //$NON-NLS-1$ | |
58 | /** | |
59 | * The trace channel 'output type' property ID. | |
60 | */ | |
61 | public static final String TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID = "trace.channel.output.type"; //$NON-NLS-1$ | |
62 | /** | |
63 | * The trace channel 'name' property name. | |
64 | */ | |
65 | public static final String TRACE_CHANNEL_NAME_PROPERTY_NAME = Messages.TraceControl_ChannelNamePropertyName; | |
66 | /** | |
67 | * The trace channel 'state' property name. | |
68 | */ | |
69 | public static final String TRACE_CHANNEL_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName; | |
70 | /** | |
71 | * The trace channel 'overwrite mode' property name. | |
72 | */ | |
73 | public static final String TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_NAME = Messages.TraceControl_OverwriteModePropertyName; | |
74 | /** | |
75 | * The trace channel 'sub-buffer size' property name. | |
76 | */ | |
77 | public static final String TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_NAME = Messages.TraceControl_SubBufferSizePropertyName; | |
78 | /** | |
79 | * The trace channel 'sub-buffer size' property name. | |
80 | */ | |
81 | public static final String TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_NAME = Messages.TraceControl_NbSubBuffersPropertyName; | |
82 | /** | |
83 | * The trace channel 'switch timer interval' property name. | |
84 | */ | |
85 | public static final String TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_NAME = Messages.TraceControl_SwitchTimerPropertyName; | |
86 | /** | |
87 | * The trace channel 'read timer interval' property name. | |
88 | */ | |
89 | public static final String TRACE_CHANNEL_READ_TIMER_PROPERTY_NAME = Messages.TraceControl_ReadTimerPropertyName; | |
90 | /** | |
91 | * The trace channel 'output type' property name. | |
92 | */ | |
93 | public static final String TRACE_CHANNEL_OUTPUT_TYPEPROPERTY_NAME = Messages.TraceControl_OutputTypePropertyName; | |
94 | ||
95 | // ------------------------------------------------------------------------ | |
96 | // Attributes | |
97 | // ------------------------------------------------------------------------ | |
98 | /** | |
99 | * The channel component which this property source is for. | |
100 | */ | |
101 | private final TraceChannelComponent fChannel; | |
102 | ||
103 | // ------------------------------------------------------------------------ | |
104 | // Constructors | |
105 | // ------------------------------------------------------------------------ | |
106 | /** | |
107 | * Constructor | |
108 | * @param component - the channel component | |
109 | */ | |
110 | public TraceChannelPropertySource(TraceChannelComponent component) { | |
111 | fChannel = component; | |
112 | } | |
113 | ||
114 | // ------------------------------------------------------------------------ | |
115 | // Operations | |
116 | // ------------------------------------------------------------------------ | |
117 | ||
118 | /* | |
119 | * (non-Javadoc) | |
115b4a01 | 120 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors() |
06b9339e BH |
121 | */ |
122 | @Override | |
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)}; | |
133 | } | |
134 | ||
135 | /* | |
136 | * (non-Javadoc) | |
115b4a01 | 137 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object) |
06b9339e BH |
138 | */ |
139 | @Override | |
140 | public Object getPropertyValue(Object id) { | |
141 | if(TRACE_CHANNEL_NAME_PROPERTY_ID.equals(id)) { | |
142 | return fChannel.getName(); | |
143 | } | |
144 | if (TRACE_CHANNEL_STATE_PROPERTY_ID.equals(id)) { | |
145 | return fChannel.getState().name(); | |
146 | } | |
147 | if(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID.equals(id)) { | |
148 | return String.valueOf(fChannel.isOverwriteMode()); | |
149 | } | |
150 | if(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID.equals(id)) { | |
151 | return String.valueOf(fChannel.getSubBufferSize()); | |
152 | } | |
153 | if(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID.equals(id)) { | |
154 | return String.valueOf(fChannel.getNumberOfSubBuffers()); | |
155 | } | |
156 | if(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID.equals(id)) { | |
157 | return String.valueOf(fChannel.getSwitchTimer()); | |
158 | } | |
159 | if(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID.equals(id)) { | |
160 | return String.valueOf(fChannel.getReadTimer()); | |
161 | } | |
162 | if(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID.equals(id)) { | |
163 | return fChannel.getOutputType(); | |
164 | } | |
165 | return null; | |
166 | } | |
167 | ||
168 | } |