gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.ui / src / org / eclipse / linuxtools / internal / lttng2 / control / ui / views / property / TraceSessionPropertySource.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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.control.ui.views.property;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages;
18 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
19 import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
20 import org.eclipse.ui.views.properties.IPropertyDescriptor;
21
22 /**
23 * <p>
24 * Property source implementation for the trace session component.
25 * </p>
26 *
27 * @author Bernd Hufmann
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$
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
59 /**
60 * The trace session name property name.
61 */
62 public static final String TRACE_SESSION_NAME_PROPERTY_NAME = Messages.TraceControl_SessionNamePropertyName;
63 /**
64 * The trace session path property name.
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;
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
84
85 // ------------------------------------------------------------------------
86 // Attributes
87 // ------------------------------------------------------------------------
88
89 /**
90 * The session component which this property source is for.
91 */
92 private final TraceSessionComponent fSession;
93
94 // ------------------------------------------------------------------------
95 // Constructors
96 // ------------------------------------------------------------------------
97
98 /**
99 * Constructor
100 * @param component - the session component
101 */
102 public TraceSessionPropertySource(TraceSessionComponent component) {
103 fSession = component;
104 }
105
106 // ------------------------------------------------------------------------
107 // Operations
108 // ------------------------------------------------------------------------
109
110 @Override
111 public IPropertyDescriptor[] getPropertyDescriptors() {
112 List<IPropertyDescriptor> list = new ArrayList<>();
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()]));
123 }
124
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 }
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 }
145 return null;
146 }
147 }
This page took 0.077132 seconds and 5 git commands to generate.