Commit | Line | Data |
---|---|---|
12c155f5 | 1 | /******************************************************************************* |
b544077e | 2 | * Copyright (c) 2010, 2011, 2012 Ericsson |
ce2388e0 | 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 | |
ce2388e0 | 8 | * |
12c155f5 FC |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
b544077e | 11 | * Bernd Hufmann - Added supplementary files handling |
12c155f5 FC |
12 | *******************************************************************************/ |
13 | ||
14 | package org.eclipse.linuxtools.tmf.ui.project.model; | |
15 | ||
5a5c2fc7 | 16 | import java.util.Arrays; |
12c155f5 FC |
17 | import java.util.HashMap; |
18 | import java.util.Map; | |
19 | ||
5e4bf87d | 20 | import org.eclipse.core.resources.IFolder; |
12c155f5 FC |
21 | import org.eclipse.core.resources.IResource; |
22 | import org.eclipse.core.runtime.CoreException; | |
23 | import org.eclipse.core.runtime.IConfigurationElement; | |
5e4bf87d | 24 | import org.eclipse.core.runtime.NullProgressMonitor; |
12c155f5 | 25 | import org.eclipse.core.runtime.Platform; |
8fd82db5 | 26 | import org.eclipse.linuxtools.internal.tmf.ui.Activator; |
d34665f9 FC |
27 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtEvent; |
28 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTrace; | |
29 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition; | |
30 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlEvent; | |
31 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace; | |
32 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition; | |
e12ecd30 | 33 | import org.eclipse.linuxtools.tmf.core.TmfCommonConstants; |
ce2388e0 | 34 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
6c13869b | 35 | import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; |
4bf17f4a | 36 | import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor; |
12c155f5 FC |
37 | import org.eclipse.ui.IActionFilter; |
38 | import org.eclipse.ui.views.properties.IPropertyDescriptor; | |
39 | import org.eclipse.ui.views.properties.IPropertySource2; | |
40 | import org.eclipse.ui.views.properties.TextPropertyDescriptor; | |
41 | ||
42 | /** | |
b544077e BH |
43 | * Implementation of trace model element representing a trace. It provides methods to instantiate |
44 | * <code>ITmfTrace</code> and <code>ITmfEvent</code> as well as editor ID from the trace type | |
45 | * extension definition. | |
46 | * | |
47 | * @version 1.0 | |
48 | * @author Francois Chouinard | |
12c155f5 FC |
49 | */ |
50 | public class TmfTraceElement extends TmfProjectModelElement implements IActionFilter, IPropertySource2 { | |
51 | ||
52 | // ------------------------------------------------------------------------ | |
53 | // Constants | |
54 | // ------------------------------------------------------------------------ | |
55 | ||
12c155f5 | 56 | // Other attributes |
b544077e BH |
57 | /** |
58 | * Bundle attribute name | |
59 | */ | |
12c155f5 | 60 | public static final String BUNDLE = "bundle"; //$NON-NLS-1$ |
b544077e BH |
61 | /** |
62 | * IsLinked attribute name. | |
63 | */ | |
12c155f5 FC |
64 | public static final String IS_LINKED = "isLinked"; //$NON-NLS-1$ |
65 | ||
66 | // Property View stuff | |
67 | private static final String sfInfoCategory = "Info"; //$NON-NLS-1$ | |
68 | private static final String sfName = "name"; //$NON-NLS-1$ | |
69 | private static final String sfPath = "path"; //$NON-NLS-1$ | |
70 | private static final String sfLocation = "location"; //$NON-NLS-1$ | |
71 | private static final String sfEventType = "type"; //$NON-NLS-1$ | |
72 | private static final String sfIsLinked = "linked"; //$NON-NLS-1$ | |
73 | ||
74 | private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName); | |
75 | private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath); | |
76 | private static final TextPropertyDescriptor sfLocationDescriptor = new TextPropertyDescriptor(sfLocation, sfLocation); | |
77 | private static final TextPropertyDescriptor sfTypeDescriptor = new TextPropertyDescriptor(sfEventType, sfEventType); | |
78 | private static final TextPropertyDescriptor sfIsLinkedDescriptor = new TextPropertyDescriptor(sfIsLinked, sfIsLinked); | |
79 | ||
80 | private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor, sfLocationDescriptor, | |
81 | sfTypeDescriptor, sfIsLinkedDescriptor }; | |
82 | ||
83 | static { | |
84 | sfNameDescriptor.setCategory(sfInfoCategory); | |
85 | sfPathDescriptor.setCategory(sfInfoCategory); | |
86 | sfLocationDescriptor.setCategory(sfInfoCategory); | |
87 | sfTypeDescriptor.setCategory(sfInfoCategory); | |
88 | sfIsLinkedDescriptor.setCategory(sfInfoCategory); | |
89 | } | |
5e4bf87d | 90 | |
12c155f5 FC |
91 | // ------------------------------------------------------------------------ |
92 | // Attributes | |
93 | // ------------------------------------------------------------------------ | |
94 | ||
95 | // This trace type ID as defined in plugin.xml | |
96 | private String fTraceTypeId = null; | |
97 | ||
98 | // ------------------------------------------------------------------------ | |
99 | // Static initialization | |
100 | // ------------------------------------------------------------------------ | |
101 | ||
102 | // The mapping of available trace type IDs to their corresponding configuration element | |
103 | private static final Map<String, IConfigurationElement> sfTraceTypeAttributes = new HashMap<String, IConfigurationElement>(); | |
104 | private static final Map<String, IConfigurationElement> sfTraceCategories = new HashMap<String, IConfigurationElement>(); | |
105 | ||
b544077e BH |
106 | /** |
107 | * Initialize statically at startup by getting extensions from the platform extension registry. | |
108 | */ | |
12c155f5 | 109 | public static void init() { |
4bf17f4a | 110 | IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfTraceType.TMF_TRACE_TYPE_ID); |
12c155f5 | 111 | for (IConfigurationElement ce : config) { |
4bf17f4a | 112 | String elementName = ce.getName(); |
113 | if (elementName.equals(TmfTraceType.TYPE_ELEM)) { | |
114 | String traceTypeId = ce.getAttribute(TmfTraceType.ID_ATTR); | |
12c155f5 | 115 | sfTraceTypeAttributes.put(traceTypeId, ce); |
4bf17f4a | 116 | } else if (elementName.equals(TmfTraceType.CATEGORY_ELEM)) { |
117 | String categoryId = ce.getAttribute(TmfTraceType.ID_ATTR); | |
12c155f5 FC |
118 | sfTraceCategories.put(categoryId, ce); |
119 | } | |
120 | } | |
121 | } | |
122 | ||
123 | // ------------------------------------------------------------------------ | |
124 | // Constructors | |
125 | // ------------------------------------------------------------------------ | |
b544077e BH |
126 | /** |
127 | * Constructor. | |
128 | * Creates trace model element under the trace folder. | |
129 | * @param name The name of trace | |
130 | * @param trace The trace resource. | |
131 | * @param parent The parent element (trace folder) | |
132 | */ | |
12c155f5 FC |
133 | public TmfTraceElement(String name, IResource trace, TmfTraceFolder parent) { |
134 | this(name, trace, (TmfProjectModelElement) parent); | |
135 | } | |
b544077e BH |
136 | /** |
137 | * Constructor. | |
138 | * Creates trace model element under the experiment folder. | |
139 | * @param name The name of trace | |
140 | * @param trace The trace resource. | |
141 | * @param parent The parent element (experiment folder) | |
142 | */ | |
12c155f5 FC |
143 | public TmfTraceElement(String name, IResource trace, TmfExperimentElement parent) { |
144 | this(name, trace, (TmfProjectModelElement) parent); | |
145 | } | |
146 | ||
147 | private TmfTraceElement(String name, IResource trace, TmfProjectModelElement parent) { | |
148 | super(name, trace, parent); | |
149 | parent.addChild(this); | |
150 | refreshTraceType(); | |
151 | } | |
152 | ||
153 | // ------------------------------------------------------------------------ | |
154 | // Operations | |
155 | // ------------------------------------------------------------------------ | |
b544077e BH |
156 | /** |
157 | * Returns the trace type ID. | |
158 | * @return trace type ID. | |
159 | */ | |
12c155f5 FC |
160 | public String getTraceType() { |
161 | return fTraceTypeId; | |
162 | } | |
163 | ||
b544077e BH |
164 | /** |
165 | * Refreshes the trace type filed by reading the trace type persistent property of the resource | |
166 | * referenece. | |
167 | */ | |
12c155f5 FC |
168 | public void refreshTraceType() { |
169 | try { | |
e12ecd30 | 170 | fTraceTypeId = getResource().getPersistentProperty(TmfCommonConstants.TRACETYPE); |
12c155f5 | 171 | } catch (CoreException e) { |
8fd82db5 | 172 | Activator.getDefault().logError("Error refreshing trace type pesistent property for trace " + getName(), e); //$NON-NLS-1$ |
12c155f5 FC |
173 | } |
174 | } | |
175 | ||
b544077e BH |
176 | /** |
177 | * Instantiate a <code>ITmfTrace</code> object based on the trace type and the corresponding extension. | |
178 | * | |
179 | * @return the <code>ITmfTrace</code> or <code>null</code> for an error | |
180 | */ | |
12c155f5 FC |
181 | public ITmfTrace<?> instantiateTrace() { |
182 | try { | |
e12ecd30 BH |
183 | |
184 | // make sure that supplementary folder exists | |
185 | refreshSupplementaryFolder(); | |
186 | ||
12c155f5 | 187 | if (fTraceTypeId != null) { |
4bf17f4a | 188 | if (fTraceTypeId.startsWith(CustomTxtTrace.class.getCanonicalName())) { |
189 | for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { | |
190 | if (fTraceTypeId.equals(CustomTxtTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ | |
191 | return new CustomTxtTrace(def); | |
192 | } | |
193 | } | |
194 | } | |
195 | if (fTraceTypeId.startsWith(CustomXmlTrace.class.getCanonicalName())) { | |
196 | for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { | |
197 | if (fTraceTypeId.equals(CustomXmlTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ | |
198 | return new CustomXmlTrace(def); | |
199 | } | |
200 | } | |
201 | } | |
12c155f5 | 202 | IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); |
4bf17f4a | 203 | ITmfTrace<?> trace = (ITmfTrace<?>) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR); |
12c155f5 FC |
204 | return trace; |
205 | } | |
206 | } catch (CoreException e) { | |
8fd82db5 | 207 | Activator.getDefault().logError("Error instantiating ITmfTrace object for trace " + getName(), e); //$NON-NLS-1$ |
12c155f5 FC |
208 | } |
209 | return null; | |
210 | } | |
211 | ||
b544077e BH |
212 | /** |
213 | * Instantiate a <code>ITmfEvent</code> object based on the trace type and the corresponding extension. | |
214 | * | |
215 | * @return the <code>ITmfEvent</code> or <code>null</code> for an error | |
216 | */ | |
ce2388e0 | 217 | public ITmfEvent instantiateEvent() { |
12c155f5 FC |
218 | try { |
219 | if (fTraceTypeId != null) { | |
4bf17f4a | 220 | if (fTraceTypeId.startsWith(CustomTxtTrace.class.getCanonicalName())) { |
221 | for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { | |
222 | if (fTraceTypeId.equals(CustomTxtTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ | |
223 | return new CustomTxtEvent(def); | |
224 | } | |
225 | } | |
226 | } | |
227 | if (fTraceTypeId.startsWith(CustomXmlTrace.class.getCanonicalName())) { | |
228 | for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { | |
229 | if (fTraceTypeId.equals(CustomXmlTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ | |
230 | return new CustomXmlEvent(def); | |
231 | } | |
232 | } | |
233 | } | |
12c155f5 | 234 | IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); |
ce2388e0 | 235 | ITmfEvent event = (ITmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR); |
12c155f5 FC |
236 | return event; |
237 | } | |
238 | } catch (CoreException e) { | |
8fd82db5 | 239 | Activator.getDefault().logError("Error instantiating ITmfEvent object for trace " + getName(), e); //$NON-NLS-1$ |
12c155f5 FC |
240 | } |
241 | return null; | |
242 | } | |
243 | ||
b544077e BH |
244 | /** |
245 | * Returns the optional editor ID from the trace type extension. | |
246 | * @return the editor ID or <code>null</code> if not defined. | |
247 | */ | |
12c155f5 FC |
248 | public String getEditorId() { |
249 | if (fTraceTypeId != null) { | |
4bf17f4a | 250 | if (fTraceTypeId.startsWith(CustomTxtTrace.class.getCanonicalName())) { |
251 | return TmfEventsEditor.ID; | |
252 | } | |
253 | if (fTraceTypeId.startsWith(CustomXmlTrace.class.getCanonicalName())) { | |
254 | return TmfEventsEditor.ID; | |
255 | } | |
12c155f5 | 256 | IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); |
4bf17f4a | 257 | IConfigurationElement[] defaultEditorCE = ce.getChildren(TmfTraceType.DEFAULT_EDITOR_ELEM); |
12c155f5 | 258 | if (defaultEditorCE.length == 1) { |
4bf17f4a | 259 | return defaultEditorCE[0].getAttribute(TmfTraceType.ID_ATTR); |
12c155f5 FC |
260 | } |
261 | } | |
262 | return null; | |
263 | } | |
e12ecd30 BH |
264 | |
265 | /** | |
266 | * Returns the <code>TmfTraceElement</code> located under the <code>TmfTracesFolder</code>. | |
267 | * | |
268 | * @return <code>this</code> if this element is under the <code>TmfTracesFolder</code> | |
269 | * else the corresponding <code>TmfTraceElement</code> if this element is under | |
270 | * <code>TmfExperimentElement</code>. | |
271 | */ | |
5e4bf87d | 272 | public TmfTraceElement getElementUnderTraceFolder() { |
e12ecd30 | 273 | |
5e4bf87d BH |
274 | // If trace is under an experiment, return original trace from the traces folder |
275 | if (getParent() instanceof TmfExperimentElement) { | |
276 | for (TmfTraceElement aTrace : getProject().getTracesFolder().getTraces()) { | |
277 | if (aTrace.getName().equals(getName())) { | |
278 | return aTrace; | |
279 | } | |
280 | } | |
281 | } | |
282 | return this; | |
283 | } | |
e12ecd30 BH |
284 | |
285 | /** | |
286 | * Deletes the trace specific supplementary folder. | |
287 | */ | |
288 | public void deleteSupplementaryFolder() { | |
289 | IFolder supplFolder = getTraceSupplementaryFolder(fResource.getName()); | |
290 | if (supplFolder.exists()) { | |
291 | try { | |
292 | supplFolder.delete(true, new NullProgressMonitor()); | |
293 | } catch (CoreException e) { | |
8fd82db5 | 294 | Activator.getDefault().logError("Error deleting supplementary folder " + supplFolder, e); //$NON-NLS-1$ |
5e4bf87d BH |
295 | } |
296 | } | |
297 | } | |
e12ecd30 BH |
298 | |
299 | /** | |
300 | * Renames the trace specific supplementary folder according to the new trace name. | |
301 | * | |
302 | * @param newTraceName The new trace name | |
303 | */ | |
304 | public void renameSupplementaryFolder(String newTraceName) { | |
305 | IFolder oldSupplFolder = getTraceSupplementaryFolder(fResource.getName()); | |
306 | IFolder newSupplFolder = getTraceSupplementaryFolder(newTraceName); | |
307 | ||
308 | // Rename supplementary folder | |
309 | if (oldSupplFolder.exists()) { | |
310 | try { | |
311 | oldSupplFolder.move(newSupplFolder.getFullPath(), true, new NullProgressMonitor()); | |
312 | } catch (CoreException e) { | |
8fd82db5 | 313 | Activator.getDefault().logError("Error renaming supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ |
b885a58c BH |
314 | } |
315 | } | |
b885a58c BH |
316 | } |
317 | ||
e12ecd30 BH |
318 | /** |
319 | * Copies the trace specific supplementary folder to the new trace name. | |
320 | * | |
321 | * @param newTraceName The new trace name | |
322 | */ | |
323 | public void copySupplementaryFolder(String newTraceName) { | |
324 | IFolder oldSupplFolder = getTraceSupplementaryFolder(fResource.getName()); | |
325 | IFolder newSupplFolder = getTraceSupplementaryFolder(newTraceName); | |
326 | ||
327 | // copy supplementary folder | |
328 | if (oldSupplFolder.exists()) { | |
329 | try { | |
330 | oldSupplFolder.copy(newSupplFolder.getFullPath(), true, new NullProgressMonitor()); | |
331 | } catch (CoreException e) { | |
8fd82db5 | 332 | Activator.getDefault().logError("Error renaming supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ |
b885a58c BH |
333 | } |
334 | } | |
335 | } | |
e12ecd30 BH |
336 | |
337 | /** | |
338 | * Copies the trace specific supplementary folder a new folder. | |
339 | * | |
340 | * @param destination The destination folder to copy to. | |
341 | */ | |
342 | public void copySupplementaryFolder(IFolder destination) { | |
343 | IFolder oldSupplFolder = getTraceSupplementaryFolder(fResource.getName()); | |
344 | ||
345 | // copy supplementary folder | |
346 | if (oldSupplFolder.exists()) { | |
347 | try { | |
348 | oldSupplFolder.copy(destination.getFullPath(), true, new NullProgressMonitor()); | |
349 | } catch (CoreException e) { | |
8fd82db5 | 350 | Activator.getDefault().logError("Error copying supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ |
b885a58c BH |
351 | } |
352 | } | |
b885a58c | 353 | } |
e12ecd30 | 354 | |
0f0d17bb | 355 | |
e12ecd30 BH |
356 | /** |
357 | * Refreshes the trace specific supplementary folder information. It creates the folder if not exists. | |
358 | * It sets the persistence property of the trace resource | |
359 | */ | |
360 | public void refreshSupplementaryFolder() { | |
361 | createSupplementaryDirectory(); | |
362 | } | |
363 | ||
364 | /** | |
365 | * Checks if supplementary resource exist or not. | |
366 | * | |
367 | * @return <code>true</code> if one or more files are under the trace supplementary folder | |
368 | */ | |
369 | public boolean hasSupplementaryResources() { | |
370 | IResource[] resources = getSupplementaryResources(); | |
371 | return (resources.length > 0); | |
0f0d17bb AM |
372 | } |
373 | ||
e12ecd30 BH |
374 | /** |
375 | * Returns the supplementary resources under the trace supplementary folder. | |
376 | * | |
377 | * @return array of resources under the trace supplementary folder. | |
378 | */ | |
379 | public IResource[] getSupplementaryResources() { | |
380 | IFolder supplFolder = getTraceSupplementaryFolder(fResource.getName()); | |
381 | if (supplFolder.exists()) { | |
382 | try { | |
383 | return supplFolder.members(); | |
384 | } catch (CoreException e) { | |
8fd82db5 | 385 | Activator.getDefault().logError("Error deleting supplementary folder " + supplFolder, e); //$NON-NLS-1$ |
e12ecd30 BH |
386 | } |
387 | } | |
388 | return new IResource[0]; | |
389 | } | |
390 | ||
391 | /** | |
392 | * Deletes the given resources. | |
393 | * | |
394 | * @param resources array of resources to delete. | |
395 | */ | |
396 | public void deleteSupplementaryResources(IResource[] resources) { | |
397 | ||
398 | for (int i = 0; i < resources.length; i++) { | |
399 | try { | |
400 | resources[i].delete(true, new NullProgressMonitor()); | |
401 | } catch (CoreException e) { | |
8fd82db5 | 402 | Activator.getDefault().logError("Error deleting supplementary resource " + resources[i], e); //$NON-NLS-1$ |
e12ecd30 BH |
403 | } |
404 | } | |
405 | } | |
406 | ||
407 | private void createSupplementaryDirectory() { | |
408 | IFolder supplFolder = getTraceSupplementaryFolder(fResource.getName()); | |
409 | if (!supplFolder.exists()) { | |
410 | try { | |
411 | supplFolder.create(true, true, new NullProgressMonitor()); | |
412 | } catch (CoreException e) { | |
8fd82db5 | 413 | Activator.getDefault().logError("Error creating resource supplementary file " + supplFolder, e); //$NON-NLS-1$ |
e12ecd30 BH |
414 | } |
415 | } | |
416 | ||
417 | try { | |
418 | fResource.setPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, supplFolder.getLocationURI().getPath()); | |
419 | } catch (CoreException e) { | |
8fd82db5 | 420 | Activator.getDefault().logError("Error setting persistant property " + TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, e); //$NON-NLS-1$ |
e12ecd30 BH |
421 | } |
422 | ||
423 | } | |
424 | ||
12c155f5 FC |
425 | // ------------------------------------------------------------------------ |
426 | // IActionFilter | |
427 | // ------------------------------------------------------------------------ | |
428 | ||
429 | @Override | |
430 | public boolean testAttribute(Object target, String name, String value) { | |
431 | if (name.equals(IS_LINKED)) { | |
432 | boolean isLinked = getResource().isLinked(); | |
433 | return Boolean.toString(isLinked).equals(value); | |
434 | } | |
435 | return false; | |
436 | } | |
437 | ||
438 | // ------------------------------------------------------------------------ | |
439 | // TmfTraceElement | |
440 | // ------------------------------------------------------------------------ | |
b544077e BH |
441 | /* |
442 | * (non-Javadoc) | |
443 | * @see org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement#getProject() | |
444 | */ | |
12c155f5 FC |
445 | @Override |
446 | public TmfProjectElement getProject() { | |
447 | if (getParent() instanceof TmfTraceFolder) { | |
448 | TmfTraceFolder folder = (TmfTraceFolder) getParent(); | |
449 | TmfProjectElement project = (TmfProjectElement) folder.getParent(); | |
450 | return project; | |
451 | } | |
452 | if (getParent() instanceof TmfExperimentElement) { | |
453 | TmfExperimentElement experiment = (TmfExperimentElement) getParent(); | |
454 | TmfExperimentFolder folder = (TmfExperimentFolder) experiment.getParent(); | |
455 | TmfProjectElement project = (TmfProjectElement) folder.getParent(); | |
456 | return project; | |
457 | } | |
458 | return null; | |
459 | } | |
460 | ||
461 | // ------------------------------------------------------------------------ | |
462 | // IPropertySource2 | |
463 | // ------------------------------------------------------------------------ | |
464 | ||
b544077e BH |
465 | /* |
466 | * (non-Javadoc) | |
467 | * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue() | |
468 | */ | |
12c155f5 FC |
469 | @Override |
470 | public Object getEditableValue() { | |
471 | return null; | |
472 | } | |
473 | ||
b544077e BH |
474 | /* |
475 | * (non-Javadoc) | |
476 | * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors() | |
477 | */ | |
12c155f5 FC |
478 | @Override |
479 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
5a5c2fc7 | 480 | return (sfDescriptors != null) ? Arrays.copyOf(sfDescriptors, sfDescriptors.length) : null; |
12c155f5 FC |
481 | } |
482 | ||
b544077e BH |
483 | /* |
484 | * (non-Javadoc) | |
485 | * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object) | |
486 | */ | |
12c155f5 FC |
487 | @Override |
488 | public Object getPropertyValue(Object id) { | |
489 | ||
ce2388e0 | 490 | if (sfName.equals(id)) { |
12c155f5 | 491 | return getName(); |
ce2388e0 | 492 | } |
12c155f5 | 493 | |
ce2388e0 | 494 | if (sfPath.equals(id)) { |
12c155f5 | 495 | return getPath().toString(); |
ce2388e0 | 496 | } |
12c155f5 | 497 | |
ce2388e0 | 498 | if (sfLocation.equals(id)) { |
12c155f5 | 499 | return getLocation().toString(); |
ce2388e0 | 500 | } |
12c155f5 | 501 | |
ce2388e0 | 502 | if (sfIsLinked.equals(id)) { |
12c155f5 | 503 | return Boolean.valueOf(getResource().isLinked()).toString(); |
ce2388e0 | 504 | } |
12c155f5 FC |
505 | |
506 | if (sfEventType.equals(id)) { | |
507 | if (fTraceTypeId != null) { | |
508 | IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); | |
4bf17f4a | 509 | return (ce != null) ? (getCategory(ce) + " : " + ce.getAttribute(TmfTraceType.NAME_ATTR)) : ""; //$NON-NLS-1$ //$NON-NLS-2$ |
12c155f5 FC |
510 | } |
511 | } | |
512 | ||
513 | return null; | |
514 | } | |
515 | ||
516 | private String getCategory(IConfigurationElement ce) { | |
4bf17f4a | 517 | String categoryId = ce.getAttribute(TmfTraceType.CATEGORY_ATTR); |
12c155f5 FC |
518 | if (categoryId != null) { |
519 | IConfigurationElement category = sfTraceCategories.get(categoryId); | |
4bf17f4a | 520 | if (category != null) { |
521 | return category.getAttribute(TmfTraceType.NAME_ATTR); | |
12c155f5 FC |
522 | } |
523 | } | |
524 | return "[no category]"; //$NON-NLS-1$ | |
525 | } | |
526 | ||
b544077e BH |
527 | /* |
528 | * (non-Javadoc) | |
529 | * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object) | |
530 | */ | |
12c155f5 FC |
531 | @Override |
532 | public void resetPropertyValue(Object id) { | |
533 | } | |
534 | ||
b544077e BH |
535 | /* |
536 | * (non-Javadoc) | |
537 | * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object) | |
538 | */ | |
12c155f5 FC |
539 | @Override |
540 | public void setPropertyValue(Object id, Object value) { | |
541 | } | |
542 | ||
b544077e BH |
543 | /* |
544 | * (non-Javadoc) | |
545 | * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertyResettable(java.lang.Object) | |
546 | */ | |
12c155f5 FC |
547 | @Override |
548 | public boolean isPropertyResettable(Object id) { | |
549 | return false; | |
550 | } | |
551 | ||
b544077e BH |
552 | /* |
553 | * (non-Javadoc) | |
554 | * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertySet(java.lang.Object) | |
555 | */ | |
12c155f5 FC |
556 | @Override |
557 | public boolean isPropertySet(Object id) { | |
558 | return false; | |
559 | } | |
560 | ||
561 | } |