1 /**********************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
;
14 import java
.util
.ArrayList
;
15 import java
.util
.List
;
17 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.messages
.Messages
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceSessionComponent
;
19 import org
.eclipse
.linuxtools
.tmf
.ui
.properties
.ReadOnlyTextPropertyDescriptor
;
20 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
24 * Property source implementation for the trace session component.
27 * @author Bernd Hufmann
29 public class TraceSessionPropertySource
extends BasePropertySource
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 * The trace session name property ID.
37 public static final String TRACE_SESSION_NAME_PROPERTY_ID
= "trace.session.name"; //$NON-NLS-1$
39 * The trace session path property ID.
41 public static final String TRACE_SESSION_PATH_PROPERTY_ID
= "trace.session.path"; //$NON-NLS-1$
43 * The trace session state ID.
45 public static final String TRACE_SESSION_STATE_PROPERTY_ID
= "trace.session.state"; //$NON-NLS-1$
47 * The trace snapshot path property ID.
49 public static final String TRACE_SNAPSHOT_PATH_PROPERTY_ID
= "trace.snapshot.path"; //$NON-NLS-1$
51 * The snapshot name property.
53 public static final String TRACE_SNAPSHOT_NAME_PROPERTY_ID
= "trace.snapshot.name"; //$NON-NLS-1$
55 * The snapshot ID property.
57 public static final String TRACE_SNAPSHOT_ID_PROPERTY_ID
= "trace.snapshot.id"; //$NON-NLS-1$
60 * The trace session name property name.
62 public static final String TRACE_SESSION_NAME_PROPERTY_NAME
= Messages
.TraceControl_SessionNamePropertyName
;
64 * The trace session path property name.
66 public static final String TRACE_SESSION_PATH_PROPERTY_NAME
= Messages
.TraceControl_SessionPathPropertyName
;
68 * The trace session state property name.
70 public static final String TRACE_SESSION_STATE_PROPERTY_NAME
= Messages
.TraceControl_StatePropertyName
;
72 * The snapshot path property name.
74 public static final String TRACE_SNAPSHOT_PATH_PROPERTY_NAME
= Messages
.TraceControl_SnapshotPathPropertyName
;
76 * The trace snapshot name property name.
78 public static final String TRACE_SNAPSHOT_NAME_PROPERTY_NAME
= Messages
.TraceControl_SnapshotNamePropertyName
;
80 * The trace snapshot ID property name.
82 public static final String TRACE_SNAPSHOT_ID_PROPERTY_NAME
= Messages
.TraceControl_SnapshotIdPropertyName
;
85 // ------------------------------------------------------------------------
87 // ------------------------------------------------------------------------
90 * The session component which this property source is for.
92 private final TraceSessionComponent fSession
;
94 // ------------------------------------------------------------------------
96 // ------------------------------------------------------------------------
100 * @param component - the session component
102 public TraceSessionPropertySource(TraceSessionComponent component
) {
103 fSession
= component
;
106 // ------------------------------------------------------------------------
108 // ------------------------------------------------------------------------
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
));
120 list
.add(new ReadOnlyTextPropertyDescriptor(TRACE_SESSION_PATH_PROPERTY_ID
, TRACE_SESSION_PATH_PROPERTY_NAME
));
122 return(list
.toArray(new IPropertyDescriptor
[list
.size()]));
126 public Object
getPropertyValue(Object id
) {
127 if(TRACE_SESSION_NAME_PROPERTY_ID
.equals(id
)) {
128 return fSession
.getName();
130 if(TRACE_SESSION_PATH_PROPERTY_ID
.equals(id
)) {
131 return fSession
.getSessionPath();
133 if (TRACE_SESSION_STATE_PROPERTY_ID
.equals(id
)) {
134 return fSession
.getSessionState().name();
136 if (TRACE_SNAPSHOT_PATH_PROPERTY_ID
.equals(id
)) {
137 return (fSession
.isSnapshotSession() ? fSession
.getSnapshotInfo().getSnapshotPath() : ""); //$NON-NLS-1$
139 if (TRACE_SNAPSHOT_NAME_PROPERTY_ID
.equals(id
)) {
140 return (fSession
.isSnapshotSession() ? fSession
.getSnapshotInfo().getName() : ""); //$NON-NLS-1$
142 if (TRACE_SNAPSHOT_ID_PROPERTY_ID
.equals(id
)) {
143 return (fSession
.isSnapshotSession() ? fSession
.getSnapshotInfo().getId() : ""); //$NON-NLS-1$