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: | |
080600d9 | 10 | * Bernd Hufmann - Initial API and implementation |
06b9339e | 11 | **********************************************************************/ |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property; |
06b9339e | 13 | |
589d0d33 BH |
14 | import java.util.ArrayList; |
15 | import java.util.List; | |
16 | ||
9315aeee | 17 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; |
115b4a01 | 18 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent; |
080600d9 | 19 | import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor; |
06b9339e | 20 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
06b9339e BH |
21 | |
22 | /** | |
06b9339e BH |
23 | * <p> |
24 | * Property source implementation for the trace session component. | |
25 | * </p> | |
5a7326dc | 26 | * |
dbd4432d | 27 | * @author Bernd Hufmann |
06b9339e BH |
28 | */ |
29 | public class TraceSessionPropertySource extends BasePropertySource { | |
30 | ||
31 | // ------------------------------------------------------------------------ | |
32 | // Constants | |
33 | // ------------------------------------------------------------------------ | |
34 | /** | |
35 | * The trace session name property ID. | |
36 | */ | |
37 | public static final String TRACE_SESSION_NAME_PROPERTY_ID = "trace.session.name"; //$NON-NLS-1$ | |
38 | /** | |
39 | * The trace session path property ID. | |
40 | */ | |
41 | public static final String TRACE_SESSION_PATH_PROPERTY_ID = "trace.session.path"; //$NON-NLS-1$ | |
42 | /** | |
43 | * The trace session state ID. | |
44 | */ | |
45 | public static final String TRACE_SESSION_STATE_PROPERTY_ID = "trace.session.state"; //$NON-NLS-1$ | |
589d0d33 BH |
46 | /** |
47 | * The trace snapshot path property ID. | |
48 | */ | |
49 | public static final String TRACE_SNAPSHOT_PATH_PROPERTY_ID = "trace.snapshot.path"; //$NON-NLS-1$ | |
50 | /** | |
51 | * The snapshot name property. | |
52 | */ | |
53 | public static final String TRACE_SNAPSHOT_NAME_PROPERTY_ID = "trace.snapshot.name"; //$NON-NLS-1$ | |
54 | /** | |
55 | * The snapshot ID property. | |
56 | */ | |
57 | public static final String TRACE_SNAPSHOT_ID_PROPERTY_ID = "trace.snapshot.id"; //$NON-NLS-1$ | |
58 | ||
06b9339e | 59 | /** |
5a7326dc | 60 | * The trace session name property name. |
06b9339e BH |
61 | */ |
62 | public static final String TRACE_SESSION_NAME_PROPERTY_NAME = Messages.TraceControl_SessionNamePropertyName; | |
63 | /** | |
5a7326dc | 64 | * The trace session path property name. |
06b9339e BH |
65 | */ |
66 | public static final String TRACE_SESSION_PATH_PROPERTY_NAME = Messages.TraceControl_SessionPathPropertyName; | |
67 | /** | |
68 | * The trace session state property name. | |
69 | */ | |
70 | public static final String TRACE_SESSION_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName; | |
589d0d33 BH |
71 | /** |
72 | * The snapshot path property name. | |
73 | */ | |
74 | public static final String TRACE_SNAPSHOT_PATH_PROPERTY_NAME = Messages.TraceControl_SnapshotPathPropertyName; | |
75 | /** | |
76 | * The trace snapshot name property name. | |
77 | */ | |
78 | public static final String TRACE_SNAPSHOT_NAME_PROPERTY_NAME = Messages.TraceControl_SnapshotNamePropertyName; | |
79 | /** | |
80 | * The trace snapshot ID property name. | |
81 | */ | |
82 | public static final String TRACE_SNAPSHOT_ID_PROPERTY_NAME = Messages.TraceControl_SnapshotIdPropertyName; | |
83 | ||
5a7326dc | 84 | |
06b9339e BH |
85 | // ------------------------------------------------------------------------ |
86 | // Attributes | |
87 | // ------------------------------------------------------------------------ | |
11252342 | 88 | |
06b9339e | 89 | /** |
5a7326dc | 90 | * The session component which this property source is for. |
06b9339e BH |
91 | */ |
92 | private final TraceSessionComponent fSession; | |
93 | ||
94 | // ------------------------------------------------------------------------ | |
95 | // Constructors | |
96 | // ------------------------------------------------------------------------ | |
11252342 | 97 | |
06b9339e BH |
98 | /** |
99 | * Constructor | |
100 | * @param component - the session component | |
101 | */ | |
102 | public TraceSessionPropertySource(TraceSessionComponent component) { | |
103 | fSession = component; | |
104 | } | |
5a7326dc | 105 | |
06b9339e BH |
106 | // ------------------------------------------------------------------------ |
107 | // Operations | |
108 | // ------------------------------------------------------------------------ | |
11252342 | 109 | |
06b9339e BH |
110 | @Override |
111 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
589d0d33 BH |
112 | List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor> (); |
113 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_NAME_PROPERTY_ID, TRACE_SESSION_NAME_PROPERTY_NAME)); | |
114 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_STATE_PROPERTY_ID, TRACE_SESSION_STATE_PROPERTY_NAME)); | |
115 | if (fSession.isSnapshotSession()) { | |
116 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SNAPSHOT_NAME_PROPERTY_ID, TRACE_SNAPSHOT_NAME_PROPERTY_NAME)); | |
117 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SNAPSHOT_PATH_PROPERTY_ID, TRACE_SNAPSHOT_PATH_PROPERTY_NAME)); | |
118 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SNAPSHOT_ID_PROPERTY_ID, TRACE_SNAPSHOT_ID_PROPERTY_NAME)); | |
119 | } else { | |
120 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_PATH_PROPERTY_ID, TRACE_SESSION_PATH_PROPERTY_NAME)); | |
121 | } | |
122 | return(list.toArray(new IPropertyDescriptor[list.size()])); | |
06b9339e BH |
123 | } |
124 | ||
06b9339e BH |
125 | @Override |
126 | public Object getPropertyValue(Object id) { | |
127 | if(TRACE_SESSION_NAME_PROPERTY_ID.equals(id)) { | |
128 | return fSession.getName(); | |
129 | } | |
130 | if(TRACE_SESSION_PATH_PROPERTY_ID.equals(id)) { | |
131 | return fSession.getSessionPath(); | |
132 | } | |
133 | if (TRACE_SESSION_STATE_PROPERTY_ID.equals(id)) { | |
134 | return fSession.getSessionState().name(); | |
135 | } | |
589d0d33 BH |
136 | if (TRACE_SNAPSHOT_PATH_PROPERTY_ID.equals(id)) { |
137 | return (fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getSnapshotPath() : ""); //$NON-NLS-1$ | |
138 | } | |
139 | if (TRACE_SNAPSHOT_NAME_PROPERTY_ID.equals(id)) { | |
140 | return (fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getName() : ""); //$NON-NLS-1$ | |
141 | } | |
142 | if (TRACE_SNAPSHOT_ID_PROPERTY_ID.equals(id)) { | |
143 | return (fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getId() : ""); //$NON-NLS-1$ | |
144 | } | |
06b9339e BH |
145 | return null; |
146 | } | |
147 | } |