use of org.jetbrains.idea.maven.utils.library.propertiesEditor.RepositoryLibraryPropertiesModel 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);
}
use of org.jetbrains.idea.maven.utils.library.propertiesEditor.RepositoryLibraryPropertiesModel in project intellij-community by JetBrains.
the class RepositoryLibraryWithDescriptionEditor method edit.
@Override
protected void edit() {
@NotNull RepositoryLibraryProperties properties = myEditorComponent.getProperties();
//String oldVersion = properties.getVersion();
boolean wasGeneratedName = RepositoryLibraryType.getInstance().getDescription(properties).equals(myEditorComponent.getLibraryEditor().getName());
RepositoryLibraryPropertiesModel model = new RepositoryLibraryPropertiesModel(properties.getVersion(), RepositoryUtils.libraryHasSources(myEditorComponent.getLibraryEditor()), RepositoryUtils.libraryHasJavaDocs(myEditorComponent.getLibraryEditor()));
RepositoryLibraryPropertiesDialog dialog = new RepositoryLibraryPropertiesDialog(myEditorComponent.getProject(), model, RepositoryLibraryDescription.findDescription(properties), true);
if (!dialog.showAndGet()) {
return;
}
myEditorComponent.getProperties().changeVersion(model.getVersion());
if (wasGeneratedName) {
myEditorComponent.renameLibrary(RepositoryLibraryType.getInstance().getDescription(properties));
}
final LibraryEditor libraryEditor = myEditorComponent.getLibraryEditor();
MavenDependenciesRemoteManager.getInstance(myEditorComponent.getProject()).downloadDependenciesAsync(properties, model.isDownloadSources(), model.isDownloadJavaDocs(), RepositoryUtils.getStorageRoot(myEditorComponent.getLibraryEditor().getUrls(OrderRootType.CLASSES), myEditorComponent.getProject()), new MavenRemoteTask.ResultProcessor<List<OrderRoot>>() {
@Override
public void process(@Nullable List<OrderRoot> roots) {
libraryEditor.removeAllRoots();
if (roots != null) {
libraryEditor.addRoots(roots);
}
}
});
}
Aggregations