Search in sources :

Example 1 with ProjectBuilder

use of com.intellij.ide.util.projectWizard.ProjectBuilder in project intellij-community by JetBrains.

the class SupportForFrameworksStep method updateStep.

@Override
public void updateStep() {
    ProjectBuilder builder = myContext.getProjectBuilder();
    if (builder instanceof ModuleBuilder) {
        myBuilder.updateFrom((ModuleBuilder) builder);
        ((ModuleBuilder) builder).addModuleConfigurationUpdater(myConfigurationUpdater);
    }
    myFrameworkSupportModel.fireWizardStepUpdated();
}
Also used : ProjectBuilder(com.intellij.ide.util.projectWizard.ProjectBuilder) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder)

Example 2 with ProjectBuilder

use of com.intellij.ide.util.projectWizard.ProjectBuilder in project intellij-community by JetBrains.

the class ModulesConfigurator method runModuleWizard.

@Nullable
ProjectBuilder runModuleWizard(Component dialogParent, boolean anImport) {
    AbstractProjectWizard wizard;
    if (anImport) {
        wizard = ImportModuleAction.selectFileAndCreateWizard(myProject, dialogParent);
        if (wizard == null)
            return null;
        if (wizard.getStepCount() == 0) {
            ProjectBuilder builder = wizard.getProjectBuilder();
            Disposer.dispose(wizard.getDisposable());
            return builder;
        }
    } else {
        wizard = new NewProjectWizard(myProject, dialogParent, this);
    }
    if (wizard.showAndGet()) {
        final ProjectBuilder builder = wizard.getProjectBuilder();
        if (builder instanceof ModuleBuilder) {
            final ModuleBuilder moduleBuilder = (ModuleBuilder) builder;
            if (moduleBuilder.getName() == null) {
                moduleBuilder.setName(wizard.getProjectName());
            }
            if (moduleBuilder.getModuleFilePath() == null) {
                moduleBuilder.setModuleFilePath(wizard.getModuleFilePath());
            }
        }
        if (!builder.validate(myProject, myProject)) {
            return null;
        }
        return wizard.getProjectBuilder();
    }
    return null;
}
Also used : ProjectBuilder(com.intellij.ide.util.projectWizard.ProjectBuilder) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder) NewProjectWizard(com.intellij.ide.projectWizard.NewProjectWizard) AbstractProjectWizard(com.intellij.ide.util.newProjectWizard.AbstractProjectWizard) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with ProjectBuilder

use of com.intellij.ide.util.projectWizard.ProjectBuilder in project intellij-community by JetBrains.

the class NewModuleAction method createModuleFromWizard.

@Nullable
public Module createModuleFromWizard(Project project, @Nullable Object dataFromContext, AbstractProjectWizard wizard) {
    final ProjectBuilder builder = wizard.getProjectBuilder();
    if (builder instanceof ModuleBuilder) {
        final ModuleBuilder moduleBuilder = (ModuleBuilder) builder;
        if (moduleBuilder.getName() == null) {
            moduleBuilder.setName(wizard.getProjectName());
        }
        if (moduleBuilder.getModuleFilePath() == null) {
            moduleBuilder.setModuleFilePath(wizard.getModuleFilePath());
        }
    }
    if (!builder.validate(project, project)) {
        return null;
    }
    Module module;
    if (builder instanceof ModuleBuilder) {
        module = ((ModuleBuilder) builder).commitModule(project, null);
        if (module != null) {
            processCreatedModule(module, dataFromContext);
        }
        return module;
    } else {
        List<Module> modules = builder.commit(project, null, new DefaultModulesProvider(project));
        if (builder.isOpenProjectSettingsAfter()) {
            ModulesConfigurator.showDialog(project, null, null);
        }
        module = modules == null || modules.isEmpty() ? null : modules.get(0);
    }
    project.save();
    return module;
}
Also used : ProjectBuilder(com.intellij.ide.util.projectWizard.ProjectBuilder) DefaultModulesProvider(com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with ProjectBuilder

use of com.intellij.ide.util.projectWizard.ProjectBuilder in project android by JetBrains.

the class AndroidImportProjectAction method doCreate.

private static void doCreate(@NotNull AddModuleWizard wizard) throws IOException {
    // TODO: Now we need to add as module if file does not exist
    ProjectBuilder projectBuilder = wizard.getProjectBuilder();
    try {
        File projectFilePath = new File(wizard.getNewProjectFilePath());
        File projectDirPath = projectFilePath.isDirectory() ? projectFilePath : projectFilePath.getParentFile();
        LOG.assertTrue(projectDirPath != null, "Cannot create project in '" + projectFilePath + "': no parent file exists");
        ensureExists(projectDirPath);
        if (StorageScheme.DIRECTORY_BASED == wizard.getStorageScheme()) {
            ensureExists(new File(projectDirPath, DIRECTORY_STORE_FOLDER));
        }
        boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode();
        ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
        Project project = projectManager.newProject(wizard.getProjectName(), projectDirPath.getPath(), true, false);
        if (project == null) {
            return;
        }
        if (!unitTestMode) {
            project.save();
        }
        if (projectBuilder != null) {
            if (!projectBuilder.validate(null, project)) {
                return;
            }
            projectBuilder.commit(project, null, EMPTY_MODULES_PROVIDER);
        }
        if (!unitTestMode) {
            project.save();
        }
    } finally {
        if (projectBuilder != null) {
            projectBuilder.cleanup();
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) Projects.canImportAsGradleProject(com.android.tools.idea.gradle.util.Projects.canImportAsGradleProject) ProjectBuilder(com.intellij.ide.util.projectWizard.ProjectBuilder) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx)

Example 5 with ProjectBuilder

use of com.intellij.ide.util.projectWizard.ProjectBuilder in project intellij-community by JetBrains.

the class CloudModuleBuilderSourceContribution method detectModuleStructure.

private void detectModuleStructure(Module module, final String contentPath) {
    final Project project = module.getProject();
    final CreateFromSourcesMode mode = new CreateFromSourcesMode() {

        @Override
        public boolean isAvailable(WizardContext context) {
            return true;
        }

        @Override
        public void addSteps(WizardContext context, ModulesProvider modulesProvider, StepSequence sequence, String specific) {
            super.addSteps(context, modulesProvider, sequence, specific);
            myProjectBuilder.setFileToImport(contentPath);
        }
    };
    final WizardContext context = new WizardContext(project);
    final StepSequence stepSequence = mode.getSteps(context, DefaultModulesProvider.createForProject(context.getProject()));
    if (stepSequence == null) {
        return;
    }
    Disposer.register(project, new Disposable() {

        @Override
        public void dispose() {
            for (ModuleWizardStep step : stepSequence.getAllSteps()) {
                step.disposeUIResources();
            }
        }
    });
    ProgressManager.getInstance().run(new Task.Backgroundable(project, CloudBundle.getText("detect.module.structure", getCloudType().getPresentableName()), false) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            for (ModuleWizardStep step = ContainerUtil.getFirstItem(stepSequence.getSelectedSteps()); step != null; step = stepSequence.getNextStep(step)) {
                if (step instanceof AbstractStepWithProgress<?>) {
                    ((AbstractStepWithProgress) step).performStep();
                } else {
                    step.updateDataModel();
                }
            }
            CloudAccountSelectionEditor.unsetAccountOnContext(context, getCloudType());
        }

        @Override
        public boolean shouldStartInBackground() {
            return false;
        }

        @Override
        public void onSuccess() {
            ProjectBuilder moduleBuilder = mode.getModuleBuilder();
            if (moduleBuilder == null) {
                return;
            }
            moduleBuilder.commit(project);
            getNotifier().showMessage(CloudBundle.getText("cloud.support.added", getCloudType().getPresentableName()), MessageType.INFO);
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) ModulesProvider(com.intellij.openapi.roots.ui.configuration.ModulesProvider) DefaultModulesProvider(com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider) Task(com.intellij.openapi.progress.Task) StepSequence(com.intellij.ide.util.newProjectWizard.StepSequence) CreateFromSourcesMode(com.intellij.ide.util.newProjectWizard.modes.CreateFromSourcesMode) Project(com.intellij.openapi.project.Project) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ProjectBuilder(com.intellij.ide.util.projectWizard.ProjectBuilder) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) WizardContext(com.intellij.ide.util.projectWizard.WizardContext)

Aggregations

ProjectBuilder (com.intellij.ide.util.projectWizard.ProjectBuilder)11 ModuleBuilder (com.intellij.ide.util.projectWizard.ModuleBuilder)5 Module (com.intellij.openapi.module.Module)5 Project (com.intellij.openapi.project.Project)4 DefaultModulesProvider (com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider)4 Nullable (org.jetbrains.annotations.Nullable)4 File (java.io.File)3 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)2 ProjectManagerEx (com.intellij.openapi.project.ex.ProjectManagerEx)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 List (java.util.List)2 Projects.canImportAsGradleProject (com.android.tools.idea.gradle.util.Projects.canImportAsGradleProject)1 NewProjectWizard (com.intellij.ide.projectWizard.NewProjectWizard)1 ProjectTypeStep (com.intellij.ide.projectWizard.ProjectTypeStep)1 AbstractProjectWizard (com.intellij.ide.util.newProjectWizard.AbstractProjectWizard)1 StepSequence (com.intellij.ide.util.newProjectWizard.StepSequence)1 CreateFromSourcesMode (com.intellij.ide.util.newProjectWizard.modes.CreateFromSourcesMode)1 WizardContext (com.intellij.ide.util.projectWizard.WizardContext)1 Step (com.intellij.ide.wizard.Step)1 Disposable (com.intellij.openapi.Disposable)1