| 1 | /********************************************************************** |
| 2 | * Copyright (c) 2012, 2013 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 | **********************************************************************/ |
| 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property; |
| 13 | |
| 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.ui.properties.ReadOnlyTextPropertyDescriptor; |
| 17 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
| 18 | |
| 19 | /** |
| 20 | * <p> |
| 21 | * Property source implementation for the trace channel component. |
| 22 | * </p> |
| 23 | * |
| 24 | * @author Bernd Hufmann |
| 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 | @Override |
| 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)}; |
| 130 | } |
| 131 | |
| 132 | @Override |
| 133 | public Object getPropertyValue(Object id) { |
| 134 | if(TRACE_CHANNEL_NAME_PROPERTY_ID.equals(id)) { |
| 135 | return fChannel.getName(); |
| 136 | } |
| 137 | if (TRACE_CHANNEL_STATE_PROPERTY_ID.equals(id)) { |
| 138 | return fChannel.getState().name(); |
| 139 | } |
| 140 | if(TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID.equals(id)) { |
| 141 | return String.valueOf(fChannel.isOverwriteMode()); |
| 142 | } |
| 143 | if(TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID.equals(id)) { |
| 144 | return String.valueOf(fChannel.getSubBufferSize()); |
| 145 | } |
| 146 | if(TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID.equals(id)) { |
| 147 | return String.valueOf(fChannel.getNumberOfSubBuffers()); |
| 148 | } |
| 149 | if(TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID.equals(id)) { |
| 150 | return String.valueOf(fChannel.getSwitchTimer()); |
| 151 | } |
| 152 | if(TRACE_CHANNEL_READ_TIMER_PROPERTY_ID.equals(id)) { |
| 153 | return String.valueOf(fChannel.getReadTimer()); |
| 154 | } |
| 155 | if(TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID.equals(id)) { |
| 156 | return fChannel.getOutputType(); |
| 157 | } |
| 158 | return null; |
| 159 | } |
| 160 | |
| 161 | } |