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);
}
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()]);
}
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;
}
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());
}
});
}
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();
}
Aggregations