Class ProjectsManager
java.lang.Object
com.nomagic.magicdraw.core.project.ProjectsManager
- All Implemented Interfaces:
ProjectPersistenceManager
Stores and manages multiple projects.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addProjectListener
(ProjectEventListener listener) Adds new project listener.void
Closes current project.void
closeProject
(Project project) Closes given projectCreates new project.createProjectFromTemplate
(String templatePath) Creates a new project from the given template.void
exportModule
(Project prj, Collection packages, String description, ProjectDescriptor module) Export local (not teamwork) module into given descriptorcom.nomagic.ci.persistence.IAttachedProject
findAttachedProject
(Project project, ProjectDescriptor projectDescriptor) Find used module according given project descriptor.findProject
(ProjectDescriptor projectDescriptor) Find loaded project according given project descriptor.Returns active open project.Returns list of open projects.void
importModule
(Project project, ProjectDescriptor descriptor) Import module into project from given descriptorboolean
Import project.boolean
isProjectActive
(Project project) Method checks if given project is active at this time.void
loadProject
(ProjectDescriptor descriptor, boolean silent) Loads project from location, described in a project descriptor.void
reloadModule
(Project project, ProjectDescriptor projectDescriptor) Reloads module.void
removeProjectListener
(ProjectEventListener listener) Removes project listener.boolean
saveModule
(Project project, com.nomagic.ci.persistence.IAttachedProject module, boolean silent, boolean temporalSave) Save module from current project into given location.boolean
saveModule
(Project project, com.nomagic.ci.persistence.IAttachedProject module, boolean silent, ProgressStatus status) Saves module without any additional dependencies checking.boolean
saveModule
(Project project, com.nomagic.ci.persistence.IAttachedProject module, boolean silent, ProgressStatus status, boolean temporalSave) Saves module without any additional dependencies checking.boolean
saveModule
(Project project, com.nomagic.ci.persistence.IAttachedProject module, boolean silent, ProgressStatus status, URI saveTo) Saves module without any additional dependencies checking.boolean
saveModule
(Project project, com.nomagic.ci.persistence.IAttachedProject module, boolean silent, ProgressStatus status, URI saveTo, boolean temporalSave) Saves module without any additional dependencies checking.boolean
saveProject
(ProjectDescriptor descriptor, boolean silent) Saves project into location specified by descriptor.void
setActiveProject
(Project project) Sets given project as active.void
sharePackage
(Project project, List<Package> packages) Deprecated.void
sharePackage
(Project project, List<Package> packages, String description) Share given list of packages in project.void
unloadModule
(Project project, ProjectDescriptor moduleDescriptor) Unload moduleboolean
useModule
(Project project, ProjectDescriptor module) Use module in given project from given descriptor.
-
Method Details
-
getProjects
Returns list of open projects.- Returns:
- list of open projects.
-
isProjectActive
Method checks if given project is active at this time.- Parameters:
project
- project to check.- Returns:
- true if given project is active.
-
setActiveProject
Sets given project as active. Updates GUI.- Parameters:
project
- the project to be set as active.
-
getActiveProject
Returns active open project.- Returns:
- active project.
-
addProjectListener
Adds new project listener.- Parameters:
listener
- listener to be added.
-
removeProjectListener
Removes project listener.- Parameters:
listener
- listener to be removed.
-
loadProject
Loads project from location, described in a project descriptor. Loading is done on EDT.- Specified by:
loadProject
in interfaceProjectPersistenceManager
- Parameters:
descriptor
- the project descriptor.silent
- if true, loads without GUI interruptions.
-
saveProject
Saves project into location specified by descriptor.- Specified by:
saveProject
in interfaceProjectPersistenceManager
- Parameters:
descriptor
- the project descriptor.silent
- if true, saves without GUI interruptions.
-
createProject
Creates new project.- Returns:
- created project.
-
createProjectFromTemplate
Creates a new project from the given template.- Parameters:
templatePath
- absolute template path- Returns:
- created project.
-
closeProject
@OpenApi public void closeProject()Closes current project. -
closeProject
Closes given project- Parameters:
project
- project to close
-
useModule
Use module in given project from given descriptor.Need to update
ProjectOptions
before using local module:
String moduleDir = moduleFile.getParent();
ProjectOptions projectOptions = project.getOptions();
Listdirectories = projectOptions.getModulesDirectories(true);
if (!directories.contains(moduleDir))
{
projectOptions.addModuleDirectory(moduleDir);
}- Specified by:
useModule
in interfaceProjectPersistenceManager
- Parameters:
project
- projectmodule
- module- Returns:
- true if module was used
-
reloadModule
Reloads module.- Specified by:
reloadModule
in interfaceProjectPersistenceManager
- Parameters:
project
- the project.projectDescriptor
- the ProjectDescriptor of the module.
-
importModule
@OpenApi public void importModule(Project project, ProjectDescriptor descriptor) throws ReadOnlyElementException Import module into project from given descriptor- Specified by:
importModule
in interfaceProjectPersistenceManager
- Parameters:
project
- projectdescriptor
- descriptor- Throws:
ReadOnlyElementException
- if user has no rights to perform this action.
-
exportModule
@OpenApi public void exportModule(Project prj, Collection packages, String description, ProjectDescriptor module) Export local (not teamwork) module into given descriptor- Specified by:
exportModule
in interfaceProjectPersistenceManager
- Parameters:
prj
- current projectpackages
- "shared" packages in projectdescription
- module descriptionmodule
- module location descriptor
-
saveModule
@OpenApi public boolean saveModule(Project project, com.nomagic.ci.persistence.IAttachedProject module, boolean silent, boolean temporalSave) Save module from current project into given location.- Specified by:
saveModule
in interfaceProjectPersistenceManager
- Parameters:
project
- projectmodule
- module to savesilent
- do not show UI messagestemporalSave
- do not change module location after save- Returns:
- true if module was saved
-
saveModule
@OpenApi public boolean saveModule(Project project, com.nomagic.ci.persistence.IAttachedProject module, boolean silent, ProgressStatus status) Saves module without any additional dependencies checking.- Specified by:
saveModule
in interfaceProjectPersistenceManager
- Parameters:
project
- projectmodule
- module to savesilent
- save in silent modestatus
- progress status- Returns:
- true if operation was successful
-
saveModule
@OpenApi public boolean saveModule(Project project, com.nomagic.ci.persistence.IAttachedProject module, boolean silent, ProgressStatus status, boolean temporalSave) Saves module without any additional dependencies checking.- Specified by:
saveModule
in interfaceProjectPersistenceManager
- Parameters:
project
- projectmodule
- module to savesilent
- save in silent modestatus
- progress statustemporalSave
- do not change module location after save- Returns:
- true if operation was successful
-
saveModule
@OpenApi public boolean saveModule(Project project, com.nomagic.ci.persistence.IAttachedProject module, boolean silent, ProgressStatus status, URI saveTo) Saves module without any additional dependencies checking.- Parameters:
project
- projectmodule
- module to savestatus
- statussilent
- save in silent modesaveTo
- where to save module, can be null, then module is saved to module.getURI() location- Returns:
- true if operation was successful
-
saveModule
@OpenApi public boolean saveModule(Project project, com.nomagic.ci.persistence.IAttachedProject module, boolean silent, @CheckForNull ProgressStatus status, @CheckForNull URI saveTo, boolean temporalSave) Saves module without any additional dependencies checking.- Parameters:
project
- projectmodule
- module to savesilent
- save in silent modestatus
- progress statussaveTo
- where to save module, can be null, then module is saved to module.getURI() locationtemporalSave
- do not change module location after save- Returns:
- true if operation was successful
-
unloadModule
Unload module- Specified by:
unloadModule
in interfaceProjectPersistenceManager
- Parameters:
project
- projectmoduleDescriptor
- module descriptor
-
findAttachedProject
@OpenApi @CheckForNull public com.nomagic.ci.persistence.IAttachedProject findAttachedProject(Project project, ProjectDescriptor projectDescriptor) Find used module according given project descriptor.- Parameters:
project
- project using module.projectDescriptor
- project descriptor of module.- Returns:
- found attached project or null
-
findProject
Find loaded project according given project descriptor.- Parameters:
projectDescriptor
- project descriptor.- Returns:
null
if project not found.
-
importProject
Import project.- Specified by:
importProject
in interfaceProjectPersistenceManager
- Parameters:
pd
- project descriptor to import.- Returns:
- true if project was imported
-
sharePackage(com.nomagic.magicdraw.core.Project, java.util.List, String)
.