use of com.intellij.openapi.module.ModifiableModuleModel in project android by JetBrains.
the class ModuleDisposer method disposeModulesAndMarkImlFilesForDeletion.
public void disposeModulesAndMarkImlFilesForDeletion(@NotNull Collection<Module> modules, @NotNull Project project, @NotNull IdeModifiableModelsProvider ideModelsProvider) {
if (!modules.isEmpty()) {
ModifiableModuleModel moduleModel = ideModelsProvider.getModifiableModuleModel();
List<File> imlFilesToRemove = new ArrayList<>();
for (Module toDispose : modules) {
File imlFilePath = new File(toSystemDependentName(toDispose.getModuleFilePath()));
imlFilesToRemove.add(imlFilePath);
moduleModel.disposeModule(toDispose);
}
DisposedModules.getInstance(project).markImlFilesForDeletion(imlFilesToRemove);
}
}
use of com.intellij.openapi.module.ModifiableModuleModel in project intellij-community by JetBrains.
the class MoveModuleToGroupTopLevel method getChildren.
@Override
@NotNull
public AnAction[] getChildren(@Nullable AnActionEvent e) {
if (e == null)
return EMPTY_ARRAY;
Project project = getEventProject(e);
if (project == null)
return EMPTY_ARRAY;
ModifiableModuleModel moduleModel = LangDataKeys.MODIFIABLE_MODULE_MODEL.getData(e.getDataContext());
ModuleGrouper grouper = ModuleGrouper.instanceFor(project, moduleModel);
List<String> topLevelGroupNames = new ArrayList<>(getTopLevelGroupNames(grouper));
Collections.sort(topLevelGroupNames);
List<AnAction> result = new ArrayList<>();
result.add(new MoveModulesOutsideGroupAction());
result.add(new MoveModulesToSubGroupAction(null));
result.add(Separator.getInstance());
for (String name : topLevelGroupNames) {
result.add(new MoveModuleToGroup(new ModuleGroup(Collections.singletonList(name))));
}
return result.toArray(new AnAction[result.size()]);
}
use of com.intellij.openapi.module.ModifiableModuleModel in project intellij-community by JetBrains.
the class MoveModulesToGroupAction method doMove.
public static void doMove(final Module[] modules, final ModuleGroup group, @Nullable final DataContext dataContext) {
Project project = modules[0].getProject();
for (final Module module : modules) {
ModifiableModuleModel model = dataContext != null ? LangDataKeys.MODIFIABLE_MODULE_MODEL.getData(dataContext) : null;
if (model != null) {
model.setModuleGroupPath(module, group == null ? null : group.getGroupPath());
} else {
ModuleManagerImpl.getInstanceImpl(project).setModuleGroupPath(module, group == null ? null : group.getGroupPath());
}
}
AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane();
if (pane != null) {
pane.updateFromRoot(true);
}
if (!ProjectSettingsService.getInstance(project).processModulesMoved(modules, group) && pane != null) {
if (group != null) {
pane.selectModuleGroup(group, true);
} else {
pane.selectModule(modules[0], true);
}
}
}
use of com.intellij.openapi.module.ModifiableModuleModel in project intellij-community by JetBrains.
the class NonProjectFileAccessTest method testAccessToModuleSystemFiles.
public void testAccessToModuleSystemFiles() throws Exception {
final Module moduleWithoutContentRoot = new WriteCommandAction<Module>(getProject()) {
@Override
protected void run(@NotNull Result<Module> result) throws Throwable {
String moduleName;
ModifiableModuleModel moduleModel = ModuleManager.getInstance(getProject()).getModifiableModel();
try {
VirtualFile moduleDir = getProject().getBaseDir().createChildDirectory(this, "moduleWithoutContentRoot");
moduleName = moduleModel.newModule(moduleDir.getPath() + "/moduleWithoutContentRoot.iml", EmptyModuleType.EMPTY_MODULE).getName();
moduleModel.commit();
} catch (Throwable t) {
moduleModel.dispose();
throw t;
}
result.setResult(ModuleManager.getInstance(getProject()).findModuleByName(moduleName));
}
}.execute().getResultObject();
PlatformTestUtil.saveProject(getProject());
VirtualFile fileUnderNonProjectModuleDir = createFileExternally(new File(moduleWithoutContentRoot.getModuleFile().getParent().getPath()));
assertFalse(ProjectFileIndex.SERVICE.getInstance(getProject()).isInContent(fileUnderNonProjectModuleDir));
typeAndCheck(moduleWithoutContentRoot.getModuleFile(), true);
typeAndCheck(myModule.getModuleFile(), true);
typeAndCheck(fileUnderNonProjectModuleDir, false);
}
use of com.intellij.openapi.module.ModifiableModuleModel in project intellij-community by JetBrains.
the class AbstractModuleDataService method importData.
@Override
public void importData(@NotNull final Collection<DataNode<E>> toImport, @Nullable ProjectData projectData, @NotNull final Project project, @NotNull IdeModifiableModelsProvider modelsProvider) {
if (toImport.isEmpty()) {
return;
}
final Collection<DataNode<E>> toCreate = filterExistingModules(toImport, modelsProvider, project);
if (!toCreate.isEmpty()) {
createModules(toCreate, modelsProvider, project);
}
for (DataNode<E> node : toImport) {
Module module = node.getUserData(MODULE_KEY);
if (module != null) {
String productionModuleId = node.getData().getProductionModuleId();
modelsProvider.setTestModuleProperties(module, productionModuleId);
setModuleOptions(module, node);
ModifiableRootModel modifiableRootModel = modelsProvider.getModifiableRootModel(module);
syncPaths(module, modifiableRootModel, node.getData());
setLanguageLevel(modifiableRootModel, node.getData());
}
}
for (DataNode<E> node : toImport) {
Module module = node.getUserData(MODULE_KEY);
if (module != null) {
final String[] groupPath;
groupPath = node.getData().getIdeModuleGroup();
final ModifiableModuleModel modifiableModel = modelsProvider.getModifiableModuleModel();
modifiableModel.setModuleGroupPath(module, groupPath);
}
}
}
Aggregations