Skip to content

Commit

Permalink
Adding the fontsize setting to set the size of the allerts too
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Harrington committed Jul 12, 2024
1 parent cf4228e commit cfa466f
Show file tree
Hide file tree
Showing 11 changed files with 506 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudio.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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<ButtonType> result = alert.showAndWait();
buttonType = result.get();
alert.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK) {
new Thread(() -> {
Expand Down Expand Up @@ -762,12 +774,24 @@ public static String slugify(String input) {

private static void promptForNewBranch(String exampleName, String reasonForCreating, Consumer<String> 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<String> result = dialog.showAndWait();
Optional<String> result = alert.showAndWait();
// The Java 8 way to get the response value (with lambda expression).
result.ifPresent(resultEvent);
});
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK) {
new Thread(() -> {
Expand Down Expand Up @@ -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
Expand Down
139 changes: 103 additions & 36 deletions src/main/java/com/neuronrobotics/bowlerstudio/ConnectionManager.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -140,14 +141,25 @@ public static BowlerAbstractDevice pickConnectedDevice(@SuppressWarnings("rawtyp
List<String> choices = DeviceManager.listConnectedDevice(class1);

if(!choices.isEmpty()){
ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(0),
ChoiceDialog<String> 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<String> result = dialog.showAndWait();
Optional<String> result = alert.showAndWait();
if (result.isPresent()) {
for (int i = 0; i < plugins.size(); i++) {
if (plugins.get(i).getManager().getName().contains(result.get())) {
Expand Down Expand Up @@ -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<String> result = dialog.showAndWait();
Optional<String> result = alert.showAndWait();
if (result.isPresent()){
URLImageProvider p;
try {
Expand All @@ -306,13 +329,24 @@ public static void onMarlinGCODE() {
}


ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(0), choices);
dialog.setTitle("GCODE Device Serial Port Chooser");
dialog.setHeaderText("Supports Marlin");
dialog.setContentText("GCODE Device Port:");

ChoiceDialog<String> 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<String> result = dialog.showAndWait();
Optional<String> result = alert.showAndWait();

// The Java 8 way to get the response value (with lambda expression).
result.ifPresent(letter -> {
Expand All @@ -333,13 +367,24 @@ public static void onConnectHokuyoURG() {
}


ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(0), choices);
dialog.setTitle("LIDAR Serial Port Chooser");
dialog.setHeaderText("Supports URG-04LX-UG01");
dialog.setContentText("Lidar Port:");

ChoiceDialog<String> 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<String> result = dialog.showAndWait();
Optional<String> result = alert.showAndWait();

// The Java 8 way to get the response value (with lambda expression).
result.ifPresent(letter -> {
Expand All @@ -360,13 +405,24 @@ public static void onConnectGamePad() {
}


ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(0), choices);
dialog.setTitle("JInput Game Controller Select");
dialog.setHeaderText("Connect a game controller");
dialog.setContentText("Controller:");

ChoiceDialog<String> 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<String> result = dialog.showAndWait();
Optional<String> result = alert.showAndWait();

// The Java 8 way to get the response value (with lambda expression).
result.ifPresent(letter -> {
Expand Down Expand Up @@ -538,13 +594,24 @@ public static void onFirmata() {
}


ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(0), choices);
dialog.setTitle("Firmata Device Serial Port Chooser");
dialog.setHeaderText("Supports Firmata");
dialog.setContentText("Firmata Device Port:");

ChoiceDialog<String> 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<String> result = dialog.showAndWait();
Optional<String> result = alert.showAndWait();

// The Java 8 way to get the response value (with lambda expression).
result.ifPresent(letter -> {
Expand Down
Loading

0 comments on commit cfa466f

Please sign in to comment.