Class ProjectsManager
- java.lang.Object
-
- com.nomagic.magicdraw.core.project.ProjectsManager
-
- All Implemented Interfaces:
ProjectPersistenceManager
@OpenApi public class ProjectsManager extends java.lang.Object implements ProjectPersistenceManager
Stores and manages multiple projects.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addProjectListener(ProjectEventListener listener)
Adds new project listener.void
closeProject()
Closes current project.void
closeProject(Project project)
Closes given projectProject
createProject()
Creates new project.Project
createProjectFromTemplate(java.lang.String templatePath)
Creates a new project from the given template.void
exportModule(Project prj, java.util.Collection packages, java.lang.String description, ProjectDescriptor module)
Export local (not teamwork) module into given descriptorIAttachedProject
findAttachedProject(Project project, ProjectDescriptor projectDescriptor)
Find used module according given project descriptor.Project
findProject(ProjectDescriptor projectDescriptor)
Find loaded project according given project descriptor.Project
getActiveProject()
Returns active open project.java.util.List<Project>
getProjects()
Returns list of open projects.void
importModule(Project project, ProjectDescriptor descriptor)
Import module into project from given descriptorboolean
importProject(ProjectDescriptor pd)
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, IAttachedProject module, boolean silent, boolean temporalSave)
Save module from current project into given location.boolean
saveModule(Project project, IAttachedProject module, boolean silent, ProgressStatus status)
Saves module without any additional dependencies checking.boolean
saveModule(Project project, IAttachedProject module, boolean silent, ProgressStatus status, boolean temporalSave)
Saves module without any additional dependencies checking.boolean
saveModule(Project project, IAttachedProject module, boolean silent, ProgressStatus status, java.net.URI saveTo)
Saves module without any additional dependencies checking.boolean
saveModule(Project project, IAttachedProject module, boolean silent, ProgressStatus status, java.net.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, java.util.List<Package> packages)
void
sharePackage(Project project, java.util.List<Package> packages, java.lang.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 Detail
-
getProjects
@OpenApi public java.util.List<Project> getProjects()
Returns list of open projects.- Returns:
- list of open projects.
-
isProjectActive
@OpenApi public boolean isProjectActive(@CheckForNull Project project)
Method checks if given project is active at this time.- Parameters:
project
- project to check.- Returns:
- true if given project is active.
-
setActiveProject
@OpenApi public void setActiveProject(@CheckForNull Project project)
Sets given project as active. Updates GUI.- Parameters:
project
- the project to be set as active.
-
getActiveProject
@OpenApi @CheckForNull public Project getActiveProject()
Returns active open project.- Returns:
- active project.
-
addProjectListener
@OpenApi public void addProjectListener(ProjectEventListener listener)
Adds new project listener.- Parameters:
listener
- listener to be added.
-
removeProjectListener
@OpenApi public void removeProjectListener(ProjectEventListener listener)
Removes project listener.- Parameters:
listener
- listener to be removed.
-
loadProject
@OpenApi public void loadProject(ProjectDescriptor descriptor, boolean silent)
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
@OpenApi public boolean saveProject(ProjectDescriptor descriptor, boolean silent)
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
@OpenApi public Project createProject()
Creates new project.- Returns:
- created project.
-
createProjectFromTemplate
@OpenApi @CheckForNull public Project createProjectFromTemplate(java.lang.String templatePath)
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
@OpenApi public void closeProject(Project project)
Closes given project- Parameters:
project
- project to close
-
useModule
@OpenApi public boolean useModule(Project project, ProjectDescriptor module)
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
@OpenApi public void reloadModule(Project project, ProjectDescriptor projectDescriptor)
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, java.util.Collection packages, java.lang.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, 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, 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, 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, IAttachedProject module, boolean silent, ProgressStatus status, java.net.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, IAttachedProject module, boolean silent, @CheckForNull ProgressStatus status, @CheckForNull java.net.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
@OpenApi public void unloadModule(Project project, ProjectDescriptor moduleDescriptor)
Unload module- Specified by:
unloadModule
in interfaceProjectPersistenceManager
- Parameters:
project
- projectmoduleDescriptor
- module descriptor
-
findAttachedProject
@OpenApi @CheckForNull public 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
@OpenApi @CheckForNull public Project findProject(ProjectDescriptor projectDescriptor)
Find loaded project according given project descriptor.- Parameters:
projectDescriptor
- project descriptor.- Returns:
null
if project not found.
-
sharePackage
@OpenApi @Deprecated public void sharePackage(Project project, java.util.List<Package> packages)
Share given list of packages in project.- Parameters:
project
- Project where packages will be shared.packages
- List of packaged, dedicated for sharing.
-
sharePackage
@OpenApi public void sharePackage(Project project, java.util.List<Package> packages, @CheckForNull java.lang.String description)
Share given list of packages in project. On CTS decomposition must be locked before sharing.- Parameters:
project
- Project where packages will be shared.packages
- List of packaged, dedicated for sharing.description
- share description, null if do not change/set the description.- Throws:
java.lang.RuntimeException
- if either some being shared package becomes invalid in the main project (that is, has been deleted or moved to a module) or is locked by another user
-
importProject
@OpenApi public boolean importProject(ProjectDescriptor pd)
Import project.- Specified by:
importProject
in interfaceProjectPersistenceManager
- Parameters:
pd
- project descriptor to import.- Returns:
- true if project was imported
-
-