Example usage for javafx.scene.control ButtonType OK

List of usage examples for javafx.scene.control ButtonType OK

Introduction

In this page you can find the example usage for javafx.scene.control ButtonType OK.

Prototype

ButtonType OK

To view the source code for javafx.scene.control ButtonType OK.

Click Source Link

Document

A pre-defined ButtonType that displays "OK" and has a ButtonData of ButtonData#OK_DONE .

Usage

From source file:spdxedit.license.FileLicenseEditor.java

public static void editConcludedLicense(SpdxFile file, SpdxDocumentContainer container) {
    LicenseEditControl control = new LicenseEditControl(container, file, true);
    if (file.getLicenseConcluded() != null) {
        control.setInitialValue(file.getLicenseConcluded());
    }// www . ja  va2 s .co m

    Dialog<Boolean> dialog = UiUtils.newDialog("Edit License", ButtonType.OK);
    dialog.getDialogPane().setContent(control.getUi());

    dialog.setResultConverter(buttonType -> {
        if (buttonType == ButtonType.OK) {
            return true;
        } else {
            return false;
        }
    });

    boolean acceptChange = dialog.showAndWait().orElse(false);

    if (acceptChange) {
        try {
            file.setLicenseConcluded(control.getValue());
        } catch (InvalidSPDXAnalysisException e) {
            throw new RuntimeException(e);

        }
    }

}

From source file:spdxedit.license.FileLicenseEditor.java

public static void extractLicenseFromFile(SpdxFile file, SpdxDocumentContainer container) {

    Dialog dialog = new Dialog();
    dialog.setTitle(Main.APP_TITLE);//  w  w w . j av  a  2 s  .  c  o m
    dialog.setHeaderText("Extract license");

    ((Stage) dialog.getDialogPane().getScene().getWindow()).getIcons()
            .addAll(UiUtils.ICON_IMAGE_VIEW.getImage());

    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL, ButtonType.OK);

    String licenseName = "";
    String licenseText = null;
    String licenseId = "";
    //TODO: Add support for multiple extracted licenses.
    if (file.getLicenseInfoFromFiles() != null && file.getLicenseInfoFromFiles().length > 0) {
        Optional<AnyLicenseInfo> foundExtractedLicense = Arrays.stream(file.getLicenseInfoFromFiles())
                .filter(license -> license instanceof ExtractedLicenseInfo).findFirst();
        if (foundExtractedLicense.isPresent()) {
            licenseName = ((ExtractedLicenseInfo) foundExtractedLicense.get()).getName();
            licenseText = ((ExtractedLicenseInfo) foundExtractedLicense.get()).getExtractedText();
            licenseId = ((ExtractedLicenseInfo) foundExtractedLicense.get()).getLicenseId();

        }
    }

    LicenseExtractControl licenseExtractControl = new LicenseExtractControl(licenseName, licenseText,
            licenseId);

    dialog.getDialogPane().setContent(licenseExtractControl.getUi());
    Optional<ButtonType> result = dialog.showAndWait();

    licenseName = licenseExtractControl.getLicenseName();
    licenseText = licenseExtractControl.getLicenseText();
    licenseId = licenseExtractControl.getLicenseId();

    //No selection
    if (!result.isPresent() || result.get() == ButtonType.CANCEL) {
        return;
    }
    //Omitted data
    if (StringUtils.isBlank(licenseName)) {
        new Alert(Alert.AlertType.ERROR, "License name cannot be blank. Use \"NOASSERTION\" instead",
                ButtonType.OK).showAndWait();
        return;
    }
    if (StringUtils.isBlank(licenseText)) {
        new Alert(Alert.AlertType.ERROR, "License text cannot be blank.", ButtonType.OK).showAndWait();
        return;
    }
    if (StringUtils.isBlank(licenseId)) {
        new Alert(Alert.AlertType.ERROR, "License ID cannot be blank.", ButtonType.OK).showAndWait();
        return;
    }
    //License already extracted
    if (SpdxLogic.findExtractedLicenseByNameAndText(container, licenseName, licenseText).isPresent()) {
        new Alert(Alert.AlertType.WARNING,
                "License " + licenseName + " with the same text has already been extracted.", ButtonType.OK)
                        .showAndWait();
        return;
    }
    //License with ID already exists
    if (SpdxLogic.findExtractedLicenseInfoById(container, licenseId).isPresent()) {
        new Alert(Alert.AlertType.WARNING, "License with ID " + licenseId + " already exists.", ButtonType.OK)
                .showAndWait();
        return;
    }

    SpdxLogic.addExtractedLicenseFromFile(file, container, licenseId, licenseName, licenseText);

}

From source file:jlotoprint.model.Template.java

public static Model load(File templateFile, boolean showFeedback) {
    Model modelRef = null;/*from  w  w w  .j  a  v  a 2s . c o  m*/
    try {
        StringWriter writer = new StringWriter();
        IOUtils.copy(new FileInputStream(templateFile), writer, "UTF-8");
        Gson g = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        modelRef = g.fromJson(writer.toString(), Model.class);
    } catch (Exception ex) {
        //Logger.getLogger(Template.class.getName()).log(Level.SEVERE, null, ex);
        if (showFeedback) {
            Alert dialog = new Alert(Alert.AlertType.ERROR, "The template you are trying to load is invalid.",
                    ButtonType.OK);
            dialog.initModality(Modality.APPLICATION_MODAL);
            dialog.showAndWait();
        }
    }
    return modelRef;
}

From source file:com.github.tddts.jet.view.fx.dialog.DevCredentialsDialog.java

@PostConstruct
public void init() {
    ButtonType cancelButtonType = new ButtonType(cancelMessage, ButtonBar.ButtonData.CANCEL_CLOSE);
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, cancelButtonType);
    setResultConverter(this::getResult);
}

From source file:com.github.tddts.jet.view.fx.dialog.DevCredentialsDialog.java

private Pair<String, String> getResult(ButtonType buttonType) {
    if (buttonType == ButtonType.OK) {
        return Pair.of(clientIdField.getText(), secretKeyField.getText());
    }// w  ww .  j  a  v a  2  s.c  o  m
    return null;
}

From source file:com.daarons.control.DeleteTableCell.java

public DeleteTableCell() {
    deleteButton = new Button();
    deleteButton.setOnAction(event -> {
        Alert deleteAlert = new Alert(Alert.AlertType.CONFIRMATION,
                "Are you " + "sure that you want to delete this?");
        deleteAlert.showAndWait().ifPresent(response -> {
            if (response == ButtonType.OK) {
                ApplicationContext applicationContext = SpringConfig.getApplicationContext();
                manageSelectionBehavior();
                String tableViewId = getTableView().getId();
                if (tableViewId.equals("csvTableView")) {
                    applicationContext.getBean(CsvController.class).removeSelectedTransferRecords();
                } else if (tableViewId.equals("uploadTableView")) {
                    applicationContext.getBean(TransferSettingsController.class)
                            .removeSelectedUploadTransferObjects();
                } else if (tableViewId.equals("downloadTableView")) {
                    applicationContext.getBean(TransferSettingsController.class)
                            .removeSelectedDownloadTransferObjects();
                }/*w w  w . j a  v  a  2 s. co m*/
            }
        });
    });
}

From source file:de.rkl.tools.tzconv.view.ZoneIdSelectionDialog.java

@SuppressWarnings("unused")
@PostConstruct//from  w  w  w.  j a va 2  s  . c  o m
public void initContent() {
    setOnShowing(this::resetFromModel);
    getDialogPane().setContent(createZoneIdSelectionBox());
    getDialogPane().getButtonTypes().add(ButtonType.OK);
    getDialogPane().getButtonTypes().add(ButtonType.CANCEL);
    setResultConverter(
            buttonType -> buttonType == ButtonType.OK ? newArrayList(pendingSelectedZoneIds.getValue()) : null);
}

From source file:io.github.mzmine.util.jfreechart.ManualZoomDialog.java

/**
 * Constructor/*w w w  .  java  2 s . com*/
 */
public ManualZoomDialog(Window parent, XYPlot plot) {

    initOwner(parent);

    setTitle("Manual zoom");

    setGraphic(new ImageView("file:icons/axesicon.png"));

    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    xAxis = (NumberAxis) plot.getDomainAxis();
    yAxis = (NumberAxis) plot.getRangeAxis();

    try {
        URL layersDialogFXML = getClass().getResource(DIALOG_FXML);
        FXMLLoader loader = new FXMLLoader(layersDialogFXML);
        loader.setController(this);
        GridPane grid = loader.load();
        getDialogPane().setContent(grid);
    } catch (Exception e) {
        e.printStackTrace();
    }

    final Button btOk = (Button) getDialogPane().lookupButton(ButtonType.OK);
    btOk.addEventFilter(ActionEvent.ACTION, event -> {
        commitChanges(event);
    });

}

From source file:gallerydemo.menu.ManagementMenuController.java

public ManagementMenuController(GalleryDemoViewController controller) {

    super(controller, "ManagementMenu.fxml");

    this.actualizeButtons();

    this.newGalleryButton.setOnAction((ActionEvent event) -> {
        this.createGalleryOrFolder(true);
    });//from   w w w  .j a va 2  s.  co m

    this.newFolderButton.setOnAction((ActionEvent event) -> {
        this.createGalleryOrFolder(false);
    });

    this.galleryPropertiesButton.setOnAction((ActionEvent event) -> {
        GalleryNode g = this.controller.getActiveGallery();

        if (g.isTrunk()) {
            return;
        }

        TextInputDialog dialog = new TextInputDialog(g.getName());
        dialog.setTitle("Umbenennen");
        dialog.setHeaderText(
                g.isGallery() ? "Die ausgewhlte Galerie umbenennen" : "Den ausgewhlten Ordner umbenennen");
        dialog.setContentText("Neuer Name:");

        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()) {
            g.setName(result.get());
            g.saveConfigFile();
        }
    });

    this.deleteGalleryButton.setOnAction((ActionEvent event) -> {
        GalleryNode g = this.controller.getActiveGallery();

        if (g.isTrunk()) {
            return;
        }

        Alert alert = new Alert(AlertType.CONFIRMATION);
        alert.setTitle("Lschen");
        alert.setHeaderText(
                g.isGallery() ? "Die ausgewhlte Galerie lschen?" : "Den ausgewhlten Ordner lschen?");
        alert.setContentText("Unwiederruflicher Vorgang!");

        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() == ButtonType.OK) {
            GalleryNode parent = (GalleryNode) g.getParent();
            Logger.getLogger("logfile").log(Level.INFO, "[delete] {0}", g.getLocation());
            try {
                FileUtils.deleteDirectory(g.getLocation());
            } catch (IOException ex) {
                Logger.getLogger("logfile").log(Level.SEVERE, null, ex);
            } finally {
                // Remove deleted gallery from tree view
                parent.getChildren().remove(g);
                this.controller.setActiveGallery(parent);
            }
        }
    });
}

From source file:employees.Employees.java

@Override
public void start(Stage stage) throws Exception {
    //        Parent root = FXMLLoader.load(getClass().getResource("MainUI.fxml"));
    //        //w  ww .  ja va  2 s . co  m
    //        Scene scene = new Scene(root);
    //        
    //        stage.setScene(scene);
    //        stage.show();
    //new LoginStage();
    Task<String> inittask = inittasks.pingServer();
    StringProperty pingResponse = new SimpleStringProperty();
    StringProperty messages = new SimpleStringProperty();
    pingResponse.bind(inittask.valueProperty());
    messages.bind(inittask.messageProperty());
    inittask.stateProperty().addListener((workerState, oldState, newState) -> {
        if (newState == Worker.State.SUCCEEDED) {
            String response = pingResponse.get();
            JSONObject obj = new JSONObject(response);
            String Status = obj.getString("Status");
            if (Status.equals("OK")) {
                AlertDialog ad = new AlertDialog();
                ad.showDialog(AlertTypes.Types.INFORMATION, "Successfull", "PING OK", "Connection Successfull");
            }
        } else if (newState == Worker.State.CANCELLED) {
            AlertDialog ad = new AlertDialog();
            ad.showDialog(AlertTypes.Types.WARNING, "Operation Aborted", "Operation Aborted",
                    "Task Was Cancelled,The System Will Now Exit");
            System.exit(0);
        } else if (newState == Worker.State.FAILED) {
            StringBuilder errstr = new StringBuilder();
            errstr.append(
                    "An Error Has Occured While Connecting to The Server, A Description of the Error is Shown Below : \n");
            errstr.append(messages.toString());
            AlertDialog ad = new AlertDialog();
            ad.showDialog(AlertTypes.Types.ERROR, "An Error Occurred While Connecting to The Server", "Error",
                    messages.get());
            Optional<ButtonType> response = AlertDialog.showConfirmation(
                    "Unable to Connect to The Server: Would you Like To Review Your Network Settings?",
                    "Connection Settings Review", "Review Connection Settings?");
            if (response.get() == ButtonType.OK) {
                try {
                    new initSettingsStage();
                } catch (IOException ex) {
                    Logger.getLogger(Employees.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    });
    new Thread(inittask).start();

}