1 /*******************************************************************************
2 * Copyright (c) 2010, 2012 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
;
15 import java
.util
.ArrayList
;
16 import java
.util
.Arrays
;
17 import java
.util
.List
;
19 import org
.eclipse
.core
.resources
.IFolder
;
20 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
21 import org
.eclipse
.ui
.views
.properties
.IPropertySource2
;
22 import org
.eclipse
.ui
.views
.properties
.TextPropertyDescriptor
;
25 * Implementation of TMF Experiment Model Element.
28 * @author Francois Chouinard
31 public class TmfExperimentElement
extends TmfProjectModelElement
implements IPropertySource2
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
37 // Property View stuff
38 private static final String sfInfoCategory
= "Info"; //$NON-NLS-1$
39 private static final String sfName
= "name"; //$NON-NLS-1$
40 private static final String sfPath
= "path"; //$NON-NLS-1$
41 private static final String sfLocation
= "location"; //$NON-NLS-1$
43 private static final TextPropertyDescriptor sfNameDescriptor
= new TextPropertyDescriptor(sfName
, sfName
);
44 private static final TextPropertyDescriptor sfPathDescriptor
= new TextPropertyDescriptor(sfPath
, sfPath
);
45 private static final TextPropertyDescriptor sfLocationDescriptor
= new TextPropertyDescriptor(sfLocation
,
48 private static final IPropertyDescriptor
[] sfDescriptors
= { sfNameDescriptor
, sfPathDescriptor
,
49 sfLocationDescriptor
};
52 sfNameDescriptor
.setCategory(sfInfoCategory
);
53 sfPathDescriptor
.setCategory(sfInfoCategory
);
54 sfLocationDescriptor
.setCategory(sfInfoCategory
);
57 // ------------------------------------------------------------------------
59 // ------------------------------------------------------------------------
62 * @param name The name of the experiment
63 * @param folder The folder reference
64 * @param parent The experiment folder reference.
66 public TmfExperimentElement(String name
, IFolder folder
, TmfExperimentFolder parent
) {
67 super(name
, folder
, parent
);
68 parent
.addChild(this);
71 // ------------------------------------------------------------------------
72 // TmfProjectModelElement
73 // ------------------------------------------------------------------------
77 * @see org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement#getResource()
80 public IFolder
getResource() {
81 return (IFolder
) fResource
;
86 * @see org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement#getProject()
89 public TmfProjectElement
getProject() {
90 return (TmfProjectElement
) getParent().getParent();
93 // ------------------------------------------------------------------------
95 // ------------------------------------------------------------------------
97 * Returns a list of TmfTraceElements contained in this experiment.
98 * @return a list of TmfTraceElements
100 public List
<TmfTraceElement
> getTraces() {
101 List
<ITmfProjectModelElement
> children
= getChildren();
102 List
<TmfTraceElement
> traces
= new ArrayList
<TmfTraceElement
>();
103 for (ITmfProjectModelElement child
: children
) {
104 if (child
instanceof TmfTraceElement
) {
105 traces
.add((TmfTraceElement
) child
);
111 // ------------------------------------------------------------------------
113 // ------------------------------------------------------------------------
117 * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
120 public Object
getEditableValue() {
126 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
129 public IPropertyDescriptor
[] getPropertyDescriptors() {
130 return (sfDescriptors
!= null) ? Arrays
.copyOf(sfDescriptors
, sfDescriptors
.length
) : null;
135 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
138 public Object
getPropertyValue(Object id
) {
140 if (sfName
.equals(id
))
143 if (sfPath
.equals(id
))
144 return getPath().toString();
146 if (sfLocation
.equals(id
))
147 return getLocation().toString();
154 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
157 public void resetPropertyValue(Object id
) {
162 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
165 public void setPropertyValue(Object id
, Object value
) {
170 * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertyResettable(java.lang.Object)
173 public boolean isPropertyResettable(Object id
) {
179 * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertySet(java.lang.Object)
182 public boolean isPropertySet(Object id
) {