Class ResourcesMgmt
- java.lang.Object
-
- net.ssehub.easy.producer.eclipse.persistency.ResourcesMgmt
-
public class ResourcesMgmt extends java.lang.ObjectResources abstraction layer.- Author:
- El-Sharkawy
-
-
Field Summary
Fields Modifier and Type Field Description private booleanenableBackgroundTasksstatic ResourcesMgmtINSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description privateResourcesMgmt()Hides the default constructor for this singleton class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEASyNatures(org.eclipse.core.resources.IProject project, java.lang.String... natures)Adds the EASy-Nature to an EclipseIProject, the project does not have this nature.voidenableBackgroundTasks(boolean enable)Enables or disables background tasks.voidfindPLProjects()Iterates through all EASy projects of the workspace, gets the config path and the uuid from all projects and adds them to theSPLsManager.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.StringgetIDfromResource(org.eclipse.core.resources.IResource theResource)Returns the ID of the project holding the resource.org.eclipse.core.resources.IProjectgetProject(java.lang.String projectname)Returns a representation of the selected project.java.io.FilegetProjectLocation(java.lang.String projectname)Retrieves the absolute path of an IProject inside the file system.chargetSeperator()Returns the local file Seperator.org.eclipse.core.resources.IWorkspacegetWorkspace()Returns a representation of the current used workspace.java.io.FilegetWorspaceFolder()Returns the workspace as aFileobject.booleanisPLPInWorkspace(java.lang.String name)Checks for a given name, whether a PLP with said name is located in the current workspace.private voidloadAndInitialize(org.eclipse.core.resources.IProject project)Loads and initializes the project.voidrefreshProject(java.lang.String projectname)Refreshes the files and folders in the package explorer view for the given project.
-
-
-
Field Detail
-
INSTANCE
public static final ResourcesMgmt INSTANCE
-
enableBackgroundTasks
private boolean enableBackgroundTasks
-
-
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 downPLPWorkspaceListener.- Parameters:
enable-trueenables the background tasks,falseelse
-
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 aFileobject.- 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 theSPLsManager. ConsidersenableBackgroundTasks.
-
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.IOExceptionAdds the EASy-Nature to an EclipseIProject, 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 openInvalidProjectnameException- 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, InvalidProjectnameExceptionLoads and initializes the project.- Parameters:
project- the project to be loaded- Throws:
java.io.IOException- in case of loading/initialization problemsInvalidProjectnameException- If the project which should be created has a non-valid name.
-
-