Search in sources :

Example 81 with ModifiableRootModel

use of com.intellij.openapi.roots.ModifiableRootModel in project intellij-community by JetBrains.

the class DefaultModuleConfigurationEditorFactoryImpl method createModuleContentRootsEditor.

@Override
public ModuleConfigurationEditor createModuleContentRootsEditor(ModuleConfigurationState state) {
    final ModifiableRootModel rootModel = state.getRootModel();
    final Module module = rootModel.getModule();
    final String moduleName = module.getName();
    return new ContentEntriesEditor(moduleName, state);
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) Module(com.intellij.openapi.module.Module)

Example 82 with ModifiableRootModel

use of com.intellij.openapi.roots.ModifiableRootModel in project intellij-community by JetBrains.

the class DefaultModuleEditorsProvider method createEditors.

@Override
public ModuleConfigurationEditor[] createEditors(ModuleConfigurationState state) {
    ModifiableRootModel rootModel = state.getRootModel();
    Module module = rootModel.getModule();
    if (!(ModuleType.get(module) instanceof JavaModuleType)) {
        return ModuleConfigurationEditor.EMPTY;
    }
    String moduleName = module.getName();
    List<ModuleConfigurationEditor> editors = new ArrayList<>();
    editors.add(new ContentEntriesEditor(moduleName, state));
    editors.add(new OutputEditor(state));
    editors.add(new ClasspathEditor(state));
    return editors.toArray(new ModuleConfigurationEditor[editors.size()]);
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) ModuleConfigurationEditor(com.intellij.openapi.module.ModuleConfigurationEditor) JavaModuleType(com.intellij.openapi.module.JavaModuleType) ArrayList(java.util.ArrayList) Module(com.intellij.openapi.module.Module)

Example 83 with ModifiableRootModel

use of com.intellij.openapi.roots.ModifiableRootModel in project intellij-community by JetBrains.

the class ModulesConfigurator method doRemoveModules.

private boolean doRemoveModules(@NotNull List<ModuleEditor> selectedEditors) {
    if (selectedEditors.isEmpty())
        return true;
    String question;
    if (myModuleEditors.size() == selectedEditors.size()) {
        question = ProjectBundle.message("module.remove.last.confirmation", selectedEditors.size());
    } else {
        question = ProjectBundle.message("module.remove.confirmation", selectedEditors.get(0).getModule().getName(), selectedEditors.size());
    }
    int result = Messages.showYesNoDialog(myProject, question, ProjectBundle.message("module.remove.confirmation.title", selectedEditors.size()), Messages.getQuestionIcon());
    if (result != Messages.YES) {
        return false;
    }
    for (ModuleEditor editor : selectedEditors) {
        myModuleEditors.remove(editor.getModule());
        final Module moduleToRemove = editor.getModule();
        // remove all dependencies on the module which is about to be removed
        List<ModifiableRootModel> modifiableRootModels = new ArrayList<>();
        for (final ModuleEditor moduleEditor : myModuleEditors.values()) {
            final ModifiableRootModel modifiableRootModel = moduleEditor.getModifiableRootModelProxy();
            ContainerUtil.addIfNotNull(modifiableRootModels, modifiableRootModel);
        }
        ModuleDeleteProvider.removeModule(moduleToRemove, null, modifiableRootModels, myModuleModel);
        Disposer.dispose(editor);
    }
    processModuleCountChanged();
    return true;
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) Module(com.intellij.openapi.module.Module)

Example 84 with ModifiableRootModel

use of com.intellij.openapi.roots.ModifiableRootModel in project intellij-community by JetBrains.

the class MavenFoldersImporter method updateProjectFolders.

public static void updateProjectFolders(final Project project, final boolean updateTargetFoldersOnly) {
    final MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
    final MavenImportingSettings settings = manager.getImportingSettings();
    WriteAction.run(() -> {
        List<ModifiableRootModel> rootModels = new ArrayList<>();
        for (Module each : ModuleManager.getInstance(project).getModules()) {
            MavenProject mavenProject = manager.findProject(each);
            if (mavenProject == null)
                continue;
            MavenRootModelAdapter a = new MavenRootModelAdapter(mavenProject, each, new IdeModifiableModelsProviderImpl(project));
            new MavenFoldersImporter(mavenProject, settings, a).config(updateTargetFoldersOnly);
            ModifiableRootModel model = a.getRootModel();
            if (model.isChanged()) {
                rootModels.add(model);
            } else {
                model.dispose();
            }
        }
        if (!rootModels.isEmpty()) {
            ModifiableModelCommitter.multiCommit(rootModels, ModuleManager.getInstance(rootModels.get((0)).getProject()).getModifiableModel());
        }
    });
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) ArrayList(java.util.ArrayList) MavenImportingSettings(org.jetbrains.idea.maven.project.MavenImportingSettings) Module(com.intellij.openapi.module.Module)

Example 85 with ModifiableRootModel

use of com.intellij.openapi.roots.ModifiableRootModel in project intellij-community by JetBrains.

the class MavenProjectImporter method collectModuleModels.

private Collection<ModuleRootModel> collectModuleModels() {
    Map<Module, ModuleRootModel> rootModels = new THashMap<>();
    for (MavenProject each : myProjectsToImportWithChanges.keySet()) {
        Module module = myMavenProjectToModule.get(each);
        ModifiableRootModel rootModel = myModelsProvider.getModifiableRootModel(module);
        rootModels.put(module, rootModel);
    }
    for (Module each : myModuleModel.getModules()) {
        if (rootModels.containsKey(each))
            continue;
        rootModels.put(each, myModelsProvider.getModifiableRootModel(each));
    }
    return rootModels.values();
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) THashMap(gnu.trove.THashMap) ModuleRootModel(com.intellij.openapi.roots.ModuleRootModel) Module(com.intellij.openapi.module.Module)

Aggregations

ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)102 Module (com.intellij.openapi.module.Module)44 VirtualFile (com.intellij.openapi.vfs.VirtualFile)29 ContentEntry (com.intellij.openapi.roots.ContentEntry)27 File (java.io.File)18 Library (com.intellij.openapi.roots.libraries.Library)15 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)14 ModuleManager (com.intellij.openapi.module.ModuleManager)8 Sdk (com.intellij.openapi.projectRoots.Sdk)8 IOException (java.io.IOException)8 NotNull (org.jetbrains.annotations.NotNull)8 OrderEntry (com.intellij.openapi.roots.OrderEntry)7 Project (com.intellij.openapi.project.Project)6 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)6 Nullable (org.jetbrains.annotations.Nullable)6 ModifiableModuleModel (com.intellij.openapi.module.ModifiableModuleModel)5 ConfigurationException (com.intellij.openapi.options.ConfigurationException)5 THashMap (gnu.trove.THashMap)5 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)4 AccessToken (com.intellij.openapi.application.AccessToken)4