Search in sources :

Example 1 with CreateProjectCommand

use of com.thecoderscorner.menu.editorui.cli.CreateProjectCommand in project tcMenu by davetcc.

the class NewProjectController method onCreate.

public void onCreate(ActionEvent actionEvent) {
    boolean newOnlyMode = newOnlyRadio.isSelected();
    if (newOnlyMode) {
        if (!passDirtyCheck())
            return;
        project.newProject();
    } else if (maybeDirectory.isPresent() && !StringHelper.isStringEmptyOrNull(projectNameField.getText())) {
        if (!passDirtyCheck())
            return;
        try {
            String projName = projectNameField.getText();
            var projectCreator = new CreateProjectCommand();
            projectCreator.createNewProject(Paths.get(maybeDirectory.get()), projName, cppMainCheckbox.isSelected(), platformCombo.getSelectionModel().getSelectedItem(), s -> logger.log(INFO, s), namespaceField.getText());
            Path emfFileName = Paths.get(maybeDirectory.get(), projName, projName + ".emf");
            project.openProject(emfFileName.toString());
        } catch (Exception e) {
            logger.log(ERROR, "Failure processing create new project", e);
            var alert = new Alert(Alert.AlertType.ERROR, "Error during create project", ButtonType.CLOSE);
            BaseDialogSupport.getJMetro().setScene(alert.getDialogPane().getScene());
            alert.showAndWait();
        }
    } else {
        var alert = new Alert(Alert.AlertType.WARNING, "Please ensure all fields are populated", ButtonType.CLOSE);
        BaseDialogSupport.getJMetro().setScene(alert.getDialogPane().getScene());
        alert.showAndWait();
        // avoid closing.
        return;
    }
    Stage stage = (Stage) createButton.getScene().getWindow();
    stage.close();
}
Also used : StringHelper(com.thecoderscorner.menu.editorui.util.StringHelper) EmbeddedPlatforms(com.thecoderscorner.menu.editorui.generator.plugin.EmbeddedPlatforms) javafx.scene.control(javafx.scene.control) Files(java.nio.file.Files) INFO(java.lang.System.Logger.Level.INFO) FXCollections(javafx.collections.FXCollections) BaseDialogSupport(com.thecoderscorner.menu.editorui.dialog.BaseDialogSupport) EmbeddedPlatform(com.thecoderscorner.menu.editorui.generator.plugin.EmbeddedPlatform) KeyEvent(javafx.scene.input.KeyEvent) CreateProjectCommand(com.thecoderscorner.menu.editorui.cli.CreateProjectCommand) CurrentEditorProject(com.thecoderscorner.menu.editorui.project.CurrentEditorProject) LogLine(com.thecoderscorner.menu.editorui.generator.ui.LogLine) File(java.io.File) ERROR(java.lang.System.Logger.Level.ERROR) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) Paths(java.nio.file.Paths) ConfigurationStorage(com.thecoderscorner.menu.editorui.storage.ConfigurationStorage) Optional(java.util.Optional) Path(java.nio.file.Path) DirectoryChooser(javafx.stage.DirectoryChooser) Path(java.nio.file.Path) CreateProjectCommand(com.thecoderscorner.menu.editorui.cli.CreateProjectCommand) Stage(javafx.stage.Stage)

Aggregations

CreateProjectCommand (com.thecoderscorner.menu.editorui.cli.CreateProjectCommand)1 BaseDialogSupport (com.thecoderscorner.menu.editorui.dialog.BaseDialogSupport)1 EmbeddedPlatform (com.thecoderscorner.menu.editorui.generator.plugin.EmbeddedPlatform)1 EmbeddedPlatforms (com.thecoderscorner.menu.editorui.generator.plugin.EmbeddedPlatforms)1 LogLine (com.thecoderscorner.menu.editorui.generator.ui.LogLine)1 CurrentEditorProject (com.thecoderscorner.menu.editorui.project.CurrentEditorProject)1 ConfigurationStorage (com.thecoderscorner.menu.editorui.storage.ConfigurationStorage)1 StringHelper (com.thecoderscorner.menu.editorui.util.StringHelper)1 File (java.io.File)1 ERROR (java.lang.System.Logger.Level.ERROR)1 INFO (java.lang.System.Logger.Level.INFO)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 Optional (java.util.Optional)1 FXCollections (javafx.collections.FXCollections)1 ActionEvent (javafx.event.ActionEvent)1 javafx.scene.control (javafx.scene.control)1 KeyEvent (javafx.scene.input.KeyEvent)1 DirectoryChooser (javafx.stage.DirectoryChooser)1