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
1 /**********************************************************************
2 * Copyright (c) 2012, 2015 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 * 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;
15
16 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
17
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;
24
25 /**
26 * <p>
27 * Property source implementation for the target node component.
28 * </p>
29 *
30 * @author Bernd Hufmann
31 */
32 public class TargetNodePropertySource extends BasePropertySource {
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$
45 /**
46 * The state property ID.
47 */
48 public static final String TARGET_NODE_STATE_PROPERTY_ID = "target.node.state"; //$NON-NLS-1$
49 /**
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.
56 */
57 public static final String TARGET_NODE_NAME_PROPERTY_NAME = Messages.TraceControl_HostNamePropertyName;
58 /**
59 * The node address property name.
60 */
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;
66 /**
67 * The node version property name.
68 */
69 public static final String TARGET_NODE_VERSION_PROPERTY_NAME = Messages.TraceControl_VersionPropertyName;
70
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
76 // ------------------------------------------------------------------------
77 // Attributes
78 // ------------------------------------------------------------------------
79 /**
80 * The node component which this property source is for.
81 */
82 private final TargetNodeComponent fTargetNode;
83
84 // ------------------------------------------------------------------------
85 // Constructors
86 // ------------------------------------------------------------------------
87 /**
88 * Constructor
89 * @param component - the node component
90 */
91 public TargetNodePropertySource(TargetNodeComponent component) {
92 fTargetNode = component;
93 }
94
95 // ------------------------------------------------------------------------
96 // Operations
97 // ------------------------------------------------------------------------
98
99 @Override
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)};
106 }
107
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)) {
114 IRemoteConnection connection = fTargetNode.getRemoteSystemProxy().getRemoteConnection();
115 if (connection.hasService(IRemoteConnectionHostService.class)) {
116 IRemoteConnectionHostService service = checkNotNull(connection.getService(IRemoteConnectionHostService.class));
117 return service.getHostname();
118 }
119 return LOCAL_CONNECTION_HOST_NAME;
120 }
121 if (TARGET_NODE_STATE_PROPERTY_ID.equals(id)) {
122 return fTargetNode.getTargetNodeState().name();
123 }
124 if (TARGET_NODE_VERSION_PROPERTY_ID.equals(id)) {
125 return fTargetNode.getNodeVersion();
126 }
127 return null;
128 }
129 }
This page took 0.045372 seconds and 5 git commands to generate.