Class ResourcesMgmt

java.lang.Object
net.ssehub.easy.producer.eclipse.persistency.ResourcesMgmt

public class ResourcesMgmt extends Object
Resources abstraction layer.
Author:
El-Sharkawy
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
     
    static final ResourcesMgmt
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Hides the default constructor for this singleton class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addEASyNatures(org.eclipse.core.resources.IProject project, String... natures)
    Adds the EASy-Nature to an Eclipse IProject, the project does not have this nature.
    void
    enableBackgroundTasks(boolean enable)
    Enables or disables background tasks.
    void
    Iterates through all EASy projects of the workspace, gets the config path and the uuid from all projects and adds them to the SPLsManager.
    private ArrayList<org.eclipse.core.resources.IProject>
    gets all PLugin projects from the workspace and adds it to an arraylist.
    org.eclipse.core.resources.IProject[]
    Returns all existing projects inside the current workspace.
    getIDfromResource(org.eclipse.core.resources.IResource theResource, org.eclipse.core.resources.IProject project)
    Returns the ID of the project holding the resource.
    org.eclipse.core.resources.IProject
    getProject(String projectname)
    Returns a representation of the selected project.
    Retrieves the absolute path of an IProject inside the file system.
    char
    Returns the local file Seperator.
    org.eclipse.core.resources.IWorkspace
    Returns a representation of the current used workspace.
    Returns the workspace as a File object.
    boolean
    Checks for a given name, whether a PLP with said name is located in the current workspace.
    private void
    loadAndInitialize(org.eclipse.core.resources.IProject project)
    Loads and initializes the project.
    void
    refreshProject(String projectname)
    Refreshes the files and folders in the package explorer view for the given project.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • INSTANCE

      public static final ResourcesMgmt INSTANCE
    • enableBackgroundTasks

      private boolean enableBackgroundTasks
  • Constructor Details

    • ResourcesMgmt

      private ResourcesMgmt()
      Hides the default constructor for this singleton class.
  • Method Details

    • enableBackgroundTasks

      public void enableBackgroundTasks(boolean enable)
      Enables or disables background tasks. This may be helpful in non-full EASy environments, such as the QualiMaster configuration application. May require shutting down PLPWorkspaceListener.
      Parameters:
      enable - true enables the background tasks, false else
    • isPLPInWorkspace

      public boolean isPLPInWorkspace(String name)
      Checks for a given name, whether a PLP with said name is located in the current workspace.
      Parameters:
      name - the name of the project to check
      Returns:
      true if the project is a plp and located in the workspace
    • getProject

      public org.eclipse.core.resources.IProject getProject(String projectname)
      Returns a representation of the selected project.
      Parameters:
      projectname - The name of the IProject which shall be retrieved.
      Returns:
      A representation of the selected project
    • getWorkspace

      public org.eclipse.core.resources.IWorkspace getWorkspace()
      Returns a representation of the current used workspace.
      Returns:
      A representation of the current used workspace or null if no workspace was loaded (this may happen if the responsible Eclipse plug-in was not loaded and started, e.g. when EASy runs as a command line tool).
    • getWorspaceFolder

      public File getWorspaceFolder()
      Returns the workspace as a File object.
      Returns:
      The location of the workspace inside the file system or null if the workspace was not loaded.
      See Also:
    • getAllProjects

      public org.eclipse.core.resources.IProject[] getAllProjects()
      Returns all existing projects inside the current workspace.
      Returns:
      All projects inside the workspace.
    • getAllPLProjects

      private ArrayList<org.eclipse.core.resources.IProject> getAllPLProjects()
      gets all PLugin projects from the workspace and adds it to an arraylist.
      Returns:
      an arraylist filled with PLugin projects
    • findPLProjects

      public void findPLProjects(EclipseProgressObserver obs)
      Iterates through all EASy projects of the workspace, gets the config path and the uuid from all projects and adds them to the SPLsManager. Considers enableBackgroundTasks.
      Parameters:
      obs - progress monitor
    • refreshProject

      public void refreshProject(String projectname)
      Refreshes the files and folders in the package explorer view for the given project.
      Parameters:
      projectname - The name of the project to be refreshed.
    • getProjectLocation

      public File getProjectLocation(String projectname)
      Retrieves the absolute path of an IProject inside the file system.
      Parameters:
      projectname - The name of the project, which location shall be determined.
      Returns:
      The location inside the file system or workspace/projectname if the specified IProject does not exist.
    • getSeperator

      public char getSeperator()
      Returns the local file Seperator.
      This method should be used instead of "\".
      Returns:
      Returns a valid file seperator.
    • getIDfromResource

      public String getIDfromResource(org.eclipse.core.resources.IResource theResource, org.eclipse.core.resources.IProject project)
      Returns the ID of the project holding the resource.
      Parameters:
      theResource - Resource of a project from which the ID should be determined.
      project - the project to operate on, may be null
      Returns:
      ID of the related project or null if it cannot be determined.
    • addEASyNatures

      public void addEASyNatures(org.eclipse.core.resources.IProject project, String... natures) throws org.eclipse.core.runtime.CoreException, InvalidProjectnameException, IOException
      Adds the EASy-Nature to an Eclipse IProject, the project does not have this nature. Will also add all another relevant information needed to work with EASy if not existent, these are:
      • The Xtext nature to open use its editors for IVML, VIL, VTL, ...
      • EASy Folder with default configuration files:
        • Main IVML file
        • Main VIL file
        • .EASyConfig
      Parameters:
      project - A project from the workspace.
      natures - Must be the Xtext and the EASy nature (unfortunately, they are provided by UI packages).
      Throws:
      org.eclipse.core.runtime.CoreException - If project does not exist or is not open
      InvalidProjectnameException - If the project which should be created has a non-valid name.
      IOException - In case of loading/initialization problems
    • loadAndInitialize

      private void loadAndInitialize(org.eclipse.core.resources.IProject project) throws IOException, InvalidProjectnameException
      Loads and initializes the project.
      Parameters:
      project - the project to be loaded
      Throws:
      IOException - in case of loading/initialization problems
      InvalidProjectnameException - If the project which should be created has a non-valid name.