use of com.intellij.openapi.roots.IdeaModifiableModelsProvider in project intellij-community by JetBrains.
the class AddFrameworkSupportInProjectStructureAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Module module = getSelectedModule();
if (module == null)
return;
final LibrariesContainer librariesContainer = LibrariesContainerFactory.createContainer(myModuleStructureConfigurable.getContext());
new AddSupportForSingleFrameworkDialog(module, myFrameworkType, myProvider, librariesContainer, new IdeaModifiableModelsProvider()).show();
}
use of com.intellij.openapi.roots.IdeaModifiableModelsProvider in project intellij-community by JetBrains.
the class AddSupportForFrameworksPanel method addSupport.
public void addSupport(@NotNull final Module module, @NotNull final ModifiableRootModel rootModel) {
List<Library> addedLibraries = new ArrayList<>();
List<FrameworkSupportNode> selectedFrameworks = getSelectedNodes();
sortFrameworks(selectedFrameworks);
List<FrameworkSupportConfigurable> selectedConfigurables = new ArrayList<>();
final IdeaModifiableModelsProvider modifiableModelsProvider = new IdeaModifiableModelsProvider();
for (FrameworkSupportNode node : selectedFrameworks) {
FrameworkSupportInModuleConfigurable configurable = node.getConfigurable();
if (configurable instanceof OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) {
selectedConfigurables.add(((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) configurable).getConfigurable());
}
final LibraryCompositionSettings settings = getLibraryCompositionSettings(node);
Library library = settings != null ? settings.addLibraries(rootModel, addedLibraries, myLibrariesContainer) : null;
if (configurable instanceof OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) {
((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) configurable).getConfigurable().addSupport(module, rootModel, library);
} else {
configurable.addSupport(module, rootModel, modifiableModelsProvider);
}
}
for (FrameworkSupportNode node : selectedFrameworks) {
FrameworkSupportInModuleProvider provider = node.getUserObject();
if (provider instanceof OldFrameworkSupportProviderWrapper) {
final FrameworkSupportProvider oldProvider = ((OldFrameworkSupportProviderWrapper) provider).getProvider();
if (oldProvider instanceof FacetBasedFrameworkSupportProvider && !addedLibraries.isEmpty()) {
((FacetBasedFrameworkSupportProvider) oldProvider).processAddedLibraries(module, addedLibraries);
}
}
}
for (FrameworkSupportCommunicator communicator : FrameworkSupportCommunicator.EP_NAME.getExtensions()) {
communicator.onFrameworkSupportAdded(module, rootModel, selectedConfigurables, myModel);
}
}
use of com.intellij.openapi.roots.IdeaModifiableModelsProvider in project intellij-community by JetBrains.
the class FrameworkSupportProviderTestCase method addSupport.
protected void addSupport() {
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
final VirtualFile root = getVirtualFile(createTempDir("contentRoot"));
PsiTestUtil.addContentRoot(myModule, root);
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
try {
List<FrameworkSupportConfigurable> selectedConfigurables = new ArrayList<>();
final IdeaModifiableModelsProvider modelsProvider = new IdeaModifiableModelsProvider();
for (FrameworkSupportNode node : myNodes.values()) {
if (node.isChecked()) {
final FrameworkSupportInModuleConfigurable configurable = getOrCreateConfigurable(node.getUserObject());
configurable.addSupport(myModule, model, modelsProvider);
if (configurable instanceof OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) {
selectedConfigurables.add(((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) configurable).getConfigurable());
}
}
}
for (FrameworkSupportCommunicator communicator : FrameworkSupportCommunicator.EP_NAME.getExtensions()) {
communicator.onFrameworkSupportAdded(myModule, model, selectedConfigurables, myFrameworkSupportModel);
}
} finally {
model.commit();
}
for (FrameworkSupportInModuleConfigurable configurable : myConfigurables.values()) {
Disposer.dispose(configurable);
}
}
}.execute().throwException();
}
use of com.intellij.openapi.roots.IdeaModifiableModelsProvider in project intellij-community by JetBrains.
the class RepositoryAddLibraryAction method addLibraryToModule.
public static void addLibraryToModule(RepositoryLibraryDescription libraryDescription, Module module) {
RepositoryLibraryPropertiesModel model = new RepositoryLibraryPropertiesModel(RepositoryUtils.DefaultVersionId, false, false);
RepositoryLibraryPropertiesDialog dialog = new RepositoryLibraryPropertiesDialog(module.getProject(), model, libraryDescription, false);
if (!dialog.showAndGet()) {
return;
}
IdeaModifiableModelsProvider modifiableModelsProvider = new IdeaModifiableModelsProvider();
final ModifiableRootModel modifiableModel = modifiableModelsProvider.getModuleModifiableModel(module);
RepositoryLibrarySupport librarySupport = new RepositoryLibrarySupport(module.getProject(), libraryDescription, model);
assert modifiableModel != null;
librarySupport.addSupport(module, modifiableModel, modifiableModelsProvider);
ApplicationManager.getApplication().runWriteAction(modifiableModel::commit);
}
Aggregations