Search in sources :

Example 1 with LibraryCompositionSettings

use of com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings in project intellij-community by JetBrains.

the class AddSupportForFrameworksPanel method validate.

public boolean validate() {
    applyLibraryOptionsForSelected();
    List<String> frameworksWithoutRequiredLibraries = new ArrayList<>();
    for (FrameworkSupportNode node : getSelectedNodes()) {
        if (node.getConfigurable().isOnlyLibraryAdded()) {
            LibraryCompositionSettings librarySettings = getLibraryCompositionSettings(node);
            if (librarySettings != null && !librarySettings.isLibraryConfigured()) {
                frameworksWithoutRequiredLibraries.add(node.getTitle());
            }
        }
    }
    if (!frameworksWithoutRequiredLibraries.isEmpty()) {
        String frameworksText = StringUtil.join(frameworksWithoutRequiredLibraries, ", ");
        Messages.showErrorDialog(myMainPanel, ProjectBundle.message("error.message.required.library.is.not.configured", frameworksText, frameworksWithoutRequiredLibraries.size()), ProjectBundle.message("error.title.required.library.is.not.configured"));
        return false;
    }
    return true;
}
Also used : LibraryCompositionSettings(com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings)

Example 2 with LibraryCompositionSettings

use of com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings 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);
    }
}
Also used : LibraryCompositionSettings(com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings) FrameworkSupportProvider(com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider) FacetBasedFrameworkSupportProvider(com.intellij.facet.ui.FacetBasedFrameworkSupportProvider) FrameworkSupportInModuleProvider(com.intellij.framework.addSupport.FrameworkSupportInModuleProvider) FrameworkSupportConfigurable(com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable) IdeaModifiableModelsProvider(com.intellij.openapi.roots.IdeaModifiableModelsProvider) Library(com.intellij.openapi.roots.libraries.Library) FrameworkSupportInModuleConfigurable(com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable) FacetBasedFrameworkSupportProvider(com.intellij.facet.ui.FacetBasedFrameworkSupportProvider) FrameworkSupportCommunicator(com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportCommunicator)

Example 3 with LibraryCompositionSettings

use of com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings in project intellij-community by JetBrains.

the class AddCustomLibraryDialog method doOKAction.

@Override
protected void doOKAction() {
    final LibraryCompositionSettings settings = myPanel.apply();
    if (settings != null && settings.downloadFiles(myPanel.getMainPanel())) {
        if (myModifiableRootModel == null) {
            final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
            new WriteAction() {

                @Override
                protected void run(@NotNull final Result result) {
                    addLibraries(model, settings);
                    model.commit();
                }
            }.execute();
        } else {
            addLibraries(myModifiableRootModel, settings);
        }
    }
    super.doOKAction();
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) LibraryCompositionSettings(com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings) WriteAction(com.intellij.openapi.application.WriteAction) Result(com.intellij.openapi.application.Result)

Example 4 with LibraryCompositionSettings

use of com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings in project intellij-community by JetBrains.

the class AddSupportForSingleFrameworkDialog method addSupport.

private boolean addSupport() {
    final LibraryCompositionSettings librarySettings = myComponent.getLibraryCompositionSettings();
    if (librarySettings != null) {
        final ModifiableRootModel modifiableModel = myModifiableModelsProvider.getModuleModifiableModel(myModule);
        if (!askAndRemoveDuplicatedLibraryEntry(modifiableModel, librarySettings.getLibraryDescription())) {
            if (myConfigurable.isOnlyLibraryAdded()) {
                myModifiableModelsProvider.disposeModuleModifiableModel(modifiableModel);
                return false;
            }
            return false;
        }
        new WriteAction() {

            protected void run(@NotNull final Result result) {
                myModifiableModelsProvider.commitModuleModifiableModel(modifiableModel);
            }
        }.execute();
        final boolean downloaded = librarySettings.downloadFiles(getRootPane());
        if (!downloaded) {
            int answer = Messages.showYesNoDialog(getRootPane(), ProjectBundle.message("warning.message.some.required.libraries.wasn.t.downloaded"), CommonBundle.getWarningTitle(), Messages.getWarningIcon());
            if (answer != Messages.YES) {
                return false;
            }
        }
    }
    new WriteAction() {

        protected void run(@NotNull final Result result) {
            final ModifiableRootModel rootModel = myModifiableModelsProvider.getModuleModifiableModel(myModule);
            if (librarySettings != null) {
                librarySettings.addLibraries(rootModel, new ArrayList<>(), myModel.getLibrariesContainer());
            }
            myConfigurable.addSupport(myModule, rootModel, myModifiableModelsProvider);
            myModifiableModelsProvider.commitModuleModifiableModel(rootModel);
        }
    }.execute();
    return true;
}
Also used : LibraryCompositionSettings(com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings) WriteAction(com.intellij.openapi.application.WriteAction) ArrayList(java.util.ArrayList) Result(com.intellij.openapi.application.Result)

Aggregations

LibraryCompositionSettings (com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings)4 Result (com.intellij.openapi.application.Result)2 WriteAction (com.intellij.openapi.application.WriteAction)2 FacetBasedFrameworkSupportProvider (com.intellij.facet.ui.FacetBasedFrameworkSupportProvider)1 FrameworkSupportInModuleConfigurable (com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable)1 FrameworkSupportInModuleProvider (com.intellij.framework.addSupport.FrameworkSupportInModuleProvider)1 FrameworkSupportConfigurable (com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable)1 FrameworkSupportProvider (com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider)1 FrameworkSupportCommunicator (com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportCommunicator)1 IdeaModifiableModelsProvider (com.intellij.openapi.roots.IdeaModifiableModelsProvider)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 Library (com.intellij.openapi.roots.libraries.Library)1 ArrayList (java.util.ArrayList)1