| 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.lttng.ui.views.control.property; |
| 13 | |
| 14 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages; |
| 15 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent; |
| 16 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
| 17 | import org.eclipse.ui.views.properties.TextPropertyDescriptor; |
| 18 | |
| 19 | /** |
| 20 | * <b><u>TraceSessionPropertySource</u></b> |
| 21 | * <p> |
| 22 | * Property source implementation for the trace session component. |
| 23 | * </p> |
| 24 | */ |
| 25 | public class TraceSessionPropertySource extends BasePropertySource { |
| 26 | |
| 27 | // ------------------------------------------------------------------------ |
| 28 | // Constants |
| 29 | // ------------------------------------------------------------------------ |
| 30 | /** |
| 31 | * The trace session name property ID. |
| 32 | */ |
| 33 | public static final String TRACE_SESSION_NAME_PROPERTY_ID = "trace.session.name"; //$NON-NLS-1$ |
| 34 | /** |
| 35 | * The trace session path property ID. |
| 36 | */ |
| 37 | public static final String TRACE_SESSION_PATH_PROPERTY_ID = "trace.session.path"; //$NON-NLS-1$ |
| 38 | /** |
| 39 | * The trace session state ID. |
| 40 | */ |
| 41 | public static final String TRACE_SESSION_STATE_PROPERTY_ID = "trace.session.state"; //$NON-NLS-1$ |
| 42 | /** |
| 43 | * The trace session name property name. |
| 44 | */ |
| 45 | public static final String TRACE_SESSION_NAME_PROPERTY_NAME = Messages.TraceControl_SessionNamePropertyName; |
| 46 | /** |
| 47 | * The trace session path property name. |
| 48 | */ |
| 49 | public static final String TRACE_SESSION_PATH_PROPERTY_NAME = Messages.TraceControl_SessionPathPropertyName; |
| 50 | /** |
| 51 | * The trace session state property name. |
| 52 | */ |
| 53 | public static final String TRACE_SESSION_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName; |
| 54 | |
| 55 | // ------------------------------------------------------------------------ |
| 56 | // Attributes |
| 57 | // ------------------------------------------------------------------------ |
| 58 | /** |
| 59 | * The session component which this property source is for. |
| 60 | */ |
| 61 | private final TraceSessionComponent fSession; |
| 62 | |
| 63 | // ------------------------------------------------------------------------ |
| 64 | // Constructors |
| 65 | // ------------------------------------------------------------------------ |
| 66 | /** |
| 67 | * Constructor |
| 68 | * @param component - the session component |
| 69 | */ |
| 70 | public TraceSessionPropertySource(TraceSessionComponent component) { |
| 71 | fSession = component; |
| 72 | } |
| 73 | |
| 74 | // ------------------------------------------------------------------------ |
| 75 | // Operations |
| 76 | // ------------------------------------------------------------------------ |
| 77 | /* |
| 78 | * (non-Javadoc) |
| 79 | * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors() |
| 80 | */ |
| 81 | @Override |
| 82 | public IPropertyDescriptor[] getPropertyDescriptors() { |
| 83 | return new IPropertyDescriptor[] { |
| 84 | new TextPropertyDescriptor(TRACE_SESSION_NAME_PROPERTY_ID, TRACE_SESSION_NAME_PROPERTY_NAME), |
| 85 | new TextPropertyDescriptor(TRACE_SESSION_PATH_PROPERTY_ID, TRACE_SESSION_PATH_PROPERTY_NAME), |
| 86 | new TextPropertyDescriptor(TRACE_SESSION_STATE_PROPERTY_ID, TRACE_SESSION_STATE_PROPERTY_NAME)}; |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | * (non-Javadoc) |
| 91 | * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object) |
| 92 | */ |
| 93 | @Override |
| 94 | public Object getPropertyValue(Object id) { |
| 95 | if(TRACE_SESSION_NAME_PROPERTY_ID.equals(id)) { |
| 96 | return fSession.getName(); |
| 97 | } |
| 98 | if(TRACE_SESSION_PATH_PROPERTY_ID.equals(id)) { |
| 99 | return fSession.getSessionPath(); |
| 100 | } |
| 101 | if (TRACE_SESSION_STATE_PROPERTY_ID.equals(id)) { |
| 102 | return fSession.getSessionState().name(); |
| 103 | } |
| 104 | return null; |
| 105 | } |
| 106 | } |