ModulesConfigurator (Project project) { if (ApplicationManager.getApplication().isHeadlessEnvironment()) return null; final ProjectStructureConfigurable structureConfigurable = ProjectStructureConfigurable.getInstance(project); StructureConfigurableContext context = structureConfigurable.isUiInitialized() ? structureConfigurable.getContext() : null; return context != null ? context.getModulesConfigurator() : null; }