Class ResourcesMgmt


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

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEASyNatures​(org.eclipse.core.resources.IProject project, java.lang.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 findPLProjects()
      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 java.util.ArrayList<org.eclipse.core.resources.IProject> getAllPLProjects()
      gets all PLugin projects from the workspace and adds it to an arraylist.
      org.eclipse.core.resources.IProject[] getAllProjects()
      Returns all existing projects inside the current workspace.
      java.lang.String getIDfromResource​(org.eclipse.core.resources.IResource theResource)
      Returns the ID of the project holding the resource.
      org.eclipse.core.resources.IProject getProject​(java.lang.String projectname)
      Returns a representation of the selected project.
      java.io.File getProjectLocation​(java.lang.String projectname)
      Retrieves the absolute path of an IProject inside the file system.
      char getSeperator()
      Returns the local file Seperator.
      org.eclipse.core.resources.IWorkspace getWorkspace()
      Returns a representation of the current used workspace.
      java.io.File getWorspaceFolder()
      Returns the workspace as a File object.
      boolean isPLPInWorkspace​(java.lang.String name)
      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​(java.lang.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 Detail

      • enableBackgroundTasks

        private boolean enableBackgroundTasks
    • Constructor Detail

      • ResourcesMgmt

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

      • 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​(java.lang.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​(java.lang.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 java.io.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:
        getWorkspace()
      • getAllProjects

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

        private java.util.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()
        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.
      • refreshProject

        public void refreshProject​(java.lang.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 java.io.File getProjectLocation​(java.lang.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 java.lang.String getIDfromResource​(org.eclipse.core.resources.IResource theResource)
        Returns the ID of the project holding the resource.
        Parameters:
        theResource - Resource of a project from which the ID should be determined.
        Returns:
        ID of the related project or null if it cannot be determined.
      • addEASyNatures

        public void addEASyNatures​(org.eclipse.core.resources.IProject project,
                                   java.lang.String... natures)
                            throws org.eclipse.core.runtime.CoreException,
                                   InvalidProjectnameException,
                                   java.io.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.
        java.io.IOException - In case of loading/initialization problems
      • loadAndInitialize

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