Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
11252342 | 2 | * Copyright (c) 2012, 2013 Ericsson |
cfe737e4 | 3 | * |
eb1bab5b 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 | |
cfe737e4 BH |
8 | * |
9 | * Contributors: | |
080600d9 | 10 | * Bernd Hufmann - Initial API and implementation |
eb1bab5b | 11 | **********************************************************************/ |
8e8c0226 | 12 | package org.eclipse.linuxtools.internal.lttng2.control.ui.views.property; |
eb1bab5b | 13 | |
8e8c0226 AM |
14 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages; |
15 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent; | |
080600d9 | 16 | import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor; |
eb1bab5b | 17 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
eb1bab5b BH |
18 | |
19 | /** | |
eb1bab5b BH |
20 | * <p> |
21 | * Property source implementation for the target node component. | |
22 | * </p> | |
cfe737e4 | 23 | * |
dbd4432d | 24 | * @author Bernd Hufmann |
eb1bab5b | 25 | */ |
06b9339e | 26 | public class TargetNodePropertySource extends BasePropertySource { |
eb1bab5b BH |
27 | |
28 | // ------------------------------------------------------------------------ | |
29 | // Constants | |
30 | // ------------------------------------------------------------------------ | |
31 | /** | |
32 | * The node name property ID. | |
33 | */ | |
34 | public static final String TARGET_NODE_NAME_PROPERTY_ID = "target.node.name"; //$NON-NLS-1$ | |
35 | /** | |
36 | * The node address property ID. | |
37 | */ | |
38 | public static final String TARGET_NODE_ADDRESS_PROPERTY_ID = "target.node.address"; //$NON-NLS-1$ | |
06b9339e BH |
39 | /** |
40 | * The state property ID. | |
41 | */ | |
42 | public static final String TARGET_NODE_STATE_PROPERTY_ID = "target.node.state"; //$NON-NLS-1$ | |
eb1bab5b | 43 | /** |
cfe737e4 BH |
44 | * The node version property ID. |
45 | */ | |
46 | public static final String TARGET_NODE_VERSION_PROPERTY_ID = "target.node.version"; //$NON-NLS-1$ | |
47 | ||
48 | /** | |
49 | * The node name property name. | |
eb1bab5b | 50 | */ |
06b9339e | 51 | public static final String TARGET_NODE_NAME_PROPERTY_NAME = Messages.TraceControl_HostNamePropertyName; |
eb1bab5b BH |
52 | /** |
53 | * The node address property name. | |
54 | */ | |
06b9339e BH |
55 | public static final String TARGET_NODE_ADDRESS_PROPERTY_NAME = Messages.TraceControl_HostAddressPropertyName; |
56 | /** | |
57 | * The state address property name. | |
58 | */ | |
59 | public static final String TARGET_NODE_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName; | |
cfe737e4 BH |
60 | /** |
61 | * The node version property name. | |
62 | */ | |
63 | public static final String TARGET_NODE_VERSION_PROPERTY_NAME = Messages.TraceControl_VersionPropertyName; | |
64 | ||
eb1bab5b BH |
65 | // ------------------------------------------------------------------------ |
66 | // Attributes | |
67 | // ------------------------------------------------------------------------ | |
68 | /** | |
cfe737e4 | 69 | * The node component which this property source is for. |
eb1bab5b | 70 | */ |
06b9339e | 71 | private final TargetNodeComponent fTargetNode; |
cfe737e4 | 72 | |
eb1bab5b BH |
73 | // ------------------------------------------------------------------------ |
74 | // Constructors | |
75 | // ------------------------------------------------------------------------ | |
76 | /** | |
77 | * Constructor | |
78 | * @param component - the node component | |
79 | */ | |
80 | public TargetNodePropertySource(TargetNodeComponent component) { | |
81 | fTargetNode = component; | |
82 | } | |
cfe737e4 | 83 | |
eb1bab5b BH |
84 | // ------------------------------------------------------------------------ |
85 | // Operations | |
86 | // ------------------------------------------------------------------------ | |
11252342 | 87 | |
eb1bab5b BH |
88 | @Override |
89 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
90 | return new IPropertyDescriptor[] { | |
5a7326dc BH |
91 | new ReadOnlyTextPropertyDescriptor(TARGET_NODE_NAME_PROPERTY_ID, TARGET_NODE_NAME_PROPERTY_NAME), |
92 | new ReadOnlyTextPropertyDescriptor(TARGET_NODE_ADDRESS_PROPERTY_ID, TARGET_NODE_ADDRESS_PROPERTY_NAME), | |
93 | new ReadOnlyTextPropertyDescriptor(TARGET_NODE_STATE_PROPERTY_ID, TARGET_NODE_STATE_PROPERTY_NAME), | |
94 | new ReadOnlyTextPropertyDescriptor(TARGET_NODE_VERSION_PROPERTY_ID, TARGET_NODE_VERSION_PROPERTY_NAME)}; | |
eb1bab5b BH |
95 | } |
96 | ||
eb1bab5b BH |
97 | @Override |
98 | public Object getPropertyValue(Object id) { | |
99 | if(TARGET_NODE_NAME_PROPERTY_ID.equals(id)) { | |
100 | return fTargetNode.getName(); | |
101 | } | |
102 | if (TARGET_NODE_ADDRESS_PROPERTY_ID.equals(id)) { | |
103 | return fTargetNode.getHostName(); | |
104 | } | |
06b9339e BH |
105 | if (TARGET_NODE_STATE_PROPERTY_ID.equals(id)) { |
106 | return fTargetNode.getTargetNodeState().name(); | |
107 | } | |
cfe737e4 BH |
108 | if (TARGET_NODE_VERSION_PROPERTY_ID.equals(id)) { |
109 | return fTargetNode.getNodeVersion(); | |
110 | } | |
eb1bab5b BH |
111 | return null; |
112 | } | |
eb1bab5b | 113 | } |