com.intellij.openapi.module
Class ModuleManager

java.lang.Object
  extended by com.intellij.openapi.module.ModuleManager

public abstract class ModuleManager
extends java.lang.Object

Provides services for working with the modules of a project.


Constructor Summary
ModuleManager()
           
 
Method Summary
abstract  void addModuleListener(ModuleListener listener)
          Adds a listener for receiving notifications to the module structure of the project.
abstract  void dispatchPendingEvent(ModuleListener listener)
          Deprecated. for internal IDEA use.
abstract  void disposeModule(Module module)
          Disposes of the specified module and removes it from the project.
abstract  Module findModuleByName(java.lang.String name)
          Returns the project module with the specified name.
static ModuleManager getInstance(Project project)
          Returns the module manager instance for the current project.
abstract  ModifiableModuleModel getModifiableModel()
          Returns the model for the list of modules in the project, which can be used to add, remove or modify modules.
abstract  java.util.List<Module> getModuleDependentModules(Module module)
          Returns the list of modules which directly depend on the specified module.
abstract  java.lang.String[] getModuleGroupPath(Module module)
          Returns the path to the group to which the specified module belongs, as an array of group names starting from the project root.
abstract  Module[] getModules()
          Returns the list of all modules in the project.
abstract  Module[] getSortedModules()
          Returns the list of modules sorted by dependency (the modules which do not depend on anything are in the beginning of the list, a module which depends on another module follows it in the list).
abstract  boolean isModuleDependent(Module module, Module onModule)
          Checks if one of the specified modules directly depends on the other module.
abstract  Module loadModule(java.lang.String filePath)
          Loads a module from an .iml file with the specified path and adds it to the project.
abstract  java.util.Comparator<Module> moduleDependencyComparator()
          Returns the module comparator which can be used for sorting modules by dependency (the modules which do not depend on anything are in the beginning of the list, a module which depends on another module follows it in the list).
abstract  Graph<Module> moduleGraph()
          Returns the graph of dependencies between modules in the project.
abstract  Module newModule(java.lang.String filePath)
          Creates a Java module at the specified path and adds it to the project to which the module manager is related.
abstract  Module newModule(java.lang.String filePath, ModuleType moduleType)
          Creates a module of the specified type at the specified path and adds it to the project to which the module manager is related.
abstract  void removeModuleListener(ModuleListener listener)
          Removes a listener for receiving notifications to the module structure of the project.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModuleManager

public ModuleManager()
Method Detail

getInstance

public static ModuleManager getInstance(Project project)
Returns the module manager instance for the current project.

Parameters:
project - the project for which the module manager is requested.
Returns:
the module manager instance.

newModule

@NotNull
public abstract Module newModule(@NotNull
                                         java.lang.String filePath)
                          throws LoadCancelledException
Creates a Java module at the specified path and adds it to the project to which the module manager is related.

Parameters:
filePath - the path at which the module is created.
Returns:
the module instance.
Throws:
LoadCancelledException - in case of internal error while creating the module.

newModule

@NotNull
public abstract Module newModule(@NotNull
                                         java.lang.String filePath,
                                         @NotNull
                                         ModuleType moduleType)
                          throws LoadCancelledException
Creates a module of the specified type at the specified path and adds it to the project to which the module manager is related.

Parameters:
filePath - the path at which the module is created.
moduleType - the type of the module to create.
Returns:
the module instance.
Throws:
LoadCancelledException - in case of internal error while creating the module.

loadModule

@NotNull
public abstract Module loadModule(@NotNull
                                          java.lang.String filePath)
                           throws InvalidDataException,
                                  java.io.IOException,
                                  org.jdom.JDOMException,
                                  ModuleWithNameAlreadyExists,
                                  ModuleCircularDependencyException,
                                  LoadCancelledException
Loads a module from an .iml file with the specified path and adds it to the project.

Parameters:
filePath - the path to load the module from.
Returns:
the module instance.
Throws:
InvalidDataException - if the data in the .iml file is semantically incorrect.
java.io.IOException - if an I/O error occurred when loading the module file.
org.jdom.JDOMException - if the file contains invalid XML data.
ModuleWithNameAlreadyExists - if a module with such a name already exists in the project.
ModuleCircularDependencyException - never actually thrown (circular module dependency is not an error).
LoadCancelledException - if loading the module was cancelled by some of the components.

disposeModule

public abstract void disposeModule(@NotNull
                                   Module module)
Disposes of the specified module and removes it from the project.

Parameters:
module - the module to remove.

getModules

@NotNull
public abstract Module[] getModules()
Returns the list of all modules in the project.

Returns:
the array of modules.

findModuleByName

@Nullable
public abstract Module findModuleByName(@NotNull
                                                 java.lang.String name)
Returns the project module with the specified name.

Parameters:
name - the name of the module to find.
Returns:
the module instance, or null if no module with such name exists.

getSortedModules

@NotNull
public abstract Module[] getSortedModules()
Returns the list of modules sorted by dependency (the modules which do not depend on anything are in the beginning of the list, a module which depends on another module follows it in the list).

Returns:
the sorted array of modules.

moduleDependencyComparator

@NotNull
public abstract java.util.Comparator<Module> moduleDependencyComparator()
Returns the module comparator which can be used for sorting modules by dependency (the modules which do not depend on anything are in the beginning of the list, a module which depends on another module follows it in the list).

Returns:
the module comparator instance.

getModuleDependentModules

@NotNull
public abstract java.util.List<Module> getModuleDependentModules(@NotNull
                                                                         Module module)
Returns the list of modules which directly depend on the specified module.

Parameters:
module - the module for which the list of dependent modules is requested.
Returns:
list of modules that depend on given module.

isModuleDependent

public abstract boolean isModuleDependent(@NotNull
                                          Module module,
                                          @NotNull
                                          Module onModule)
Checks if one of the specified modules directly depends on the other module.

Parameters:
module - the module to check the dependency for.
onModule - the module on which module may depend.
Returns:
true if module directly depends on onModule, false otherwise.

addModuleListener

public abstract void addModuleListener(@NotNull
                                       ModuleListener listener)
Adds a listener for receiving notifications to the module structure of the project.

Parameters:
listener - the listener instance.

removeModuleListener

public abstract void removeModuleListener(@NotNull
                                          ModuleListener listener)
Removes a listener for receiving notifications to the module structure of the project.

Parameters:
listener - the listener instance.

moduleGraph

@NotNull
public abstract Graph<Module> moduleGraph()
Returns the graph of dependencies between modules in the project.

Returns:
the module dependency graph.

getModifiableModel

@NotNull
public abstract ModifiableModuleModel getModifiableModel()
Returns the model for the list of modules in the project, which can be used to add, remove or modify modules.

Returns:
the modifiable model instance.

dispatchPendingEvent

public abstract void dispatchPendingEvent(@NotNull
                                          ModuleListener listener)
Deprecated. for internal IDEA use.


getModuleGroupPath

@Nullable
public abstract java.lang.String[] getModuleGroupPath(@NotNull
                                                               Module module)
Returns the path to the group to which the specified module belongs, as an array of group names starting from the project root.

Parameters:
module - the module for which the path is requested.
Returns:
the path to the group for the module, or null if the module does not belong to any group.