Fix new errors due to automatic annotation of Class<T> types
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / property / TargetNodePropertySource.java
CommitLineData
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 14package org.eclipse.tracecompass.internal.lttng2.control.ui.views.property;
eb1bab5b 15
2f79cfbc
AM
16import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
17
18import org.eclipse.remote.core.IRemoteConnection;
533d0bc3 19import org.eclipse.remote.core.IRemoteConnectionHostService;
9bc60be7
AM
20import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
21import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
2bdf0193 22import org.eclipse.tracecompass.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
eb1bab5b 23import org.eclipse.ui.views.properties.IPropertyDescriptor;
eb1bab5b
BH
24
25/**
eb1bab5b
BH
26 * <p>
27 * Property source implementation for the target node component.
28 * </p>
cfe737e4 29 *
dbd4432d 30 * @author Bernd Hufmann
eb1bab5b 31 */
06b9339e 32public class TargetNodePropertySource extends BasePropertySource {
eb1bab5b
BH
33
34 // ------------------------------------------------------------------------
35 // Constants
36 // ------------------------------------------------------------------------
37 /**
38 * The node name property ID.
39 */
40 public static final String TARGET_NODE_NAME_PROPERTY_ID = "target.node.name"; //$NON-NLS-1$
41 /**
42 * The node address property ID.
43 */
44 public static final String TARGET_NODE_ADDRESS_PROPERTY_ID = "target.node.address"; //$NON-NLS-1$
06b9339e
BH
45 /**
46 * The state property ID.
47 */
48 public static final String TARGET_NODE_STATE_PROPERTY_ID = "target.node.state"; //$NON-NLS-1$
eb1bab5b 49 /**
cfe737e4
BH
50 * The node version property ID.
51 */
52 public static final String TARGET_NODE_VERSION_PROPERTY_ID = "target.node.version"; //$NON-NLS-1$
53
54 /**
55 * The node name property name.
eb1bab5b 56 */
06b9339e 57 public static final String TARGET_NODE_NAME_PROPERTY_NAME = Messages.TraceControl_HostNamePropertyName;
eb1bab5b
BH
58 /**
59 * The node address property name.
60 */
06b9339e
BH
61 public static final String TARGET_NODE_ADDRESS_PROPERTY_NAME = Messages.TraceControl_HostAddressPropertyName;
62 /**
63 * The state address property name.
64 */
65 public static final String TARGET_NODE_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
cfe737e4
BH
66 /**
67 * The node version property name.
68 */
69 public static final String TARGET_NODE_VERSION_PROPERTY_NAME = Messages.TraceControl_VersionPropertyName;
70
533d0bc3
BH
71 /**
72 * The name of the address for local host
73 */
74 private static final String LOCAL_CONNECTION_HOST_NAME = "localhost"; //$NON-NLS-1$
75
eb1bab5b
BH
76 // ------------------------------------------------------------------------
77 // Attributes
78 // ------------------------------------------------------------------------
79 /**
cfe737e4 80 * The node component which this property source is for.
eb1bab5b 81 */
06b9339e 82 private final TargetNodeComponent fTargetNode;
cfe737e4 83
eb1bab5b
BH
84 // ------------------------------------------------------------------------
85 // Constructors
86 // ------------------------------------------------------------------------
87 /**
88 * Constructor
89 * @param component - the node component
90 */
91 public TargetNodePropertySource(TargetNodeComponent component) {
92 fTargetNode = component;
93 }
cfe737e4 94
eb1bab5b
BH
95 // ------------------------------------------------------------------------
96 // Operations
97 // ------------------------------------------------------------------------
11252342 98
eb1bab5b
BH
99 @Override
100 public IPropertyDescriptor[] getPropertyDescriptors() {
101 return new IPropertyDescriptor[] {
5a7326dc
BH
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)};
eb1bab5b
BH
106 }
107
eb1bab5b
BH
108 @Override
109 public Object getPropertyValue(Object id) {
110 if(TARGET_NODE_NAME_PROPERTY_ID.equals(id)) {
111 return fTargetNode.getName();
112 }
113 if (TARGET_NODE_ADDRESS_PROPERTY_ID.equals(id)) {
2f79cfbc
AM
114 IRemoteConnection connection = fTargetNode.getRemoteSystemProxy().getRemoteConnection();
115 if (connection.hasService(IRemoteConnectionHostService.class)) {
116 IRemoteConnectionHostService service = checkNotNull(connection.getService(IRemoteConnectionHostService.class));
117 return service.getHostname();
533d0bc3
BH
118 }
119 return LOCAL_CONNECTION_HOST_NAME;
eb1bab5b 120 }
06b9339e
BH
121 if (TARGET_NODE_STATE_PROPERTY_ID.equals(id)) {
122 return fTargetNode.getTargetNodeState().name();
123 }
cfe737e4
BH
124 if (TARGET_NODE_VERSION_PROPERTY_ID.equals(id)) {
125 return fTargetNode.getNodeVersion();
126 }
eb1bab5b
BH
127 return null;
128 }
eb1bab5b 129}
This page took 0.116585 seconds and 5 git commands to generate.