Search in sources :

Example 1 with ButtonType

use of javafx.scene.control.ButtonType in project DistributedFractalNetwork by Budder21.

the class NetworkCreationTool method createNetwork.

/**
	 * This method, when called, will bring the user through a series of menus helping them
	 * configure the Network they wish to set up.
	 * @return whether or not the network was successfully created.
	 */
public boolean createNetwork() {
    File[] fractals = new File(Constants.FRACTAL_FILEPATH).listFiles();
    List<String> choices = new ArrayList<>();
    for (File f : fractals) {
        if (!f.getName().equals("palettes"))
            choices.add(f.getName());
    }
    ChoiceDialog<String> dialog1 = null;
    try {
        dialog1 = new ChoiceDialog<>(choices.get(0), choices);
    } catch (IndexOutOfBoundsException e) {
        AlertMenu alarm = new AlertMenu("Cannot create network: no fractal found on this computer.", "Fractals are searched for in the fractals folder. Please save a fractal to that folder and try again.");
    }
    dialog1.setTitle("Create Network");
    dialog1.setHeaderText("Step 1");
    dialog1.setContentText("Choose a fractal:");
    System.out.println("here...");
    RenderManager fractal = null;
    try {
        fractal = new RenderManager(dialog1.showAndWait().get());
    } catch (Exception e) {
        return false;
    }
    Pair<Integer, Integer> dimension = displayDialog2();
    if (dimension == null)
        return false;
    fractal.setScreenResolution(new Dimension(dimension.getKey(), dimension.getValue()));
    Pair<Double, Double> params = getParams();
    if (params == null)
        return false;
    if (params.getKey() == null)
        return false;
    if (params.getValue() == null)
        return false;
    fractal.setZoom(params.getKey());
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Create Network");
    alert.setHeaderText("Step 4");
    alert.setContentText("Choose a directory:");
    ButtonType buttonTypeOne = new ButtonType("Choose");
    ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
    alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeCancel);
    Optional<ButtonType> result = alert.showAndWait();
    String directory = "";
    if (result.get() == buttonTypeOne) {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        File selectedDirectory = directoryChooser.showDialog(null);
        if (selectedDirectory == null) {
            return false;
        } else {
            directory = selectedDirectory.getPath();
        }
    } else {
        return false;
    }
    this.server = new Server(fractal, params.getValue(), directory);
    return true;
}
Also used : Server(server.Server) ArrayList(java.util.ArrayList) Dimension(java.awt.Dimension) Alert(javafx.scene.control.Alert) File(java.io.File) RenderManager(fractal.RenderManager) ButtonType(javafx.scene.control.ButtonType) DirectoryChooser(javafx.stage.DirectoryChooser)

Example 2 with ButtonType

use of javafx.scene.control.ButtonType in project POL-POM-5 by PlayOnLinux.

the class MainController method setOnClose.

public void setOnClose(Runnable onClose) {
    this.mainWindow.setOnCloseRequest(event -> {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.initOwner(this.mainWindow);
        alert.setTitle(applicationName);
        alert.setHeaderText(tr("Are you sure you want to close all {0} windows?", applicationName));
        Optional<ButtonType> result = alert.showAndWait();
        if (result.isPresent() && result.get() == ButtonType.OK) {
            Platform.exit();
            onClose.run();
        } else {
            event.consume();
        }
    });
}
Also used : Alert(javafx.scene.control.Alert) ButtonType(javafx.scene.control.ButtonType)

Example 3 with ButtonType

use of javafx.scene.control.ButtonType in project aima-java by aimacode.

the class MapPaneCtrl method showMapEntityInfoDialog.

/**
     * Finds the visible entity next to the specified view coordinates and shows
     * informations about it.
     *
     * @param debug
     *            Enables a more detailed view.
     */
private void showMapEntityInfoDialog(MapEntity entity, boolean debug) {
    List<MapEntity> entities = new ArrayList<>();
    if (entity.getName() != null || entity.getAttributes().length > 0 || debug)
        entities.add(entity);
    if (entity instanceof MapNode) {
        MapNode mNode = (MapNode) entity;
        for (WayRef ref : mNode.getWayRefs()) {
            MapEntity me = ref.getWay();
            if (me.getName() != null || me.getAttributes().length > 0 || debug)
                entities.add(me);
        }
    }
    for (MapEntity me : entities) {
        String header = (me.getName() != null) ? me.getName() : "";
        StringBuilder content = new StringBuilder();
        if (debug)
            header += " (" + ((me instanceof MapNode) ? "Node " : "Way ") + me.getId() + ")";
        if (me instanceof MapNode) {
            content.append("Lat: ").append(((MapNode) me).getLat()).append(" Lon: ").append(((MapNode) me).getLon()).append(" ");
        }
        if (me.getAttributes().length > 0) {
            EntityAttribute[] atts = me.getAttributes();
            content.append("Attributs: ");
            for (EntityAttribute att : atts) {
                content.append(att.getKey()).append("=").append(att.getValue()).append(" ");
            }
        }
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Map Entity Info");
        alert.setHeaderText(header);
        alert.setContentText(content.toString());
        Optional<ButtonType> result = alert.showAndWait();
        if (!result.isPresent())
            break;
    }
}
Also used : WayRef(aimax.osm.data.entities.WayRef) EntityAttribute(aimax.osm.data.entities.EntityAttribute) ArrayList(java.util.ArrayList) Alert(javafx.scene.control.Alert) MapEntity(aimax.osm.data.entities.MapEntity) MapNode(aimax.osm.data.entities.MapNode) ButtonType(javafx.scene.control.ButtonType)

Example 4 with ButtonType

use of javafx.scene.control.ButtonType in project Gargoyle by callakrsos.

the class DialogUtil method showConfirmDialog.

/**
	 * confirm Dialog
	 *
	 * confirm 다이얼로그
	 *
	 * @return
	 */
public static ButtonType showConfirmDialog() {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Confirmation Dialog");
    alert.setHeaderText("Look, a Confirmation Dialog");
    alert.setContentText("Are you ok with this?");
    Optional<ButtonType> result = alert.showAndWait();
    /*
		 * if (result.get() == ButtonType.OK) { // ... user chose OK } else { // ... user chose CANCEL or closed the dialog }
		 */
    return result.get();
}
Also used : Alert(javafx.scene.control.Alert) ButtonType(javafx.scene.control.ButtonType)

Example 5 with ButtonType

use of javafx.scene.control.ButtonType in project Gargoyle by callakrsos.

the class DialogUtil method showYesOrNoDialog.

// public static Optional<Pair<String, String>> showYesOrNoDialog(String title, String message) {
// return showYesOrNoDialog(SharedMemory.getPrimaryStage(), title, message, consumer, null);
// }
public static Optional<Pair<String, String>> showYesOrNoDialog(Stage stage, String title, String message, Consumer<? super Pair<String, String>> consumer, Consumer<Dialog<Pair<String, String>>> dialogHandler) {
    // Create the custom dialog.
    Dialog<Pair<String, String>> dialog = new Dialog<>();
    dialog.setTitle(title);
    dialog.setHeaderText(message);
    // Set the button types.
    ButtonType yesBtn = new ButtonType("Yes", ButtonData.YES);
    ButtonType noBtn = new ButtonType("No", ButtonData.NO);
    dialog.getDialogPane().getButtonTypes().addAll(yesBtn, noBtn);
    dialog.setResultConverter(dialogButton -> {
        if (dialogButton == yesBtn) {
            return new Pair<>("RESULT", "Y");
        } else if (dialogButton == noBtn) {
            return new Pair<>("RESULT", "N");
        }
        return null;
    });
    dialog.initOwner(stage);
    if (dialogHandler != null)
        dialogHandler.accept(dialog);
    Optional<Pair<String, String>> result = dialog.showAndWait();
    if (consumer != null)
        result.ifPresent(consumer);
    return result;
}
Also used : Dialog(javafx.scene.control.Dialog) ButtonType(javafx.scene.control.ButtonType) Pair(javafx.util.Pair)

Aggregations

ButtonType (javafx.scene.control.ButtonType)18 Alert (javafx.scene.control.Alert)9 Dialog (javafx.scene.control.Dialog)5 File (java.io.File)4 Label (javafx.scene.control.Label)4 GridPane (javafx.scene.layout.GridPane)4 Pair (javafx.util.Pair)4 TextField (javafx.scene.control.TextField)3 FileChooser (javafx.stage.FileChooser)3 Dimension (java.awt.Dimension)2 ArrayList (java.util.ArrayList)2 FXML (javafx.fxml.FXML)2 Insets (javafx.geometry.Insets)2 Node (javafx.scene.Node)2 DialogPane (javafx.scene.control.DialogPane)2 PasswordField (javafx.scene.control.PasswordField)2 DirectoryChooser (javafx.stage.DirectoryChooser)2 EntityAttribute (aimax.osm.data.entities.EntityAttribute)1 MapEntity (aimax.osm.data.entities.MapEntity)1 MapNode (aimax.osm.data.entities.MapNode)1