From cfa466f1d3f26a6943611d7216b5f1433a0169c3 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Fri, 12 Jul 2024 11:58:39 -0400 Subject: [PATCH] Adding the fontsize setting to set the size of the allerts too --- .../bowlerstudio/AddFileToGistController.java | 13 ++ .../bowlerstudio/BowlerStudio.java | 25 +++ .../bowlerstudio/BowlerStudioMenu.java | 70 ++++++- .../bowlerstudio/ConnectionManager.java | 139 ++++++++++---- .../bowlerstudio/MakeReleaseController.java | 25 ++- .../NewVitaminWizardController.java | 49 +++++ .../creature/MobleBaseMenueFactory.java | 174 ++++++++++++++---- .../scripting/AskToDeleteWidget.java | 58 ++++++ .../scripting/ScriptingFileWidget.java | 47 +---- .../external/BlenderExternalEditor.java | 3 +- .../nrconsole/util/PromptForGit.java | 42 ++++- 11 files changed, 506 insertions(+), 139 deletions(-) create mode 100644 src/main/java/com/neuronrobotics/bowlerstudio/scripting/AskToDeleteWidget.java diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/AddFileToGistController.java b/src/main/java/com/neuronrobotics/bowlerstudio/AddFileToGistController.java index 57e60ab9b..eb34da714 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/AddFileToGistController.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/AddFileToGistController.java @@ -14,6 +14,7 @@ import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; +import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Alert; @@ -274,6 +275,18 @@ void createProject(ActionEvent event) { repoName.setText(slugVer); Alert alert = new Alert(javafx.scene.control.Alert.AlertType.INFORMATION); alert.setContentText("Repository Name must Valid: " + slugVer); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); alert.showAndWait(); BowlerStudio.runLater(() -> { newProject.setDisable(false); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudio.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudio.java index f705323fb..6e849dc4c 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudio.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudio.java @@ -44,6 +44,7 @@ import javafx.application.Platform; import javafx.fxml.FXMLLoader; import javafx.geometry.Rectangle2D; +import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Alert; @@ -357,6 +358,18 @@ public static void main(String[] args) throws Exception { alert.setHeaderText("Insuffient Ram Capibilities in 32 bit mode"); alert.setContentText("This applications uses more that 4gb of ram\nA 32 bit JVM mode detected: " + System.getProperty("os.arch")); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); alert.showAndWait(); System.exit(1); }); @@ -579,6 +592,18 @@ public boolean get(String name, String url) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("Message"); alert.setHeaderText("Would you like to download: " + name + "\nfrom:\n" + url); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); Optional result = alert.showAndWait(); buttonType = result.get(); alert.close(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudioMenu.java b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudioMenu.java index edddec8f2..addccd539 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudioMenu.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudioMenu.java @@ -32,6 +32,7 @@ import javafx.event.Event; import javafx.event.EventHandler; import javafx.fxml.FXML; +import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.control.Alert.AlertType; import javafx.stage.FileChooser.ExtensionFilter; @@ -604,7 +605,18 @@ public static void checkandDelete(String url) { alert.setTitle("Are you sure you have published all your work?"); alert.setHeaderText("This will wipe out the local cache for "+url); alert.setContentText("All files that are not published will be deleted"); - + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); Optional result = alert.showAndWait(); if (result.get() == ButtonType.OK) { new Thread(() -> { @@ -762,12 +774,24 @@ public static String slugify(String input) { private static void promptForNewBranch(String exampleName, String reasonForCreating, Consumer resultEvent) { BowlerStudio.runLater(() -> { - TextInputDialog dialog = new TextInputDialog(exampleName); - dialog.setTitle("Create New Branch"); - dialog.setHeaderText(reasonForCreating); - dialog.setContentText("Enter a new branch name: "); + TextInputDialog alert = new TextInputDialog(exampleName); + alert.setTitle("Create New Branch"); + alert.setHeaderText(reasonForCreating); + alert.setContentText("Enter a new branch name: "); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); // The Java 8 way to get the response value (with lambda expression). result.ifPresent(resultEvent); }); @@ -902,6 +926,18 @@ private void switchToThisNewBranch(String url, final MenuItem onBranch, Ref sele alert.setTitle("CheckoutConflictException");// line 2 alert.setHeaderText("This repo is in an a dirty state");// line 3 alert.setContentText("Please commit your changes before switching.\nAlternatly you can revert your changes.\nRepository must not have uncommitted changes before changing branches.");// line 4 + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); alert.showAndWait(); // line 5 }); return; @@ -1207,7 +1243,18 @@ public void clearScriptCache(ActionEvent event) { alert.setTitle("Are you sure you have published all your work?"); alert.setHeaderText("This will wipe out the local cache"); alert.setContentText("All files that are not published will be deleted"); - + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); Optional result = alert.showAndWait(); if (result.get() == ButtonType.OK) { new Thread(() -> { @@ -1341,6 +1388,15 @@ void onLoadGit(ActionEvent event) { TextInputDialog td = new TextInputDialog(); td.setHeaderText("Enter Git URL"); td.setResizable(true); + Node root = td.getDialogPane(); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + td.getDialogPane().applyCss(); + td.getDialogPane().layout(); + }); td.showAndWait(); // set the text of the label diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/ConnectionManager.java b/src/main/java/com/neuronrobotics/bowlerstudio/ConnectionManager.java index edc63f5e4..6b7b444e2 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/ConnectionManager.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/ConnectionManager.java @@ -1,6 +1,7 @@ package com.neuronrobotics.bowlerstudio; import com.neuronrobotics.bowlerstudio.assets.AssetFactory; +import com.neuronrobotics.bowlerstudio.assets.FontSizeManager; import com.neuronrobotics.bowlerstudio.utils.BowlerConnectionMenu; import com.neuronrobotics.imageprovider.AbstractImageProvider; //import com.neuronrobotics.imageprovider.OpenCVImageProvider; @@ -140,14 +141,25 @@ public static BowlerAbstractDevice pickConnectedDevice(@SuppressWarnings("rawtyp List choices = DeviceManager.listConnectedDevice(class1); if(!choices.isEmpty()){ - ChoiceDialog dialog = new ChoiceDialog<>(choices.get(0), + ChoiceDialog alert = new ChoiceDialog<>(choices.get(0), choices); - dialog.setTitle("Bowler Device Chooser"); - dialog.setHeaderText("Choose connected bowler device"); - dialog.setContentText("Device Name:"); - + alert.setTitle("Bowler Device Chooser"); + alert.setHeaderText("Choose connected bowler device"); + alert.setContentText("Device Name:"); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); if (result.isPresent()) { for (int i = 0; i < plugins.size(); i++) { if (plugins.get(i).getManager().getName().contains(result.get())) { @@ -275,13 +287,24 @@ public static void onConnectFileSourceCamera() { public static void onConnectURLSourceCamera() { - TextInputDialog dialog = new TextInputDialog("http://neuronrobotics.com/img/AndrewHarrington/2014-09-15-86.jpg"); - dialog.setTitle("URL Image Source"); - dialog.setHeaderText("This url will be loaded each capture."); - dialog.setContentText("URL "); - + TextInputDialog alert = new TextInputDialog("http://neuronrobotics.com/img/AndrewHarrington/2014-09-15-86.jpg"); + alert.setTitle("URL Image Source"); + alert.setHeaderText("This url will be loaded each capture."); + alert.setContentText("URL "); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); if (result.isPresent()){ URLImageProvider p; try { @@ -306,13 +329,24 @@ public static void onMarlinGCODE() { } - ChoiceDialog dialog = new ChoiceDialog<>(choices.get(0), choices); - dialog.setTitle("GCODE Device Serial Port Chooser"); - dialog.setHeaderText("Supports Marlin"); - dialog.setContentText("GCODE Device Port:"); - + ChoiceDialog alert = new ChoiceDialog<>(choices.get(0), choices); + alert.setTitle("GCODE Device Serial Port Chooser"); + alert.setHeaderText("Supports Marlin"); + alert.setContentText("GCODE Device Port:"); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); // The Java 8 way to get the response value (with lambda expression). result.ifPresent(letter -> { @@ -333,13 +367,24 @@ public static void onConnectHokuyoURG() { } - ChoiceDialog dialog = new ChoiceDialog<>(choices.get(0), choices); - dialog.setTitle("LIDAR Serial Port Chooser"); - dialog.setHeaderText("Supports URG-04LX-UG01"); - dialog.setContentText("Lidar Port:"); - + ChoiceDialog alert = new ChoiceDialog<>(choices.get(0), choices); + alert.setTitle("LIDAR Serial Port Chooser"); + alert.setHeaderText("Supports URG-04LX-UG01"); + alert.setContentText("Lidar Port:"); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); // The Java 8 way to get the response value (with lambda expression). result.ifPresent(letter -> { @@ -360,13 +405,24 @@ public static void onConnectGamePad() { } - ChoiceDialog dialog = new ChoiceDialog<>(choices.get(0), choices); - dialog.setTitle("JInput Game Controller Select"); - dialog.setHeaderText("Connect a game controller"); - dialog.setContentText("Controller:"); - + ChoiceDialog alert = new ChoiceDialog<>(choices.get(0), choices); + alert.setTitle("JInput Game Controller Select"); + alert.setHeaderText("Connect a game controller"); + alert.setContentText("Controller:"); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); // The Java 8 way to get the response value (with lambda expression). result.ifPresent(letter -> { @@ -538,13 +594,24 @@ public static void onFirmata() { } - ChoiceDialog dialog = new ChoiceDialog<>(choices.get(0), choices); - dialog.setTitle("Firmata Device Serial Port Chooser"); - dialog.setHeaderText("Supports Firmata"); - dialog.setContentText("Firmata Device Port:"); - + ChoiceDialog alert = new ChoiceDialog<>(choices.get(0), choices); + alert.setTitle("Firmata Device Serial Port Chooser"); + alert.setHeaderText("Supports Firmata"); + alert.setContentText("Firmata Device Port:"); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); // The Java 8 way to get the response value (with lambda expression). result.ifPresent(letter -> { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/MakeReleaseController.java b/src/main/java/com/neuronrobotics/bowlerstudio/MakeReleaseController.java index 4f7df7c3e..5a5c32d00 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/MakeReleaseController.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/MakeReleaseController.java @@ -25,6 +25,7 @@ import javafx.application.Application; import javafx.application.Platform; import javafx.fxml.FXMLLoader; +import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.TextFormatter.Change; @@ -107,13 +108,25 @@ void makeRelease(ActionEvent event) { private void CreatenewWorkflow(ActionEvent event, String newTag, Object[] st) { BowlerStudio.runLater(() -> { - ChoiceDialog d = new ChoiceDialog(st[0], st); - d.setTitle("Choose File From this Repo to release"); - d.setHeaderText("Select file to compile in CI"); - d.setContentText("File:"); + ChoiceDialog alert = new ChoiceDialog(st[0], st); + alert.setTitle("Choose File From this Repo to release"); + alert.setHeaderText("Select file to compile in CI"); + alert.setContentText("File:"); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // show the dialog - d.showAndWait(); - String selectedItem = (String) d.getSelectedItem(); + alert.showAndWait(); + String selectedItem = (String) alert.getSelectedItem(); new Thread(() -> { String filename = selectedItem.split("\\.")[0]; diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/NewVitaminWizardController.java b/src/main/java/com/neuronrobotics/bowlerstudio/NewVitaminWizardController.java index 619f58c5e..f81158b24 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/NewVitaminWizardController.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/NewVitaminWizardController.java @@ -29,6 +29,7 @@ import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; +import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Alert; @@ -213,6 +214,18 @@ void onConfirmSize(ActionEvent event) { alert.setTitle("No name specified!"); alert.setHeaderText("Names must be at least 2 charrectors long"); alert.setContentText("Try again..."); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); alert.showAndWait(); }); return; @@ -269,6 +282,18 @@ void onConfirmSize(ActionEvent event) { alert.setTitle("Size already Exists"); alert.setHeaderText("Name must be unique"); alert.setContentText("Rename and confirm to continue..."); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); alert.showAndWait(); }); return; @@ -353,6 +378,18 @@ void onConfirmType(ActionEvent event) { alert.setTitle("No name specified!"); alert.setHeaderText("Names must be at least 2 charrectors long"); alert.setContentText("Try again..."); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); alert.showAndWait(); }); return; @@ -364,6 +401,18 @@ void onConfirmType(ActionEvent event) { alert.setTitle("Name Format Wrong"); alert.setHeaderText("Name must be without spaces or special chars"); alert.setContentText("Changed to "+slug+" confirm to continue..."); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); alert.showAndWait(); BowlerStudio.runLater(() -> newTypeNameField.setText(slug)); }); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobleBaseMenueFactory.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobleBaseMenueFactory.java index ed66b3070..410904eaf 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobleBaseMenueFactory.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/MobleBaseMenueFactory.java @@ -7,6 +7,7 @@ import com.neuronrobotics.bowlerstudio.ConnectionManager; import com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler; import com.neuronrobotics.bowlerstudio.assets.AssetFactory; +import com.neuronrobotics.bowlerstudio.assets.FontSizeManager; import com.neuronrobotics.bowlerstudio.physics.TransformFactory; import com.neuronrobotics.bowlerstudio.printbed.PrintBedManager; import com.neuronrobotics.bowlerstudio.scripting.PasswordManager; @@ -23,6 +24,7 @@ import javafx.application.Platform; import javafx.fxml.FXMLLoader; import javafx.scene.Group; +import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.control.*; import javafx.scene.control.Alert.AlertType; @@ -30,6 +32,7 @@ import javafx.scene.transform.Affine; import javafx.stage.DirectoryChooser; import javafx.stage.Modality; +import javafx.stage.Stage; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -175,13 +178,24 @@ public static void load(MobileBase device, TreeView view, TreeItem { BowlerStudio.runLater(() -> { String oldname = device.getScriptingName(); - TextInputDialog dialog = new TextInputDialog(oldname + "_copy"); - dialog.setTitle("Making a copy of " + oldname); - dialog.setHeaderText("Set the scripting name for this creature"); - dialog.setContentText("Set the name of the new creature:"); - + TextInputDialog alert = new TextInputDialog(oldname + "_copy"); + alert.setTitle("Making a copy of " + oldname); + alert.setHeaderText("Set the scripting name for this creature"); + alert.setContentText("Set the name of the new creature:"); + Node r = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + r.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); if (result.isPresent()) { view.getSelectionModel().select(rootItem); System.out.println("Your new creature: " + result.get()); @@ -415,9 +429,20 @@ public void run() { } Set optionsKeys = options.keySet(); BowlerStudio.runLater(() -> { - ChoiceDialog d = new ChoiceDialog(optionsKeys.toArray()[0].toString(), optionsKeys); - - Optional result = d.showAndWait(); + ChoiceDialog alert = new ChoiceDialog(optionsKeys.toArray()[0].toString(), optionsKeys); + Node r = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + r.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); + Optional result = alert.showAndWait(); if (result.isPresent()) new Thread(() -> { String back = result.get(); @@ -758,13 +783,24 @@ private static void addAppendage(MobileBase base, TreeView view, boolean creatureIsOwnedByUser) { BowlerStudio.runLater(() -> { - TextInputDialog dialog = new TextInputDialog(newDevice.getScriptingName()); - dialog.setTitle("Add a new limb of"); - dialog.setHeaderText("Set the scripting name for this limb"); - dialog.setContentText("Please the name of the new limb:"); - + TextInputDialog alert = new TextInputDialog(newDevice.getScriptingName()); + alert.setTitle("Add a new limb of"); + alert.setHeaderText("Set the scripting name for this limb"); + alert.setContentText("Please the name of the new limb:"); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); if (result.isPresent()) { view.getSelectionModel().select(rootItem); new Thread() { @@ -929,7 +965,18 @@ private static void loadSingleLink(int linkIndex, MobileBase base, TreeView alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); Optional result = alert.showAndWait(); view.getSelectionModel().select(rootItem); if (result.get() == ButtonType.OK) { @@ -950,13 +997,24 @@ public void run() { callbackMapForTreeitems.put(addMobileBase, () -> { BowlerStudio.runLater(() -> { - TextInputDialog dialog = new TextInputDialog(conf.getName() + "_MobileBase_" + conf.getSlaveLinks().size()); - dialog.setTitle("Add a new Follower mobilebase of"); - dialog.setHeaderText("Set the scripting name for this Follower link"); - dialog.setContentText("Please the name of the new Follower link:"); - + TextInputDialog alert = new TextInputDialog(conf.getName() + "_MobileBase_" + conf.getSlaveLinks().size()); + alert.setTitle("Add a new Follower mobilebase of"); + alert.setHeaderText("Set the scripting name for this Follower link"); + alert.setContentText("Please the name of the new Follower link:"); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); if (result.isPresent()) { view.getSelectionModel().select(rootItem); new Thread() { @@ -985,13 +1043,24 @@ public void run() { // creatureLab)); // } BowlerStudio.runLater(() -> { - TextInputDialog dialog = new TextInputDialog(conf.getName() + "_Follower_" + conf.getSlaveLinks().size()); - dialog.setTitle("Add a new Follower link of"); - dialog.setHeaderText("Set the scripting name for this Follower link"); - dialog.setContentText("Please the name of the new Follower link:"); - + TextInputDialog alert = new TextInputDialog(conf.getName() + "_Follower_" + conf.getSlaveLinks().size()); + alert.setTitle("Add a new Follower link of"); + alert.setHeaderText("Set the scripting name for this Follower link"); + alert.setContentText("Please the name of the new Follower link:"); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); if (result.isPresent()) { view.getSelectionModel().select(rootItem); new Thread() { @@ -1033,7 +1102,18 @@ public void run() { alert.setTitle("Confirm removing link"); alert.setHeaderText("This will remove " + conf.getName()); alert.setContentText("Are sure you wish to remove this link?"); - + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); Optional result = alert.showAndWait(); view.getSelectionModel().select(rootItem); if (result.get() == ButtonType.OK) { @@ -1186,7 +1266,18 @@ private static void loadSingleLimb(MobileBase base, TreeView view, DHPar alert.setTitle("Confirm removing limb"); alert.setHeaderText("This will remove " + dh.getScriptingName()); alert.setContentText("Are sure you wish to remove this limb?"); - + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); Optional result = alert.showAndWait(); view.getSelectionModel().select(rootItem); if (result.get() == ButtonType.OK) { @@ -1231,13 +1322,24 @@ private static void loadSingleLimb(MobileBase base, TreeView view, DHPar // } BowlerStudio.runLater(() -> { int size = dh.getLinkConfigurations().size(); - TextInputDialog dialog = new TextInputDialog("Link_" + size); - dialog.setTitle("Add a new link of"); - dialog.setHeaderText("Set the scripting name for this link"); - dialog.setContentText("Please the name of the new link:"); - + TextInputDialog alert = new TextInputDialog("Link_" + size); + alert.setTitle("Add a new link of"); + alert.setHeaderText("Set the scripting name for this link"); + alert.setContentText("Please the name of the new link:"); + Node root = alert.getDialogPane(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); if (result.isPresent()) { view.getSelectionModel().select(rootItem); new Thread() { diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/AskToDeleteWidget.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/AskToDeleteWidget.java new file mode 100644 index 000000000..583513d0a --- /dev/null +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/AskToDeleteWidget.java @@ -0,0 +1,58 @@ +package com.neuronrobotics.bowlerstudio.scripting; + +import java.util.concurrent.CompletableFuture; + +import com.neuronrobotics.bowlerstudio.assets.FontSizeManager; + +import javafx.application.Platform; +import javafx.scene.Node; +import javafx.scene.control.Alert; +import javafx.scene.control.ButtonType; +import javafx.stage.Stage; + +public class AskToDeleteWidget { + public static boolean askToDeleteFile(String name) { + CompletableFuture future = new CompletableFuture<>(); + + Platform.runLater(() -> { + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setTitle("File Exists"); + alert.setHeaderText(name); + alert.setContentText("Delete existing and replace?"); + + ButtonType yes = new ButtonType("Yes"); + ButtonType no = new ButtonType("No"); + + alert.getButtonTypes().setAll(yes, no); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(event -> alert.hide()); + Node root = alert.getDialogPane(); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + stage.sizeToScene(); + }); + boolean result = alert.showAndWait().map(response -> { + if (response == yes) + return true; + if (response == no) + return false; + return null; + }).orElse(null); + + future.complete(result); + }); + + try { + return future.get(); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + +} diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingFileWidget.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingFileWidget.java index 075a99ba6..67fb17660 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingFileWidget.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/ScriptingFileWidget.java @@ -323,7 +323,7 @@ private void convertResults(String fileType) throws Exception { ScriptingEngine.ignore(url, "/**.FCBak"); ScriptingEngine.ignore(url, "**.blend1"); if(newFile.exists() ) { - if(askToDeleteFile(file)) { + if(AskToDeleteWidget.askToDeleteFile(file)) { newFile.delete(); } } @@ -342,7 +342,7 @@ private void convertResults(String fileType) throws Exception { try { newFile = ScriptingEngine.fileFromGit(url, file); if(newFile.exists() && !useSingleFileFOrImports) { - if(askToDeleteFile(file)) { + if(AskToDeleteWidget.askToDeleteFile(file)) { newFile.delete(); }else continue; @@ -370,49 +370,6 @@ private void convertResults(String fileType) throws Exception { BowlerStudio.createFileTab(newFile); } - public static boolean askToDeleteFile(String name) { - CompletableFuture future = new CompletableFuture<>(); - - Platform.runLater(() -> { - Alert alert = new Alert(Alert.AlertType.CONFIRMATION); - alert.setTitle("File Exists"); - alert.setHeaderText(name); - alert.setContentText("Delete existing and replace?"); - - ButtonType yes = new ButtonType("Yes"); - ButtonType no = new ButtonType("No"); - - alert.getButtonTypes().setAll(yes, no); - Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - stage.setOnCloseRequest(event -> alert.hide()); - Node root = alert.getDialogPane(); - FontSizeManager.addListener(fontNum -> { - int tmp = fontNum - 10; - if (tmp < 12) - tmp = 12; - root.setStyle("-fx-font-size: " + tmp + "pt"); - alert.getDialogPane().applyCss(); - alert.getDialogPane().layout(); - stage.sizeToScene(); - }); - boolean result = alert.showAndWait().map(response -> { - if (response == yes) - return true; - if (response == no) - return false; - return null; - }).orElse(null); - - future.complete(result); - }); - - try { - return future.get(); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } public String chooseFileType() { CompletableFuture future = new CompletableFuture<>(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/external/BlenderExternalEditor.java b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/external/BlenderExternalEditor.java index 980c87008..ba5cccc7e 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/scripting/external/BlenderExternalEditor.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/scripting/external/BlenderExternalEditor.java @@ -19,6 +19,7 @@ import com.neuronrobotics.bowlerstudio.BowlerStudio; import com.neuronrobotics.bowlerstudio.BowlerStudioController; import com.neuronrobotics.bowlerstudio.assets.AssetFactory; +import com.neuronrobotics.bowlerstudio.scripting.AskToDeleteWidget; import com.neuronrobotics.bowlerstudio.scripting.BlenderLoader; import com.neuronrobotics.bowlerstudio.scripting.DownloadManager; import com.neuronrobotics.bowlerstudio.scripting.IExternalEditor; @@ -46,7 +47,7 @@ public void launch(File file, Button advanced) { if(filename.toLowerCase().endsWith(".stl")) { File blenderfile = new File(dir.getAbsolutePath()+delim()+file.getName()+".blend"); - if(ScriptingFileWidget.askToDeleteFile(blenderfile.getName())) { + if(AskToDeleteWidget.askToDeleteFile(blenderfile.getName())) { blenderfile.delete(); } BlenderLoader.toBlenderFile(file, blenderfile); diff --git a/src/main/java/com/neuronrobotics/nrconsole/util/PromptForGit.java b/src/main/java/com/neuronrobotics/nrconsole/util/PromptForGit.java index a1b02d1c1..8a1b701d0 100644 --- a/src/main/java/com/neuronrobotics/nrconsole/util/PromptForGit.java +++ b/src/main/java/com/neuronrobotics/nrconsole/util/PromptForGit.java @@ -4,12 +4,15 @@ import java.util.Optional; import com.neuronrobotics.bowlerstudio.BowlerStudio; +import com.neuronrobotics.bowlerstudio.assets.FontSizeManager; import com.neuronrobotics.bowlerstudio.creature.IGistPromptCompletionListener; import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; import javafx.application.Platform; +import javafx.scene.Node; import javafx.scene.control.ChoiceDialog; import javafx.scene.control.TextInputDialog; +import javafx.stage.Stage; public class PromptForGit { private PromptForGit() { @@ -17,14 +20,26 @@ private PromptForGit() { public static void prompt(String purpose, String defaultID, IGistPromptCompletionListener listener){ BowlerStudio.runLater(() -> { - TextInputDialog dialog = new TextInputDialog(defaultID); - dialog.setTitle(purpose); - dialog.setHeaderText("Enter the URL (Clone vie HTTPS)"); - dialog.setContentText("Git Clone URL: "); - dialog.setResizable(true); - dialog.setWidth(800); + TextInputDialog alert = new TextInputDialog(defaultID); + alert.setTitle(purpose); + alert.setHeaderText("Enter the URL (Clone vie HTTPS)"); + alert.setContentText("Git Clone URL: "); + alert.setResizable(true); + alert.setWidth(800); + Node rt = alert.getDialogPane(); + Stage st = (Stage) alert.getDialogPane().getScene().getWindow(); + st.setOnCloseRequest(ev -> alert.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + rt.setStyle("-fx-font-size: " + tmp + "pt"); + alert.getDialogPane().applyCss(); + alert.getDialogPane().layout(); + st.sizeToScene(); + }); // Traditional way to get the response value. - Optional result = dialog.showAndWait(); + Optional result = alert.showAndWait(); if (result.isPresent()){ String gistcode=null; @@ -48,7 +63,18 @@ public static void prompt(String purpose, String defaultID, IGistPromptCompletio d.setTitle("Choose a file in the git"); d.setHeaderText("Select from the files in the git to pick the Creature File"); d.setContentText("Choose A Creature:"); - + Node root = d.getDialogPane(); + Stage stage = (Stage) d.getDialogPane().getScene().getWindow(); + stage.setOnCloseRequest(ev -> d.hide()); + FontSizeManager.addListener(fontNum -> { + int tmp = fontNum - 10; + if (tmp < 12) + tmp = 12; + root.setStyle("-fx-font-size: " + tmp + "pt"); + d.getDialogPane().applyCss(); + d.getDialogPane().layout(); + stage.sizeToScene(); + }); // Traditional way to get the response value. Optional r = d.showAndWait(); if (r.isPresent()){