Merge branch 'master' into lttng-kepler
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TmfExperimentFolder.java
1 /*******************************************************************************
2 * Copyright (c) 2010 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.project.model;
14
15 import java.util.Arrays;
16
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 /**
23 * Implementation of the model element for the experiment folder.
24 * <p>
25 * @version 1.0
26 * @author Francois Chouinard
27 *
28 */
29 public class TmfExperimentFolder extends TmfProjectModelElement implements IPropertySource2 {
30
31 // ------------------------------------------------------------------------
32 // Constants
33 // ------------------------------------------------------------------------
34 /**
35 * The name of the experiment folder.
36 */
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
61 /**
62 * Constructor.
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 */
68 public TmfExperimentFolder(String name, IFolder folder, TmfProjectElement parent) {
69 super(name, folder, parent);
70 parent.addChild(this);
71 }
72
73 // ------------------------------------------------------------------------
74 // TmfProjectModelElement
75 // ------------------------------------------------------------------------
76 /*
77 * (non-Javadoc)
78 * @see org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement#getResource()
79 */
80 @Override
81 public IFolder getResource() {
82 return (IFolder) fResource;
83 }
84
85 /*
86 * (non-Javadoc)
87 * @see org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement#getProject()
88 */
89 @Override
90 public TmfProjectElement getProject() {
91 return (TmfProjectElement) getParent();
92 }
93
94 /*
95 * (non-Javadoc)
96 * @see org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement#refresh()
97 */
98 @Override
99 public void refresh() {
100 TmfProjectElement project = (TmfProjectElement) getParent();
101 project.refresh();
102 }
103
104 // ------------------------------------------------------------------------
105 // IPropertySource2
106 // ------------------------------------------------------------------------
107 /*
108 * (non-Javadoc)
109 * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
110 */
111 @Override
112 public Object getEditableValue() {
113 return null;
114 }
115 /*
116 * (non-Javadoc)
117 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
118 */
119 @Override
120 public IPropertyDescriptor[] getPropertyDescriptors() {
121 return (sfDescriptors != null) ? Arrays.copyOf(sfDescriptors, sfDescriptors.length) : null;
122 }
123
124 /*
125 * (non-Javadoc)
126 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
127 */
128 @Override
129 public Object getPropertyValue(Object id) {
130
131 if (sfName.equals(id)) {
132 return getName();
133 }
134
135 if (sfPath.equals(id)) {
136 return getPath().toString();
137 }
138
139 if (sfLocation.equals(id)) {
140 return getLocation().toString();
141 }
142
143 return null;
144 }
145 /*
146 * (non-Javadoc)
147 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
148 */
149 @Override
150 public void resetPropertyValue(Object id) {
151 }
152 /*
153 * (non-Javadoc)
154 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
155 */
156 @Override
157 public void setPropertyValue(Object id, Object value) {
158 }
159 /*
160 * (non-Javadoc)
161 * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertyResettable(java.lang.Object)
162 */
163 @Override
164 public boolean isPropertyResettable(Object id) {
165 return false;
166 }
167 /*
168 * (non-Javadoc)
169 * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertySet(java.lang.Object)
170 */
171 @Override
172 public boolean isPropertySet(Object id) {
173 return false;
174 }
175
176 }
177
This page took 0.040396 seconds and 6 git commands to generate.