Search in sources :

Example 6 with DialogPane

use of javafx.scene.control.DialogPane in project aic-praise by aic-sri-international.

the class FXUtil method exception.

public static void exception(Throwable th) {
    Dialog<ButtonType> dialog = new Dialog<ButtonType>();
    dialog.setTitle("Program exception");
    final DialogPane dialogPane = dialog.getDialogPane();
    dialogPane.setContentText("Details of the problem:");
    dialogPane.getButtonTypes().addAll(ButtonType.OK);
    dialogPane.setContentText(th.getMessage());
    dialog.initModality(Modality.APPLICATION_MODAL);
    Label label = new Label("Exception stacktrace:");
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    th.printStackTrace(pw);
    pw.close();
    TextArea textArea = new TextArea(sw.toString());
    textArea.setEditable(false);
    textArea.setWrapText(true);
    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);
    GridPane root = new GridPane();
    root.setVisible(false);
    root.setMaxWidth(Double.MAX_VALUE);
    root.add(label, 0, 0);
    root.add(textArea, 0, 1);
    dialogPane.setExpandableContent(root);
    dialog.showAndWait();
}
Also used : DialogPane(javafx.scene.control.DialogPane) GridPane(javafx.scene.layout.GridPane) StringWriter(java.io.StringWriter) TextArea(javafx.scene.control.TextArea) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) ButtonType(javafx.scene.control.ButtonType) PrintWriter(java.io.PrintWriter)

Example 7 with DialogPane

use of javafx.scene.control.DialogPane in project FinalCrypt by ron-from-nl.

the class GUIFX method welcome.

private void welcome() {
    targetFCPathList = new FCPathList();
    updateDashboard(targetFCPathList);
    configuration = new Configuration(ui);
    version = new Version(ui);
    version.checkCurrentlyInstalledVersion(this);
    status("Welcome to " + Version.getProduct() + " " + version.getCurrentlyInstalledOverallVersionString() + "\r\n", false);
    log("Welcome to " + Version.getProduct() + " " + version.getCurrentlyInstalledOverallVersionString() + "\r\n");
    log("Copyright: " + Version.getCopyright() + " " + Version.getAuthor() + "\r\n");
    log("Email:     " + Version.getAuthorEmail() + "\r\n");
    log("Logfiles:  " + configuration.getLogDirPath().toString() + "\r\n");
    log("\r\n");
    log("Tip: FinalCrypt command line (DOS) usage:\r\n");
    log("java -cp FinalCrypt.jar rdj/CLUI --help\r\n");
    log("\r\n");
    copyrightLabel.setText("Copyright: " + Version.getCopyright() + " " + Version.getAuthor());
    // cpuIndicator
    Rectangle rect = new Rectangle(0, 0, 100, 100);
    Tooltip cpuIndicatorToolTip = new Tooltip("Process CPU Load");
    Tooltip.install(rect, cpuIndicatorToolTip);
    cpuIndicator.setTooltip(cpuIndicatorToolTip);
    // for: ProcessCpuLoad()
    // procCPULoadAttribute = "ProcessCpuLoad";
    mbs = ManagementFactory.getPlatformMBeanServer();
    try {
        name = ObjectName.getInstance("java.lang:type=OperatingSystem");
    } catch (MalformedObjectNameException | NullPointerException ex) {
        status(ex.getMessage(), true);
    }
    Timeline timeline = new Timeline(new KeyFrame(Duration.millis(200), ae -> cpuIndicator.setProgress(getProcessCpuLoad())));
    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.play();
    Platform.runLater(new Runnable() {

        @Override
        public void run() {
            String title = "Welcome to " + Version.getProduct();
            String header = "Brief Introduction:";
            String infotext = "Step 1 Select items to en/decrypt on the left side.\r\n";
            infotext += "Step 2 Select personal cipher file on the right side.\r\n";
            infotext += "Step 3 Click [Encrypt] or [Decrypt] at the bottom left.\r\n";
            infotext += "\r\n";
            infotext += "That's it! Not hard right?\r\n";
            infotext += "\r\n";
            infotext += "Optional:\r\n";
            infotext += "\r\n";
            infotext += "Double click to open files.\r\n";
            infotext += "Click [LOG] to see details.\r\n";
            infotext += "Click [Check Update] sometimes.\r\n";
            infotext += "Tip:  Watch statusbar at bottom.\r\n";
            infotext += "Tip:  Make backups of your data.\r\n";
            infotext += "\r\n";
            infotext += "Live to love - Enjoy your privacy.\r\n\r\n";
            /*
                Linux: ${user.home}/.java/.userPrefs/_\!\(\)\!~\!\"q\!#4\!\[w\"_\!%k\!\[g\"\}\!#@\!\<\!\=\=/prefs.xml 
                
                For Windows systemRoot and userRoot are stored in HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs and HKEY_CURRENT_USER\Software\JavaSoft\Prefs respectively.
                For Unix systemRoot and userRoot are stored in "/etc/.java" and "${user.home}/.java/.userPrefs", respectively.
                Note that for Unix the locations can be changed by specifying "java.util.prefs.userRoot" and "java.util.prefs.systemRoot" properties
                Mac OS X ~/Library/Preferences in multiple plist files.
                Mac OS X uses the java.util.prefs.MacOSXPreferencesFactory class. See lists.apple.com/archives/java-dev/2010/Jul/msg00056.html 
                the java.util.prefs.MacOSXPreferencesFactory class should be in rt.jar in JDK 1.7 or later.
                See hg.openjdk.java.net/macosx-port/macosx-port/jdk/file/… for the source code.
                JDK 8 all the items in java.util.prefs:                 
*/
            Preferences prefs = Preferences.userRoot().node(this.getClass().getName());
            // if no val then "Unknown" prefs location registry: HKEY_CURRENT_USER\Software\JavaSoft\Prefs
            String val = prefs.get("Hide Intro", "Unknown");
            if (!val.equals("Yes")) {
                Alert alert = introAlert(AlertType.INFORMATION, title, header, infotext, "Don't show again", param -> prefs.put("Hide Intro", param ? "Yes" : "No"), ButtonType.OK);
                if (alert.showAndWait().filter(t -> t == ButtonType.OK).isPresent()) {
                }
            }
        }
    });
    Alert alert = new Alert(AlertType.INFORMATION);
    // Style the Alert
    DialogPane dialogPane = alert.getDialogPane();
    dialogPane.getStylesheets().add(getClass().getResource("myInfoAlerts.css").toExternalForm());
    dialogPane.getStyleClass().add("myDialog");
// alert.setTitle("Info");
// alert.setHeaderText("Welcome");
// alert.setResizable(true);
// String infotext = new String();
// infotext  = "Welcome.\r\n";
// alert.setContentText(infotext);
// alert.setOnShowing(new EventHandler<DialogEvent>()
// {
// @Override
// public void handle(DialogEvent event)
// {
// //              JavaFX Delay Timer to prevent not on application thread error
// Timeline timeline = new Timeline(new KeyFrame( Duration.millis(1000), ae ->
// alert.close()
// )); timeline.play();
// }
// });
// alert.showAndWait();
}
Also used : Button(javafx.scene.control.Button) Initializable(javafx.fxml.Initializable) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) JToggleButton(javax.swing.JToggleButton) Timer(java.util.Timer) Application(javafx.application.Application) Parent(javafx.scene.Parent) TabPane(javafx.scene.control.TabPane) AlertType(javafx.scene.control.Alert.AlertType) Locale(java.util.Locale) URI(java.net.URI) JFileChooser(javax.swing.JFileChooser) TimerTask(java.util.TimerTask) Path(java.nio.file.Path) ReflectionException(javax.management.ReflectionException) Alert(javafx.scene.control.Alert) Font(java.awt.Font) Predicate(java.util.function.Predicate) StandardOpenOption(java.nio.file.StandardOpenOption) Event(javafx.event.Event) Rectangle(javafx.scene.shape.Rectangle) Timeline(javafx.animation.Timeline) ObjectName(javax.management.ObjectName) Group(javafx.scene.Group) Component(java.awt.Component) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) MalformedObjectNameException(javax.management.MalformedObjectNameException) List(java.util.List) Duration(javafx.util.Duration) ToggleButton(javafx.scene.control.ToggleButton) Scene(javafx.scene.Scene) TextArea(javafx.scene.control.TextArea) ButtonType(javafx.scene.control.ButtonType) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) MouseEvent(javafx.scene.input.MouseEvent) AttributeList(javax.management.AttributeList) ArrayList(java.util.ArrayList) LinkOption(java.nio.file.LinkOption) ProgressBar(javafx.scene.control.ProgressBar) Calendar(java.util.Calendar) ResourceBundle(java.util.ResourceBundle) FXMLLoader(javafx.fxml.FXMLLoader) Attribute(javax.management.Attribute) MBeanServer(javax.management.MBeanServer) Container(java.awt.Container) ManagementFactory(java.lang.management.ManagementFactory) Tooltip(javafx.scene.control.Tooltip) Animation(javafx.animation.Animation) InstanceNotFoundException(javax.management.InstanceNotFoundException) GridPane(javafx.scene.layout.GridPane) Desktop(java.awt.Desktop) ProgressIndicator(javafx.scene.control.ProgressIndicator) Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) Label(javafx.scene.control.Label) JButton(javax.swing.JButton) Files(java.nio.file.Files) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) FileFilter(javax.swing.filechooser.FileFilter) File(java.io.File) Preferences(java.util.prefs.Preferences) Consumer(java.util.function.Consumer) ActionEvent(javafx.event.ActionEvent) DialogPane(javafx.scene.control.DialogPane) Stage(javafx.stage.Stage) Tab(javafx.scene.control.Tab) PlatformImpl(com.sun.javafx.application.PlatformImpl) SwingNode(javafx.embed.swing.SwingNode) MalformedObjectNameException(javax.management.MalformedObjectNameException) Tooltip(javafx.scene.control.Tooltip) Rectangle(javafx.scene.shape.Rectangle) DialogPane(javafx.scene.control.DialogPane) Timeline(javafx.animation.Timeline) KeyFrame(javafx.animation.KeyFrame) Alert(javafx.scene.control.Alert) Preferences(java.util.prefs.Preferences)

Example 8 with DialogPane

use of javafx.scene.control.DialogPane in project FinalCrypt by ron-from-nl.

the class GUIFX method targetInfoLabelClicked.

@FXML
private void targetInfoLabelClicked(MouseEvent event) {
    Alert alert = new Alert(AlertType.INFORMATION);
    // Style the Alert
    DialogPane dialogPane = alert.getDialogPane();
    dialogPane.getStylesheets().add(getClass().getResource("myInfoAlerts.css").toExternalForm());
    dialogPane.getStyleClass().add("myDialog");
    alert.setTitle("Information Dialog");
    alert.setHeaderText("What about your selected items?");
    alert.setResizable(true);
    String infotext = new String();
    infotext = "These are the files and maps you want to en / decrypt.\r\n";
    infotext += "Hold down [Ctrl] / [Shift] to select multiple items.\r\n";
    infotext += "\r\n";
    infotext += "Encrypted files get the \".bit\" extension added.\r\n";
    infotext += "Decrypted files get the \".bit\" extension removed.\r\n";
    infotext += "\r\n";
    infotext += "Original files are securely deleted after en / decryption.\r\n";
    infotext += "\r\n";
    alert.setContentText(infotext);
    alert.showAndWait();
}
Also used : DialogPane(javafx.scene.control.DialogPane) Alert(javafx.scene.control.Alert) FXML(javafx.fxml.FXML)

Example 9 with DialogPane

use of javafx.scene.control.DialogPane in project TagLauncher_3 by ammarx.

the class Launcher_Main_Controller method showFirstTimeMessage.

public void showFirstTimeMessage() {
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle("Minecraft Launcher - Welcome");
    alert.setHeaderText("Greetings Player...");
    alert.setContentText("" + "It looks like this is your first time using our launcher and we wanted to provide you with some help.\n\n" + "By default, the launcher doesn't come with any versions of Minecraft installed so you will need to download the version you wish to play via the options menu.\n\n" + "Once in the options menu, click the dropdown menu under the Version Settings title and choose the version you want. When you have chosen, click the download button and wait for the launcher to download all the necessary files.");
    alert.initStyle(StageStyle.UTILITY);
    DialogPane dialogPane = alert.getDialogPane();
    dialogPane.getStylesheets().add("taglauncher_3/css/purple.css");
    Stage stage = (Stage) dialogPane.getScene().getWindow();
    stage.setAlwaysOnTop(true);
    stage.toFront();
    alert.show();
}
Also used : DialogPane(javafx.scene.control.DialogPane) Stage(javafx.stage.Stage) Alert(javafx.scene.control.Alert)

Example 10 with DialogPane

use of javafx.scene.control.DialogPane in project TagLauncher_3 by ammarx.

the class Launcher_Options_Controller method _optionsSelectVersionInstall.

@FXML
private void _optionsSelectVersionInstall(ActionEvent event) {
    if (optionsSelectVersion.getValue() == null || optionsSelectVersion.getValue().equals("")) {
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle("Minecraft Launcher - Error");
        alert.setHeaderText("Invaild selection.");
        alert.setContentText("Please select a version to install prior to installing.");
        alert.initStyle(StageStyle.UTILITY);
        DialogPane dialogPane = alert.getDialogPane();
        dialogPane.getStylesheets().add("taglauncher_3/css/purple.css");
        alert.show();
        return;
    }
    optionsSelectVersionInstall.setDisable(true);
    optionsExit.setDisable(true);
    optionsClose.setDisable(true);
    optionsSelectVersion.setDisable(true);
    if (optionsSelectVersionForce.isSelected()) {
        System.out.println("Selected!");
    } else {
        System.out.println("NOT Selected!");
    }
    tagapi_3.API_Interface API = new tagapi_3.API_Interface();
    ExecutorService executor = Executors.newCachedThreadPool();
    executor.submit(() -> {
        API.downloadMinecraft((String) optionsSelectVersion.getValue(), optionsSelectVersionForce.isSelected());
        return null;
    });
    executor.shutdown();
    Thread t = new Thread(() -> {
        while (true) {
            try {
                Platform.runLater(() -> {
                    if (Launcher_Settings.showDebugStatus == true) {
                        optionStatus.setText(API.getLog());
                    } else {
                        if (API.getLog().startsWith("[dl] URL: https://launchermeta")) {
                            optionStatus.setText("Status: " + Launcher_Settings.Status.DOWNLOADING_LM);
                        }
                        if (API.getLog().startsWith("[dl] DOWNLOADING...HASH:")) {
                            optionStatus.setText("Status: " + Launcher_Settings.Status.DOWNLOADING);
                        }
                        if (API.getLog().startsWith("[dl] DOWNLOADING MINECRAFT JAR")) {
                            optionStatus.setText("Status: " + Launcher_Settings.Status.DOWNLOADING_M);
                        }
                        if (API.getLog().startsWith("[dl] Downloading: https://libraries")) {
                            optionStatus.setText("Status: " + Launcher_Settings.Status.DOWNLOADING_L);
                        }
                        if (API.getLog().startsWith("[dl] Getting NATIVES URL")) {
                            optionStatus.setText("Status: " + Launcher_Settings.Status.FINALIZING);
                        }
                    }
                });
                Thread.sleep(10);
                if (API.getLog().equals("[dl] Download Complete!")) {
                    Platform.runLater(() -> {
                        optionStatus.setText("Status: " + Launcher_Settings.Status.DOWNLOAD_COMPLETE);
                        Alert alert = new Alert(Alert.AlertType.INFORMATION);
                        alert.setTitle("Minecraft Launcher - Success");
                        alert.setHeaderText("Download Complete.");
                        alert.initStyle(StageStyle.UTILITY);
                        DialogPane dialogPane = alert.getDialogPane();
                        dialogPane.getStylesheets().add("taglauncher_3/css/purple.css");
                        alert.setContentText("Version: " + (String) optionsSelectVersion.getValue() + " has been downloaded & installed!");
                        ;
                        optionStatus.setText("Status: " + Launcher_Settings.Status.IDLE);
                        optionsSelectVersionInstall.setDisable(false);
                        optionsExit.setDisable(false);
                        optionsClose.setDisable(false);
                        optionsSelectVersion.setDisable(false);
                        optionsSelectFastStart.setSelected(false);
                        Launcher_Settings.refreshVersionList = true;
                        Launcher_Settings.fastStartUp = false;
                        alert.showAndWait();
                        API.dumpLogs();
                    });
                    return;
                }
            } catch (Exception e) {
            }
        }
    });
    t.start();
}
Also used : DialogPane(javafx.scene.control.DialogPane) ExecutorService(java.util.concurrent.ExecutorService) Alert(javafx.scene.control.Alert) FXML(javafx.fxml.FXML)

Aggregations

DialogPane (javafx.scene.control.DialogPane)10 Alert (javafx.scene.control.Alert)8 FXML (javafx.fxml.FXML)6 ExecutorService (java.util.concurrent.ExecutorService)3 Label (javafx.scene.control.Label)3 Stage (javafx.stage.Stage)3 File (java.io.File)2 IOException (java.io.IOException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ResourceBundle (java.util.ResourceBundle)2 ButtonType (javafx.scene.control.ButtonType)2 TextArea (javafx.scene.control.TextArea)2 GridPane (javafx.scene.layout.GridPane)2 PlatformImpl (com.sun.javafx.application.PlatformImpl)1 Component (java.awt.Component)1 Container (java.awt.Container)1 Desktop (java.awt.Desktop)1 Font (java.awt.Font)1