Class TmfTraceElement

All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, ITmfProjectModelElement, org.eclipse.ui.IActionFilter, org.eclipse.ui.views.properties.IPropertySource, org.eclipse.ui.views.properties.IPropertySource2

public class TmfTraceElement extends TmfCommonProjectElement implements org.eclipse.ui.IActionFilter, org.eclipse.ui.views.properties.IPropertySource2
Implementation of trace model element representing a trace. It provides methods to instantiate ITmfTrace and ITmfEvent as well as editor ID from the trace type extension definition.
Version:
1.0
Author:
Francois Chouinard
  • Field Details

  • Constructor Details

    • TmfTraceElement

      public TmfTraceElement(String name, org.eclipse.core.resources.IResource trace, TmfTraceFolder parent)
      Constructor. Creates trace model element under the trace folder.
      Parameters:
      name - The name of trace
      trace - The trace resource.
      parent - The parent element (trace folder)
    • TmfTraceElement

      public TmfTraceElement(String name, org.eclipse.core.resources.IResource trace, TmfExperimentElement parent)
      Constructor. Creates trace model element under the experiment folder.
      Parameters:
      name - The name of trace
      trace - The trace resource.
      parent - The parent element (experiment folder)
  • Method Details

    • init

      public static void init()
      Initialize statically at startup by getting extensions from the platform extension registry.
    • getIcon

      public @NonNull org.eclipse.swt.graphics.Image getIcon()
      Description copied from interface: ITmfProjectModelElement
      Returns the icon of this element.
      Specified by:
      getIcon in interface ITmfProjectModelElement
      Overrides:
      getIcon in class TmfCommonProjectElement
      Returns:
      The icon
      Since:
      2.0
    • getLabelText

      public String getLabelText()
      Description copied from interface: ITmfProjectModelElement
      Returns the text of the label of this element.
      Specified by:
      getLabelText in interface ITmfProjectModelElement
      Returns:
      The label text
      Since:
      2.0
    • instantiateTrace

      public ITmfTrace instantiateTrace()
      Instantiate a ITmfTrace object based on the trace type and the corresponding extension.
      Specified by:
      instantiateTrace in class TmfCommonProjectElement
      Returns:
      the ITmfTrace or null for an error
    • instantiateEvent

      public ITmfEvent instantiateEvent()
      Instantiate a ITmfEvent object based on the trace type and the corresponding extension.
      Returns:
      the ITmfEvent or null for an error
    • getEditorId

      public String getEditorId()
      Description copied from class: TmfCommonProjectElement
      Returns the optional editor ID from the trace type extension.
      Specified by:
      getEditorId in class TmfCommonProjectElement
      Returns:
      the editor ID or null if not defined.
    • getBookmarksFile

      public org.eclipse.core.resources.IFile getBookmarksFile()
      Returns the file resource used to store bookmarks. The file may not exist.
      Overrides:
      getBookmarksFile in class TmfCommonProjectElement
      Returns:
      the bookmarks file
    • getElementUnderTraceFolder

      public TmfTraceElement getElementUnderTraceFolder()
      Returns the TmfTraceElement located under the TmfTracesFolder.
      Returns:
      this if this element is under the TmfTracesFolder else the corresponding TmfTraceElement if this element is under TmfExperimentElement.
    • getTypeName

      public String getTypeName()
      Description copied from class: TmfCommonProjectElement
      Get a friendly name for the type of element this common project element is, to be displayed in UI messages.
      Specified by:
      getTypeName in class TmfCommonProjectElement
      Returns:
      A string for the type of project element this object is, for example "trace" or "experiment"
    • testAttribute

      public boolean testAttribute(Object target, String name, String value)
      Specified by:
      testAttribute in interface org.eclipse.ui.IActionFilter
    • getEditableValue

      public Object getEditableValue()
      Specified by:
      getEditableValue in interface org.eclipse.ui.views.properties.IPropertySource
    • getTrace

      public ITmfTrace getTrace()
      Description copied from class: TmfCommonProjectElement
      Get the instantiated trace associated with this element.
      Overrides:
      getTrace in class TmfCommonProjectElement
      Returns:
      The instantiated trace or null if trace is not (yet) available
    • getPropertyDescriptors

      public org.eclipse.ui.views.properties.IPropertyDescriptor[] getPropertyDescriptors()
      Specified by:
      getPropertyDescriptors in interface org.eclipse.ui.views.properties.IPropertySource
    • getPropertyValue

      public Object getPropertyValue(Object id)
      Specified by:
      getPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource
    • resetPropertyValue

      public void resetPropertyValue(Object id)
      Specified by:
      resetPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource
    • setPropertyValue

      public void setPropertyValue(Object id, Object value)
      Specified by:
      setPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource
    • isPropertyResettable

      public boolean isPropertyResettable(Object id)
      Specified by:
      isPropertyResettable in interface org.eclipse.ui.views.properties.IPropertySource2
    • isPropertySet

      public boolean isPropertySet(Object id)
      Specified by:
      isPropertySet in interface org.eclipse.ui.views.properties.IPropertySource
      Specified by:
      isPropertySet in interface org.eclipse.ui.views.properties.IPropertySource2
    • copy

      public TmfTraceElement copy(String newName)
      Copy this trace in the trace folder. No other parameters are mentioned so the trace is copied in this element's project trace folder
      Parameters:
      newName - The new trace name
      Returns:
      the new Resource object
    • closeEditors

      public void closeEditors()
      Close opened editors associated with this trace.
      Overrides:
      closeEditors in class TmfCommonProjectElement
    • delete

      public void delete(org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws org.eclipse.core.runtime.CoreException
      Delete the trace resource, remove it from experiments and delete its supplementary files
      Parameters:
      progressMonitor - a progress monitor, or null if progress reporting is not desired
      Throws:
      org.eclipse.core.runtime.CoreException - thrown when IResource.delete fails
    • delete

      public void delete(org.eclipse.core.runtime.IProgressMonitor progressMonitor, boolean overwriting) throws org.eclipse.core.runtime.CoreException
      Delete the trace resource, and optionally remove it from experiments and delete its supplementary files.
      Parameters:
      progressMonitor - a progress monitor, or null if progress reporting is not desired
      overwriting - if true, keep the trace in experiments and only delete non-hidden supplementary files (keeping the properties sub-folder), otherwise remove the trace from experiments and delete the supplementary folder completely
      Throws:
      org.eclipse.core.runtime.CoreException - thrown when IResource.delete fails
      Since:
      3.1
    • delete

      public void delete(org.eclipse.core.runtime.IProgressMonitor progressMonitor, boolean overwriting, boolean closeEditors) throws org.eclipse.core.runtime.CoreException
      Delete the trace resource, and optionally remove it from experiments and delete its supplementary files. Editors are first closed if requested.
      Parameters:
      progressMonitor - a progress monitor, or null if progress reporting is not desired
      overwriting - if true, keep the trace in experiments and only delete non-hidden supplementary files (keeping the properties sub-folder), otherwise remove the trace from experiments and delete the supplementary folder completely
      closeEditors - if true, editors associated with this trace are first closed before proceeding, otherwise it is the responsibility of the caller to first close editors before calling the method
      Throws:
      org.eclipse.core.runtime.CoreException - thrown when IResource.delete fails
      Since:
      4.0
    • setStartTime

      public void setStartTime(ITmfTimestamp startTime)
      Update the trace's start time
      Parameters:
      startTime - updated start time for this trace
      Since:
      3.0
    • getStartTime

      public ITmfTimestamp getStartTime()
      Getter for the trace start time
      Returns:
      the start time from the trace if available, or from self when read in advance from supplementary files or from fast trace read. Return null if completely unknown.
      Since:
      3.0
    • setEndTime

      public void setEndTime(@NonNull ITmfTimestamp end)
      Update the trace's end time
      Parameters:
      end - updated end time for this trace
      Since:
      3.0
    • getEndTime

      public ITmfTimestamp getEndTime()
      Getter for the trace end time
      Returns:
      the end time from the trace if available, or from self when read in advance from supplementary files or from fast trace read. Return null if completely unknown.
      Since:
      3.0
    • deleteSupplementaryResources

      public void deleteSupplementaryResources(org.eclipse.core.resources.IResource[] resources)
      Description copied from class: TmfCommonProjectElement
      Deletes the given resources.
      Overrides:
      deleteSupplementaryResources in class TmfCommonProjectElement
      Parameters:
      resources - array of resources to delete.
    • deleteSupplementaryResources

      public void deleteSupplementaryResources()
      Deletes all supplementary resources in the supplementary directory. Also delete the supplementary resources of experiments that contain this trace.
      Overrides:
      deleteSupplementaryResources in class TmfCommonProjectElement