Search in sources :

Example 1 with ProjectImportBuilder

use of com.intellij.projectImport.ProjectImportBuilder in project intellij-community by JetBrains.

the class AddModuleWizard method initModuleWizard.

private void initModuleWizard(@Nullable final Project project, @Nullable final String defaultPath) {
    myWizardContext.addContextListener(new WizardContext.Listener() {

        public void buttonsUpdateRequested() {
            updateButtons();
        }

        public void nextStepRequested() {
            doNextAction();
        }
    });
    myWizardMode = new ImportMode(myImportProviders);
    StepSequence sequence = myWizardMode.getSteps(myWizardContext, DefaultModulesProvider.createForProject(project));
    appendSteps(sequence);
    for (ProjectImportProvider provider : myImportProviders) {
        provider.getBuilder().setFileToImport(defaultPath);
    }
    if (myImportProviders.length == 1) {
        final ProjectImportBuilder builder = myImportProviders[0].getBuilder();
        myWizardContext.setProjectBuilder(builder);
        builder.setUpdate(getWizardContext().getProject() != null);
    }
    init();
}
Also used : ProjectImportProvider(com.intellij.projectImport.ProjectImportProvider) ImportMode(com.intellij.ide.util.newProjectWizard.modes.ImportMode) WizardContext(com.intellij.ide.util.projectWizard.WizardContext) ProjectImportBuilder(com.intellij.projectImport.ProjectImportBuilder)

Example 2 with ProjectImportBuilder

use of com.intellij.projectImport.ProjectImportBuilder in project intellij-community by JetBrains.

the class ModulesConfigurator method addModule.

@Nullable
public List<Module> addModule(Component parent, boolean anImport) {
    if (myProject.isDefault())
        return null;
    final ProjectBuilder builder = runModuleWizard(parent, anImport);
    if (builder != null) {
        final List<Module> modules = new ArrayList<>();
        final List<Module> committedModules;
        if (builder instanceof ProjectImportBuilder<?>) {
            final ModifiableArtifactModel artifactModel = ProjectStructureConfigurable.getInstance(myProject).getArtifactsStructureConfigurable().getModifiableArtifactModel();
            committedModules = ((ProjectImportBuilder<?>) builder).commit(myProject, myModuleModel, this, artifactModel);
        } else {
            committedModules = builder.commit(myProject, myModuleModel, this);
        }
        if (committedModules != null) {
            modules.addAll(committedModules);
        }
        ApplicationManager.getApplication().runWriteAction(() -> {
            for (Module module : modules) {
                getOrCreateModuleEditor(module);
            }
        });
        return modules;
    }
    return null;
}
Also used : ProjectBuilder(com.intellij.ide.util.projectWizard.ProjectBuilder) ProjectImportBuilder(com.intellij.projectImport.ProjectImportBuilder) ModifiableArtifactModel(com.intellij.packaging.artifacts.ModifiableArtifactModel) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ProjectImportBuilder (com.intellij.projectImport.ProjectImportBuilder)2 ImportMode (com.intellij.ide.util.newProjectWizard.modes.ImportMode)1 ProjectBuilder (com.intellij.ide.util.projectWizard.ProjectBuilder)1 WizardContext (com.intellij.ide.util.projectWizard.WizardContext)1 Module (com.intellij.openapi.module.Module)1 ModifiableArtifactModel (com.intellij.packaging.artifacts.ModifiableArtifactModel)1 ProjectImportProvider (com.intellij.projectImport.ProjectImportProvider)1 Nullable (org.jetbrains.annotations.Nullable)1