1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 Ericsson, École Polytechnique de Montréal
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 * Bernd Hufmann - Added supplementary files handling
12 * Geneviève Bastien - Moved supplementary files handling to parent class,
13 * added code to copy trace
14 * Patrick Tasse - Close editors to release resources
15 * Jean-Christian Kouame - added trace properties to be shown into
17 *******************************************************************************/
19 package org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
;
21 import java
.io
.ByteArrayInputStream
;
22 import java
.io
.InputStream
;
23 import java
.util
.ArrayList
;
24 import java
.util
.Arrays
;
25 import java
.util
.HashMap
;
26 import java
.util
.LinkedList
;
27 import java
.util
.List
;
30 import org
.eclipse
.core
.resources
.IFile
;
31 import org
.eclipse
.core
.resources
.IFolder
;
32 import org
.eclipse
.core
.resources
.IResource
;
33 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
34 import org
.eclipse
.core
.runtime
.CoreException
;
35 import org
.eclipse
.core
.runtime
.IConfigurationElement
;
36 import org
.eclipse
.core
.runtime
.IPath
;
37 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
38 import org
.eclipse
.core
.runtime
.Platform
;
39 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
40 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomTxtEvent
;
41 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomTxtTrace
;
42 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomTxtTraceDefinition
;
43 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomXmlEvent
;
44 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomXmlTrace
;
45 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomXmlTraceDefinition
;
46 import org
.eclipse
.linuxtools
.tmf
.core
.TmfCommonConstants
;
47 import org
.eclipse
.linuxtools
.tmf
.core
.analysis
.IAnalysisModuleHelper
;
48 import org
.eclipse
.linuxtools
.tmf
.core
.analysis
.TmfAnalysisManager
;
49 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
50 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
51 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalManager
;
52 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
53 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
54 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTraceProperties
;
55 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTrace
;
56 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTraceManager
;
57 import org
.eclipse
.linuxtools
.tmf
.ui
.editors
.TmfEventsEditor
;
58 import org
.eclipse
.linuxtools
.tmf
.ui
.properties
.ReadOnlyTextPropertyDescriptor
;
59 import org
.eclipse
.ui
.IActionFilter
;
60 import org
.eclipse
.ui
.IEditorReference
;
61 import org
.eclipse
.ui
.IWorkbench
;
62 import org
.eclipse
.ui
.IWorkbenchPage
;
63 import org
.eclipse
.ui
.IWorkbenchWindow
;
64 import org
.eclipse
.ui
.PartInitException
;
65 import org
.eclipse
.ui
.PlatformUI
;
66 import org
.eclipse
.ui
.part
.FileEditorInput
;
67 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
68 import org
.eclipse
.ui
.views
.properties
.IPropertySource2
;
71 * Implementation of trace model element representing a trace. It provides
72 * methods to instantiate <code>ITmfTrace</code> and <code>ITmfEvent</code> as
73 * well as editor ID from the trace type extension definition.
76 * @author Francois Chouinard
78 public class TmfTraceElement
extends TmfWithFolderElement
implements IActionFilter
, IPropertySource2
{
80 // ------------------------------------------------------------------------
82 // ------------------------------------------------------------------------
86 * Bundle attribute name
88 public static final String BUNDLE
= "bundle"; //$NON-NLS-1$
90 * IsLinked attribute name.
92 public static final String IS_LINKED
= "isLinked"; //$NON-NLS-1$
94 // Property View stuff
95 private static final String sfResourcePropertiesCategory
= Messages
.TmfTraceElement_ResourceProperties
;
96 private static final String sfName
= Messages
.TmfTraceElement_Name
;
97 private static final String sfPath
= Messages
.TmfTraceElement_Path
;
98 private static final String sfLocation
= Messages
.TmfTraceElement_Location
;
99 private static final String sfEventType
= Messages
.TmfTraceElement_EventType
;
100 private static final String sfIsLinked
= Messages
.TmfTraceElement_IsLinked
;
101 private static final String sfTracePropertiesCategory
= Messages
.TmfTraceElement_TraceProperties
;
103 private static final ReadOnlyTextPropertyDescriptor sfNameDescriptor
= new ReadOnlyTextPropertyDescriptor(sfName
, sfName
);
104 private static final ReadOnlyTextPropertyDescriptor sfPathDescriptor
= new ReadOnlyTextPropertyDescriptor(sfPath
, sfPath
);
105 private static final ReadOnlyTextPropertyDescriptor sfLocationDescriptor
= new ReadOnlyTextPropertyDescriptor(sfLocation
, sfLocation
);
106 private static final ReadOnlyTextPropertyDescriptor sfTypeDescriptor
= new ReadOnlyTextPropertyDescriptor(sfEventType
, sfEventType
);
107 private static final ReadOnlyTextPropertyDescriptor sfIsLinkedDescriptor
= new ReadOnlyTextPropertyDescriptor(sfIsLinked
, sfIsLinked
);
109 private static final IPropertyDescriptor
[] sfDescriptors
= { sfNameDescriptor
, sfPathDescriptor
, sfLocationDescriptor
,
110 sfTypeDescriptor
, sfIsLinkedDescriptor
};
113 sfNameDescriptor
.setCategory(sfResourcePropertiesCategory
);
114 sfPathDescriptor
.setCategory(sfResourcePropertiesCategory
);
115 sfLocationDescriptor
.setCategory(sfResourcePropertiesCategory
);
116 sfTypeDescriptor
.setCategory(sfResourcePropertiesCategory
);
117 sfIsLinkedDescriptor
.setCategory(sfResourcePropertiesCategory
);
120 private static final String BOOKMARKS_HIDDEN_FILE
= ".bookmarks"; //$NON-NLS-1$
122 // ------------------------------------------------------------------------
124 // ------------------------------------------------------------------------
126 // This trace type ID as defined in plugin.xml
127 private String fTraceTypeId
= null;
129 // ------------------------------------------------------------------------
130 // Static initialization
131 // ------------------------------------------------------------------------
133 // The mapping of available trace type IDs to their corresponding
134 // configuration element
135 private static final Map
<String
, IConfigurationElement
> sfTraceTypeAttributes
= new HashMap
<String
, IConfigurationElement
>();
136 private static final Map
<String
, IConfigurationElement
> sfTraceCategories
= new HashMap
<String
, IConfigurationElement
>();
139 * Initialize statically at startup by getting extensions from the platform
140 * extension registry.
142 public static void init() {
143 IConfigurationElement
[] config
= Platform
.getExtensionRegistry().getConfigurationElementsFor(TmfTraceType
.TMF_TRACE_TYPE_ID
);
144 for (IConfigurationElement ce
: config
) {
145 String elementName
= ce
.getName();
146 if (elementName
.equals(TmfTraceType
.TYPE_ELEM
)) {
147 String traceTypeId
= ce
.getAttribute(TmfTraceType
.ID_ATTR
);
148 sfTraceTypeAttributes
.put(traceTypeId
, ce
);
149 } else if (elementName
.equals(TmfTraceType
.CATEGORY_ELEM
)) {
150 String categoryId
= ce
.getAttribute(TmfTraceType
.ID_ATTR
);
151 sfTraceCategories
.put(categoryId
, ce
);
156 // ------------------------------------------------------------------------
158 // ------------------------------------------------------------------------
160 * Constructor. Creates trace model element under the trace folder.
165 * The trace resource.
167 * The parent element (trace folder)
169 public TmfTraceElement(String name
, IResource trace
, TmfTraceFolder parent
) {
170 this(name
, trace
, (TmfProjectModelElement
) parent
);
174 * Constructor. Creates trace model element under the experiment folder.
179 * The trace resource.
181 * The parent element (experiment folder)
183 public TmfTraceElement(String name
, IResource trace
, TmfExperimentElement parent
) {
184 this(name
, trace
, (TmfProjectModelElement
) parent
);
187 private TmfTraceElement(String name
, IResource trace
, TmfProjectModelElement parent
) {
188 super(name
, trace
, parent
);
189 parent
.addChild(this);
191 TmfSignalManager
.register(this);
194 // ------------------------------------------------------------------------
196 // ------------------------------------------------------------------------
198 * Returns the trace type ID.
200 * @return trace type ID.
202 public String
getTraceType() {
207 * Refreshes the trace type filed by reading the trace type persistent
208 * property of the resource referenece.
210 public void refreshTraceType() {
212 fTraceTypeId
= getResource().getPersistentProperty(TmfCommonConstants
.TRACETYPE
);
214 } catch (CoreException e
) {
215 Activator
.getDefault().logError("Error refreshing trace type pesistent property for trace " + getName(), e
); //$NON-NLS-1$
220 * Instantiate a <code>ITmfTrace</code> object based on the trace type and
221 * the corresponding extension.
223 * @return the <code>ITmfTrace</code> or <code>null</code> for an error
225 public ITmfTrace
instantiateTrace() {
228 // make sure that supplementary folder exists
229 refreshSupplementaryFolder();
231 if (fTraceTypeId
!= null) {
232 if (fTraceTypeId
.startsWith(CustomTxtTrace
.class.getCanonicalName())) {
233 for (CustomTxtTraceDefinition def
: CustomTxtTraceDefinition
.loadAll()) {
234 if (fTraceTypeId
.equals(CustomTxtTrace
.class.getCanonicalName() + ":" + def
.definitionName
)) { //$NON-NLS-1$
235 return new CustomTxtTrace(def
);
239 if (fTraceTypeId
.startsWith(CustomXmlTrace
.class.getCanonicalName())) {
240 for (CustomXmlTraceDefinition def
: CustomXmlTraceDefinition
.loadAll()) {
241 if (fTraceTypeId
.equals(CustomXmlTrace
.class.getCanonicalName() + ":" + def
.definitionName
)) { //$NON-NLS-1$
242 return new CustomXmlTrace(def
);
246 IConfigurationElement ce
= sfTraceTypeAttributes
.get(fTraceTypeId
);
250 ITmfTrace trace
= (ITmfTrace
) ce
.createExecutableExtension(TmfTraceType
.TRACE_TYPE_ATTR
);
253 } catch (CoreException e
) {
254 Activator
.getDefault().logError("Error instantiating ITmfTrace object for trace " + getName(), e
); //$NON-NLS-1$
260 * Instantiate a <code>ITmfEvent</code> object based on the trace type and
261 * the corresponding extension.
263 * @return the <code>ITmfEvent</code> or <code>null</code> for an error
265 public ITmfEvent
instantiateEvent() {
267 if (fTraceTypeId
!= null) {
268 if (fTraceTypeId
.startsWith(CustomTxtTrace
.class.getCanonicalName())) {
269 for (CustomTxtTraceDefinition def
: CustomTxtTraceDefinition
.loadAll()) {
270 if (fTraceTypeId
.equals(CustomTxtTrace
.class.getCanonicalName() + ":" + def
.definitionName
)) { //$NON-NLS-1$
271 return new CustomTxtEvent(def
);
275 if (fTraceTypeId
.startsWith(CustomXmlTrace
.class.getCanonicalName())) {
276 for (CustomXmlTraceDefinition def
: CustomXmlTraceDefinition
.loadAll()) {
277 if (fTraceTypeId
.equals(CustomXmlTrace
.class.getCanonicalName() + ":" + def
.definitionName
)) { //$NON-NLS-1$
278 return new CustomXmlEvent(def
);
282 IConfigurationElement ce
= sfTraceTypeAttributes
.get(fTraceTypeId
);
286 ITmfEvent event
= (ITmfEvent
) ce
.createExecutableExtension(TmfTraceType
.EVENT_TYPE_ATTR
);
289 } catch (CoreException e
) {
290 Activator
.getDefault().logError("Error instantiating ITmfEvent object for trace " + getName(), e
); //$NON-NLS-1$
296 * Returns the optional editor ID from the trace type extension.
298 * @return the editor ID or <code>null</code> if not defined.
300 public String
getEditorId() {
301 if (fTraceTypeId
!= null) {
302 if (fTraceTypeId
.startsWith(CustomTxtTrace
.class.getCanonicalName())) {
303 return TmfEventsEditor
.ID
;
305 if (fTraceTypeId
.startsWith(CustomXmlTrace
.class.getCanonicalName())) {
306 return TmfEventsEditor
.ID
;
308 IConfigurationElement ce
= sfTraceTypeAttributes
.get(fTraceTypeId
);
309 IConfigurationElement
[] defaultEditorCE
= ce
.getChildren(TmfTraceType
.DEFAULT_EDITOR_ELEM
);
310 if (defaultEditorCE
.length
== 1) {
311 return defaultEditorCE
[0].getAttribute(TmfTraceType
.ID_ATTR
);
318 * Returns the file resource used to store bookmarks after creating it if
319 * necessary. If the trace resource is a file, it is returned directly. If
320 * the trace resource is a folder, a linked file is returned. The file will
321 * be created if it does not exist.
323 * @return the bookmarks file
324 * @throws CoreException
325 * if the bookmarks file cannot be created
328 public IFile
createBookmarksFile() throws CoreException
{
329 IFile file
= getBookmarksFile();
330 if (fResource
instanceof IFolder
) {
331 if (!file
.exists()) {
332 final IFile bookmarksFile
= getProject().getTracesFolder().getResource().getFile(BOOKMARKS_HIDDEN_FILE
);
333 if (!bookmarksFile
.exists()) {
334 final InputStream source
= new ByteArrayInputStream(new byte[0]);
335 bookmarksFile
.create(source
, true, null);
337 bookmarksFile
.setHidden(true);
338 file
.createLink(bookmarksFile
.getLocation(), IResource
.REPLACE
, null);
339 file
.setHidden(true);
340 file
.setPersistentProperty(TmfCommonConstants
.TRACETYPE
, TmfTrace
.class.getCanonicalName());
347 * Returns the file resource used to store bookmarks. The file may not
350 * @return the bookmarks file
353 public IFile
getBookmarksFile() {
355 if (fResource
instanceof IFile
) {
356 file
= (IFile
) fResource
;
357 } else if (fResource
instanceof IFolder
) {
358 final IFolder folder
= (IFolder
) fResource
;
359 file
= folder
.getFile(getName() + '_');
365 * Returns the <code>TmfTraceElement</code> located under the
366 * <code>TmfTracesFolder</code>.
368 * @return <code>this</code> if this element is under the
369 * <code>TmfTracesFolder</code> else the corresponding
370 * <code>TmfTraceElement</code> if this element is under
371 * <code>TmfExperimentElement</code>.
373 public TmfTraceElement
getElementUnderTraceFolder() {
375 // If trace is under an experiment, return original trace from the
377 if (getParent() instanceof TmfExperimentElement
) {
378 for (TmfTraceElement aTrace
: getProject().getTracesFolder().getTraces()) {
379 if (aTrace
.getName().equals(getName())) {
387 // ------------------------------------------------------------------------
389 // ------------------------------------------------------------------------
392 public boolean testAttribute(Object target
, String name
, String value
) {
393 if (name
.equals(IS_LINKED
)) {
394 boolean isLinked
= getResource().isLinked();
395 return Boolean
.toString(isLinked
).equals(value
);
400 // ------------------------------------------------------------------------
402 // ------------------------------------------------------------------------
405 public TmfProjectElement
getProject() {
406 if (getParent() instanceof TmfTraceFolder
) {
407 TmfTraceFolder folder
= (TmfTraceFolder
) getParent();
408 TmfProjectElement project
= (TmfProjectElement
) folder
.getParent();
411 if (getParent() instanceof TmfExperimentElement
) {
412 TmfExperimentElement experiment
= (TmfExperimentElement
) getParent();
413 TmfExperimentFolder folder
= (TmfExperimentFolder
) experiment
.getParent();
414 TmfProjectElement project
= (TmfProjectElement
) folder
.getParent();
420 // ------------------------------------------------------------------------
422 // ------------------------------------------------------------------------
425 public Object
getEditableValue() {
430 * Get the trace properties of this traceElement if the corresponding trace
431 * is opened in an editor
433 * @return a map with the names and values of the trace properties
434 * respectively as keys and values
436 private Map
<String
, String
> getTraceProperties() {
437 for (ITmfTrace openedTrace
: TmfTraceManager
.getInstance().getOpenedTraces()) {
438 for (ITmfTrace singleTrace
: TmfTraceManager
.getTraceSet(openedTrace
)) {
439 if (this.getLocation().toString().endsWith(singleTrace
.getPath())) {
440 if (singleTrace
instanceof ITmfTraceProperties
) {
441 ITmfTraceProperties traceProperties
= (ITmfTraceProperties
) singleTrace
;
442 return traceProperties
.getTraceProperties();
447 return new HashMap
<String
, String
>();
451 public IPropertyDescriptor
[] getPropertyDescriptors() {
452 Map
<String
, String
> traceProperties
= getTraceProperties();
453 if (!traceProperties
.isEmpty()) {
454 IPropertyDescriptor
[] propertyDescriptorArray
= new IPropertyDescriptor
[traceProperties
.size() + sfDescriptors
.length
];
456 for (Map
.Entry
<String
, String
> varName
: traceProperties
.entrySet()) {
457 ReadOnlyTextPropertyDescriptor descriptor
= new ReadOnlyTextPropertyDescriptor(this.getName() + "_" + varName
.getKey(), varName
.getKey()); //$NON-NLS-1$
458 descriptor
.setCategory(sfTracePropertiesCategory
);
459 propertyDescriptorArray
[index
] = descriptor
;
462 for (int i
= 0; i
< sfDescriptors
.length
; i
++) {
463 propertyDescriptorArray
[index
] = sfDescriptors
[i
];
466 return propertyDescriptorArray
;
468 return Arrays
.copyOf(sfDescriptors
, sfDescriptors
.length
);
472 public Object
getPropertyValue(Object id
) {
474 if (sfName
.equals(id
)) {
478 if (sfPath
.equals(id
)) {
479 return getPath().toString();
482 if (sfLocation
.equals(id
)) {
483 return getLocation().toString();
486 if (sfIsLinked
.equals(id
)) {
487 return Boolean
.valueOf(getResource().isLinked()).toString();
490 if (sfEventType
.equals(id
)) {
491 if (fTraceTypeId
!= null) {
492 IConfigurationElement ce
= sfTraceTypeAttributes
.get(fTraceTypeId
);
493 return (ce
!= null) ?
(getCategory(ce
) + " : " + ce
.getAttribute(TmfTraceType
.NAME_ATTR
)) : ""; //$NON-NLS-1$ //$NON-NLS-2$
497 Map
<String
, String
> traceProperties
= getTraceProperties();
498 if (id
!= null && !traceProperties
.isEmpty()) {
499 String key
= (String
) id
;
500 key
= key
.replaceFirst(this.getName() + "_", ""); //$NON-NLS-1$ //$NON-NLS-2$
501 String value
= traceProperties
.get(key
);
508 private static String
getCategory(IConfigurationElement ce
) {
509 String categoryId
= ce
.getAttribute(TmfTraceType
.CATEGORY_ATTR
);
510 if (categoryId
!= null) {
511 IConfigurationElement category
= sfTraceCategories
.get(categoryId
);
512 if (category
!= null) {
513 return category
.getAttribute(TmfTraceType
.NAME_ATTR
);
516 return "[no category]"; //$NON-NLS-1$
520 public void resetPropertyValue(Object id
) {
524 public void setPropertyValue(Object id
, Object value
) {
528 public boolean isPropertyResettable(Object id
) {
533 public boolean isPropertySet(Object id
) {
538 * Copy this trace in the trace folder. No other parameters are mentioned so
539 * the trace is copied in this element's project trace folder
543 * @return the new Resource object
546 public TmfTraceElement
copy(String string
) {
547 TmfTraceFolder folder
= this.getProject().getTracesFolder();
548 IResource res
= super.copy(string
, false);
549 return new TmfTraceElement(string
, res
, folder
);
553 * Close opened editors associated with this trace.
557 public void closeEditors() {
558 // Close the trace if open
559 IFile file
= getBookmarksFile();
560 FileEditorInput input
= new FileEditorInput(file
);
561 IWorkbench wb
= PlatformUI
.getWorkbench();
562 for (IWorkbenchWindow wbWindow
: wb
.getWorkbenchWindows()) {
563 for (IWorkbenchPage wbPage
: wbWindow
.getPages()) {
564 for (IEditorReference editorReference
: wbPage
.getEditorReferences()) {
566 if (editorReference
.getEditorInput().equals(input
)) {
567 wbPage
.closeEditor(editorReference
.getEditor(false), false);
569 } catch (PartInitException e
) {
570 Activator
.getDefault().logError("Error closing editor for trace " + getName(), e
); //$NON-NLS-1$
576 // Close experiments that contain the trace if open
577 if (getParent() instanceof TmfTraceFolder
) {
578 TmfExperimentFolder experimentFolder
= getProject().getExperimentsFolder();
579 for (ITmfProjectModelElement experiment
: experimentFolder
.getChildren()) {
580 for (ITmfProjectModelElement child
: experiment
.getChildren()) {
581 if (child
.getName().equals(getName())) {
582 ((TmfExperimentElement
) experiment
).closeEditors();
587 } else if (getParent() instanceof TmfExperimentElement
) {
588 TmfExperimentElement experiment
= (TmfExperimentElement
) getParent();
589 experiment
.closeEditors();
594 * Delete the trace resource, remove it from experiments and delete its
595 * supplementary files
597 * @param progressMonitor
598 * a progress monitor, or null if progress reporting is not
601 * @throws CoreException
602 * thrown when IResource.delete fails
605 public void delete(IProgressMonitor progressMonitor
) throws CoreException
{
608 IPath path
= fResource
.getLocation();
609 if (path
!= null && (getParent() instanceof TmfTraceFolder
)) {
610 TmfExperimentFolder experimentFolder
= getProject().getExperimentsFolder();
612 // Propagate the removal to traces
613 for (ITmfProjectModelElement experiment
: experimentFolder
.getChildren()) {
614 List
<ITmfProjectModelElement
> toRemove
= new LinkedList
<ITmfProjectModelElement
>();
615 for (ITmfProjectModelElement child
: experiment
.getChildren()) {
616 if (child
.getName().equals(getName())) {
620 for (ITmfProjectModelElement child
: toRemove
) {
621 ((TmfExperimentElement
) experiment
).removeTrace((TmfTraceElement
) child
);
625 // Delete supplementary files
626 deleteSupplementaryFolder();
629 // Finally, delete the trace
630 fResource
.delete(true, progressMonitor
);
634 * Get the instantiated trace associated with this element.
636 * @return The instantiated trace or null if trace is not (yet) available
639 public ITmfTrace
getTrace() {
640 for (ITmfTrace trace
: TmfTraceManager
.getInstance().getOpenedTraces()) {
641 if (trace
.getResource().equals(getResource())) {
648 private void refreshAnalysis() {
649 List
<TmfAnalysisElement
> list
= getAvailableAnalysis();
651 /* Remove children */
652 getChildren().clear();
654 /* Add the children again */
655 for (TmfAnalysisElement module
: list
) {
662 * Get the list of analysis elements
664 * @return Array of analysis elements
667 public List
<TmfAnalysisElement
> getAvailableAnalysis() {
668 List
<TmfAnalysisElement
> list
= new ArrayList
<TmfAnalysisElement
>();
670 TraceTypeHelper helper
= TmfTraceType
.getInstance().getTraceType(getTraceType());
672 Class
<?
extends ITmfTrace
> traceClass
= null;
674 if (helper
== null && fTraceTypeId
!= null) {
675 if (fTraceTypeId
.startsWith(CustomTxtTrace
.class.getCanonicalName())) {
676 for (CustomTxtTraceDefinition def
: CustomTxtTraceDefinition
.loadAll()) {
677 if (fTraceTypeId
.equals(CustomTxtTrace
.class.getCanonicalName() + ":" + def
.definitionName
)) { //$NON-NLS-1$
678 traceClass
= CustomTxtTrace
.class;
682 if (fTraceTypeId
.startsWith(CustomXmlTrace
.class.getCanonicalName())) {
683 for (CustomXmlTraceDefinition def
: CustomXmlTraceDefinition
.loadAll()) {
684 if (fTraceTypeId
.equals(CustomXmlTrace
.class.getCanonicalName() + ":" + def
.definitionName
)) { //$NON-NLS-1$
685 traceClass
= CustomTxtTrace
.class;
689 } else if (helper
!= null) {
690 traceClass
= helper
.getTraceClass();
693 if (traceClass
== null) {
697 /** Get the base path to put the resource to */
698 IPath path
= fResource
.getFullPath();
700 for (IAnalysisModuleHelper module
: TmfAnalysisManager
.getAnalysisModules(traceClass
).values()) {
702 /** No need for the resource to exist, nothing will be done with it */
703 IFolder newresource
= ResourcesPlugin
.getWorkspace().getRoot().getFolder(path
.append(module
.getId()));
705 TmfAnalysisElement analysis
= new TmfAnalysisElement(module
.getName(), newresource
, this, module
.getId());
713 * Handler for the Trace Opened signal
716 * The incoming signal
719 public void traceOpened(TmfTraceOpenedSignal signal
) {
720 IResource resource
= signal
.getTrace().getResource();
721 if ((resource
== null) || !resource
.equals(getResource())) {
726 getParent().refresh();