Class ResourcesMgmt
java.lang.Object
net.ssehub.easy.producer.eclipse.persistency.ResourcesMgmt
Resources abstraction layer.
- Author:
- El-Sharkawy
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateHides the default constructor for this singleton class. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEASyNatures(org.eclipse.core.resources.IProject project, String... natures) Adds the EASy-Nature to an EclipseIProject, the project does not have this nature.voidenableBackgroundTasks(boolean enable) Enables or disables background tasks.voidIterates through all EASy projects of the workspace, gets the config path and the uuid from all projects and adds them to theSPLsManager.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.IProjectgetProject(String projectname) Returns a representation of the selected project.getProjectLocation(String projectname) Retrieves the absolute path of anIProjectinside the file system.charReturns the local file Seperator.org.eclipse.core.resources.IWorkspaceReturns a representation of the current used workspace.Returns the workspace as aFileobject.booleanisPLPInWorkspace(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(String projectname) Refreshes the files and folders in the package explorer view for the given project.
-
Field Details
-
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 downPLPWorkspaceListener.- Parameters:
enable-trueenables the background tasks,falseelse
-
isPLPInWorkspace
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
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
nullif 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
Returns the workspace as aFileobject.- Returns:
- The location of the workspace inside the file system or
nullif 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
gets all PLugin projects from the workspace and adds it to an arraylist.- Returns:
- an arraylist filled with PLugin projects
-
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.- Parameters:
obs- progress monitor
-
refreshProject
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
Retrieves the absolute path of anIProjectinside the file system.- Parameters:
projectname- The name of the project, which location shall be determined.- Returns:
- The location inside the file system or
workspace/projectnameif the specifiedIProjectdoes 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 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.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 problemsInvalidProjectnameException- If the project which should be created has a non-valid name.
-