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;
}
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);
}
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();
}
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;
}
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;
}
Aggregations