1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 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
.Arrays
;
17 import org
.eclipse
.core
.resources
.IFolder
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.util
.ReadOnlyTextPropertyDescriptor
;
19 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
20 import org
.eclipse
.ui
.views
.properties
.IPropertySource2
;
23 * Implementation of the model element for the experiment folder.
26 * @author Francois Chouinard
29 public class TmfExperimentFolder
extends TmfProjectModelElement
implements IPropertySource2
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 * The name of the experiment folder.
37 public static final String EXPER_FOLDER_NAME
= "Experiments"; //$NON-NLS-1$
39 // Property View stuff
40 private static final String sfInfoCategory
= "Info"; //$NON-NLS-1$
41 private static final String sfName
= "name"; //$NON-NLS-1$
42 private static final String sfPath
= "path"; //$NON-NLS-1$
43 private static final String sfLocation
= "location"; //$NON-NLS-1$
45 private static final ReadOnlyTextPropertyDescriptor sfNameDescriptor
= new ReadOnlyTextPropertyDescriptor(sfName
, sfName
);
46 private static final ReadOnlyTextPropertyDescriptor sfPathDescriptor
= new ReadOnlyTextPropertyDescriptor(sfPath
, sfPath
);
47 private static final ReadOnlyTextPropertyDescriptor sfLocationDescriptor
= new ReadOnlyTextPropertyDescriptor(sfLocation
, sfLocation
);
49 private static final IPropertyDescriptor
[] sfDescriptors
= { sfNameDescriptor
, sfPathDescriptor
, sfLocationDescriptor
};
52 sfNameDescriptor
.setCategory(sfInfoCategory
);
53 sfPathDescriptor
.setCategory(sfInfoCategory
);
54 sfLocationDescriptor
.setCategory(sfInfoCategory
);
57 // ------------------------------------------------------------------------
59 // ------------------------------------------------------------------------
63 * Creates a TmfExperimentFolder model element.
64 * @param name The name of the folder
65 * @param folder The folder reference
66 * @param parent The parent (project element)
68 public TmfExperimentFolder(String name
, IFolder folder
, TmfProjectElement parent
) {
69 super(name
, folder
, parent
);
70 parent
.addChild(this);
73 // ------------------------------------------------------------------------
74 // TmfProjectModelElement
75 // ------------------------------------------------------------------------
78 * @see org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement#getResource()
81 public IFolder
getResource() {
82 return (IFolder
) fResource
;
87 * @see org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement#getProject()
90 public TmfProjectElement
getProject() {
91 return (TmfProjectElement
) getParent();
96 * @see org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement#refresh()
99 public void refresh() {
100 TmfProjectElement project
= (TmfProjectElement
) getParent();
104 // ------------------------------------------------------------------------
106 // ------------------------------------------------------------------------
109 * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
112 public Object
getEditableValue() {
117 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
120 public IPropertyDescriptor
[] getPropertyDescriptors() {
121 return Arrays
.copyOf(sfDescriptors
, sfDescriptors
.length
);
126 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
129 public Object
getPropertyValue(Object id
) {
131 if (sfName
.equals(id
)) {
135 if (sfPath
.equals(id
)) {
136 return getPath().toString();
139 if (sfLocation
.equals(id
)) {
140 return getLocation().toString();
147 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
150 public void resetPropertyValue(Object id
) {
154 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
157 public void setPropertyValue(Object id
, Object value
) {
161 * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertyResettable(java.lang.Object)
164 public boolean isPropertyResettable(Object id
) {
169 * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertySet(java.lang.Object)
172 public boolean isPropertySet(Object id
) {