package jetbrains.mps.ide.migration.wizard; /*Generated by MPS */ import com.intellij.ide.wizard.AbstractWizardEx; import com.intellij.openapi.project.Project; import java.util.List; import jetbrains.mps.migration.global.ProjectMigration; import jetbrains.mps.internal.collections.runtime.Sequence; import jetbrains.mps.migration.global.ProjectMigrationWithOptions; import jetbrains.mps.internal.collections.runtime.ITranslator2; import jetbrains.mps.internal.collections.runtime.IVisitor; import jetbrains.mps.internal.collections.runtime.ListSequence; import java.util.ArrayList; public class MigrationWizard extends AbstractWizardEx { public MigrationWizard(Project project, MigrationSession session) { super("Migration Assistant Wizard", project, createSteps(session)); setSize(700, 400); } private static List<BaseStep> createSteps(final MigrationSession session) { Iterable<ProjectMigration> projectMig = session.getMigrationManager().getProjectMigrationsToApply(); Sequence.fromIterable(projectMig).ofType(ProjectMigrationWithOptions.class).translate(new ITranslator2<ProjectMigrationWithOptions, ProjectMigrationWithOptions.Option>() { public Iterable<ProjectMigrationWithOptions.Option> translate(ProjectMigrationWithOptions it) { return it.getOptions(); } }).visitAll(new IVisitor<ProjectMigrationWithOptions.Option>() { public void visit(ProjectMigrationWithOptions.Option it) { session.getOptions().addOption(it); } }); return ListSequence.fromListAndArray(new ArrayList<BaseStep>(), new InitialStep(session), new MigrationStep(session)); } @Override public boolean isAutoAdjustable() { return true; } @Override protected void updateButtons() { super.updateButtons(); // our steps can provide different next/prev button texts getCancelButton().setEnabled(((BaseStep) getCurrentStepObject()).canBeCancelled()); String nextLabel = ((BaseStep) getCurrentStepObject()).nextButtonLabel(); if (nextLabel != null) { getNextButton().setText(nextLabel); } String cancelLabel = ((BaseStep) getCurrentStepObject()).cancelButtonLabel(); if (cancelLabel != null) { getCancelButton().setText(cancelLabel); getRootPane().setDefaultButton(getCancelButton()); } } @Override protected String getHelpID() { return "migration.assistant"; } @Override protected String getDimensionServiceKey() { return "#jetbrains.mps.ide.migration.MigrationAssistantWizard"; } }