Commit | Line | Data |
---|---|---|
06b9339e | 1 | /********************************************************************** |
11252342 | 2 | * Copyright (c) 2012, 2013 Ericsson |
5a7326dc | 3 | * |
06b9339e BH |
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 | |
5a7326dc BH |
8 | * |
9 | * Contributors: | |
080600d9 | 10 | * Bernd Hufmann - Initial API and implementation |
06b9339e | 11 | **********************************************************************/ |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property; |
06b9339e | 13 | |
83051fc3 | 14 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BufferType; |
9315aeee | 15 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; |
115b4a01 | 16 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent; |
080600d9 | 17 | import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor; |
06b9339e | 18 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
06b9339e BH |
19 | |
20 | /** | |
06b9339e BH |
21 | * <p> |
22 | * Property source implementation for the trace domain component. | |
23 | * </p> | |
5a7326dc | 24 | * |
dbd4432d | 25 | * @author Bernd Hufmann |
06b9339e BH |
26 | */ |
27 | public class TraceDomainPropertySource extends BasePropertySource { | |
28 | ||
29 | // ------------------------------------------------------------------------ | |
30 | // Constants | |
31 | // ------------------------------------------------------------------------ | |
32 | ||
33 | /** | |
34 | * The trace domain 'name' property ID. | |
35 | */ | |
36 | public static final String TRACE_DOMAIN_NAME_PROPERTY_ID = "trace.domain.name"; //$NON-NLS-1$ | |
37 | /** | |
5a7326dc | 38 | * The trace domain 'name' property name. |
06b9339e BH |
39 | */ |
40 | public static final String TRACE_DOMAIN_NAME_PROPERTY_NAME = Messages.TraceControl_DomainNamePropertyName; | |
ca8c54b3 SD |
41 | /** |
42 | * The domain 'buffer type' property ID. | |
43 | */ | |
44 | public static final String BUFFER_TYPE_PROPERTY_ID = "trace.domain.bufferType"; //$NON-NLS-1$ | |
45 | /** | |
46 | * The domain 'buffer type' property name. | |
47 | */ | |
48 | public static final String BUFER_TYPE_PROPERTY_NAME = Messages.TraceControl_BufferTypePropertyName; | |
5a7326dc | 49 | |
06b9339e BH |
50 | // ------------------------------------------------------------------------ |
51 | // Attributes | |
52 | // ------------------------------------------------------------------------ | |
11252342 | 53 | |
06b9339e | 54 | /** |
5a7326dc | 55 | * The trace domain component which this property source is for. |
06b9339e | 56 | */ |
ca8c54b3 | 57 | private final TraceDomainComponent fDomain; |
5a7326dc | 58 | |
06b9339e BH |
59 | // ------------------------------------------------------------------------ |
60 | // Constructors | |
61 | // ------------------------------------------------------------------------ | |
11252342 | 62 | |
06b9339e BH |
63 | /** |
64 | * Constructor | |
65 | * @param component - the trace domain component | |
66 | */ | |
67 | public TraceDomainPropertySource(TraceDomainComponent component) { | |
ca8c54b3 | 68 | fDomain = component; |
06b9339e | 69 | } |
5a7326dc | 70 | |
06b9339e BH |
71 | // ------------------------------------------------------------------------ |
72 | // Operations | |
73 | // ------------------------------------------------------------------------ | |
11252342 | 74 | |
06b9339e BH |
75 | @Override |
76 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
83051fc3 | 77 | if (fDomain.getBufferType() == BufferType.BUFFER_TYPE_UNKNOWN) { |
ca8c54b3 SD |
78 | return new IPropertyDescriptor[] { |
79 | new ReadOnlyTextPropertyDescriptor(TRACE_DOMAIN_NAME_PROPERTY_ID, TRACE_DOMAIN_NAME_PROPERTY_NAME) }; | |
80 | } | |
81 | ||
06b9339e | 82 | return new IPropertyDescriptor[] { |
ca8c54b3 SD |
83 | new ReadOnlyTextPropertyDescriptor(TRACE_DOMAIN_NAME_PROPERTY_ID, TRACE_DOMAIN_NAME_PROPERTY_NAME), |
84 | new ReadOnlyTextPropertyDescriptor(BUFFER_TYPE_PROPERTY_ID, BUFER_TYPE_PROPERTY_NAME) }; | |
06b9339e BH |
85 | } |
86 | ||
06b9339e BH |
87 | @Override |
88 | public Object getPropertyValue(Object id) { | |
ca8c54b3 | 89 | if(BUFFER_TYPE_PROPERTY_ID.equals(id)){ |
83051fc3 | 90 | return fDomain.getBufferType().getInName(); |
ca8c54b3 SD |
91 | } |
92 | ||
06b9339e | 93 | if(TRACE_DOMAIN_NAME_PROPERTY_ID.equals(id)) { |
ca8c54b3 | 94 | return fDomain.getName(); |
06b9339e BH |
95 | } |
96 | return null; | |
97 | } | |
98 | ||
99 | } |