tmf: Show all trace analysis and views under the experiment
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / project / model / TmfExperimentElement.java
CommitLineData
12c155f5 1/*******************************************************************************
58ffe079 2 * Copyright (c) 2010, 2015 Ericsson, École Polytechnique de Montréal
c4c81d91 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
c4c81d91 8 *
12c155f5
FC
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
beb19106 11 * Geneviève Bastien - Copied code to add/remove traces in this class
a72a6830 12 * Patrick Tasse - Close editors to release resources
8f5221c2 13 * Geneviève Bastien - Experiment instantiated with trace type
12c155f5
FC
14 *******************************************************************************/
15
2bdf0193 16package org.eclipse.tracecompass.tmf.ui.project.model;
12c155f5
FC
17
18import java.util.ArrayList;
5a5c2fc7 19import java.util.Arrays;
dca8b422
BH
20import java.util.Collections;
21import java.util.Comparator;
f537c959 22import java.util.HashMap;
12c155f5 23import java.util.List;
beb19106 24import java.util.Map;
3a31ae77 25import java.util.stream.Collectors;
12c155f5 26
339d539c 27import org.eclipse.core.resources.IContainer;
c4c81d91 28import org.eclipse.core.resources.IFile;
12c155f5 29import org.eclipse.core.resources.IFolder;
c4c81d91 30import org.eclipse.core.resources.IResource;
339d539c
PT
31import org.eclipse.core.resources.IResourceProxy;
32import org.eclipse.core.resources.IResourceProxyVisitor;
beb19106
GB
33import org.eclipse.core.resources.IWorkspace;
34import org.eclipse.core.resources.ResourcesPlugin;
c4c81d91 35import org.eclipse.core.runtime.CoreException;
8f5221c2 36import org.eclipse.core.runtime.IConfigurationElement;
beb19106 37import org.eclipse.core.runtime.IPath;
977ca87f 38import org.eclipse.core.runtime.IStatus;
8f5221c2 39import org.eclipse.core.runtime.InvalidRegistryObjectException;
339d539c 40import org.eclipse.core.runtime.NullProgressMonitor;
8f5221c2 41import org.eclipse.core.runtime.Platform;
a485bc7f 42import org.eclipse.core.runtime.Status;
dff70ccd 43import org.eclipse.jdt.annotation.NonNull;
8f5221c2 44import org.eclipse.osgi.util.NLS;
dff70ccd 45import org.eclipse.swt.graphics.Image;
ea01e5a2 46import org.eclipse.swt.widgets.Display;
2bdf0193 47import org.eclipse.tracecompass.internal.tmf.ui.Activator;
58ffe079 48import org.eclipse.tracecompass.internal.tmf.ui.editors.ITmfEventsEditorConstants;
2bdf0193 49import org.eclipse.tracecompass.tmf.core.TmfCommonConstants;
ff7b95a5
GB
50import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper;
51import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisManager;
2bdf0193
AM
52import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType;
53import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper;
ff7b95a5 54import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
5c5fa260 55import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment;
2bdf0193
AM
56import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor;
57import org.eclipse.tracecompass.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
12c155f5
FC
58import org.eclipse.ui.views.properties.IPropertyDescriptor;
59import org.eclipse.ui.views.properties.IPropertySource2;
12c155f5
FC
60
61/**
b544077e 62 * Implementation of TMF Experiment Model Element.
12c155f5 63 * <p>
dc62dbee 64 *
b544077e
BH
65 * @version 1.0
66 * @author Francois Chouinard
c4c81d91 67 *
12c155f5 68 */
16036bc2 69public class TmfExperimentElement extends TmfCommonProjectElement implements IPropertySource2 {
12c155f5
FC
70
71 // ------------------------------------------------------------------------
72 // Constants
73 // ------------------------------------------------------------------------
74
75 // Property View stuff
067cd9de
BH
76 private static final String INFO_CATEGORY = "Info"; //$NON-NLS-1$
77 private static final String NAME = "name"; //$NON-NLS-1$
78 private static final String PATH = "path"; //$NON-NLS-1$
79 private static final String LOCATION = "location"; //$NON-NLS-1$
80 private static final String FOLDER_SUFFIX = "_exp"; //$NON-NLS-1$
81 private static final String EXPERIMENT_TYPE = "type"; //$NON-NLS-1$
12ec416d 82 private static final String EXPERIMENT_TYPE_ID = "type ID"; //$NON-NLS-1$
067cd9de
BH
83
84 private static final ReadOnlyTextPropertyDescriptor NAME_DESCRIPTOR = new ReadOnlyTextPropertyDescriptor(NAME, NAME);
85 private static final ReadOnlyTextPropertyDescriptor PATH_DESCRIPTOR = new ReadOnlyTextPropertyDescriptor(PATH, PATH);
86 private static final ReadOnlyTextPropertyDescriptor LOCATION_DESCRIPTOR = new ReadOnlyTextPropertyDescriptor(LOCATION,
87 LOCATION);
88 private static final ReadOnlyTextPropertyDescriptor TYPE_DESCRIPTOR = new ReadOnlyTextPropertyDescriptor(EXPERIMENT_TYPE, EXPERIMENT_TYPE);
12ec416d 89 private static final ReadOnlyTextPropertyDescriptor TYPE_ID_DESCRIPTOR = new ReadOnlyTextPropertyDescriptor(EXPERIMENT_TYPE_ID, EXPERIMENT_TYPE_ID);
067cd9de
BH
90
91 private static final IPropertyDescriptor[] DESCRIPTORS = { NAME_DESCRIPTOR, PATH_DESCRIPTOR,
12ec416d 92 LOCATION_DESCRIPTOR, TYPE_DESCRIPTOR, TYPE_ID_DESCRIPTOR };
12c155f5
FC
93
94 static {
067cd9de
BH
95 NAME_DESCRIPTOR.setCategory(INFO_CATEGORY);
96 PATH_DESCRIPTOR.setCategory(INFO_CATEGORY);
97 LOCATION_DESCRIPTOR.setCategory(INFO_CATEGORY);
98 TYPE_DESCRIPTOR.setCategory(INFO_CATEGORY);
12ec416d 99 TYPE_ID_DESCRIPTOR.setCategory(INFO_CATEGORY);
12c155f5
FC
100 }
101
8f5221c2
GB
102 // The mapping of available trace type IDs to their corresponding
103 // configuration element
067cd9de
BH
104 private static final Map<String, IConfigurationElement> TRACE_TYPE_ATTRIBUTES = new HashMap<>();
105 private static final Map<String, IConfigurationElement> TRACE_TYPE_UI_ATTRIBUTES = new HashMap<>();
106 private static final Map<String, IConfigurationElement> TRACE_CATEGORIES = new HashMap<>();
8f5221c2
GB
107
108 // ------------------------------------------------------------------------
109 // Static initialization
110 // ------------------------------------------------------------------------
111
112 /**
113 * Initialize statically at startup by getting extensions from the platform
114 * extension registry.
8f5221c2
GB
115 */
116 public static void init() {
117 IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfTraceType.TMF_TRACE_TYPE_ID);
118 for (IConfigurationElement ce : config) {
119 String elementName = ce.getName();
120 if (elementName.equals(TmfTraceType.EXPERIMENT_ELEM)) {
121 String traceTypeId = ce.getAttribute(TmfTraceType.ID_ATTR);
067cd9de 122 TRACE_TYPE_ATTRIBUTES.put(traceTypeId, ce);
8f5221c2
GB
123 } else if (elementName.equals(TmfTraceType.CATEGORY_ELEM)) {
124 String categoryId = ce.getAttribute(TmfTraceType.ID_ATTR);
067cd9de 125 TRACE_CATEGORIES.put(categoryId, ce);
8f5221c2
GB
126 }
127 }
128
129 /*
130 * Read the corresponding tmf.ui "tracetypeui" extension point for this
131 * trace type, if it exists.
132 */
133 config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfTraceTypeUIUtils.TMF_TRACE_TYPE_UI_ID);
134 for (IConfigurationElement ce : config) {
135 String elemName = ce.getName();
136 if (TmfTraceTypeUIUtils.EXPERIMENT_ELEM.equals(elemName)) {
137 String traceType = ce.getAttribute(TmfTraceTypeUIUtils.TRACETYPE_ATTR);
067cd9de 138 TRACE_TYPE_UI_ATTRIBUTES.put(traceType, ce);
8f5221c2
GB
139 }
140 }
141 }
c4c81d91 142
12c155f5
FC
143 // ------------------------------------------------------------------------
144 // Constructors
145 // ------------------------------------------------------------------------
b544077e 146 /**
c4c81d91 147 * Constructor
dc62dbee
CB
148 *
149 * @param name
150 * The name of the experiment
151 * @param folder
152 * The folder reference
153 * @param parent
154 * The experiment folder reference.
b544077e 155 */
12c155f5
FC
156 public TmfExperimentElement(String name, IFolder folder, TmfExperimentFolder parent) {
157 super(name, folder, parent);
12c155f5
FC
158 }
159
160 // ------------------------------------------------------------------------
161 // TmfProjectModelElement
162 // ------------------------------------------------------------------------
163
164 @Override
165 public IFolder getResource() {
b3e4798c 166 return (IFolder) super.getResource();
12c155f5
FC
167 }
168
b3e4798c
AM
169 /**
170 * @since 2.0
171 */
f537c959 172 @Override
b3e4798c 173 protected void refreshChildren() {
f537c959
PT
174 IFolder folder = getResource();
175
8f5221c2 176 /* Update the trace children of this experiment */
f537c959
PT
177 // Get the children from the model
178 Map<String, ITmfProjectModelElement> childrenMap = new HashMap<>();
339d539c
PT
179 for (TmfTraceElement trace : getTraces()) {
180 childrenMap.put(trace.getElementPath(), trace);
f537c959
PT
181 }
182
339d539c
PT
183 List<IResource> members = getTraceResources();
184 for (IResource resource : members) {
185 String name = resource.getName();
186 String elementPath = resource.getFullPath().makeRelativeTo(folder.getFullPath()).toString();
187 ITmfProjectModelElement element = childrenMap.get(elementPath);
188 if (element instanceof TmfTraceElement) {
189 childrenMap.remove(elementPath);
190 } else {
191 element = new TmfTraceElement(name, resource, this);
b3e4798c 192 addChild(element);
f537c959 193 }
f537c959
PT
194 }
195
196 // Cleanup dangling children from the model
197 for (ITmfProjectModelElement danglingChild : childrenMap.values()) {
198 removeChild(danglingChild);
199 }
8f5221c2 200
8f5221c2 201 /* Update the analysis under this experiment */
9928ddeb 202 super.refreshChildren();
ff7b95a5
GB
203
204 /*
205 * If the experiment is opened, add any analysis that was not added by
206 * the parent if it is available with the experiment
207 */
208 ITmfTrace experiment = getTrace();
209 if (experiment == null) {
210 return;
211 }
5c727157
AM
212
213 /* super.refreshChildren() above should have set this */
3a31ae77
BH
214 TmfViewsElement viewsElement = getChildElementViews();
215 if (viewsElement == null) {
216 return;
217 }
5c727157 218
ff7b95a5
GB
219 Map<String, TmfAnalysisElement> analysisMap = new HashMap<>();
220 for (TmfAnalysisElement analysis : getAvailableAnalysis()) {
221 analysisMap.put(analysis.getAnalysisId(), analysis);
3a31ae77 222 analysis.refreshChildren();
ff7b95a5
GB
223 }
224 for (IAnalysisModuleHelper module : TmfAnalysisManager.getAnalysisModules().values()) {
225 if (!analysisMap.containsKey(module.getId()) && module.appliesToExperiment() && (experiment.getAnalysisModule(module.getId()) != null)) {
b3e4798c 226 IFolder newresource = ResourcesPlugin.getWorkspace().getRoot().getFolder(getResource().getFullPath().append(module.getId()));
5c727157
AM
227 TmfAnalysisElement analysis = new TmfAnalysisElement(module.getName(), newresource, viewsElement, module);
228 viewsElement.addChild(analysis);
ff7b95a5
GB
229 analysis.refreshChildren();
230 analysisMap.put(module.getId(), analysis);
231 }
232 }
f537c959
PT
233 }
234
3a31ae77
BH
235 @Override
236 public List<TmfAnalysisElement> getChildrenAvailableAnalysis() {
237 List<TmfTraceElement> traces = getChildren().stream()
238 .filter(elem -> (elem instanceof TmfTraceElement))
239 .map(elem -> ((TmfTraceElement) elem).getElementUnderTraceFolder())
240 .collect(Collectors.toList());
241
242 List<TmfAnalysisElement> analyses = new ArrayList<>();
243 for (TmfTraceElement traceElem : traces) {
244 if (traceElem.getChildElementViews() != null) {
245 analyses.addAll(traceElem.getAvailableAnalysis());
246 }
247 }
248 return analyses;
249 }
250
339d539c
PT
251 private List<IResource> getTraceResources() {
252 IFolder folder = getResource();
253 final List<IResource> list = new ArrayList<>();
254 try {
255 folder.accept(new IResourceProxyVisitor() {
256 @Override
257 public boolean visit(IResourceProxy resource) throws CoreException {
258 if (resource.isLinked()) {
259 list.add(resource.requestResource());
260 }
261 return true;
262 }
263 }, IResource.NONE);
264 } catch (CoreException e) {
265 }
dca8b422
BH
266 Comparator<IResource> comparator = new Comparator<IResource>() {
267 @Override
268 public int compare(IResource o1, IResource o2) {
269 return o1.getFullPath().toString().compareTo(o2.getFullPath().toString());
270 }
271 };
272 Collections.sort(list, comparator);
339d539c
PT
273 return list;
274 }
275
dff70ccd
AM
276 /**
277 * @since 2.0
278 */
279 @Override
280 public @NonNull Image getIcon() {
281 Image icon = super.getIcon();
282 return (icon == null ? TmfProjectModelIcons.DEFAULT_EXPERIMENT_ICON : icon);
283 }
284
285 /**
286 * @since 2.0
287 */
288 @Override
289 public String getLabelText() {
290 return getName() + " [" + getTraces().size() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
291 }
292
12c155f5
FC
293 // ------------------------------------------------------------------------
294 // Operations
295 // ------------------------------------------------------------------------
11252342 296
8f5221c2
GB
297 /**
298 * Refreshes the trace type filed by reading the trace type persistent
299 * property of the resource reference.
300 *
301 * If trace type is null after refresh, set it to the generic trace type
302 * (for seamless upgrade)
303 */
304 @Override
305 public void refreshTraceType() {
306 super.refreshTraceType();
307 if (getTraceType() == null) {
a4a116c3 308 IConfigurationElement ce = TmfTraceType.getTraceAttributes(TmfTraceType.DEFAULT_EXPERIMENT_TYPE);
8f5221c2
GB
309 if (ce != null) {
310 try {
311 IFolder experimentFolder = getResource();
312 experimentFolder.setPersistentProperty(TmfCommonConstants.TRACETYPE, ce.getAttribute(TmfTraceType.ID_ATTR));
313 super.refreshTraceType();
314 } catch (InvalidRegistryObjectException | CoreException e) {
315 }
316 }
317 }
318 }
319
b544077e
BH
320 /**
321 * Returns a list of TmfTraceElements contained in this experiment.
dc62dbee 322 *
b544077e
BH
323 * @return a list of TmfTraceElements
324 */
8f5221c2 325 @Override
12c155f5
FC
326 public List<TmfTraceElement> getTraces() {
327 List<ITmfProjectModelElement> children = getChildren();
507b1336 328 List<TmfTraceElement> traces = new ArrayList<>();
12c155f5
FC
329 for (ITmfProjectModelElement child : children) {
330 if (child instanceof TmfTraceElement) {
331 traces.add((TmfTraceElement) child);
332 }
333 }
334 return traces;
335 }
336
beb19106
GB
337 /**
338 * Adds a trace to the experiment
339 *
dc62dbee
CB
340 * @param trace
341 * The trace element to add
beb19106
GB
342 */
343 public void addTrace(TmfTraceElement trace) {
38dfaec4
BH
344 addTrace(trace, true);
345 }
346
347 /**
348 * Adds a trace to the experiment
349 *
dc62dbee
CB
350 * @param trace
351 * The trace element to add
352 * @param refresh
353 * Flag for refreshing the project
38dfaec4
BH
354 */
355 public void addTrace(TmfTraceElement trace, boolean refresh) {
beb19106
GB
356 /**
357 * Create a link to the actual trace and set the trace type
358 */
359 IFolder experiment = getResource();
360 IResource resource = trace.getResource();
361 IPath location = resource.getLocation();
362 IWorkspace workspace = ResourcesPlugin.getWorkspace();
363 try {
4b3b667b 364 String traceTypeId = TmfTraceType.getTraceTypeId(trace.getResource());
a4a116c3 365 TraceTypeHelper traceType = TmfTraceType.getTraceType(traceTypeId);
beb19106
GB
366
367 if (resource instanceof IFolder) {
339d539c
PT
368 IFolder folder = experiment.getFolder(trace.getElementPath());
369 TraceUtils.createFolder((IFolder) folder.getParent(), new NullProgressMonitor());
977ca87f
PT
370 IStatus result = workspace.validateLinkLocation(folder, location);
371 if (result.isOK() || result.matches(IStatus.INFO | IStatus.WARNING)) {
beb19106 372 folder.createLink(location, IResource.REPLACE, null);
5f398902 373 if (traceType != null) {
38dfaec4 374 TmfTraceTypeUIUtils.setTraceType(folder, traceType, refresh);
5f398902 375 }
beb19106
GB
376
377 } else {
378 Activator.getDefault().logError("Error creating link. Invalid trace location " + location); //$NON-NLS-1$
379 }
380 } else {
339d539c
PT
381 IFile file = experiment.getFile(trace.getElementPath());
382 TraceUtils.createFolder((IFolder) file.getParent(), new NullProgressMonitor());
977ca87f
PT
383 IStatus result = workspace.validateLinkLocation(file, location);
384 if (result.isOK() || result.matches(IStatus.INFO | IStatus.WARNING)) {
beb19106 385 file.createLink(location, IResource.REPLACE, null);
5f398902 386 if (traceType != null) {
38dfaec4 387 TmfTraceTypeUIUtils.setTraceType(file, traceType, refresh);
5f398902 388 }
beb19106
GB
389 } else {
390 Activator.getDefault().logError("Error creating link. Invalid trace location " + location); //$NON-NLS-1$
391 }
392 }
393 } catch (CoreException e) {
394 Activator.getDefault().logError("Error creating link to location " + location, e); //$NON-NLS-1$
395 }
396
397 }
398
399 /**
400 * Removes a trace from an experiment
401 *
dc62dbee
CB
402 * @param trace
403 * The trace to remove
404 * @throws CoreException
405 * exception
beb19106
GB
406 */
407 public void removeTrace(TmfTraceElement trace) throws CoreException {
408
ea01e5a2
PT
409 // Close editors in UI Thread
410 Display.getDefault().syncExec(new Runnable() {
411 @Override
412 public void run() {
413 closeEditors();
414 }
415 });
beb19106 416
3a31ae77
BH
417 /* Remove all trace analyses from experiment view */
418 List<TmfAnalysisElement> analysisElements = trace.getElementUnderTraceFolder().getAvailableAnalysis();
419 TmfViewsElement view = getChildElementViews();
420
421 if (view != null) {
422 view.removeChildrenAnalysis(analysisElements);
423 }
424
dc62dbee 425 /* Finally, remove the trace from experiment */
beb19106 426 removeChild(trace);
339d539c 427 deleteTraceResource(trace.getResource());
d9030b38 428 deleteSupplementaryResources();
beb19106
GB
429 }
430
339d539c
PT
431 private void deleteTraceResource(IResource resource) throws CoreException {
432 resource.delete(true, null);
433 IContainer parent = resource.getParent();
434 // delete empty folders up to the parent experiment folder
435 if (!parent.equals(getResource()) && parent.members().length == 0) {
436 deleteTraceResource(parent);
437 }
438 }
439
8f5221c2 440 @Override
81fe3479 441 public IFile createBookmarksFile() throws CoreException {
a485bc7f
BH
442 TmfExperimentFolder experimentFolder = getProject().getExperimentsFolder();
443 if (experimentFolder == null) {
444 throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TmfProject_ExperimentFolderNotExists));
445 }
446 return createBookmarksFile(experimentFolder.getResource(), ITmfEventsEditorConstants.EXPERIMENT_EDITOR_INPUT_TYPE);
8f5221c2
GB
447 }
448
449 @Override
450 public String getEditorId() {
451 /* See if a default editor was set for this experiment type */
452 if (getTraceType() != null) {
067cd9de 453 IConfigurationElement ce = TRACE_TYPE_UI_ATTRIBUTES.get(getTraceType());
c1c0dfd0
GB
454 if (ce != null) {
455 IConfigurationElement[] defaultEditorCE = ce.getChildren(TmfTraceTypeUIUtils.DEFAULT_EDITOR_ELEM);
456 if (defaultEditorCE.length == 1) {
457 return defaultEditorCE[0].getAttribute(TmfTraceType.ID_ATTR);
458 }
81fe3479 459 }
c4c81d91 460 }
8f5221c2
GB
461
462 /* No default editor, try to find a common editor for all traces */
463 final List<TmfTraceElement> traceEntries = getTraces();
464 String commonEditorId = null;
465
466 for (TmfTraceElement element : traceEntries) {
467 // If all traces use the same editorId, use it, otherwise use the
468 // default
469 final String editorId = element.getEditorId();
470 if (commonEditorId == null) {
471 commonEditorId = (editorId != null) ? editorId : TmfEventsEditor.ID;
472 } else if (!commonEditorId.equals(editorId)) {
473 commonEditorId = TmfEventsEditor.ID;
474 }
475 }
476 return null;
81fe3479
PT
477 }
478
479 /**
8f5221c2
GB
480 * Instantiate a {@link TmfExperiment} object based on the experiment type
481 * and the corresponding extension.
482 *
483 * @return the {@link TmfExperiment} or <code>null</code> for an error
81fe3479 484 */
8f5221c2
GB
485 @Override
486 public TmfExperiment instantiateTrace() {
487 try {
488
489 // make sure that supplementary folder exists
490 refreshSupplementaryFolder();
491
492 if (getTraceType() != null) {
493
067cd9de 494 IConfigurationElement ce = TRACE_TYPE_ATTRIBUTES.get(getTraceType());
8f5221c2
GB
495 if (ce == null) {
496 return null;
497 }
498 TmfExperiment experiment = (TmfExperiment) ce.createExecutableExtension(TmfTraceType.EXPERIMENT_TYPE_ATTR);
499 return experiment;
500 }
501 } catch (CoreException e) {
502 Activator.getDefault().logError(NLS.bind(Messages.TmfExperimentElement_ErrorInstantiatingTrace, getName()), e);
503 }
504 return null;
505 }
506
507 @Override
508 public String getTypeName() {
509 return Messages.TmfExperimentElement_TypeName;
c4c81d91
PT
510 }
511
12c155f5
FC
512 // ------------------------------------------------------------------------
513 // IPropertySource2
514 // ------------------------------------------------------------------------
515
516 @Override
517 public Object getEditableValue() {
518 return null;
519 }
520
521 @Override
522 public IPropertyDescriptor[] getPropertyDescriptors() {
067cd9de 523 return Arrays.copyOf(DESCRIPTORS, DESCRIPTORS.length);
12c155f5
FC
524 }
525
526 @Override
527 public Object getPropertyValue(Object id) {
528
067cd9de 529 if (NAME.equals(id)) {
12c155f5 530 return getName();
c4c81d91 531 }
12c155f5 532
067cd9de 533 if (PATH.equals(id)) {
12c155f5 534 return getPath().toString();
c4c81d91 535 }
12c155f5 536
067cd9de 537 if (LOCATION.equals(id)) {
12c155f5 538 return getLocation().toString();
c4c81d91 539 }
12c155f5 540
067cd9de 541 if (EXPERIMENT_TYPE.equals(id)) {
8f5221c2 542 if (getTraceType() != null) {
067cd9de 543 IConfigurationElement ce = TRACE_TYPE_ATTRIBUTES.get(getTraceType());
8f5221c2
GB
544 if (ce == null) {
545 return ""; //$NON-NLS-1$
546 }
547 String categoryId = ce.getAttribute(TmfTraceType.CATEGORY_ATTR);
548 if (categoryId != null) {
067cd9de 549 IConfigurationElement category = TRACE_CATEGORIES.get(categoryId);
8f5221c2
GB
550 if (category != null) {
551 return category.getAttribute(TmfTraceType.NAME_ATTR) + ':' + ce.getAttribute(TmfTraceType.NAME_ATTR);
552 }
553 }
554 return ce.getAttribute(TmfTraceType.NAME_ATTR);
555 }
556 }
12ec416d
BH
557 if (EXPERIMENT_TYPE_ID.equals(id)) {
558 if (getTraceType() != null) {
559 IConfigurationElement ce = TRACE_TYPE_ATTRIBUTES.get(getTraceType());
560 if (ce == null) {
561 return ""; //$NON-NLS-1$
562 }
563 return ce.getAttribute(TmfTraceType.ID_ATTR);
564 }
565 }
8f5221c2 566
12c155f5
FC
567 return null;
568 }
c4c81d91 569
12c155f5
FC
570 @Override
571 public void resetPropertyValue(Object id) {
572 }
573
574 @Override
575 public void setPropertyValue(Object id, Object value) {
576 }
577
578 @Override
579 public boolean isPropertyResettable(Object id) {
580 return false;
581 }
582
583 @Override
584 public boolean isPropertySet(Object id) {
585 return false;
586 }
587
99504bb8
GB
588 /**
589 * Return the suffix for resource names
dc62dbee 590 *
99504bb8
GB
591 * @return The folder suffix
592 */
593 @Override
594 public String getSuffix() {
067cd9de 595 return FOLDER_SUFFIX;
99504bb8
GB
596 }
597
12c155f5 598}
This page took 0.135412 seconds and 5 git commands to generate.