Search in sources :

Example 6 with ModulesConfigurator

use of com.intellij.openapi.roots.ui.configuration.ModulesConfigurator in project intellij-community by JetBrains.

the class ExternalModuleStructureExtension method disposeUIResources.

@Override
public void disposeUIResources() {
    try {
        if (isExternalSystemsInvolved) {
            assert myOrphanProjectsCandidates != null;
            assert myProject != null;
            if (myExternalProjectsToRestore != null) {
                for (Pair<ProjectSystemId, ExternalProjectSettings> settingsPair : myExternalProjectsToRestore.values()) {
                    AbstractExternalSystemSettings settings = ExternalSystemApiUtil.getSettings(myProject, settingsPair.first);
                    String rootProjectPath = settingsPair.second.getExternalProjectPath();
                    if (settings.getLinkedProjectSettings(rootProjectPath) == null) {
                        //noinspection unchecked
                        settings.linkProject(settingsPair.second);
                    }
                    myOrphanProjectsCandidates.remove(rootProjectPath);
                }
            }
            ModulesConfigurator modulesConfigurator = getModulesConfigurator(myProject);
            if (modulesConfigurator != null) {
                for (Map.Entry<String, ProjectSystemId> entry : myOrphanProjectsCandidates.entrySet()) {
                    String rootProjectPath = entry.getKey();
                    if (StringUtil.isNotEmpty(rootProjectPath)) {
                        unlinkProject(myProject, entry.getValue(), rootProjectPath);
                    }
                }
            }
        }
    } catch (Throwable e) {
        LOG.warn(e);
    } finally {
        myProject = null;
        myExternalProjectsToRestore = null;
        myOrphanProjectsCandidates = null;
    }
}
Also used : AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) HashMap(java.util.HashMap) Map(java.util.Map) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)

Example 7 with ModulesConfigurator

use of com.intellij.openapi.roots.ui.configuration.ModulesConfigurator in project intellij-plugins by JetBrains.

the class BuildConfigurationProjectStructureElement method checkDependencies.

private void checkDependencies(final ProjectStructureProblemsHolder problemsHolder, final FlexProjectConfigurationEditor editor) {
    final ModulesConfigurator modulesConfigurator = myContext.getModulesConfigurator();
    for (DependencyEntry entry : myBc.getDependencies().getEntries()) {
        if (entry instanceof BuildConfigurationEntry) {
            final String moduleName = ((BuildConfigurationEntry) entry).getModuleName();
            final String bcName = ((BuildConfigurationEntry) entry).getBcName();
            final Module module = modulesConfigurator.getModule(moduleName);
            String errorMessage = null;
            if (module == null) {
                errorMessage = FlexBundle.message("bc.problem.dependency.module.not.found", moduleName);
            } else if (ContainerUtil.find(editor.getConfigurations(module), configuration -> bcName.equals(configuration.getName())) == null) {
                errorMessage = FlexBundle.message("bc.problem.dependency.bc.not.found", bcName, moduleName);
            }
            if (errorMessage != null) {
                Object location = DependenciesConfigurable.Location.TableEntry.forBc(moduleName, bcName);
                PlaceInProjectStructure place = new PlaceInBuildConfiguration(this, DependenciesConfigurable.TAB_NAME, location);
                problemsHolder.registerProblem(errorMessage, null, ProjectStructureProblemType.error("flex-bc-dependency-bc"), place, null);
            }
        }
    }
}
Also used : ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) Module(com.intellij.openapi.module.Module)

Example 8 with ModulesConfigurator

use of com.intellij.openapi.roots.ui.configuration.ModulesConfigurator in project intellij-plugins by JetBrains.

the class BuildConfigurationProjectStructureElement method getUsagesInElement.

@Override
public List<ProjectStructureElementUsage> getUsagesInElement() {
    FlexBCConfigurator configurator = FlexBuildConfigurationsExtension.getInstance().getConfigurator();
    final FlexProjectConfigurationEditor editor = configurator.getConfigEditor();
    assert editor != null;
    final ModulesConfigurator modulesConfigurator = myContext.getModulesConfigurator();
    final List<ProjectStructureElementUsage> usages = new ArrayList<>();
    for (DependencyEntry dependencyEntry : myBc.getDependencies().getEntries()) {
        if (dependencyEntry instanceof SharedLibraryEntry) {
            String libraryName = ((SharedLibraryEntry) dependencyEntry).getLibraryName();
            String libraryLevel = ((SharedLibraryEntry) dependencyEntry).getLibraryLevel();
            final Library library = myContext.getLibrary(libraryName, libraryLevel);
            if (library != null) {
                usages.add(new UsageInBcDependencies(this, new LibraryProjectStructureElement(myContext, library)) {

                    @Override
                    public void removeSourceElement() {
                        libraryReplaced(library, null);
                    }

                    @Override
                    public void replaceElement(final ProjectStructureElement newElement) {
                        libraryReplaced(library, ((LibraryProjectStructureElement) newElement).getLibrary());
                    }
                });
            }
        } else if (dependencyEntry instanceof BuildConfigurationEntry) {
            final BuildConfigurationEntry bcEntry = (BuildConfigurationEntry) dependencyEntry;
            Module module = modulesConfigurator.getModule(bcEntry.getModuleName());
            if (module != null) {
                final ModifiableFlexBuildConfiguration bc = ContainerUtil.find(editor.getConfigurations(module), configuration -> bcEntry.getBcName().equals(configuration.getName()));
                if (bc != null) {
                    usages.add(new UsageInBcDependencies(this, new BuildConfigurationProjectStructureElement(bc, module, myContext)) {

                        @Override
                        public void removeSourceElement() {
                        // ignore as editor already listens to BC removal
                        }

                        @Override
                        public void replaceElement(final ProjectStructureElement newElement) {
                            throw new UnsupportedOperationException();
                        }
                    });
                }
            }
            bcEntry.findBuildConfiguration();
        }
    }
    Sdk sdk = myBc.getSdk();
    if (sdk != null) {
        usages.add(new UsageInBcDependencies(this, new SdkProjectStructureElement(myContext, sdk)) {

            @Override
            public void removeSourceElement() {
                myBc.getDependencies().setSdkEntry(null);
            }

            @Override
            public void replaceElement(final ProjectStructureElement newElement) {
                throw new UnsupportedOperationException();
            }
        });
    }
    return usages;
}
Also used : FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContainerUtil(com.intellij.util.containers.ContainerUtil) ArrayList(java.util.ArrayList) Library(com.intellij.openapi.roots.libraries.Library) FlexCompilerHandler(com.intellij.lang.javascript.flex.build.FlexCompilerHandler) StructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext) com.intellij.openapi.roots.ui.configuration.projectRoot.daemon(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon) FileUtil(com.intellij.openapi.util.io.FileUtil) Module(com.intellij.openapi.module.Module) FlexCommonBundle(com.intellij.flex.FlexCommonBundle) FlexBuildConfigurationsExtension(com.intellij.lang.javascript.flex.projectStructure.FlexBuildConfigurationsExtension) FlexBCConfigurator(com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator) OrderRootType(com.intellij.openapi.roots.OrderRootType) FlexBundle(com.intellij.lang.javascript.flex.FlexBundle) ValidateFlashConfigurationsPrecompileTask(com.intellij.lang.javascript.flex.build.ValidateFlashConfigurationsPrecompileTask) com.intellij.lang.javascript.flex.projectStructure.model(com.intellij.lang.javascript.flex.projectStructure.model) Sdk(com.intellij.openapi.projectRoots.Sdk) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) LinkageType(com.intellij.flex.model.bc.LinkageType) FlexProjectRootsUtil(com.intellij.lang.javascript.flex.projectStructure.options.FlexProjectRootsUtil) FlashProjectStructureProblem(com.intellij.lang.javascript.flex.build.FlashProjectStructureProblem) Nullable(org.jetbrains.annotations.Nullable) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Place(com.intellij.ui.navigation.Place) List(java.util.List) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) Condition(com.intellij.openapi.util.Condition) ArrayList(java.util.ArrayList) FlexBCConfigurator(com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) Library(com.intellij.openapi.roots.libraries.Library) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module)

Aggregations

ModulesConfigurator (com.intellij.openapi.roots.ui.configuration.ModulesConfigurator)8 Module (com.intellij.openapi.module.Module)5 NotNull (org.jetbrains.annotations.NotNull)3 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)2 AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)2 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)2 Project (com.intellij.openapi.project.Project)2 ModuleEditor (com.intellij.openapi.roots.ui.configuration.ModuleEditor)2 Nullable (org.jetbrains.annotations.Nullable)2 FlexCommonBundle (com.intellij.flex.FlexCommonBundle)1 LinkageType (com.intellij.flex.model.bc.LinkageType)1 FlexBundle (com.intellij.lang.javascript.flex.FlexBundle)1 FlashProjectStructureProblem (com.intellij.lang.javascript.flex.build.FlashProjectStructureProblem)1 FlexCompilerHandler (com.intellij.lang.javascript.flex.build.FlexCompilerHandler)1 ValidateFlashConfigurationsPrecompileTask (com.intellij.lang.javascript.flex.build.ValidateFlashConfigurationsPrecompileTask)1 FlexBCConfigurator (com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator)1 FlexBuildConfigurationsExtension (com.intellij.lang.javascript.flex.projectStructure.FlexBuildConfigurationsExtension)1 com.intellij.lang.javascript.flex.projectStructure.model (com.intellij.lang.javascript.flex.projectStructure.model)1 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)1 FlexProjectRootsUtil (com.intellij.lang.javascript.flex.projectStructure.options.FlexProjectRootsUtil)1