Search in sources :

Example 1 with RepositoryLibraryPropertiesModel

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);
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) IdeaModifiableModelsProvider(com.intellij.openapi.roots.IdeaModifiableModelsProvider) RepositoryLibraryPropertiesModel(org.jetbrains.idea.maven.utils.library.propertiesEditor.RepositoryLibraryPropertiesModel) RepositoryLibraryPropertiesDialog(org.jetbrains.idea.maven.utils.library.propertiesEditor.RepositoryLibraryPropertiesDialog)

Example 2 with RepositoryLibraryPropertiesModel

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);
            }
        }
    });
}
Also used : LibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor) RepositoryLibraryPropertiesModel(org.jetbrains.idea.maven.utils.library.propertiesEditor.RepositoryLibraryPropertiesModel) List(java.util.List) OrderRoot(com.intellij.openapi.roots.libraries.ui.OrderRoot) NotNull(org.jetbrains.annotations.NotNull) RepositoryLibraryPropertiesDialog(org.jetbrains.idea.maven.utils.library.propertiesEditor.RepositoryLibraryPropertiesDialog) MavenRemoteTask(org.jetbrains.idea.maven.utils.library.remote.MavenRemoteTask)

Aggregations

RepositoryLibraryPropertiesDialog (org.jetbrains.idea.maven.utils.library.propertiesEditor.RepositoryLibraryPropertiesDialog)2 RepositoryLibraryPropertiesModel (org.jetbrains.idea.maven.utils.library.propertiesEditor.RepositoryLibraryPropertiesModel)2 IdeaModifiableModelsProvider (com.intellij.openapi.roots.IdeaModifiableModelsProvider)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 OrderRoot (com.intellij.openapi.roots.libraries.ui.OrderRoot)1 LibraryEditor (com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor)1 List (java.util.List)1 NotNull (org.jetbrains.annotations.NotNull)1 MavenRemoteTask (org.jetbrains.idea.maven.utils.library.remote.MavenRemoteTask)1