| 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 | **********************************************************************/ |
| 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property; |
| 13 | |
| 14 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; |
| 15 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent; |
| 16 | import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor; |
| 17 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
| 18 | |
| 19 | /** |
| 20 | * <p> |
| 21 | * Property source implementation for the target node component. |
| 22 | * </p> |
| 23 | * |
| 24 | * @author Bernd Hufmann |
| 25 | */ |
| 26 | public class TargetNodePropertySource extends BasePropertySource { |
| 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$ |
| 39 | /** |
| 40 | * The state property ID. |
| 41 | */ |
| 42 | public static final String TARGET_NODE_STATE_PROPERTY_ID = "target.node.state"; //$NON-NLS-1$ |
| 43 | /** |
| 44 | * The node version property ID. |
| 45 | */ |
| 46 | public static final String TARGET_NODE_VERSION_PROPERTY_ID = "target.node.version"; //$NON-NLS-1$ |
| 47 | |
| 48 | /** |
| 49 | * The node name property name. |
| 50 | */ |
| 51 | public static final String TARGET_NODE_NAME_PROPERTY_NAME = Messages.TraceControl_HostNamePropertyName; |
| 52 | /** |
| 53 | * The node address property name. |
| 54 | */ |
| 55 | public static final String TARGET_NODE_ADDRESS_PROPERTY_NAME = Messages.TraceControl_HostAddressPropertyName; |
| 56 | /** |
| 57 | * The state address property name. |
| 58 | */ |
| 59 | public static final String TARGET_NODE_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName; |
| 60 | /** |
| 61 | * The node version property name. |
| 62 | */ |
| 63 | public static final String TARGET_NODE_VERSION_PROPERTY_NAME = Messages.TraceControl_VersionPropertyName; |
| 64 | |
| 65 | // ------------------------------------------------------------------------ |
| 66 | // Attributes |
| 67 | // ------------------------------------------------------------------------ |
| 68 | /** |
| 69 | * The node component which this property source is for. |
| 70 | */ |
| 71 | private final TargetNodeComponent fTargetNode; |
| 72 | |
| 73 | // ------------------------------------------------------------------------ |
| 74 | // Constructors |
| 75 | // ------------------------------------------------------------------------ |
| 76 | /** |
| 77 | * Constructor |
| 78 | * @param component - the node component |
| 79 | */ |
| 80 | public TargetNodePropertySource(TargetNodeComponent component) { |
| 81 | fTargetNode = component; |
| 82 | } |
| 83 | |
| 84 | // ------------------------------------------------------------------------ |
| 85 | // Operations |
| 86 | // ------------------------------------------------------------------------ |
| 87 | /* |
| 88 | * (non-Javadoc) |
| 89 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors() |
| 90 | */ |
| 91 | @Override |
| 92 | public IPropertyDescriptor[] getPropertyDescriptors() { |
| 93 | return new IPropertyDescriptor[] { |
| 94 | new ReadOnlyTextPropertyDescriptor(TARGET_NODE_NAME_PROPERTY_ID, TARGET_NODE_NAME_PROPERTY_NAME), |
| 95 | new ReadOnlyTextPropertyDescriptor(TARGET_NODE_ADDRESS_PROPERTY_ID, TARGET_NODE_ADDRESS_PROPERTY_NAME), |
| 96 | new ReadOnlyTextPropertyDescriptor(TARGET_NODE_STATE_PROPERTY_ID, TARGET_NODE_STATE_PROPERTY_NAME), |
| 97 | new ReadOnlyTextPropertyDescriptor(TARGET_NODE_VERSION_PROPERTY_ID, TARGET_NODE_VERSION_PROPERTY_NAME)}; |
| 98 | } |
| 99 | |
| 100 | /* |
| 101 | * (non-Javadoc) |
| 102 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object) |
| 103 | */ |
| 104 | @Override |
| 105 | public Object getPropertyValue(Object id) { |
| 106 | if(TARGET_NODE_NAME_PROPERTY_ID.equals(id)) { |
| 107 | return fTargetNode.getName(); |
| 108 | } |
| 109 | if (TARGET_NODE_ADDRESS_PROPERTY_ID.equals(id)) { |
| 110 | return fTargetNode.getHostName(); |
| 111 | } |
| 112 | if (TARGET_NODE_STATE_PROPERTY_ID.equals(id)) { |
| 113 | return fTargetNode.getTargetNodeState().name(); |
| 114 | } |
| 115 | if (TARGET_NODE_VERSION_PROPERTY_ID.equals(id)) { |
| 116 | return fTargetNode.getNodeVersion(); |
| 117 | } |
| 118 | return null; |
| 119 | } |
| 120 | } |