diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/AddFileToGistController.java b/src/main/java/com/neuronrobotics/bowlerstudio/AddFileToGistController.java index b124ec5ba..e3cb9df4a 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/AddFileToGistController.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/AddFileToGistController.java @@ -68,7 +68,7 @@ public class AddFileToGistController extends Application { private boolean isArduino; private static final Pattern NONLATIN = Pattern.compile("[^\\w-]"); private static final Pattern WHITESPACE = Pattern.compile("[\\s]"); - + private String forcedType=null; public static String toSlug(String input) { String nowhitespace = WHITESPACE.matcher(input).replaceAll("-"); String normalized = Normalizer.normalize(nowhitespace, Form.NFD); @@ -122,21 +122,8 @@ public void start(Stage primaryStage) throws Exception { extention.setOnAction(event -> { try { - langaugeIcon.setImage(AssetFactory - .loadAsset("Script-Tab-" + extention.getSelectionModel().getSelectedItem() + ".png")); - String key = extention.getSelectionModel().getSelectedItem(); - IScriptingLanguage l = ScriptingEngine.getLangaugesMap().get(key); - - if (l != null) { - extentionStr = l.getFileExtenetion().get(0); - } else - extentionStr = ".groovy"; - if(!extentionStr.startsWith(".")) { - extentionStr="."+extentionStr; - } - isArduino = ArduinoLoader.class.isInstance(l); - - setGitRepo(gitRepo); + String selectedItem = extention.getSelectionModel().getSelectedItem(); + setSelected(selectedItem); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); @@ -155,6 +142,29 @@ public void start(Stage primaryStage) throws Exception { }); } + private void setSelected(String selectedItem) throws Exception { + String file = "Script-Tab-" + selectedItem + ".png"; + Image loadAsset = AssetFactory.loadAsset(file); + try { + langaugeIcon.setImage(loadAsset); + }catch(Throwable t) { + t.printStackTrace(); + } + String key = selectedItem; + IScriptingLanguage l = ScriptingEngine.getLangaugesMap().get(key); + + if (l != null) { + extentionStr = l.getFileExtenetion().get(0); + } else + extentionStr = ".groovy"; + if(!extentionStr.startsWith(".")) { + extentionStr="."+extentionStr; + } + isArduino = ArduinoLoader.class.isInstance(l); + + setGitRepo(gitRepo); + } + @FXML public void onAddFile(ActionEvent event) { new Thread(() -> { @@ -287,4 +297,26 @@ public void setGitRepo(String gitRepo) { }); } } + + public void setFileExtensionType(IScriptingLanguage lang) { + String string = lang.getShellType(); + try { + setSelected(string); + BowlerStudio.runLater(() -> { + extention.setValue(string); + extention.setDisable(true); + }); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public void start(Stage s, IScriptingLanguage iScriptingLanguage) throws Exception { + start(s); + BowlerStudio.runLater(()->{ + setFileExtensionType(iScriptingLanguage); + }); + } } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/NewCreatureWizard.java b/src/main/java/com/neuronrobotics/bowlerstudio/NewCreatureWizard.java index 2d3fee083..3309715ff 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/NewCreatureWizard.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/NewCreatureWizard.java @@ -1,13 +1,27 @@ package com.neuronrobotics.bowlerstudio; +import com.neuronrobotics.bowlerstudio.scripting.IScriptingLanguage; +import com.neuronrobotics.bowlerstudio.scripting.RobotHelper; + +import javafx.stage.Stage; + public class NewCreatureWizard { public static void run() { - new Thread(()->{ - Thread.setDefaultUncaughtExceptionHandler(new IssueReportingExceptionHandler()); - - - }).start(); + BowlerStudio.runLater(()->{ + Stage s = new Stage(); + new Thread(()->{ + Thread.setDefaultUncaughtExceptionHandler(new IssueReportingExceptionHandler()); + AddFileToGistController controller = new AddFileToGistController(null, BowlerStudioMenu.getSelfRef()); + try { + controller.start(s,(IScriptingLanguage)new RobotHelper()); + } catch (Exception e) { + e.printStackTrace(); + } + + }).start(); + }); + } }