1 /**********************************************************************
2 * Copyright (c) 2012, 2015 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
12 * Bernd Hufmann - Update to org.eclipse.remote API 2.0
13 **********************************************************************/
14 package org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.property
;
16 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
18 import org
.eclipse
.remote
.core
.IRemoteConnection
;
19 import org
.eclipse
.remote
.core
.IRemoteConnectionHostService
;
20 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
21 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TargetNodeComponent
;
22 import org
.eclipse
.tracecompass
.tmf
.ui
.properties
.ReadOnlyTextPropertyDescriptor
;
23 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
27 * Property source implementation for the target node component.
30 * @author Bernd Hufmann
32 public class TargetNodePropertySource
extends BasePropertySource
{
34 // ------------------------------------------------------------------------
36 // ------------------------------------------------------------------------
38 * The node name property ID.
40 public static final String TARGET_NODE_NAME_PROPERTY_ID
= "target.node.name"; //$NON-NLS-1$
42 * The node address property ID.
44 public static final String TARGET_NODE_ADDRESS_PROPERTY_ID
= "target.node.address"; //$NON-NLS-1$
46 * The state property ID.
48 public static final String TARGET_NODE_STATE_PROPERTY_ID
= "target.node.state"; //$NON-NLS-1$
50 * The node version property ID.
52 public static final String TARGET_NODE_VERSION_PROPERTY_ID
= "target.node.version"; //$NON-NLS-1$
55 * The node name property name.
57 public static final String TARGET_NODE_NAME_PROPERTY_NAME
= Messages
.TraceControl_HostNamePropertyName
;
59 * The node address property name.
61 public static final String TARGET_NODE_ADDRESS_PROPERTY_NAME
= Messages
.TraceControl_HostAddressPropertyName
;
63 * The state address property name.
65 public static final String TARGET_NODE_STATE_PROPERTY_NAME
= Messages
.TraceControl_StatePropertyName
;
67 * The node version property name.
69 public static final String TARGET_NODE_VERSION_PROPERTY_NAME
= Messages
.TraceControl_VersionPropertyName
;
72 * The name of the address for local host
74 private static final String LOCAL_CONNECTION_HOST_NAME
= "localhost"; //$NON-NLS-1$
76 // ------------------------------------------------------------------------
78 // ------------------------------------------------------------------------
80 * The node component which this property source is for.
82 private final TargetNodeComponent fTargetNode
;
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
89 * @param component - the node component
91 public TargetNodePropertySource(TargetNodeComponent component
) {
92 fTargetNode
= component
;
95 // ------------------------------------------------------------------------
97 // ------------------------------------------------------------------------
100 public IPropertyDescriptor
[] getPropertyDescriptors() {
101 return new IPropertyDescriptor
[] {
102 new ReadOnlyTextPropertyDescriptor(TARGET_NODE_NAME_PROPERTY_ID
, TARGET_NODE_NAME_PROPERTY_NAME
),
103 new ReadOnlyTextPropertyDescriptor(TARGET_NODE_ADDRESS_PROPERTY_ID
, TARGET_NODE_ADDRESS_PROPERTY_NAME
),
104 new ReadOnlyTextPropertyDescriptor(TARGET_NODE_STATE_PROPERTY_ID
, TARGET_NODE_STATE_PROPERTY_NAME
),
105 new ReadOnlyTextPropertyDescriptor(TARGET_NODE_VERSION_PROPERTY_ID
, TARGET_NODE_VERSION_PROPERTY_NAME
)};
109 public Object
getPropertyValue(Object id
) {
110 if(TARGET_NODE_NAME_PROPERTY_ID
.equals(id
)) {
111 return fTargetNode
.getName();
113 if (TARGET_NODE_ADDRESS_PROPERTY_ID
.equals(id
)) {
114 IRemoteConnection connection
= fTargetNode
.getRemoteSystemProxy().getRemoteConnection();
115 if (connection
.hasService(IRemoteConnectionHostService
.class)) {
116 IRemoteConnectionHostService service
= checkNotNull(connection
.getService(IRemoteConnectionHostService
.class));
117 return service
.getHostname();
119 return LOCAL_CONNECTION_HOST_NAME
;
121 if (TARGET_NODE_STATE_PROPERTY_ID
.equals(id
)) {
122 return fTargetNode
.getTargetNodeState().name();
124 if (TARGET_NODE_VERSION_PROPERTY_ID
.equals(id
)) {
125 return fTargetNode
.getNodeVersion();