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