Search in sources :

Example 6 with ModuleWizardStep

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

the class AbstractProjectWizard method doPreviousAction.

@Override
protected void doPreviousAction() {
    if (myDelegate != null) {
        myDelegate.doPreviousAction();
        return;
    }
    final ModuleWizardStep step = getCurrentStepObject();
    step.onStepLeaving();
    if (step instanceof StepWithSubSteps) {
        ((StepWithSubSteps) step).doPreviousAction();
    }
    super.doPreviousAction();
}
Also used : StepWithSubSteps(com.intellij.ide.wizard.StepWithSubSteps) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep)

Example 7 with ModuleWizardStep

use of com.intellij.ide.util.projectWizard.ModuleWizardStep 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)

Example 8 with ModuleWizardStep

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

the class CreateFromSourcesMode method addSteps.

public void addSteps(WizardContext context, ModulesProvider modulesProvider, StepSequence sequence, String specific) {
    final ProjectFromSourcesBuilderImpl projectBuilder = new ProjectFromSourcesBuilderImpl(context, modulesProvider);
    myProjectBuilder = projectBuilder;
    final Icon icon = context.getStepIcon();
    if (context.isCreatingNewProject()) {
        addStep(sequence, new ProjectNameStep(context, this), specific);
    }
    addStep(sequence, new RootsDetectionStep(projectBuilder, context, sequence, icon, "reference.dialogs.new.project.fromCode.source"), specific);
    Set<String> detectorTypes = new HashSet<>();
    for (ProjectStructureDetector detector : ProjectStructureDetector.EP_NAME.getExtensions()) {
        detectorTypes.add(detector.getDetectorId());
        for (ModuleWizardStep step : detector.createWizardSteps(projectBuilder, projectBuilder.getProjectDescriptor(detector), icon)) {
            sequence.addSpecificStep(detector.getDetectorId(), step);
        }
    }
    if (FrameworkDetectionStep.isEnabled()) {
        FrameworkDetectionStep frameworkDetectionStep = new FrameworkDetectionStep(icon, projectBuilder) {

            public List<ModuleDescriptor> getModuleDescriptors() {
                final List<ModuleDescriptor> moduleDescriptors = new ArrayList<>();
                for (ProjectDescriptor descriptor : projectBuilder.getSelectedDescriptors()) {
                    moduleDescriptors.addAll(descriptor.getModules());
                }
                return moduleDescriptors;
            }
        };
        projectBuilder.addConfigurationUpdater(frameworkDetectionStep);
        sequence.addCommonFinishingStep(frameworkDetectionStep, detectorTypes);
    }
}
Also used : ArrayList(java.util.ArrayList) ProjectFromSourcesBuilderImpl(com.intellij.ide.util.projectWizard.importSources.impl.ProjectFromSourcesBuilderImpl) ModuleDescriptor(com.intellij.ide.util.importProject.ModuleDescriptor) ProjectStructureDetector(com.intellij.ide.util.projectWizard.importSources.ProjectStructureDetector) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ProjectNameStep(com.intellij.ide.util.newProjectWizard.ProjectNameStep) ProjectDescriptor(com.intellij.ide.util.importProject.ProjectDescriptor) FrameworkDetectionStep(com.intellij.ide.util.importProject.FrameworkDetectionStep) RootsDetectionStep(com.intellij.ide.util.importProject.RootsDetectionStep) HashSet(java.util.HashSet)

Example 9 with ModuleWizardStep

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

the class AbstractProjectWizard method doFinishAction.

@VisibleForTesting
public boolean doFinishAction() {
    if (myDelegate != null) {
        myDelegate.doFinishAction();
        return true;
    }
    int idx = getCurrentStep();
    try {
        do {
            final ModuleWizardStep step = mySteps.get(idx);
            if (step != getCurrentStepObject()) {
                step.updateStep();
            }
            if (!commitStepData(step)) {
                return false;
            }
            step.onStepLeaving();
            try {
                step._commit(true);
            } catch (CommitStepException e) {
                handleCommitException(e);
                return false;
            }
            if (!isLastStep(idx)) {
                idx = getNextStep(idx);
            } else {
                for (ModuleWizardStep wizardStep : mySteps) {
                    try {
                        wizardStep.onWizardFinished();
                    } catch (CommitStepException e) {
                        handleCommitException(e);
                        return false;
                    }
                }
                break;
            }
        } while (true);
    } finally {
        myCurrentStep = idx;
        updateStep();
    }
    return true;
}
Also used : CommitStepException(com.intellij.ide.wizard.CommitStepException) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 10 with ModuleWizardStep

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

the class AbstractProjectWizard method getNextStep.

@Override
protected final int getNextStep(final int step) {
    ModuleWizardStep nextStep = null;
    final StepSequence stepSequence = getSequence();
    if (stepSequence != null) {
        ModuleWizardStep current = mySteps.get(step);
        if (isStepWithNotCompletedSubSteps(current)) {
            return step;
        }
        nextStep = stepSequence.getNextStep(current);
        while (nextStep != null && !nextStep.isStepVisible()) {
            nextStep = stepSequence.getNextStep(nextStep);
        }
    }
    return nextStep == null ? step : mySteps.indexOf(nextStep);
}
Also used : ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep)

Aggregations

ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)27 Project (com.intellij.openapi.project.Project)5 ArrayList (java.util.ArrayList)5 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 DelegatingProgressIndicator (com.intellij.ide.util.DelegatingProgressIndicator)2 ProjectBuilder (com.intellij.ide.util.projectWizard.ProjectBuilder)2 ProjectWizardStepFactory (com.intellij.ide.util.projectWizard.ProjectWizardStepFactory)2 SettingsStep (com.intellij.ide.util.projectWizard.SettingsStep)2 WizardContext (com.intellij.ide.util.projectWizard.WizardContext)2 ProjectStructureDetector (com.intellij.ide.util.projectWizard.importSources.ProjectStructureDetector)2 Step (com.intellij.ide.wizard.Step)2 Module (com.intellij.openapi.module.Module)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 ModuleImporter (com.android.tools.idea.gradle.project.ModuleImporter)1 WrapArchiveWizardPath (com.android.tools.idea.npw.deprecated.WrapArchiveWizardPath)1 Template (com.android.tools.idea.templates.Template)1 TemplateManager (com.android.tools.idea.templates.TemplateManager)1 ModelWizardStep (com.android.tools.idea.wizard.model.ModelWizardStep)1