Class ProjectsManager

java.lang.Object
com.nomagic.magicdraw.core.project.ProjectsManager
All Implemented Interfaces:
ProjectPersistenceManager

@OpenApi public class ProjectsManager extends Object implements ProjectPersistenceManager
Stores and manages multiple projects.
  • Method Details

    • getProjects

      @OpenApi public 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 interface ProjectPersistenceManager
      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 interface ProjectPersistenceManager
      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(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();
      List directories = projectOptions.getModulesDirectories(true);
      if (!directories.contains(moduleDir))
      {
          projectOptions.addModuleDirectory(moduleDir);
      }

      Specified by:
      useModule in interface ProjectPersistenceManager
      Parameters:
      project - project
      module - module
      Returns:
      true if module was used
    • reloadModule

      @OpenApi public void reloadModule(Project project, ProjectDescriptor projectDescriptor)
      Reloads module.
      Specified by:
      reloadModule in interface ProjectPersistenceManager
      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 interface ProjectPersistenceManager
      Parameters:
      project - project
      descriptor - 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 interface ProjectPersistenceManager
      Parameters:
      prj - current project
      packages - "shared" packages in project
      description - module description
      module - 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 interface ProjectPersistenceManager
      Parameters:
      project - project
      module - module to save
      silent - do not show UI messages
      temporalSave - 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 interface ProjectPersistenceManager
      Parameters:
      project - project
      module - module to save
      silent - save in silent mode
      status - 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 interface ProjectPersistenceManager
      Parameters:
      project - project
      module - module to save
      silent - save in silent mode
      status - progress status
      temporalSave - 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 - project
      module - module to save
      status - status
      silent - save in silent mode
      saveTo - 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 - project
      module - module to save
      silent - save in silent mode
      status - progress status
      saveTo - where to save module, can be null, then module is saved to module.getURI() location
      temporalSave - 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 interface ProjectPersistenceManager
      Parameters:
      project - project
      moduleDescriptor - 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

      @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, 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, List<Package> packages, @CheckForNull 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:
      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 interface ProjectPersistenceManager
      Parameters:
      pd - project descriptor to import.
      Returns:
      true if project was imported