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 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property; |
eb1bab5b | 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.TargetNodeComponent; |
eb1bab5b | 16 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
eb1bab5b BH |
17 | import org.eclipse.ui.views.properties.TextPropertyDescriptor; |
18 | ||
19 | /** | |
eb1bab5b BH |
20 | * <p> |
21 | * Property source implementation for the target node component. | |
22 | * </p> | |
dbd4432d BH |
23 | * |
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 BH |
43 | /** |
44 | * The node name property name. | |
45 | */ | |
06b9339e | 46 | public static final String TARGET_NODE_NAME_PROPERTY_NAME = Messages.TraceControl_HostNamePropertyName; |
eb1bab5b BH |
47 | /** |
48 | * The node address property name. | |
49 | */ | |
06b9339e BH |
50 | public static final String TARGET_NODE_ADDRESS_PROPERTY_NAME = Messages.TraceControl_HostAddressPropertyName; |
51 | /** | |
52 | * The state address property name. | |
53 | */ | |
54 | public static final String TARGET_NODE_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName; | |
eb1bab5b BH |
55 | |
56 | // ------------------------------------------------------------------------ | |
57 | // Attributes | |
58 | // ------------------------------------------------------------------------ | |
59 | /** | |
60 | * The node component which this property source is for. | |
61 | */ | |
06b9339e | 62 | private final TargetNodeComponent fTargetNode; |
eb1bab5b BH |
63 | |
64 | // ------------------------------------------------------------------------ | |
65 | // Constructors | |
66 | // ------------------------------------------------------------------------ | |
67 | /** | |
68 | * Constructor | |
69 | * @param component - the node component | |
70 | */ | |
71 | public TargetNodePropertySource(TargetNodeComponent component) { | |
72 | fTargetNode = component; | |
73 | } | |
74 | ||
75 | // ------------------------------------------------------------------------ | |
76 | // Operations | |
77 | // ------------------------------------------------------------------------ | |
78 | /* | |
79 | * (non-Javadoc) | |
115b4a01 | 80 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors() |
eb1bab5b BH |
81 | */ |
82 | @Override | |
83 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
84 | return new IPropertyDescriptor[] { | |
85 | new TextPropertyDescriptor(TARGET_NODE_NAME_PROPERTY_ID, TARGET_NODE_NAME_PROPERTY_NAME), | |
86 | new TextPropertyDescriptor(TARGET_NODE_ADDRESS_PROPERTY_ID, TARGET_NODE_ADDRESS_PROPERTY_NAME), | |
06b9339e | 87 | new TextPropertyDescriptor(TARGET_NODE_STATE_PROPERTY_ID, TARGET_NODE_STATE_PROPERTY_NAME)}; |
eb1bab5b BH |
88 | } |
89 | ||
90 | /* | |
91 | * (non-Javadoc) | |
115b4a01 | 92 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object) |
eb1bab5b BH |
93 | */ |
94 | @Override | |
95 | public Object getPropertyValue(Object id) { | |
96 | if(TARGET_NODE_NAME_PROPERTY_ID.equals(id)) { | |
97 | return fTargetNode.getName(); | |
98 | } | |
99 | if (TARGET_NODE_ADDRESS_PROPERTY_ID.equals(id)) { | |
100 | return fTargetNode.getHostName(); | |
101 | } | |
06b9339e BH |
102 | if (TARGET_NODE_STATE_PROPERTY_ID.equals(id)) { |
103 | return fTargetNode.getTargetNodeState().name(); | |
104 | } | |
eb1bab5b BH |
105 | return null; |
106 | } | |
eb1bab5b | 107 | } |