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