Example usage for javafx.scene.control Alert Alert

List of usage examples for javafx.scene.control Alert Alert

Introduction

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

Prototype

public Alert(@NamedArg("alertType") AlertType alertType) 

Source Link

Document

Creates an alert with the given AlertType (refer to the AlertType documentation for clarification over which one is most appropriate).

Usage

From source file:ui.main.MainViewController.java

private void takeCall() {
    if (contactsManager.getAvailabilityforCalling(currentChat.getParticipant())) {
        try {/*  www. ja  v a2 s  .  c om*/
            //default configuration and initialization of the form
            Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("ui/call/CallView.fxml"));

            Scene scene = new Scene(root);

            Stage stage = new Stage();

            stage.setScene(scene);
            stage.show();

            stage.setResizable(false);
            stage.setTitle("IMP : Voice");
        } catch (IOException ex) {
            Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        Alert alert = new Alert(Alert.AlertType.WARNING);
        alert.setTitle("IMP");
        alert.setHeaderText("Username is unavailable for calling!");
        alert.setContentText("The user is not available for calling. "
                + "Please contact the user or the server administrator");
        alert.showAndWait();
    }
}

From source file:investiagenofx2.view.InvestiaGenOFXController.java

@FXML
void handleMnuAbout(ActionEvent event) {
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    ((Stage) alert.getDialogPane().getScene().getWindow()).getIcons()
            .add(new Image("/myIcons/Teddy-Bear-Sick-icon.png"));
    alert.setTitle("Information");
    alert.setX(InvestiaGenOFX.getPrimaryStage().getX() + 100);
    alert.setY(InvestiaGenOFX.getPrimaryStage().getY() + 100);
    alert.setHeaderText("InvestiaGenOFX");
    alert.setContentText("Version 2.0_6");
    alert.show();/*from w  w  w .  j a va  2  s . c om*/
}

From source file:com.github.drbookings.ui.controller.MainController.java

private void showAbout() {

    final Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle("About DrBookings");
    final TextArea label = new TextArea();

    label.setEditable(false);//  w  w w  .  j  a v  a2s  .c  o m
    label.setPrefHeight(400);
    label.setPrefWidth(400);
    label.getStyleClass().add("copyable-label");

    final StringBuilder sb = new StringBuilder();

    try {
        sb.append("Application version\t").append(Manifests.read("Implementation-Version")).append("\n");
        sb.append("Build time\t\t").append(Manifests.read("Build-Time")).append("\n");
    } catch (final Exception e) {
        if (logger.isInfoEnabled()) {
            logger.error("Failed to add manifest entry", e.getLocalizedMessage());
        }
    }

    label.setText(sb.toString());
    alert.setHeaderText("proudly brought to you by kerner1000");
    alert.setContentText(null);
    alert.getDialogPane().setContent(label);
    alert.showAndWait();
}

From source file:statos2_0.MainA.java

@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle(nameseller + "[" + storename + "]");
    primaryStage.show();//from  ww w . ja v a 2 s  .c om

    primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
        public void handle(WindowEvent we) {

            updsel(m, 1);
        }
    });
    GridPane grid = new GridPane();
    grid.setHgap(14);
    grid.setVgap(14);
    grid.setPadding(new Insets(5, 5, 5, 5));
    //System.out.println("****"+m);
    txg3.setVisible(false);
    // ,    1
    sp1.setValueFactory(spfd);
    spb1.setValueFactory(sfi);
    sp2.setValueFactory(sfi2);
    sp3.setValueFactory(sfi3);
    p1.setId("firstlab");
    p2.setId("firstlab");
    p3.setId("firstlab");
    kasnbn.setId("secondlab");
    kasvnbn.setId("secondlab");
    sumnbn.setId("secondlab");
    vyr.setId("vyr");
    sumvnbn.setId("secondlab");
    JSONParser jP5 = new JSONParser();
    JSONObject jsons5 = new JSONObject();
    List<NameValuePair> para5 = new ArrayList<NameValuePair>();

    para5.add(new BasicNameValuePair("idm", String.valueOf(m)));
    jsons5 = jP5.makeHttpRequest(url_cashgetm, "POST", para5);
    int success = jsons5.getInt("success");
    if (!jsons5.isNull("success")) {
        //res=true;
        // System.out.println("TRUE");

        double all = jsons5.getDouble("all");
        double dayall = Double.parseDouble(jsons5.get("dayall").toString());
        double daybn = Double.parseDouble(jsons5.get("daybn").toString());
        days = dayall + daybn;
        if (days <= 7999 & days > 0) {
            smvyr += (days / 100) * 3;
        } else if (days > 7999) {
            smvyr += (days / 100) * 4;
        }
        vyr.setText(":" + smvyr);
        sumnbn.setText(all + " .");
        sumvnbn.setText(dayall + " / " + daybn);
    }

    litg.setText(":");
    {//    
        sp1.setVisible(false);
        spb1.setVisible(false);
        lb1.setVisible(false);
        t1.setVisible(false);
        bt1.setVisible(false);
        lbb1.setVisible(false);
        cbx4.setVisible(false);
    }
    {//  , 
        sp2.setVisible(false);
        lb2.setVisible(false);
        t2.setVisible(false);
        bt2.setVisible(false);
    }
    {//   

        sp3.setVisible(false);
        lb3.setVisible(false);
        t3.setVisible(false);
        bt3.setVisible(false);

    }

    res.editableProperty().setValue(Boolean.FALSE);
    t1.editableProperty().setValue(Boolean.FALSE);
    t2.editableProperty().setValue(Boolean.FALSE);
    t3.editableProperty().setValue(Boolean.FALSE);
    titg.editableProperty().setValue(Boolean.FALSE);
    //cbx1.setItems(GetByTag(TAG_NAME, "1"));
    //cbx2.setItems(GetByTag(TAG_NAME, "2"));
    //cbx3.setItems(GetByTag(TAG_NAME, "3"));
    //cbx4.setItems(GetByTag(TAG_NAME, "4"));

    //cbx1.valueProperty().addListener(new );
    cbx1.setId("comboprod");
    cbx2.setId("comboprod");
    cbx3.setId("comboprod");

    txg3.setPrefSize(70, 80);

    sp1.setPrefSize(75, 80);
    sp2.setPrefSize(75, 80);
    sp3.setPrefSize(75, 80);
    spb1.setPrefSize(75, 80);
    lb1.setId("labl");
    lb2.setId("labl");
    lb3.setId("labl");
    lbb1.setId("labl");
    t1.setId("textost");
    t2.setId("textost");
    t3.setId("textost");
    bt1.setId("btitg");
    bt2.setId("btitg");
    bt3.setId("btitg");
    cbx4.setId("combbot");
    //lb1.setPrefSize(25, 40);
    //lb2.setPrefSize(25, 40);
    //lb3.setPrefSize(25, 40);

    //t1.setPrefSize(150, 40);
    //t2.setPrefSize(150, 40);
    //t3.setPrefSize(150, 40);

    //cbx4.setPrefSize(160,40);
    //bt2.setPrefSize(40, 40);
    //bt3.setPrefSize(40, 40);

    //spb1.setPrefSize(80, 40);

    //lbb1.setPrefSize(40,40);

    //bt1.setPrefSize(40, 40);

    titg.setPrefSize(120, 80);
    litg.setId("itgl");
    res.setPrefSize(300, 300);

    lb1.setText("");
    lb2.setText("");
    lb3.setText("");
    bt1.setText("+");
    bt2.setText("+");
    bt3.setText("+");
    lbb1.setText("");
    bres.setText("");
    bitg.setText("");
    bdlg.setText("");
    bbn.setText("/");
    //sp1.setValueFactory();
    grid.add(p1, 0, 0);
    grid.add(p2, 0, 1);
    grid.add(p3, 0, 2);

    grid.add(cbx1, 1, 0);
    grid.add(cbx2, 1, 1);
    grid.add(cbx3, 1, 2);

    grid.add(sp1, 2, 0);
    grid.add(sp2, 2, 1);
    grid.add(sp3, 2, 2);
    grid.add(txg3, 2, 2);
    grid.add(lb1, 3, 0);
    grid.add(lb2, 3, 1);
    grid.add(lb3, 3, 2);

    grid.add(t1, 4, 0);
    grid.add(t2, 4, 1);
    grid.add(t3, 4, 2);

    grid.add(cbx4, 5, 0);
    grid.add(bt2, 5, 1);
    grid.add(bt3, 5, 2);

    grid.add(spb1, 6, 0);
    grid.add(lbb1, 7, 0);
    grid.add(bt1, 8, 0);
    //grid.add(res, 1, 4, 3, 3);
    grid.add(res, 0, 3, 2, 3);
    litg.setAlignment(Pos.BASELINE_RIGHT);
    grid.add(litg, 2, 3);

    grid.add(titg, 3, 3, 2, 1);
    grid.add(bitg, 2, 4);
    grid.add(btcl, 4, 4);

    grid.add(kasnbn, 10, 0);
    grid.add(sumnbn, 10, 1);
    grid.add(kasvnbn, 10, 2);
    grid.add(sumvnbn, 10, 3);
    grid.add(vyr, 10, 4);
    grid.add(close, 10, 8);

    close.setOnAction(event -> {

        /**
             Dialog<Void> dialog = new Dialog<>();
        dialog.initModality(Modality.WINDOW_MODAL);
        dialog.initOwner(primaryStage);//stage here is the stage of your webview
        //dialog.initStyle(StageStyle.TRANSPARENT);
        Label loader = new Label("LOADING");
        //loader.setContentDisplay(ContentDisplay.DOWN);
        loader.setGraphic(new ProgressIndicator());
        dialog.getDialogPane().setGraphic(loader);
        DropShadow ds = new DropShadow();
        ds.setOffsetX(1.3); ds.setOffsetY(1.3); ds.setColor(Color.DARKGRAY);
        dialog.getDialogPane().setEffect(ds);
        //ButtonType btn = new ButtonType("OK",ButtonData.CANCEL_CLOSE);
                
        //dialog.getDialogPane().getButtonTypes().add(btn);
        dialog.show();  
            runJsons();
                    
            dialog.hide();
            dialog.close();
                 
           **/

        Alert alert = new Alert(AlertType.CONFIRMATION);
        alert.setTitle("");

        alert.setHeaderText(" ");
        alert.setContentText("    ?");
        ButtonType buttonTypeOne = new ButtonType("");

        ButtonType buttonTypeCancel = new ButtonType("", ButtonData.CANCEL_CLOSE);

        alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeCancel);
        Optional<ButtonType> result2 = alert.showAndWait();
        if (result2.get() == buttonTypeOne) {
            updsel(m, 1);
            cashday(m);
            System.exit(0);
        }

    });
    btcl.setOnAction(event -> {
        jsares.clear();
        res.setText("");
        titg.setText("");
        itog = 0;
        chcount = 1;
        cbx1.getSelectionModel().clearSelection();
        cbx2.getSelectionModel().clearSelection();
        cbx3.getSelectionModel().clearSelection();
        cbx4.getSelectionModel().clearSelection();
        cbx4.setVisible(false);
        sp1.getValueFactory().setValue(0.0);
        sp2.getValueFactory().setValue(0);
        sp3.getValueFactory().setValue(0);
        spb1.getValueFactory().setValue(0);
        sp1.setVisible(false);
        sp2.setVisible(false);
        sp3.setVisible(false);
        spb1.setVisible(false);
        lb1.setVisible(false);
        lb2.setVisible(false);
        lb3.setVisible(false);
        lbb1.setVisible(false);
        t1.setVisible(false);
        t2.setVisible(false);
        t3.setVisible(false);
        bt1.setVisible(false);
        bt2.setVisible(false);
        bt3.setVisible(false);

    });
    bitg.setOnAction(event -> {
        Alert alert = new Alert(AlertType.CONFIRMATION);
        alert.setTitle("");
        alert.setHeaderText(" ");
        alert.setContentText("  ?");
        ButtonType buttonOK = new ButtonType("");
        ButtonType buttonCancel = new ButtonType("", ButtonData.CANCEL_CLOSE);
        alert.getButtonTypes().setAll(buttonOK, buttonCancel);
        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() == buttonOK)

        {

            alert = new Alert(AlertType.CONFIRMATION);
            alert.setTitle("");

            alert.setHeaderText("  ");
            alert.setContentText("  ");
            ButtonType buttonTypeOne = new ButtonType("");
            ButtonType buttonTypeTwo = new ButtonType("");
            //ButtonType buttonTypeThree = new ButtonType("Three");
            ButtonType buttonTypeCancel = new ButtonType("", ButtonData.CANCEL_CLOSE);

            alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeTwo, /*buttonTypeThree,*/ buttonTypeCancel);
            Optional<ButtonType> result2 = alert.showAndWait();
            if (result2.get() == buttonTypeOne) {
                // ... user chose "One"
                typepay = "";
                finishnal(titg.getText(), res.getText(), 1);

            } else if (result2.get() == buttonTypeTwo) {
                // ... user chose "Two"
                typepay = "";
                finishnal(titg.getText(), res.getText(), 2);
            } /*
                      
              else if (result2.get() == buttonTypeThree) {
                // ... user chose "Three"
              }*/ else {
                // ... user chose CANCEL or closed the dialog
            }

        } else {
            // ... user chose CANCEL or closed the dialog
        }
    });
    txg3.setOnMouseClicked(event -> {
        Dialog dialog = new Dialog();
        GridPane gr = new GridPane();
        gr.setHgap(3);
        gr.setVgap(5);
        gr.setPadding(new Insets(10, 10, 10, 10));
        Button b1 = new Button("1");
        b1.setPrefSize(50, 50);
        Button b2 = new Button("2");
        b2.setPrefSize(50, 50);
        Button b3 = new Button("3");
        b3.setPrefSize(50, 50);
        Button b4 = new Button("4");
        b4.setPrefSize(50, 50);
        Button b5 = new Button("5");
        b5.setPrefSize(50, 50);
        Button b6 = new Button("6");
        b6.setPrefSize(50, 50);
        Button b7 = new Button("7");
        b7.setPrefSize(50, 50);
        Button b8 = new Button("8");
        b8.setPrefSize(50, 50);
        Button b9 = new Button("9");
        b9.setPrefSize(50, 50);
        Button b0 = new Button("0");
        b0.setPrefSize(50, 50);
        Button bd = new Button(".");
        bd.setPrefSize(50, 50);
        Button bc = new Button("C");
        bc.setPrefSize(50, 50);
        Button bok = new Button("");
        bc.setPrefSize(50, 50);
        Button bno = new Button("");
        bc.setPrefSize(50, 50);
        gr.add(b1, 0, 0);
        gr.add(b2, 1, 0);
        gr.add(b3, 2, 0);
        gr.add(b4, 0, 1);
        gr.add(b5, 1, 1);
        gr.add(b6, 2, 1);
        gr.add(b7, 0, 2);
        gr.add(b8, 1, 2);
        gr.add(b9, 2, 2);
        gr.add(bd, 0, 3);
        gr.add(b0, 1, 3);
        gr.add(bc, 2, 3);
        //gr.add(bok, 0, 4);
        //gr.add(bno, 3, 4);

        b1.setOnAction(even -> {
            txg3.setText(txg3.getText() + "1");
        });
        b2.setOnAction(even -> {
            txg3.setText(txg3.getText() + "2");
        });
        b3.setOnAction(even -> {
            txg3.setText(txg3.getText() + "3");
        });
        b4.setOnAction(even -> {
            txg3.setText(txg3.getText() + "4");
        });
        b5.setOnAction(even -> {
            txg3.setText(txg3.getText() + "5");
        });
        b6.setOnAction(even -> {
            txg3.setText(txg3.getText() + "6");
        });
        b7.setOnAction(even -> {
            txg3.setText(txg3.getText() + "7");
        });
        b8.setOnAction(even -> {
            txg3.setText(txg3.getText() + "8");
        });
        b9.setOnAction(even -> {
            txg3.setText(txg3.getText() + "9");
        });
        bc.setOnAction(even -> {
            txg3.setText("");

        });
        bd.setOnAction(even -> {
            txg3.setText(txg3.getText() + ".");
        });
        b0.setOnAction(even -> {
            txg3.setText(txg3.getText() + "0");
        });

        ButtonType okk = new ButtonType("OK", ButtonData.OK_DONE);
        ButtonType no = new ButtonType("", ButtonData.CANCEL_CLOSE);
        //gr.add(okk, 0, 4);

        dialog.getDialogPane().setContent(gr);
        dialog.getDialogPane().getButtonTypes().addAll(no, okk);
        dialog.setX(350);
        dialog.setY(260);
        Optional res = dialog.showAndWait();
        runJsons();
        // dialog.setResult(ButtonData.CANCEL_CLOSE);

        //dialog.showAndWait();
    });
    txg3.lengthProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            if (newValue.intValue() > oldValue.intValue()) {
                char ch = txg3.getText().charAt(oldValue.intValue());

                // Check if the new character is the number or other's
                if ((!(ch >= '0' && ch <= '9'))) {

                    // if it's not number then just setText to previous one
                    if (ch == '.') {
                    } else {
                        txg3.setText(txg3.getText().substring(0, txg3.getText().length() - 1));
                    }
                }
                double res;

                if (cbx3.getSelectionModel().getSelectedIndex() >= 0) {
                    res = Double.parseDouble(txg3.getText());
                    res = res / 1000;
                    //System.out.println("RES-"+res+"balanc"+balancech(cbx3.getSelectionModel().getSelectedItem().toString())+"BASE"+Double.parseDouble(getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(),MT)));
                    if ((res + balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3)) > Double
                            .parseDouble(
                                    getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT))) {
                        txg3.setText("");
                        Alert alert = new Alert(Alert.AlertType.ERROR);
                        alert.setTitle("!");
                        alert.setHeaderText("!");
                        alert.setContentText("   \n   !");
                        alert.showAndWait();
                    }
                }

            }
        }

    });
    cbx1.setOnMouseClicked(new EventHandler() {

        @Override
        public void handle(Event event) {
            spb1.getValueFactory().setValue(0);
            sp1.getValueFactory().setValue(0.0);
            runJsons();
            cbx1.setItems(GetByTag(TAG_NAME, "1"));
            //cbx1.getSelectionModel().clearSelection(); 
            int[] remove = new int[cbx1.getItems().size()];
            for (int i = 0; i < cbx1.getItems().size(); i++) {
                //System.out.println("****"+m);
                if (!isHave(cbx1.getItems().get(i).toString(), 1)) {
                    //

                } else {

                }
            }

            cbx1.show();

        }

    });

    sp1.setOnMouseClicked(event -> {
        if (cbx1.getSelectionModel().getSelectedItem() != null) {
            double spres = Double.parseDouble(sp1.getEditor().getText().toString().replace(",", "."));
            double salesres = balancech(cbx1.getSelectionModel().getSelectedItem().toString(), 1);
            double balancestore = Double
                    .parseDouble(getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, MT));
            // System.out.println(balancestore+" "+spres+" "+salesres);
            if ((balancestore - (spres + salesres)) >= 0) {

            } else {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   \n   !");
                alert.showAndWait();
                sp1.getValueFactory().setValue(0.0);

            }
        }
    });
    sp2.setOnMouseClicked(event -> {
        if (cbx2.getSelectionModel().getSelectedIndex() >= 0) {
            double spres = Double.parseDouble(sp2.getEditor().getText().toString());
            double salesres = balancech(cbx2.getSelectionModel().getSelectedItem().toString(), 2);
            double balancestore = Double
                    .parseDouble(getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, MT));
            if ((balancestore - (spres + salesres)) >= 0) {

            } else {

                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   \n   !");
                alert.showAndWait();
                sp2.getValueFactory().setValue(0);

            }
        }
    });
    spb1.setOnMouseClicked(event -> {
        if (cbx4.getSelectionModel().getSelectedIndex() >= 0) {
            double spres = Double.parseDouble(spb1.getEditor().getText().toString());
            double salesres = balancech(cbx4.getSelectionModel().getSelectedItem().toString(), 4);
            double balancestore = Double
                    .parseDouble(getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, MT));
            if ((balancestore - (spres + salesres)) >= 0) {

            } else {

                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   \n   !");
                alert.showAndWait();
                spb1.getValueFactory().setValue(0);
            }
        }
    });
    sp3.setOnMouseClicked(event -> {
        if (cbx3.getSelectionModel().getSelectedIndex() >= 0) {
            double spres = Double.parseDouble(sp3.getEditor().getText().toString());
            double salesres = balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3);
            double balancestore = Double
                    .parseDouble(getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT));
            if ((balancestore - (spres + salesres)) >= 0) {

            } else {

                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   \n   !");
                alert.showAndWait();
                sp3.getValueFactory().setValue(0);
            }
        }
    });
    cbx4.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {

        @Override
        public void changed(ObservableValue observable, Object oldValue, Object newValue) {
            if (observable.getValue() == null) {

            } else {
                if (!isHave(cbx4.getSelectionModel().getSelectedItem().toString(), 4)) {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("!");
                    alert.setHeaderText("!");
                    alert.setContentText(
                            cbx4.getSelectionModel().getSelectedItem().toString() + "   !");
                    Optional<ButtonType> result = alert.showAndWait();
                    if (result.get() == ButtonType.OK) {
                        cbx4.getSelectionModel().clearSelection();
                    } else {
                        cbx4.getSelectionModel().clearSelection();
                    }
                } else {

                }
            }
        }
    });
    cbx1.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {

        @Override
        public void changed(ObservableValue observable, Object oldValue, Object newValue) {

            if (observable.getValue() == null) {

            } else {

                if (!isHave(cbx1.getSelectionModel().getSelectedItem().toString(), 1)) {
                    Alert alert = new Alert(Alert.AlertType.ERROR);

                    alert.setTitle("!");
                    alert.setHeaderText("!");
                    alert.setContentText(
                            cbx1.getSelectionModel().getSelectedItem().toString() + "   !");
                    Optional<ButtonType> result = alert.showAndWait();
                    if (result.get() == ButtonType.OK) {
                        sp1.setVisible(false);
                        sp1.getValueFactory().setValue(0.0);
                        lb1.setVisible(false);
                        t1.setVisible(false);
                        cbx4.setVisible(false);
                        spb1.setVisible(false);
                        spb1.getValueFactory().setValue(0);
                        lbb1.setVisible(false);
                        bt1.setVisible(false);
                        cbx1.getSelectionModel().clearSelection();
                    } else {
                        sp1.setVisible(false);
                        sp1.getValueFactory().setValue(0.0);
                        lb1.setVisible(false);
                        t1.setVisible(false);
                        cbx4.setVisible(false);
                        spb1.setVisible(false);
                        spb1.getValueFactory().setValue(0);
                        lbb1.setVisible(false);
                        bt1.setVisible(false);
                        cbx1.getSelectionModel().clearSelection();

                    }
                } else {

                    sp2.setVisible(false);
                    lb2.setVisible(false);
                    t2.setVisible(false);
                    bt2.setVisible(false);
                    sp2.getValueFactory().setValue(0);
                    cbx2.getSelectionModel().clearSelection();

                    txg3.setVisible(false);
                    sp3.setVisible(false);
                    lb3.setVisible(false);
                    t3.setVisible(false);
                    bt3.setVisible(false);
                    sp3.getValueFactory().setValue(0);
                    cbx3.getSelectionModel().clearSelection();
                    double curbal = Double.parseDouble(
                            getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, MT))
                            - balancech(cbx1.getSelectionModel().getSelectedItem().toString(), 1);
                    t1.setText(ost + " " + curbal + " .");
                    cbx4.setItems(GetByTag(TAG_NAME, "4"));
                    sp1.setVisible(true);
                    lb1.setVisible(true);
                    t1.setVisible(true);
                    cbx4.setVisible(true);
                    spb1.setVisible(true);
                    lbb1.setVisible(true);
                    bt1.setVisible(true);

                    if (cbx1.getSelectionModel().getSelectedItem().toString().matches("")) {
                        sp1.setVisible(false);
                        t1.setVisible(false);
                        lb1.setVisible(false);
                    }
                }
            }
        }
    });
    bt1.setOnAction(event -> {
        if (cbx1.getSelectionModel().getSelectedItem().toString().matches("")) {

            if (spb1.getValueFactory().getValue() < 1) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("    !");
                alert.showAndWait();
            } else {

                double bottlprice = Double.parseDouble(
                        getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "price"));
                int bottlc = spb1.getValueFactory().getValue();
                double bottleitg = bottlc * bottlprice;

                res.setText(res.getText() + printCh2(cbx4.getSelectionModel().getSelectedItem().toString(),
                        "", bottlc, bottlprice) + "\n");

                itog = itog + bottleitg;
                titg.setText(String.valueOf(itog));
                jsores = new JSONObject();
                jsores.put(TIP, getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "id"));
                jsores.put(TCOUNT, bottlc);
                jsores.put(TRES, bottleitg);
                jsores.put(TM, m);
                jsores.put(TSELLER, selid);//   ID 
                SimpleDateFormat fff = new SimpleDateFormat("dd.MM.yyyy HH.mm");
                jsores.put(TDATE, fff.format(System.currentTimeMillis()));
                jsores.put(TAG_CHECK, checkcheck());
                jsares.add(jsores);
                sp1.setVisible(!true);
                lb1.setVisible(!true);
                t1.setVisible(!true);
                cbx4.setVisible(!true);
                spb1.setVisible(!true);
                lbb1.setVisible(!true);
                bt1.setVisible(!true);
                spb1.getValueFactory().setValue(0);
                sp1.getValueFactory().setValue(0.0);
                cbx1.getSelectionModel().clearSelection();
                cbx4.getSelectionModel().clearSelection();

            }
        } else {
            if (sp1.getValueFactory().getValue() < 0.5) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("    !");
                alert.showAndWait();
            } else if (cbx4.getSelectionModel().getSelectedItem() == null) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("    !");
                alert.showAndWait();

            } else if (spb1.getValueFactory().getValue() < 1) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("    !");
                alert.showAndWait();
            } /*else if(cbx4.getSelectionModel().getSelectedItem().toString().matches("")){
               Alert alert = new Alert(Alert.AlertType.ERROR);
              alert.setTitle("!");
              alert.setHeaderText("!");
              alert.setContentText("    !");
              alert.showAndWait();  
              }*/else {
                double liters = sp1.getValueFactory().getValue();
                double bottlc = spb1.getValueFactory().getValue();
                String sb = cbx4.getSelectionModel().getSelectedItem().toString();
                double bottlsz = 0;
                if (sb.contains("0.5") | sb.contains("0,5")) {
                    bottlsz = 0.5;
                } else if (sb.contains("1.0") | sb.contains("1,0")) {
                    bottlsz = 1.0;
                } else if (sb.contains("1.5") | sb.contains("1,5")) {
                    bottlsz = 1.5;
                } else if (sb.contains("2,0") | sb.contains("2.0") | sb.contains("2")) {
                    bottlsz = 2.0;
                } else if (sb.contains("3,0") | sb.contains("3.0") | sb.contains("3")) {
                    bottlsz = 3.0;
                } else if (sb.contains("")) {
                    bottlsz = 0.5;
                }

                if ((bottlsz * bottlc) == liters) {
                    double price = Double.parseDouble(
                            getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, TAG_PRICE));
                    String prodn = cbx1.getSelectionModel().getSelectedItem().toString();
                    double itg = 0;
                    if (getTwotag(prodn, 1, "sales").matches("1")) {
                        if (liters % 3 == 0) {
                            price = ((liters * price) - ((liters / 3) * price)) / liters;
                            itg = liters * price;
                        } else {
                            itg = liters * price;
                        }
                    } else {
                        itg = liters * price;
                    }
                    double bottlprice = 0;
                    if (sp1.isVisible()
                            & !cbx4.getSelectionModel().getSelectedItem().toString().contains("")) {
                        bottlprice = Double.parseDouble(
                                getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "price"));
                    } else if (sp1.isVisible()
                            & cbx4.getSelectionModel().getSelectedItem().toString().contains("")) {
                        bottlprice = 0;
                    } else if (!sp1.isVisible()
                            & cbx4.getSelectionModel().getSelectedItem().toString().contains("")) {
                        bottlprice = 0;
                    }
                    res.setText(res.getText() + printCh2(cbx1.getSelectionModel().getSelectedItem().toString(),
                            "", liters, price) + "\n");
                    res.setText(res.getText() + printCh2(cbx4.getSelectionModel().getSelectedItem().toString(),
                            "", bottlc, bottlprice) + "\n");
                    itog += itg;

                    jsores = new JSONObject();
                    jsores.put(TIP, getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, "id"));
                    jsores.put(TCOUNT, String.valueOf(liters));
                    jsores.put(TRES, itg);
                    jsores.put(TM, m);
                    jsores.put(TSELLER, selid);//   ID 
                    //jsores.put("balance", (balance1.get(cbx1.getSelectionModel().getSelectedIndex()) - coun));          
                    SimpleDateFormat ff = new SimpleDateFormat("dd.MM.yyyy HH.mm");
                    jsores.put(TDATE, ff.format(System.currentTimeMillis()));
                    //jsores.put("seltype","1");        
                    //jsores.put("dolgid","1");
                    jsores.put(TAG_CHECK, checkcheck());
                    jsares.add(jsores);
                    double bottleitg = bottlprice * bottlc;

                    itog = itog + bottleitg;
                    titg.setText(String.valueOf(itog));
                    jsores = new JSONObject();
                    jsores.put(TIP, getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "id"));
                    jsores.put(TCOUNT, bottlc);
                    jsores.put(TRES, bottleitg);
                    jsores.put(TM, m);
                    jsores.put(TSELLER, selid);//   ID 
                    //jsores.put("balance", (balanceb.get(cbx4.getSelectionModel().getSelectedIndex()) - counb));          
                    SimpleDateFormat fff = new SimpleDateFormat("dd.MM.yyyy HH.mm");
                    jsores.put(TDATE, fff.format(System.currentTimeMillis()));
                    //jsores.put("seltype",1);    !
                    //jsores.put("dolgid",1);
                    jsores.put(TAG_CHECK, checkcheck());
                    jsares.add(jsores);
                    //System.out.println(jsares);
                    sp1.setVisible(!true);
                    lb1.setVisible(!true);
                    t1.setVisible(!true);
                    cbx4.setVisible(!true);
                    spb1.setVisible(!true);
                    lbb1.setVisible(!true);
                    bt1.setVisible(!true);
                    spb1.getValueFactory().setValue(0);
                    sp1.getValueFactory().setValue(0.0);
                    cbx1.getSelectionModel().clearSelection();
                    cbx4.getSelectionModel().clearSelection();

                } else {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("!");
                    alert.setHeaderText("!");
                    alert.setContentText("    !");
                    alert.showAndWait();

                }
            }
        }
    });

    cbx2.setOnMouseClicked(new EventHandler() {
        @Override
        public void handle(Event event) {
            runJsons();
            cbx2.setItems(GetByTag(TAG_NAME, "2"));
            cbx2.show();
        }
    });

    cbx2.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {

        @Override
        public void changed(ObservableValue observable, Object oldValue, Object newValue) {

            if (observable.getValue() == null) {

            } else {
                if (!isHave(cbx2.getSelectionModel().getSelectedItem().toString(), 2)) {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("!");
                    alert.setHeaderText("!");
                    alert.setContentText(
                            cbx2.getSelectionModel().getSelectedItem().toString() + "   !");
                    Optional<ButtonType> result = alert.showAndWait();
                    if (result.get() == ButtonType.OK) {
                        sp2.setVisible(false);
                        sp2.getValueFactory().setValue(0);
                        lb2.setVisible(false);
                        t2.setVisible(false);
                        bt2.setVisible(false);
                        cbx2.getSelectionModel().clearSelection();
                    } else {
                        sp2.setVisible(false);
                        sp2.getValueFactory().setValue(0);
                        lb2.setVisible(false);
                        t2.setVisible(false);
                        bt2.setVisible(false);
                        cbx2.getSelectionModel().clearSelection();
                    }
                } else {
                    txg3.setVisible(false);
                    sp3.setVisible(!true);
                    lb3.setVisible(!true);
                    t3.setVisible(!true);
                    bt3.setVisible(!true);
                    sp3.getValueFactory().setValue(0);
                    cbx3.getSelectionModel().clearSelection();

                    cbx4.setVisible(!true);
                    sp1.setVisible(!true);
                    lb1.setVisible(!true);
                    t1.setVisible(!true);
                    spb1.setVisible(!true);
                    lbb1.setVisible(!true);
                    bt1.setVisible(!true);
                    sp1.getValueFactory().setValue(0.0);
                    spb1.getValueFactory().setValue(0);
                    cbx1.getSelectionModel().clearSelection();

                    sp2.setVisible(true);
                    lb2.setVisible(true);
                    t2.setVisible(true);
                    bt2.setVisible(true);
                    sp2.getValueFactory().setValue(0);
                    //System.out.println("////////"+newValue+"/////");
                    double curbal = Double.parseDouble(
                            getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, MT))
                            - balancech(cbx2.getSelectionModel().getSelectedItem().toString(), 2);
                    t2.setText(ost + " " + curbal + " .");
                }
            }
        }
    });
    bt2.setOnAction(event -> {
        if (sp2.getValueFactory().getValue() < 1) {
            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("!");
            alert.setHeaderText("!");
            alert.setContentText("    !");
            alert.showAndWait();
        } else {
            int coun = Integer.parseInt(sp2.getEditor().getText());
            double price = Double.parseDouble(
                    getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, TAG_PRICE));
            double itg = coun * price;
            res.setText(res.getText()
                    + printCh2(cbx2.getSelectionModel().getSelectedItem().toString(), "", coun, price)
                    + "\n");
            itog = itog + itg;
            titg.setText(String.valueOf(itog));
            jsores = new JSONObject();
            jsores.put(TIP, getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, TAG_ID));
            jsores.put(TCOUNT, String.valueOf(coun));
            jsores.put(TRES, itg);
            jsores.put(TM, m);
            jsores.put(TSELLER, selid);//   ID 
            //jsores.put("balance", (balance2.get(cbx2.getSelectionModel().getSelectedIndex()) - coun));
            SimpleDateFormat ff = new SimpleDateFormat("dd.MM.yyyy HH.mm");
            jsores.put(TDATE, ff.format(System.currentTimeMillis()));
            //jsores.put("seltype","1");     !!!!!!
            //jsores.put("dolgid","1");
            jsores.put(TAG_CHECK, checkcheck());
            jsares.add(jsores);
            sp2.setVisible(!true);
            lb2.setVisible(!true);
            t2.setVisible(!true);
            bt2.setVisible(!true);
            sp2.getValueFactory().setValue(0);
            cbx2.getSelectionModel().clearSelection();
        }
    });
    cbx3.setOnMouseClicked(new EventHandler() {
        @Override
        public void handle(Event event) {

            sp3.getValueFactory().setValue(0);
            runJsons();
            cbx3.setItems(GetByTag(TAG_NAME, "3"));
            cbx3.show();
        }
    });

    cbx3.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {

        @Override
        public void changed(ObservableValue observable, Object oldValue, Object newValue) {
            if (observable.getValue() == null) {

            } else {

                if (!isHave(cbx3.getSelectionModel().getSelectedItem().toString(), 3)) {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("!");
                    alert.setHeaderText("!");
                    alert.setContentText(
                            cbx3.getSelectionModel().getSelectedItem().toString() + "   !");
                    Optional<ButtonType> result = alert.showAndWait();
                    if (result.get() == ButtonType.OK) {
                        sp3.setVisible(false);
                        sp3.getValueFactory().setValue(0);
                        lb3.setVisible(false);
                        t3.setVisible(false);
                        bt3.setVisible(false);
                        cbx3.getSelectionModel().clearSelection();
                    } else {
                        sp3.setVisible(false);
                        sp3.getValueFactory().setValue(0);
                        lb3.setVisible(false);
                        t3.setVisible(false);
                        bt3.setVisible(false);
                        cbx3.getSelectionModel().clearSelection();
                    }
                } else {
                    sp1.setVisible(!true);
                    lb1.setVisible(!true);
                    t1.setVisible(!true);
                    cbx4.setVisible(!true);
                    spb1.setVisible(!true);
                    lbb1.setVisible(!true);
                    bt1.setVisible(!true);
                    //spb1.getEditor().setText("0");
                    //sp1.getEditor().setText("0");
                    cbx1.getSelectionModel().clearSelection();

                    sp2.setVisible(!true);
                    lb2.setVisible(!true);
                    t2.setVisible(!true);
                    bt2.setVisible(!true);
                    sp2.getValueFactory().setValue(0);
                    cbx2.getSelectionModel().clearSelection();

                    sp3.setVisible(true);
                    lb3.setVisible(true);
                    t3.setVisible(true);
                    bt3.setVisible(true);
                    sp3.getValueFactory().setValue(0);
                    if (getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, TAG_ZT)
                            .equals("2")) {

                        double curbal = Double.parseDouble(
                                getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT))
                                - (balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3));
                        String pattern = "##0.00";
                        DecimalFormat decimalFormat = new DecimalFormat(pattern);
                        String format = decimalFormat.format(curbal);

                        t3.setText(ost + " " + format + " .");
                        lb3.setText("");

                        sp3.setVisible(false);
                        txg3.setVisible(true);
                        txg3.setText("");

                    } else {
                        double curbal = Double.parseDouble(
                                getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT))
                                - balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3);
                        t3.setText(ost + " " + curbal + " .");
                        lb3.setText("");
                        txg3.setVisible(false);
                        sp3.setVisible(true);
                    }
                }
            }
        }
    });

    bt3.setOnAction(event -> {
        int typez = Integer.parseInt(getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, "zt"));

        if (sp3.isVisible() & sp3.getValueFactory().getValue() < 1) {

            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("!");
            alert.setHeaderText("!");
            alert.setContentText("    !");
            alert.showAndWait();
        } else if (txg3.isVisible() & txg3.getText().equals("")) {

            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("!");
            alert.setHeaderText("!!");
            alert.setContentText("    !");
            alert.showAndWait();

        } else {

            double coun = 0;
            double price = Double.parseDouble(
                    getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, TAG_PRICE));
            double itg = 0;
            double itgcoun = 0;
            if (lb3.getText().equals("")) {
                //System.out.println(lb3.getText());
                coun = sp3.getValueFactory().getValue();
                itg = coun * price;
                itgcoun = coun;
                // System.out.println("SPINNER" + coun);
                res.setText(res.getText()
                        + printCh2(cbx3.getSelectionModel().getSelectedItem().toString(), "", coun, price)
                        + "\n");

            } else if (lb3.getText().equals("")) {
                // System.out.println(lb3.getText());
                coun = Double.parseDouble(txg3.getText());

                itg = ((price * coun) / 100);
                // System.out.println("!!!???!!!"+coun+"   "+price);
                res.setText(res.getText()
                        + printCh3(cbx3.getSelectionModel().getSelectedItem().toString(), "", coun, price)
                        + "\n");
                itgcoun = (double) coun / 1000;
                //System.out.println("TEXT" + coun+"  "+itgcoun);

            }
            String pattern = "##0.0";
            DecimalFormat decimalFormat = new DecimalFormat(pattern);
            String format = decimalFormat.format(itg);
            itog = itog + itg;
            titg.setText(String.valueOf(itog));
            jsores = new JSONObject();
            jsores.put(TIP, getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, TAG_ID));
            jsores.put(TCOUNT, Double.parseDouble(String.valueOf(itgcoun)));
            jsores.put(TRES, itg);
            jsores.put(TM, m);
            jsores.put(TSELLER, selid);//   ID 
            //jsores.put("balance", (balance3.get(cbx3.getSelectionModel().getSelectedIndex()) - coun));
            SimpleDateFormat ff = new SimpleDateFormat("dd.MM.yyyy HH.mm");
            jsores.put(TDATE, ff.format(System.currentTimeMillis()));
            //jsores.put("seltype","1");   !!!!!
            //jsores.put("dolgid","1");
            jsores.put(TAG_CHECK, checkcheck());
            //System.out.println(jsores);
            jsares.add(jsores);
            sp3.setVisible(!true);
            lb3.setVisible(!true);
            t3.setVisible(!true);
            bt3.setVisible(!true);
            sp3.getValueFactory().setValue(0);
            cbx3.getSelectionModel().clearSelection();
            txg3.setVisible(false);
            // }
        }
    });
    Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
    Scene scene = new Scene(grid, sSize.width, sSize.height);
    primaryStage.setScene(scene);
    scene.getStylesheets().add(MainA.class.getResource("main.css").toExternalForm());
    primaryStage.show();

}

From source file:editeurpanovisu.EquiCubeDialogController.java

/**
 *
 * @param strTypeTransf// w  ww .  j ava  2 s .  co m
 * @throws Exception Exceptions
 */
public void afficheFenetre(String strTypeTransf) throws Exception {
    lvListeFichier.getItems().clear();
    stTransformations = new Stage(StageStyle.UTILITY);
    apTransformations = new AnchorPane();
    stTransformations.initModality(Modality.APPLICATION_MODAL);
    stTransformations.setResizable(true);
    apTransformations.setStyle("-fx-background-color : #ff0000;");

    VBox vbFenetre = new VBox();
    HBox hbChoix = new HBox();
    Pane paneChoixFichier = new Pane();
    btnAjouteFichiers = new Button("Ajouter des Fichiers");
    paneChoixTypeFichier = new Pane();
    Label lblType = new Label("Type des Fichiers de sortie");
    rbJpeg = new RadioButton("JPEG (.jpg)");
    rbBmp = new RadioButton("BMP (.bmp)");
    rbTiff = new RadioButton("TIFF (.tif)");
    cbSharpen = new CheckBox("Masque de nettet");
    cbSharpen.setSelected(EditeurPanovisu.isbNetteteTransf());
    slSharpen = new Slider(0, 2, EditeurPanovisu.getNiveauNetteteTransf());
    lblSharpen = new Label();
    double lbl = (Math.round(EditeurPanovisu.getNiveauNetteteTransf() * 20.d) / 20.d);
    lblSharpen.setText(lbl + "");
    slSharpen.setDisable(!EditeurPanovisu.isbNetteteTransf());
    lblSharpen.setDisable(!EditeurPanovisu.isbNetteteTransf());
    Pane paneboutons = new Pane();
    btnAnnuler = new Button("Fermer la fentre");
    btnValider = new Button("Lancer le traitement");

    strTypeTransformation = strTypeTransf;
    Image imgTransf;
    if (strTypeTransf.equals(EquiCubeDialogController.EQUI2CUBE)) {
        stTransformations.setTitle("Transformation d'quirectangulaire en faces de cube");
        imgTransf = new Image(
                "file:" + EditeurPanovisu.getStrRepertAppli() + File.separator + "images/equi2cube.png");
    } else {
        stTransformations.setTitle("Transformation de faces de cube en quirectangulaire");
        imgTransf = new Image(
                "file:" + EditeurPanovisu.getStrRepertAppli() + File.separator + "images/cube2equi.png");
    }
    ImageView ivTypeTransfert = new ImageView(imgTransf);
    ivTypeTransfert.setLayoutX(35);
    ivTypeTransfert.setLayoutY(280);
    paneChoixTypeFichier.getChildren().add(ivTypeTransfert);
    apTransformations.setPrefHeight(EditeurPanovisu.getHauteurE2C());
    apTransformations.setPrefWidth(EditeurPanovisu.getLargeurE2C());

    paneChoixFichier.setPrefHeight(350);
    paneChoixFichier.setPrefWidth(410);
    paneChoixFichier.setStyle("-fx-background-color: #d0d0d0; -fx-border-color: #bbb;");
    paneChoixTypeFichier.setPrefHeight(350);
    paneChoixTypeFichier.setPrefWidth(180);
    paneChoixTypeFichier.setStyle("-fx-background-color: #d0d0d0; -fx-border-color: #bbb;");
    hbChoix.getChildren().addAll(paneChoixFichier, paneChoixTypeFichier);
    vbFenetre.setPrefHeight(400);
    vbFenetre.setPrefWidth(600);
    apTransformations.getChildren().add(vbFenetre);
    hbChoix.setPrefHeight(350);
    hbChoix.setPrefWidth(600);
    hbChoix.setStyle("-fx-background-color: #d0d0d0;");
    paneboutons.setPrefHeight(50);
    paneboutons.setPrefWidth(600);
    paneboutons.setStyle("-fx-background-color: #d0d0d0;");
    vbFenetre.setStyle("-fx-background-color: #d0d0d0;");
    btnAnnuler.setLayoutX(296);
    btnAnnuler.setLayoutY(10);
    btnValider.setLayoutX(433);
    btnValider.setLayoutY(10);
    lvListeFichier.setPrefHeight(290);
    lvListeFichier.setPrefWidth(380);
    lvListeFichier.setEditable(true);
    lvListeFichier.setLayoutX(14);
    lvListeFichier.setLayoutY(14);
    btnAjouteFichiers.setLayoutX(259);
    btnAjouteFichiers.setLayoutY(319);
    paneChoixFichier.getChildren().addAll(lvListeFichier, btnAjouteFichiers);
    if (strTypeTransf.equals(EquiCubeDialogController.EQUI2CUBE)) {
        lblDragDropE2C = new Label(rbLocalisation.getString("transformation.dragDropE2C"));
    } else {
        lblDragDropE2C = new Label(rbLocalisation.getString("transformation.dragDropC2E"));
    }
    lblDragDropE2C.setMinHeight(lvListeFichier.getPrefHeight());
    lblDragDropE2C.setMaxHeight(lvListeFichier.getPrefHeight());
    lblDragDropE2C.setMinWidth(lvListeFichier.getPrefWidth());
    lblDragDropE2C.setMaxWidth(lvListeFichier.getPrefWidth());
    lblDragDropE2C.setLayoutX(14);
    lblDragDropE2C.setLayoutY(14);
    lblDragDropE2C.setAlignment(Pos.CENTER);
    lblDragDropE2C.setTextFill(Color.web("#c9c7c7"));
    lblDragDropE2C.setTextAlignment(TextAlignment.CENTER);
    lblDragDropE2C.setWrapText(true);
    lblDragDropE2C.setStyle("-fx-font-size : 24px");
    lblDragDropE2C.setStyle("-fx-background-color : rgba(128,128,128,0.1)");
    paneChoixFichier.getChildren().add(lblDragDropE2C);

    lblType.setLayoutX(14);
    lblType.setLayoutY(14);
    rbBmp.setLayoutX(43);
    rbBmp.setLayoutY(43);
    rbBmp.setUserData("bmp");
    if (EditeurPanovisu.getStrTypeFichierTransf().equals("bmp")) {
        rbBmp.setSelected(true);
    }
    rbBmp.setToggleGroup(tgTypeFichier);
    rbJpeg.setLayoutX(43);
    rbJpeg.setLayoutY(71);
    rbJpeg.setUserData("jpg");
    if (EditeurPanovisu.getStrTypeFichierTransf().equals("jpg")) {
        rbJpeg.setSelected(true);
    }
    rbJpeg.setToggleGroup(tgTypeFichier);
    if (EditeurPanovisu.getStrTypeFichierTransf().equals("tif")) {
        rbTiff.setSelected(true);
    }
    rbTiff.setLayoutX(43);
    rbTiff.setLayoutY(99);
    rbTiff.setToggleGroup(tgTypeFichier);
    rbTiff.setUserData("tif");
    tgTypeFichier.selectedToggleProperty().addListener((ov, old_toggle, new_toggle) -> {
        EditeurPanovisu.setStrTypeFichierTransf(tgTypeFichier.getSelectedToggle().getUserData().toString());
    });
    cbSharpen.setLayoutX(43);
    cbSharpen.setLayoutY(127);
    cbSharpen.selectedProperty().addListener((ov, old_val, new_val) -> {
        slSharpen.setDisable(!new_val);
        lblSharpen.setDisable(!new_val);
        EditeurPanovisu.setbNetteteTransf(new_val);
    });

    slSharpen.setShowTickMarks(true);
    slSharpen.setShowTickLabels(true);
    slSharpen.setMajorTickUnit(0.5f);
    slSharpen.setMinorTickCount(4);
    slSharpen.setBlockIncrement(0.05f);
    slSharpen.setSnapToTicks(true);
    slSharpen.setLayoutX(23);
    slSharpen.setLayoutY(157);
    slSharpen.setTooltip(new Tooltip("Choisissez le niveau d'accentuation de l'image"));
    slSharpen.valueProperty().addListener((observableValue, oldValue, newValue) -> {
        if (newValue == null) {
            lblSharpen.setText("");
            return;
        }
        DecimalFormat dfArrondi = new DecimalFormat();
        dfArrondi.setMaximumFractionDigits(2); //arrondi  2 chiffres apres la virgules
        dfArrondi.setMinimumFractionDigits(2);
        dfArrondi.setDecimalSeparatorAlwaysShown(true);

        lblSharpen.setText(dfArrondi.format(Math.round(newValue.floatValue() * 20.f) / 20.f) + "");
        EditeurPanovisu.setNiveauNetteteTransf(newValue.doubleValue());
    });

    slSharpen.setPrefWidth(120);
    lblSharpen.setLayoutX(150);
    lblSharpen.setLayoutY(150);
    lblSharpen.setMinWidth(30);
    lblSharpen.setMaxWidth(30);
    lblSharpen.setTextAlignment(TextAlignment.RIGHT);

    paneChoixTypeFichier.getChildren().addAll(lblType, rbBmp, rbJpeg, rbTiff, cbSharpen, slSharpen, lblSharpen);
    pbBarreImage.setLayoutX(40);
    pbBarreImage.setLayoutY(190);
    pbBarreImage.setStyle("-fx-accent : #0000bb");
    pbBarreImage.setVisible(false);
    paneChoixTypeFichier.getChildren().add(pbBarreImage);
    pbBarreAvancement = new ProgressBar();
    pbBarreAvancement.setLayoutX(40);
    pbBarreAvancement.setLayoutY(220);
    pbBarreImage.setStyle("-fx-accent : #00bb00");
    paneChoixTypeFichier.getChildren().add(pbBarreAvancement);
    pbBarreAvancement.setVisible(false);

    paneboutons.getChildren().addAll(btnAnnuler, btnValider);
    vbFenetre.getChildren().addAll(hbChoix, paneboutons);
    Scene scnTransformations = new Scene(apTransformations);
    stTransformations.setScene(scnTransformations);
    stTransformations.show();

    btnAnnuler.setOnAction((e) -> {
        annulerE2C();
    });
    btnValider.setOnAction((e) -> {
        if (!bTraitementEffectue) {
            validerE2C();
        }
    });
    btnAjouteFichiers.setOnAction((e) -> {
        lblTermine.setText("");
        fileLstFichier = choixFichiers();
        if (fileLstFichier != null) {
            if (bTraitementEffectue) {
                lvListeFichier.getItems().clear();
                bTraitementEffectue = false;
            }
            for (File fileLstFichier1 : fileLstFichier) {
                String strNomFich = fileLstFichier1.getAbsolutePath();
                lvListeFichier.getItems().add(strNomFich);
            }
        }
    });
    lvListeFichier.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
        @Override
        public ListCell<String> call(ListView<String> list) {
            return new ListeTransformationCouleur();
        }
    });
    apTransformations.setOnDragOver((event) -> {
        Dragboard dbFichiersTransformation = event.getDragboard();
        if (dbFichiersTransformation.hasFiles()) {
            event.acceptTransferModes(TransferMode.ANY);
        } else {
            event.consume();
        }
    });
    stTransformations.widthProperty().addListener((arg0, arg1, arg2) -> {
        EditeurPanovisu.setLargeurE2C(stTransformations.getWidth());
        apTransformations.setPrefWidth(stTransformations.getWidth());
        vbFenetre.setPrefWidth(stTransformations.getWidth());
        btnAnnuler.setLayoutX(stTransformations.getWidth() - 314);
        btnValider.setLayoutX(stTransformations.getWidth() - 157);
        paneChoixFichier.setPrefWidth(stTransformations.getWidth() - 200);
        lvListeFichier.setPrefWidth(stTransformations.getWidth() - 240);
        lblDragDropE2C.setMinWidth(lvListeFichier.getPrefWidth());
        lblDragDropE2C.setMaxWidth(lvListeFichier.getPrefWidth());

        btnAjouteFichiers.setLayoutX(stTransformations.getWidth() - 341);
    });

    stTransformations.heightProperty().addListener((arg0, arg1, arg2) -> {
        EditeurPanovisu.setHauteurE2C(stTransformations.getHeight());
        apTransformations.setPrefHeight(stTransformations.getHeight());
        vbFenetre.setPrefHeight(stTransformations.getHeight());
        paneChoixFichier.setPrefHeight(stTransformations.getHeight() - 80);
        hbChoix.setPrefHeight(stTransformations.getHeight() - 80);
        lvListeFichier.setPrefHeight(stTransformations.getHeight() - 140);
        lblDragDropE2C.setMinHeight(lvListeFichier.getPrefHeight());
        lblDragDropE2C.setMaxHeight(lvListeFichier.getPrefHeight());
        btnAjouteFichiers.setLayoutY(stTransformations.getHeight() - 121);
    });
    stTransformations.setWidth(EditeurPanovisu.getLargeurE2C());
    stTransformations.setHeight(EditeurPanovisu.getHauteurE2C());
    apTransformations.setOnDragDropped((event) -> {
        Dragboard dbFichiersTransformation = event.getDragboard();
        boolean bSucces = false;
        File[] fileLstFich;
        fileLstFich = null;
        if (dbFichiersTransformation.hasFiles()) {
            lblTermine.setText("");
            bSucces = true;
            String[] stringFichiersPath = new String[200];
            int i = 0;
            for (File file1 : dbFichiersTransformation.getFiles()) {
                stringFichiersPath[i] = file1.getAbsolutePath();
                i++;
            }
            int iNb = i;
            i = 0;
            boolean bAttention = false;
            File[] fileLstFich1 = new File[stringFichiersPath.length];
            for (int j = 0; j < iNb; j++) {

                String strNomfich = stringFichiersPath[j];
                File fileTransf = new File(strNomfich);
                String strExtension = strNomfich.substring(strNomfich.lastIndexOf(".") + 1, strNomfich.length())
                        .toLowerCase();
                if (strExtension.equals("bmp") || strExtension.equals("jpg") || strExtension.equals("tif")) {
                    if (i == 0) {
                        strRepertFichier = fileTransf.getParent();
                    }
                    Image img = null;
                    if (strExtension != "tif") {
                        img = new Image("file:" + fileTransf.getAbsolutePath());
                    } else {
                        try {
                            img = ReadWriteImage.readTiff(strNomfich);
                        } catch (ImageReadException ex) {
                            Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null,
                                    ex);
                        } catch (IOException ex) {
                            Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null,
                                    ex);
                        }
                    }
                    if (strTypeTransformation.equals(EquiCubeDialogController.EQUI2CUBE)) {
                        if (img.getWidth() == 2 * img.getHeight()) {
                            fileLstFich1[i] = fileTransf;
                            i++;
                        } else {
                            bAttention = true;
                        }
                    } else {
                        if (img.getWidth() == img.getHeight()) {
                            String strNom = fileTransf.getAbsolutePath().substring(0,
                                    fileTransf.getAbsolutePath().length() - 6);
                            boolean bTrouve = false;
                            for (int ik = 0; ik < i; ik++) {
                                String strNom1 = fileLstFich1[ik].getAbsolutePath().substring(0,
                                        fileTransf.getAbsolutePath().length() - 6);
                                if (strNom.equals(strNom1)) {
                                    bTrouve = true;
                                }
                            }
                            if (!bTrouve) {
                                fileLstFich1[i] = fileTransf;
                                i++;
                            }
                        } else {
                            bAttention = true;
                        }

                    }
                }
            }
            if (bAttention) {
                Alert alert = new Alert(AlertType.ERROR);
                alert.setTitle(rbLocalisation.getString("transformation.traiteImages"));
                alert.setHeaderText(null);
                alert.setContentText(rbLocalisation.getString("transformation.traiteImagesType"));
                alert.showAndWait();
            }
            fileLstFichier = new File[i];
            System.arraycopy(fileLstFich1, 0, fileLstFichier, 0, i);
        }
        if (fileLstFichier != null) {
            if (bTraitementEffectue) {
                lvListeFichier.getItems().clear();
                bTraitementEffectue = false;
            }
            for (File lstFichier1 : fileLstFichier) {
                String nomFich = lstFichier1.getAbsolutePath();
                lvListeFichier.getItems().add(nomFich);
            }
        }
        lblDragDropE2C.setVisible(false);
        event.setDropCompleted(bSucces);
        event.consume();
    });

}

From source file:ui.main.MainViewController.java

private void addConversationListener() {
    conversations.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
        @Override/*  w  w w.  j  av a 2 s  . c om*/
        public void changed(ObservableValue observable, Object oldValue, Object newValue) {
            if (newValue == null) {
                chatterName.setText("");
                return;
            }
            contacts.getSelectionModel().clearSelection();
            chatList.getChildren().clear();
            chatterName.setText(((HostedRoom) newValue).getName());
            chatterPresence.setText("Group Chat");
            chatterAvatar.setImage(new Image("resources/guest.png", 100, 100, true, true));

            Iterator<GroupChatManager> i = loggedMucs.iterator();
            while (i.hasNext()) {
                GroupChatManager gcm = i.next();
                if (gcm.getRoom().equals(((HostedRoom) newValue).getJid())) {
                    currentmuc = gcm.getMuc();
                    //getConversationHistory();
                    reloadConversationMessages(gcm.getMsgList());
                    return;
                }
            }

            try {
                currentmuc = chatManager.joinRoom(((HostedRoom) newValue).getJid());
                loggedMucs.add(new GroupChatManager(currentmuc, getConversationHistory()));
            } catch (NonAuthorizedException e) {

                TextInputDialog dialog = new TextInputDialog();
                dialog.setTitle("Closed Conference Login");
                dialog.setHeaderText("Password Required!");
                dialog.setContentText("Password :");

                Optional<String> result = dialog.showAndWait();
                if (result.isPresent()) {
                    try {
                        currentmuc = chatManager.joinPrivateRoom(((HostedRoom) newValue).getJid(),
                                result.get());
                        loggedMucs.add(new GroupChatManager(currentmuc, getConversationHistory()));
                    } catch (NonAuthorizedException ex) {
                        Alert alert = new Alert(Alert.AlertType.INFORMATION);
                        alert.setTitle("Invalid Password!");
                        alert.setHeaderText("Conversation cannot be displayed!");
                        alert.setContentText(
                                "The password for the conversation is incorrect. Please try again!");
                        alert.showAndWait();
                        return;
                    }
                }
            }

            ChatsManager.setSelectedConversation(newValue.toString());
            isSingleChat = false;

            hideExtraComButtons();
            addConversationMessageListener();

        }
    });
}

From source file:acmi.l2.clientmod.l2smr.Controller.java

private void onException(String text, Throwable ex) {
    ex.printStackTrace();//from   w  ww .  j  a v  a2s.c  om

    Platform.runLater(() -> {
        if (SHOW_STACKTRACE) {
            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("Error");
            alert.setHeaderText(null);
            alert.setContentText(text);

            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            String exceptionText = sw.toString();

            Label label = new Label("Exception stacktrace:");

            TextArea textArea = new TextArea(exceptionText);
            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 expContent = new GridPane();
            expContent.setMaxWidth(Double.MAX_VALUE);
            expContent.add(label, 0, 0);
            expContent.add(textArea, 0, 1);

            alert.getDialogPane().setExpandableContent(expContent);

            alert.showAndWait();
        } else {
            //noinspection ThrowableResultOfMethodCallIgnored
            Throwable t = getTop(ex);

            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle(t.getClass().getSimpleName());
            alert.setHeaderText(text);
            alert.setContentText(t.getMessage());

            alert.showAndWait();
        }
    });
}

From source file:UI.MainStageController.java

/**
 * creates the file not found alert box//  www  . jav  a  2 s  .c om
 */
private void fileNotFoundAlertBox() {
    fileNotFoundAlert = new Alert(Alert.AlertType.ERROR);
    fileNotFoundAlert.setTitle("File not found");
    fileNotFoundAlert.setHeaderText("File not found");
    fileNotFoundAlert.setContentText("Could not find the file you were looking for");

    //style the alert
    DialogPane dialogPane = fileNotFoundAlert.getDialogPane();
    dialogPane.getStylesheets().add("/UI/alertStyle.css");

    Exception fileNotFoundException = new FileNotFoundException("Could not find your selected file");

    //create expandable exception
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    fileNotFoundException.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was: ");

    TextArea textArea = new TextArea(exceptionText);
    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 expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    // Set expandable Exception into the dialog pane.
    fileNotFoundAlert.getDialogPane().setExpandableContent(expContent);
    fileNotFoundAlert.showAndWait();
}

From source file:UI.MainStageController.java

@FXML
/**//from w  ww. ja v  a 2  s. c  o  m
 *
 * Shows information about the software.
 */
private void showAboutAlert() {
    Hyperlink hyperlink = new Hyperlink();
    hyperlink.setText("https://github.com/jmueller95/CORNETTO");
    Text text = new Text("Cornetto is a modern tool to visualize and calculate correlations between"
            + "samples.\nIt was created in 2017 by students of the group of Professor Huson in Tbingen.\nThe group"
            + "was supervised by Caner Bagci.\n\n" + "This project is licensed under the MIT License.\n\n"
            + "For more information go to: ");

    TextFlow textFlow = new TextFlow(text, hyperlink);

    text.setWrappingWidth(500);
    aboutAlert = new Alert(Alert.AlertType.INFORMATION);
    aboutAlert.setTitle("About " + GlobalConstants.NAME_OF_PROGRAM);
    aboutAlert.setHeaderText("What is " + GlobalConstants.NAME_OF_PROGRAM);
    aboutAlert.getDialogPane().setContent(textFlow);
    aboutAlert.show();
}

From source file:UI.MainStageController.java

/**
 * Prompts an alert if the user tries to load a file that does not match the requirements.
 *//* w  w w . j a  v  a2  s. co m*/
//TODO: If multiple files are wrong, not every file should get its own alert.
private void showWrongFileAlert() {
    wrongFileAlert = new Alert(Alert.AlertType.ERROR);
    wrongFileAlert.setTitle("File not loaded");
    wrongFileAlert.setHeaderText("Invalid file.");
    wrongFileAlert.setContentText("You tried to load a file with a wrong file type.");
    wrongFileAlert.show();
}