Skip to content

Commit

Permalink
Fixing the NewCreatureWizard
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Nov 2, 2023
1 parent a75da0f commit 97d4058
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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(() -> {
Expand Down Expand Up @@ -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);
});
}
}
Original file line number Diff line number Diff line change
@@ -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();
});

}

}

0 comments on commit 97d4058

Please sign in to comment.