Commit | Line | Data |
---|---|---|
eb1bab5b 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 | **********************************************************************/ | |
31a6a4e4 | 12 | package org.eclipse.linuxtools.internal.lttng.ui.views.control.property; |
eb1bab5b | 13 | |
31a6a4e4 BH |
14 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages; |
15 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TargetNodeComponent; | |
eb1bab5b | 16 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
eb1bab5b BH |
17 | import org.eclipse.ui.views.properties.TextPropertyDescriptor; |
18 | ||
19 | /** | |
20 | * <b><u>TargetNodePropertySource</u></b> | |
21 | * <p> | |
22 | * Property source implementation for the target node component. | |
23 | * </p> | |
24 | */ | |
06b9339e | 25 | public class TargetNodePropertySource extends BasePropertySource { |
eb1bab5b BH |
26 | |
27 | // ------------------------------------------------------------------------ | |
28 | // Constants | |
29 | // ------------------------------------------------------------------------ | |
30 | /** | |
31 | * The node name property ID. | |
32 | */ | |
33 | public static final String TARGET_NODE_NAME_PROPERTY_ID = "target.node.name"; //$NON-NLS-1$ | |
34 | /** | |
35 | * The node address property ID. | |
36 | */ | |
37 | public static final String TARGET_NODE_ADDRESS_PROPERTY_ID = "target.node.address"; //$NON-NLS-1$ | |
06b9339e BH |
38 | /** |
39 | * The state property ID. | |
40 | */ | |
41 | public static final String TARGET_NODE_STATE_PROPERTY_ID = "target.node.state"; //$NON-NLS-1$ | |
eb1bab5b BH |
42 | /** |
43 | * The node name property name. | |
44 | */ | |
06b9339e | 45 | public static final String TARGET_NODE_NAME_PROPERTY_NAME = Messages.TraceControl_HostNamePropertyName; |
eb1bab5b BH |
46 | /** |
47 | * The node address property name. | |
48 | */ | |
06b9339e BH |
49 | public static final String TARGET_NODE_ADDRESS_PROPERTY_NAME = Messages.TraceControl_HostAddressPropertyName; |
50 | /** | |
51 | * The state address property name. | |
52 | */ | |
53 | public static final String TARGET_NODE_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName; | |
eb1bab5b BH |
54 | |
55 | // ------------------------------------------------------------------------ | |
56 | // Attributes | |
57 | // ------------------------------------------------------------------------ | |
58 | /** | |
59 | * The node component which this property source is for. | |
60 | */ | |
06b9339e | 61 | private final TargetNodeComponent fTargetNode; |
eb1bab5b BH |
62 | |
63 | // ------------------------------------------------------------------------ | |
64 | // Constructors | |
65 | // ------------------------------------------------------------------------ | |
66 | /** | |
67 | * Constructor | |
68 | * @param component - the node component | |
69 | */ | |
70 | public TargetNodePropertySource(TargetNodeComponent component) { | |
71 | fTargetNode = component; | |
72 | } | |
73 | ||
74 | // ------------------------------------------------------------------------ | |
75 | // Operations | |
76 | // ------------------------------------------------------------------------ | |
77 | /* | |
78 | * (non-Javadoc) | |
31a6a4e4 | 79 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors() |
eb1bab5b BH |
80 | */ |
81 | @Override | |
82 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
83 | return new IPropertyDescriptor[] { | |
84 | new TextPropertyDescriptor(TARGET_NODE_NAME_PROPERTY_ID, TARGET_NODE_NAME_PROPERTY_NAME), | |
85 | new TextPropertyDescriptor(TARGET_NODE_ADDRESS_PROPERTY_ID, TARGET_NODE_ADDRESS_PROPERTY_NAME), | |
06b9339e | 86 | new TextPropertyDescriptor(TARGET_NODE_STATE_PROPERTY_ID, TARGET_NODE_STATE_PROPERTY_NAME)}; |
eb1bab5b BH |
87 | } |
88 | ||
89 | /* | |
90 | * (non-Javadoc) | |
31a6a4e4 | 91 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object) |
eb1bab5b BH |
92 | */ |
93 | @Override | |
94 | public Object getPropertyValue(Object id) { | |
95 | if(TARGET_NODE_NAME_PROPERTY_ID.equals(id)) { | |
96 | return fTargetNode.getName(); | |
97 | } | |
98 | if (TARGET_NODE_ADDRESS_PROPERTY_ID.equals(id)) { | |
99 | return fTargetNode.getHostName(); | |
100 | } | |
06b9339e BH |
101 | if (TARGET_NODE_STATE_PROPERTY_ID.equals(id)) { |
102 | return fTargetNode.getTargetNodeState().name(); | |
103 | } | |
eb1bab5b BH |
104 | return null; |
105 | } | |
eb1bab5b | 106 | } |