Commit | Line | Data |
---|---|---|
12c155f5 FC |
1 | /******************************************************************************* |
2 | * Copyright (c) 2010 Ericsson | |
9a47bdf1 | 3 | * |
12c155f5 FC |
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 | |
9a47bdf1 | 8 | * |
12c155f5 FC |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.ui.project.model; | |
14 | ||
5a5c2fc7 FC |
15 | import java.util.Arrays; |
16 | ||
12c155f5 FC |
17 | import org.eclipse.core.resources.IFolder; |
18 | import org.eclipse.ui.views.properties.IPropertyDescriptor; | |
19 | import org.eclipse.ui.views.properties.IPropertySource2; | |
20 | import org.eclipse.ui.views.properties.TextPropertyDescriptor; | |
21 | ||
22 | /** | |
b544077e | 23 | * Implementation of the model element for the experiment folder. |
12c155f5 | 24 | * <p> |
b544077e BH |
25 | * @version 1.0 |
26 | * @author Francois Chouinard | |
9a47bdf1 | 27 | * |
12c155f5 FC |
28 | */ |
29 | public class TmfExperimentFolder extends TmfProjectModelElement implements IPropertySource2 { | |
30 | ||
31 | // ------------------------------------------------------------------------ | |
32 | // Constants | |
33 | // ------------------------------------------------------------------------ | |
b544077e BH |
34 | /** |
35 | * The name of the experiment folder. | |
36 | */ | |
12c155f5 FC |
37 | public static final String EXPER_FOLDER_NAME = "Experiments"; //$NON-NLS-1$ |
38 | ||
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$ | |
44 | ||
45 | private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName); | |
46 | private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath); | |
47 | private static final TextPropertyDescriptor sfLocationDescriptor = new TextPropertyDescriptor(sfLocation, sfLocation); | |
48 | ||
49 | private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor, sfLocationDescriptor }; | |
50 | ||
51 | static { | |
52 | sfNameDescriptor.setCategory(sfInfoCategory); | |
53 | sfPathDescriptor.setCategory(sfInfoCategory); | |
54 | sfLocationDescriptor.setCategory(sfInfoCategory); | |
55 | } | |
56 | ||
57 | // ------------------------------------------------------------------------ | |
58 | // Constructors | |
59 | // ------------------------------------------------------------------------ | |
60 | ||
b544077e | 61 | /** |
9a47bdf1 | 62 | * Constructor. |
b544077e BH |
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) | |
67 | */ | |
12c155f5 FC |
68 | public TmfExperimentFolder(String name, IFolder folder, TmfProjectElement parent) { |
69 | super(name, folder, parent); | |
70 | parent.addChild(this); | |
71 | } | |
72 | ||
73 | // ------------------------------------------------------------------------ | |
74 | // TmfProjectModelElement | |
75 | // ------------------------------------------------------------------------ | |
b544077e BH |
76 | /* |
77 | * (non-Javadoc) | |
78 | * @see org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement#getResource() | |
79 | */ | |
12c155f5 FC |
80 | @Override |
81 | public IFolder getResource() { | |
82 | return (IFolder) fResource; | |
83 | } | |
9a47bdf1 | 84 | |
b544077e BH |
85 | /* |
86 | * (non-Javadoc) | |
87 | * @see org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement#getProject() | |
88 | */ | |
12c155f5 FC |
89 | @Override |
90 | public TmfProjectElement getProject() { | |
91 | return (TmfProjectElement) getParent(); | |
92 | } | |
9a47bdf1 | 93 | |
b544077e BH |
94 | /* |
95 | * (non-Javadoc) | |
96 | * @see org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement#refresh() | |
97 | */ | |
12c155f5 FC |
98 | @Override |
99 | public void refresh() { | |
100 | TmfProjectElement project = (TmfProjectElement) getParent(); | |
101 | project.refresh(); | |
102 | } | |
103 | ||
b544077e | 104 | // ------------------------------------------------------------------------ |
be222f56 PT |
105 | // IPropertySource2 |
106 | // ------------------------------------------------------------------------ | |
b544077e BH |
107 | /* |
108 | * (non-Javadoc) | |
109 | * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue() | |
be222f56 PT |
110 | */ |
111 | @Override | |
112 | public Object getEditableValue() { | |
113 | return null; | |
114 | } | |
b544077e BH |
115 | /* |
116 | * (non-Javadoc) | |
117 | * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors() | |
be222f56 PT |
118 | */ |
119 | @Override | |
120 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
77fdc5df | 121 | return Arrays.copyOf(sfDescriptors, sfDescriptors.length); |
be222f56 | 122 | } |
9a47bdf1 | 123 | |
b544077e BH |
124 | /* |
125 | * (non-Javadoc) | |
126 | * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object) | |
be222f56 PT |
127 | */ |
128 | @Override | |
129 | public Object getPropertyValue(Object id) { | |
130 | ||
9a47bdf1 | 131 | if (sfName.equals(id)) { |
be222f56 | 132 | return getName(); |
9a47bdf1 | 133 | } |
be222f56 | 134 | |
9a47bdf1 | 135 | if (sfPath.equals(id)) { |
be222f56 | 136 | return getPath().toString(); |
9a47bdf1 | 137 | } |
be222f56 | 138 | |
9a47bdf1 | 139 | if (sfLocation.equals(id)) { |
be222f56 | 140 | return getLocation().toString(); |
9a47bdf1 | 141 | } |
be222f56 PT |
142 | |
143 | return null; | |
144 | } | |
145 | /* | |
b544077e BH |
146 | * (non-Javadoc) |
147 | * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object) | |
be222f56 PT |
148 | */ |
149 | @Override | |
150 | public void resetPropertyValue(Object id) { | |
151 | } | |
b544077e BH |
152 | /* |
153 | * (non-Javadoc) | |
154 | * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object) | |
be222f56 PT |
155 | */ |
156 | @Override | |
157 | public void setPropertyValue(Object id, Object value) { | |
158 | } | |
b544077e BH |
159 | /* |
160 | * (non-Javadoc) | |
161 | * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertyResettable(java.lang.Object) | |
be222f56 PT |
162 | */ |
163 | @Override | |
164 | public boolean isPropertyResettable(Object id) { | |
165 | return false; | |
166 | } | |
b544077e BH |
167 | /* |
168 | * (non-Javadoc) | |
169 | * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertySet(java.lang.Object) | |
be222f56 PT |
170 | */ |
171 | @Override | |
172 | public boolean isPropertySet(Object id) { | |
173 | return false; | |
174 | } | |
175 | ||
176 | } | |
12c155f5 | 177 |