Search in sources :

Example 1 with ModulesConfigurator

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

the class AbstractExternalProjectImportBuilder method commit.

@Override
public List<Module> commit(final Project project, final ModifiableModuleModel model, final ModulesProvider modulesProvider, final ModifiableArtifactModel artifactModel) {
    project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, Boolean.TRUE);
    final DataNode<ProjectData> externalProjectNode = getExternalProjectNode();
    if (externalProjectNode != null) {
        beforeCommit(externalProjectNode, project);
    }
    final boolean isFromUI = model != null;
    final List<Module> modules = ContainerUtil.newSmartList();
    final IdeModifiableModelsProvider modelsProvider = isFromUI ? new IdeUIModifiableModelsProvider(project, model, (ModulesConfigurator) modulesProvider, artifactModel) {

        @NotNull
        @Override
        public Module newModule(@NotNull @NonNls String filePath, String moduleTypeId) {
            final Module module = super.newModule(filePath, moduleTypeId);
            modules.add(module);
            return module;
        }
    } : new IdeModifiableModelsProviderImpl(project) {

        @NotNull
        @Override
        public Module newModule(@NotNull @NonNls String filePath, String moduleTypeId) {
            final Module module = super.newModule(filePath, moduleTypeId);
            modules.add(module);
            return module;
        }
    };
    AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, myExternalSystemId);
    final ExternalProjectSettings projectSettings = getCurrentExternalProjectSettings();
    //noinspection unchecked
    Set<ExternalProjectSettings> projects = ContainerUtilRt.newHashSet(systemSettings.getLinkedProjectsSettings());
    // add current importing project settings to linked projects settings or replace if similar already exist
    projects.remove(projectSettings);
    projects.add(projectSettings);
    //noinspection unchecked
    systemSettings.copyFrom(myControl.getSystemSettings());
    //noinspection unchecked
    systemSettings.setLinkedProjectsSettings(projects);
    if (externalProjectNode != null) {
        if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
            ExternalProjectDataSelectorDialog dialog = new ExternalProjectDataSelectorDialog(project, new InternalExternalProjectInfo(myExternalSystemId, projectSettings.getExternalProjectPath(), externalProjectNode));
            if (dialog.hasMultipleDataToSelect()) {
                dialog.showAndGet();
            } else {
                Disposer.dispose(dialog.getDisposable());
            }
        }
        if (!project.isInitialized()) {
            StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> finishImport(project, externalProjectNode, isFromUI, modules, modelsProvider, projectSettings));
        } else
            finishImport(project, externalProjectNode, isFromUI, modules, modelsProvider, projectSettings);
    }
    return modules;
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) InternalExternalProjectInfo(com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo) NotNull(org.jetbrains.annotations.NotNull) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) IdeUIModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeUIModifiableModelsProvider) AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) ExternalProjectDataSelectorDialog(com.intellij.openapi.externalSystem.service.ui.ExternalProjectDataSelectorDialog) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) Module(com.intellij.openapi.module.Module) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 2 with ModulesConfigurator

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

the class ProjectFacetsConfigurator method createContext.

protected FacetEditorContext createContext(@NotNull final Facet facet, @Nullable final FacetEditorContext parentContext) {
    Module module = facet.getModule();
    ModulesConfigurator modulesConfigurator = myContext.getModulesConfigurator();
    ModuleEditor moduleEditor = modulesConfigurator.getModuleEditor(module);
    if (moduleEditor == null) {
        LOG.error("ModuleEditor[" + module.getName() + "]==null: disposed = " + module.isDisposed() + ", is in model = " + Arrays.asList(modulesConfigurator.getModules()).contains(module));
    }
    final ModuleConfigurationState state = moduleEditor.createModuleConfigurationState();
    return new MyProjectConfigurableContext(facet, parentContext, state);
}
Also used : ModuleConfigurationState(com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) Module(com.intellij.openapi.module.Module) ModuleEditor(com.intellij.openapi.roots.ui.configuration.ModuleEditor)

Example 3 with ModulesConfigurator

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

the class IdeaModifiableModelsProvider method getModuleModifiableModel.

@Override
@Nullable
public ModifiableRootModel getModuleModifiableModel(final Module module) {
    final Project project = module.getProject();
    final ModulesConfigurator configurator = getModulesConfigurator(project);
    if (configurator != null) {
        if (!configurator.isModuleModelCommitted()) {
            final ModuleEditor moduleEditor = configurator.getModuleEditor(module);
            if (moduleEditor != null) {
                return moduleEditor.getModifiableRootModelProxy();
            }
        }
    }
    return ModuleRootManager.getInstance(module).getModifiableModel();
}
Also used : Project(com.intellij.openapi.project.Project) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) ModuleEditor(com.intellij.openapi.roots.ui.configuration.ModuleEditor) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with ModulesConfigurator

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

the class LibrariesContainerFactory method createContainer.

@NotNull
public static LibrariesContainer createContainer(@NotNull WizardContext context, @NotNull ModulesProvider modulesProvider) {
    final LibrariesContainer container;
    if (modulesProvider instanceof ModulesConfigurator) {
        ModulesConfigurator configurator = (ModulesConfigurator) modulesProvider;
        container = createContainer(configurator.getContext());
    } else {
        container = createContainer(context.getProject());
    }
    return container;
}
Also used : ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with ModulesConfigurator

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

the class ExternalModuleStructureExtension method moduleRemoved.

@Override
public void moduleRemoved(Module module) {
    String systemIdString = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
    if (StringUtil.isEmpty(systemIdString))
        return;
    String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module);
    if (StringUtil.isEmpty(rootProjectPath))
        return;
    Project project = module.getProject();
    ModulesConfigurator modulesConfigurator = getModulesConfigurator(project);
    if (modulesConfigurator == null)
        return;
    for (Module m : modulesConfigurator.getModules()) {
        if (m != module && rootProjectPath.equals(ExternalSystemApiUtil.getExternalRootProjectPath(m))) {
            return;
        }
    }
    ProjectSystemId systemId = new ProjectSystemId(systemIdString);
    ExternalSystemApiUtil.getSettings(project, systemId).unlinkExternalProject(rootProjectPath);
    assert myOrphanProjectsCandidates != null;
    myOrphanProjectsCandidates.put(rootProjectPath, systemId);
    isExternalSystemsInvolved = true;
}
Also used : Project(com.intellij.openapi.project.Project) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) 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