Commit | Line | Data |
---|---|---|
06b9339e | 1 | /********************************************************************** |
11252342 | 2 | * Copyright (c) 2012, 2013 Ericsson |
5a7326dc | 3 | * |
06b9339e 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 | |
5a7326dc BH |
8 | * |
9 | * Contributors: | |
06b9339e BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property; |
06b9339e | 13 | |
9315aeee | 14 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; |
115b4a01 | 15 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent; |
5a7326dc | 16 | import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor; |
06b9339e | 17 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
06b9339e BH |
18 | |
19 | /** | |
06b9339e BH |
20 | * <p> |
21 | * Property source implementation for the trace session component. | |
22 | * </p> | |
5a7326dc | 23 | * |
dbd4432d | 24 | * @author Bernd Hufmann |
06b9339e BH |
25 | */ |
26 | public class TraceSessionPropertySource extends BasePropertySource { | |
27 | ||
28 | // ------------------------------------------------------------------------ | |
29 | // Constants | |
30 | // ------------------------------------------------------------------------ | |
31 | /** | |
32 | * The trace session name property ID. | |
33 | */ | |
34 | public static final String TRACE_SESSION_NAME_PROPERTY_ID = "trace.session.name"; //$NON-NLS-1$ | |
35 | /** | |
36 | * The trace session path property ID. | |
37 | */ | |
38 | public static final String TRACE_SESSION_PATH_PROPERTY_ID = "trace.session.path"; //$NON-NLS-1$ | |
39 | /** | |
40 | * The trace session state ID. | |
41 | */ | |
42 | public static final String TRACE_SESSION_STATE_PROPERTY_ID = "trace.session.state"; //$NON-NLS-1$ | |
43 | /** | |
5a7326dc | 44 | * The trace session name property name. |
06b9339e BH |
45 | */ |
46 | public static final String TRACE_SESSION_NAME_PROPERTY_NAME = Messages.TraceControl_SessionNamePropertyName; | |
47 | /** | |
5a7326dc | 48 | * The trace session path property name. |
06b9339e BH |
49 | */ |
50 | public static final String TRACE_SESSION_PATH_PROPERTY_NAME = Messages.TraceControl_SessionPathPropertyName; | |
51 | /** | |
52 | * The trace session state property name. | |
53 | */ | |
54 | public static final String TRACE_SESSION_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName; | |
5a7326dc | 55 | |
06b9339e BH |
56 | // ------------------------------------------------------------------------ |
57 | // Attributes | |
58 | // ------------------------------------------------------------------------ | |
11252342 | 59 | |
06b9339e | 60 | /** |
5a7326dc | 61 | * The session component which this property source is for. |
06b9339e BH |
62 | */ |
63 | private final TraceSessionComponent fSession; | |
64 | ||
65 | // ------------------------------------------------------------------------ | |
66 | // Constructors | |
67 | // ------------------------------------------------------------------------ | |
11252342 | 68 | |
06b9339e BH |
69 | /** |
70 | * Constructor | |
71 | * @param component - the session component | |
72 | */ | |
73 | public TraceSessionPropertySource(TraceSessionComponent component) { | |
74 | fSession = component; | |
75 | } | |
5a7326dc | 76 | |
06b9339e BH |
77 | // ------------------------------------------------------------------------ |
78 | // Operations | |
79 | // ------------------------------------------------------------------------ | |
11252342 | 80 | |
06b9339e BH |
81 | @Override |
82 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
83 | return new IPropertyDescriptor[] { | |
5a7326dc BH |
84 | new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_NAME_PROPERTY_ID, TRACE_SESSION_NAME_PROPERTY_NAME), |
85 | new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_PATH_PROPERTY_ID, TRACE_SESSION_PATH_PROPERTY_NAME), | |
86 | new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_STATE_PROPERTY_ID, TRACE_SESSION_STATE_PROPERTY_NAME)}; | |
06b9339e BH |
87 | } |
88 | ||
06b9339e BH |
89 | @Override |
90 | public Object getPropertyValue(Object id) { | |
91 | if(TRACE_SESSION_NAME_PROPERTY_ID.equals(id)) { | |
92 | return fSession.getName(); | |
93 | } | |
94 | if(TRACE_SESSION_PATH_PROPERTY_ID.equals(id)) { | |
95 | return fSession.getSessionPath(); | |
96 | } | |
97 | if (TRACE_SESSION_STATE_PROPERTY_ID.equals(id)) { | |
98 | return fSession.getSessionState().name(); | |
99 | } | |
100 | return null; | |
101 | } | |
102 | } |