Search in sources :

Example 1 with SettingsStep

use of com.intellij.ide.util.projectWizard.SettingsStep in project flutter-intellij by flutter.

the class FlutterProjectCreator method createModule.

public void createModule() {
    Project project = myModel.project().getValue();
    VirtualFile baseDir = project.getBaseDir();
    if (baseDir == null) {
        // Project was deleted.
        return;
    }
    String baseDirPath = baseDir.getPath();
    String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, myModel.projectName().get(), "");
    String contentRoot = baseDirPath + "/" + moduleName;
    File location = new File(contentRoot);
    if (!location.exists() && !location.mkdirs()) {
        String message = ActionsBundle.message("action.NewDirectoryProject.cannot.create.dir", location.getAbsolutePath());
        Messages.showErrorDialog(project, message, ActionsBundle.message("action.NewDirectoryProject.title"));
        return;
    }
    // ModuleBuilder mixes UI and model code too much to easily reuse. We have to override a bunch of stuff to ensure
    // that methods which expect a live UI do not get called.
    FlutterModuleBuilder builder = new FlutterModuleBuilder() {

        @NotNull
        @Override
        public FlutterCreateAdditionalSettings getAdditionalSettings() {
            return makeAdditionalSettings();
        }

        @Override
        protected FlutterSdk getFlutterSdk() {
            return FlutterSdk.forPath(myModel.flutterSdk().get());
        }

        @Override
        public boolean validate(Project current, Project dest) {
            return true;
        }

        @Override
        public ModuleWizardStep getCustomOptionsStep(final WizardContext context, final Disposable parentDisposable) {
            return null;
        }

        @Override
        public void setFlutterSdkPath(String s) {
        }

        @Override
        public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
            return null;
        }
    };
    builder.setName(myModel.projectName().get());
    builder.setModuleFilePath(toSystemIndependentName(contentRoot) + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
    builder.commitModule(project, null);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Disposable(com.intellij.openapi.Disposable) Project(com.intellij.openapi.project.Project) WizardContext(com.intellij.ide.util.projectWizard.WizardContext) SettingsStep(com.intellij.ide.util.projectWizard.SettingsStep) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull) FlutterModuleBuilder(io.flutter.module.FlutterModuleBuilder)

Example 2 with SettingsStep

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

the class EduCCModuleBuilder method modifySettingsStep.

@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
    ModuleWizardStep javaSettingsStep = ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, this, Conditions.alwaysTrue());
    Function<JTextField, String> getValue = JTextComponent::getText;
    getWizardInputField("ccname", "", "Name:", myPanel.getNameField(), getValue).addToSettings(settingsStep);
    getWizardInputField("ccauthor", "", "Author:", myPanel.getAuthorField(), getValue).addToSettings(settingsStep);
    LanguageExtensionPoint[] extensions = new ExtensionPointName<LanguageExtensionPoint>(EduCourseConfigurator.EP_NAME).getExtensions();
    myLanguageComboBox.removeAllItems();
    for (LanguageExtensionPoint extension : extensions) {
        String languageId = extension.getKey();
        Language language = Language.findLanguageByID(languageId);
        if (language == null) {
            LOG.info("Language with id " + languageId + " not found");
        }
        myLanguageComboBox.addItem(new LanguageWrapper(language));
    }
    getWizardInputField("cclang", "", "Language:", myLanguageComboBox, comboBox -> (String) comboBox.getSelectedItem()).addToSettings(settingsStep);
    getWizardInputField("ccdescr", "", "Description:", myPanel.getDescriptionField(), JTextArea::getText).addToSettings(settingsStep);
    return javaSettingsStep;
}
Also used : Language(com.intellij.lang.Language) ModuleWithNameAlreadyExists(com.intellij.openapi.module.ModuleWithNameAlreadyExists) InvalidDataException(com.intellij.openapi.util.InvalidDataException) Function(java.util.function.Function) WizardInputField(com.intellij.ide.util.projectWizard.WizardInputField) JDOMException(org.jdom.JDOMException) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) CCNewProjectPanel(com.jetbrains.edu.coursecreator.ui.CCNewProjectPanel) StudyProjectGenerator(com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator) EduCourseModuleBuilder(com.jetbrains.edu.learning.intellij.generation.EduCourseModuleBuilder) Project(com.intellij.openapi.project.Project) Conditions(com.intellij.openapi.util.Conditions) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) ComboBox(com.intellij.openapi.ui.ComboBox) Lesson(com.jetbrains.edu.learning.courseFormat.Lesson) IOException(java.io.IOException) StudyTaskManager(com.jetbrains.edu.learning.StudyTaskManager) ProjectWizardStepFactory(com.intellij.ide.util.projectWizard.ProjectWizardStepFactory) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) Task(com.jetbrains.edu.learning.courseFormat.Task) JTextComponent(javax.swing.text.JTextComponent) File(java.io.File) EduCourseConfigurator(com.jetbrains.edu.learning.intellij.EduCourseConfigurator) ExtensionPointName(com.intellij.openapi.extensions.ExtensionPointName) Nullable(org.jetbrains.annotations.Nullable) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) SettingsStep(com.intellij.ide.util.projectWizard.SettingsStep) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) CCUtils(com.jetbrains.edu.coursecreator.CCUtils) Course(com.jetbrains.edu.learning.courseFormat.Course) javax.swing(javax.swing) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) Language(com.intellij.lang.Language) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

SettingsStep (com.intellij.ide.util.projectWizard.SettingsStep)2 Project (com.intellij.openapi.project.Project)2 File (java.io.File)2 NotNull (org.jetbrains.annotations.NotNull)2 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)1 ProjectWizardStepFactory (com.intellij.ide.util.projectWizard.ProjectWizardStepFactory)1 WizardContext (com.intellij.ide.util.projectWizard.WizardContext)1 WizardInputField (com.intellij.ide.util.projectWizard.WizardInputField)1 Language (com.intellij.lang.Language)1 LanguageExtensionPoint (com.intellij.lang.LanguageExtensionPoint)1 Disposable (com.intellij.openapi.Disposable)1 Logger (com.intellij.openapi.diagnostic.Logger)1 ExtensionPointName (com.intellij.openapi.extensions.ExtensionPointName)1 ModifiableModuleModel (com.intellij.openapi.module.ModifiableModuleModel)1 Module (com.intellij.openapi.module.Module)1 ModuleWithNameAlreadyExists (com.intellij.openapi.module.ModuleWithNameAlreadyExists)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 ComboBox (com.intellij.openapi.ui.ComboBox)1 Conditions (com.intellij.openapi.util.Conditions)1