Example usage for javafx.stage Modality APPLICATION_MODAL

List of usage examples for javafx.stage Modality APPLICATION_MODAL

Introduction

In this page you can find the example usage for javafx.stage Modality APPLICATION_MODAL.

Prototype

Modality APPLICATION_MODAL

To view the source code for javafx.stage Modality APPLICATION_MODAL.

Click Source Link

Document

Defines a modal window that blocks events from being delivered to any other application window.

Usage

From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java

public void handleSetupLayers(Event event) {
    try {/*from  w ww  . j  a v a 2s  .c o  m*/
        URL layersDialogFXML = getClass().getResource(LAYERS_DIALOG_FXML);
        FXMLLoader loader = new FXMLLoader(layersDialogFXML);
        Stage layersDialog = loader.load();
        MsSpectrumLayersDialogController controller = loader.getController();
        controller.configure(datasets, this);
        layersDialog.initModality(Modality.APPLICATION_MODAL);
        layersDialog.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:editeurpanovisu.EquiCubeDialogController.java

/**
 *
 * @param strTypeTransf//  w w w  .j a v  a  2s .  c  o  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:genrsa.GenRSAController.java

/**
 * Muestra por pantalla la informacin relativa a genRSA 
 * @param event /* ww  w  . jav  a  2s  .c om*/
 */
public void aboutGenRSA(ActionEvent event) {
    Stage stage;
    FXMLLoader fxmlLoader;
    Parent root;

    try {
        stage = new Stage();
        fxmlLoader = new FXMLLoader(getClass().getResource("/About/About.fxml"));
        root = fxmlLoader.load();

        Scene scene = new Scene(root);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.initOwner(this.unitsD.getScene().getWindow());
        stage.setResizable(false);
        stage.getIcons().add(new Image(GenRSAController.class.getResourceAsStream("/allImages/genRSA.png")));
        stage.setTitle("Acerca de genRSA v2.1");
        stage.setScene(scene);
        stage.show();

    } catch (IOException ex) {
        //no pongo mensaje de error, porque no se puede dar el caso
    }

}

From source file:patientmanagerv1.HomeController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    //start with the forum and the common questions page, add-on the profile page and private messaging features

    //passLoaded = false;

    //sets the current Patient
    try {/*from w w  w  .  java2  s . c  om*/
        String entireFileText = new Scanner(new File(installationPath + "/currentpatient.txt"))
                .useDelimiter("//A").next();
        String[] nameArray = entireFileText.split(",");

        firstName = nameArray[0].toLowerCase();
        lastName = nameArray[1].toLowerCase();
        dob = nameArray[2];
    } catch (Exception e) {
    }

    //checks the signed status
    try {
        FileReader reader = new FileReader(
                installationPath + "/userdata/" + firstName + lastName + dob + "/EvaluationForm/signed.txt");
        //+ "/userdata/" + get.currentPatientFirstName + get.currentPatientLastName + "/EvaluationForm/first.txt");
        BufferedReader br = new BufferedReader(reader);
        String signedStatus = br.readLine();
        br.close();
        reader.close();

        if (signedStatus.equalsIgnoreCase("true")) {
            dccSigned = true;
        } else {
            dccSigned = false;
        }

        FileReader reader2 = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob
                + "/EvaluationForm/assistantsigned.txt");
        //+ "/userdata/" + get.currentPatientFirstName + get.currentPatientLastName + "/EvaluationForm/first.txt");
        BufferedReader br2 = new BufferedReader(reader2);
        String assistantSigned = br2.readLine();
        br2.close();
        reader2.close();

        if (assistantSigned.equalsIgnoreCase("true")) {
            partnerSigned = true;
        } else {
            partnerSigned = false;
        }

        /*saveButton.setDisable(false);
        sign.setVisible(true);
        sign.setDisable(true);
        signature.setVisible(false);*/

        if (signedStatus.equalsIgnoreCase("false") && (assistantSigned.equalsIgnoreCase("false"))) {
            saveButton.setDisable(false);
            sign.setVisible(true);
            sign.setDisable(false);
            assistantsign.setVisible(true);
            assistantsign.setDisable(false);
            assistantsignature.setVisible(false);
            signature.setVisible(false);
            signature2.setVisible(false);
            ap.setDisable(false);
        } else if (signedStatus.equalsIgnoreCase("true") && (assistantSigned.equalsIgnoreCase("false"))) {
            saveButton.setDisable(true);
            sign.setVisible(false);
            assistantsign.setVisible(true);
            assistantsign.setDisable(false);
            assistantsignature.setVisible(false);
            signature.setVisible(true);
            signature2.setVisible(true);
            signature.setText("This document has been digitally signed by David Zhvikov MD");
            ap.setDisable(true);
        } else if (signedStatus.equalsIgnoreCase("false") && (assistantSigned.equalsIgnoreCase("true"))) {
            saveButton.setDisable(true);
            sign.setVisible(true);
            assistantsign.setVisible(false);
            assistantsign.setDisable(true);
            assistantsignature.setVisible(true);
            signature.setVisible(false);
            signature2.setVisible(false);
            signature.setText("This document has been digitally signed by David Zhvikov MD");
            ap.setDisable(true);
        } else {
            saveButton.setDisable(true);
            sign.setVisible(false);
            assistantsign.setVisible(false);
            assistantsign.setDisable(true);
            assistantsignature.setVisible(true);
            signature.setVisible(true);
            signature2.setVisible(true);
            signature.setText("This document has been digitally signed by David Zhvikov MD");
            ap.setDisable(true);
        }
    } catch (Exception e) {
    }

    //loads the ListView

    try {
        FileReader r2 = new FileReader(
                installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");
        BufferedReader b2 = new BufferedReader(r2);

        String s;
        ArrayList progressNotes = new ArrayList();

        while ((s = b2.readLine()) != null) {
            //System.out.println(s);
            progressNotes.add(s);
        }

        b2.close();
        r2.close();

        //Adds the Progress Notes to the ListView

        ObservableList<String> items = FXCollections.observableArrayList("Single", "Double");
        items.clear();

        for (int counter = 0; counter < progressNotes.size(); counter++) {
            items.add(progressNotes.get(counter).toString());
        }

        listOfProgressReports.setItems(items);

        //String[] ethnicityArray = ethnicity.split(",");
    } catch (Exception e) {
        //System.out.println("file not found");
    }

    //initializes the evaluation form [with the new patient's name] for the current patient
    fillName();

    fillDOB();

    fillAge(loaded);

    fillGender();

    fillMaritalStatus();

    fillEthnicity();

    fillReferredBy();

    fillReasonForReferral();

    fillSourceOfInformation();

    fillReliabilityOfInformation();

    fillHistoryOfPresentIllness();

    fillSignsSymptoms();

    fillCurrentMedications();

    fillPastPsychiatricHistory();

    fillPastHistoryOf();

    fillHistoryOfMedicationTrialsInThePast();

    fillSubstanceUseHistory();

    fillDeniesHistoryOf();

    fillSocialHistory();

    fillParentsSiblingsChildren();

    fillFamilyHistoryOfMentalIllness();

    fillEducation();

    fillEmployment();

    fillLegalHistory();

    fillPastMedicalHistory();

    fillAllergies();

    fillAppearance();

    fillEyeContact();

    fillAttitude();

    fillMotorActivity();

    fillAffect();

    fillMood();

    fillSpeech();

    fillThoughtProcess();

    fillThoughtContent();

    fillPerception();

    fillSuicidality();

    fillHomicidality();

    fillOrientation();

    fillShortTermMemory();

    fillLongTermMemory();

    fillGeneralFundOfKnowledge();

    fillIntellect();

    fillAbstraction();

    fillJudgementAndInsight();

    fillClinicalNotes();

    fillTreatmentPlan();

    fillSideEffects();

    fillLabs();

    fillEnd();

    fillSignatureZone();

    //        currentPatientFirstName = get.currentPatientFirstName;
    //        currentPatientLastName = get.currentPatientLastName;

    //sets the current patient
    /*try
    {
    String entireFileText = new Scanner(new File(installationPath + "/Patients.txt")).useDelimiter("//A").next();
    String[] arrayOfNames = entireFileText.split(";");
            
            
    System.out.println("Patient Name: " + arrayOfNames[arrayOfNames.length - 1]);
            
    String nameWithComma = arrayOfNames[arrayOfNames.length - 1];
    String[] nameArray = nameWithComma.split(",");
            
    firstName = nameArray[0].toLowerCase();
    lastName = nameArray[1].toLowerCase();
            
            
            
    }
    catch(Exception e)
    {}*/

    /*ArrayList progressNotes = new ArrayList();
            
    for(int i = 0; i < listOfProgressReports.getItems().size(); i++)
    {
        progressNotes.add(listOfProgressReports.getItems().get(i));
    }*/

    //broken and betrayed
    //of the ecsts's you've shown me.
    //...for me, italicsmaster, she put emphasis/lingered on the word. "M"

    menu.getMenus().removeAll();
    Menu file = new Menu("File");
    Menu edit = new Menu("Edit");
    Menu view = new Menu("View");
    Menu help = new Menu("About");
    Menu speech = new Menu("Speech Options");

    MenuItem save = new MenuItem("Save");
    MenuItem print = new MenuItem("Print");
    MenuItem printWithSettings = new MenuItem("Print With Settings");
    MenuItem export = new MenuItem("Export to");
    MenuItem logout = new MenuItem("Return to Patient Selection");
    MenuItem deleteThisPatient = new MenuItem("Delete This Patient");
    MenuItem exit = new MenuItem("Exit");

    MenuItem undo = new MenuItem("Undo (ctrl+z)");
    MenuItem redo = new MenuItem("Redo (ctrl+y)");
    MenuItem selectAll = new MenuItem("Select All (ctrl+A)");
    MenuItem cut = new MenuItem("Cut (ctrl+x)");
    MenuItem copy = new MenuItem("Copy (ctrl+c)");
    MenuItem paste = new MenuItem("Paste (ctrl+v)");
    MenuItem enableBackdoorModifications = new MenuItem("Enable Modification of this Evaluation Post-Signing");

    Menu submenu1 = new Menu("Create");
    Menu submenu2 = new Menu("Load");
    Menu submenu3 = new Menu("New");
    MenuItem createProgressReport = new MenuItem("Progress Report");
    MenuItem loadProgressReport = new MenuItem("Progress Report");
    MenuItem deleteProgressReport = new MenuItem("Delete selected progress report");
    submenu1.getItems().add(submenu3);
    submenu3.getItems().add(createProgressReport);
    submenu2.getItems().add(loadProgressReport);

    MenuItem howToUse = new MenuItem("How to use patient manager");
    MenuItem versionInfo = new MenuItem("About Patient Manager/Version Info");

    /*MenuItem read = new MenuItem("Read to me");
    MenuItem launch = new MenuItem("Launch Dictation");*/
    //read to me menu, dictation menu- select a document to read aloud, read this passage aloud, launch windows in-built dictation, download brainac dictation online
    Menu read = new Menu("Read to me");
    Menu launch = new Menu("Dictation");

    Menu readPassageOrFormStartStop = new Menu("Read this passage/read this form");

    MenuItem startReading1 = new MenuItem("Start");
    MenuItem stopReading1 = new MenuItem("Stop");
    MenuItem startReading2 = new MenuItem("Start");
    MenuItem stopReading2 = new MenuItem("Stop");
    Menu readUploadedDocument = new Menu("Select a document to read");
    MenuItem launchWindowsDictation = new MenuItem("Launch Windows' Built-In Dictation");
    MenuItem launchBrainacDictation = new MenuItem("Download Brainac Dictation");

    startReading1.setDisable(true);
    stopReading1.setDisable(true);
    startReading2.setDisable(true);
    stopReading2.setDisable(true);

    readPassageOrFormStartStop.getItems().add(startReading1);
    readPassageOrFormStartStop.getItems().add(stopReading1);
    readUploadedDocument.getItems().add(startReading2);
    readUploadedDocument.getItems().add(stopReading2);

    readPassageOrFormStartStop.setDisable(true);
    readUploadedDocument.setDisable(true);

    launchBrainacDictation.setDisable(true);

    read.getItems().add(readPassageOrFormStartStop);
    read.getItems().add(readUploadedDocument);
    launch.getItems().add(launchWindowsDictation);
    launch.getItems().add(launchBrainacDictation);

    file.getItems().add(save);
    file.getItems().add(print);
    file.getItems().add(printWithSettings);
    file.getItems().add(export);
    file.getItems().add(logout);
    file.getItems().add(deleteThisPatient);
    file.getItems().add(exit);

    edit.getItems().add(undo);
    edit.getItems().add(redo);
    edit.getItems().add(selectAll);
    edit.getItems().add(cut);
    edit.getItems().add(copy);
    edit.getItems().add(paste);
    edit.getItems().add(enableBackdoorModifications);

    view.getItems().add(submenu1);
    view.getItems().add(submenu2);
    view.getItems().add(deleteProgressReport);

    help.getItems().add(howToUse);
    help.getItems().add(versionInfo);

    speech.getItems().add(read);
    speech.getItems().add(launch);

    menu.prefWidthProperty().bind(masterPane.widthProperty());
    //menu.setStyle("-fx-padding: 0 20 0 20;");

    //menu.getMenus().addAll(file, edit, view, help, speech);
    menu.getMenus().add(file);
    menu.getMenus().add(edit);
    menu.getMenus().add(view);
    menu.getMenus().add(speech);
    menu.getMenus().add(help);

    undo.setDisable(true);
    redo.setDisable(true);
    cut.setDisable(true);
    copy.setDisable(true);
    paste.setDisable(true);
    selectAll.setDisable(true);

    deleteThisPatient.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {

            int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this patient?",
                    "Warning", JOptionPane.OK_CANCEL_OPTION);

            if (result == 2) {

            }

            if (result == 0) {
                int result2 = JOptionPane.showConfirmDialog(null,
                        "Are you ABSOLUTELY sure you want to delete this patient?", "Warning",
                        JOptionPane.OK_CANCEL_OPTION);

                if (result2 == 2) {

                }
                if (result2 == 0) {
                    String patientToDelete = firstName + "," + lastName + "," + dob; //listOfProgressReports.getSelectionModel().getSelectedItem().toString();

                    //            String currRepNoColons = currRep.replace(":", "");
                    //        currRepNoColons = currRepNoColons.trim();

                    //1) removes the report from the list in the file
                    try {
                        FileReader r2 = new FileReader(installationPath + "/patients.txt");
                        BufferedReader b2 = new BufferedReader(r2);

                        String s = b2.readLine();
                        String[] patients = s.split(";"); //String[] ssArray = ss.split(",");

                        /*for(int i = 0; i < patients.size(); i++)
                        {
                                
                        }*/

                        /*while((s = b2.readLine()) != null)
                        {
                            //System.out.println(s);
                                
                            if(!s.equalsIgnoreCase(patientToDelete))
                            {patients.add(s);}
                        }*/

                        b2.close();
                        r2.close();

                        File fff = new File(installationPath + "/patients.txt");
                        FileWriter ddd = new FileWriter(fff, false);
                        BufferedWriter bw = new BufferedWriter(ddd);
                        ddd.append("");
                        bw.close();
                        ddd.close();

                        for (int i = 0; i < patients.length; i++) {
                            File openProgressReportsList = new File(installationPath + "/patients.txt");
                            FileWriter fw = new FileWriter(openProgressReportsList, true);
                            BufferedWriter bufferedwriter = new BufferedWriter(fw);
                            if (!(patients[i].equalsIgnoreCase(patientToDelete))) {
                                fw.append(patients[i].toLowerCase() + ";");
                            }
                            bufferedwriter.close();
                            fw.close();
                        }
                    } catch (Exception ex) {

                    }

                    /*try{
                            FileReader reader = new FileReader(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");
                            BufferedReader br = new BufferedReader(reader); 
                            String fileContents = br.readLine();
                            br.close();
                            reader.close();
                            
                            fileContents = fileContents.replace(currRep, "");
                            //System.out.println("fc:" + fileContents);
                            
                            //writes the new contents to the file:
                            //writes the new report to the list
                            File openProgressReportsList = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");
                            FileWriter fw = new FileWriter(openProgressReportsList, false);           
                            BufferedWriter bufferedwriter = new BufferedWriter(fw);
                            fw.append(fileContents);
                            bufferedwriter.close();
                            fw.close();
                    }
                    catch(Exception e)
                    {
                            
                    }*/

                    //2) Deletes the folder for that progress report
                    try {
                        File directory = new File(installationPath + "/userdata/" + firstName + lastName + dob
                                + "/ProgressNotes");
                        File[] subdirs = directory.listFiles((FileFilter) DirectoryFileFilter.DIRECTORY);
                        for (File dir : subdirs) {
                            File deleteThis = new File(installationPath + "/userdata/" + firstName + lastName
                                    + dob + "/ProgressNotes/" + dir.getName());
                            //System.out.println("Directory: " + dir.getName());
                            File[] filez = deleteThis.listFiles();

                            for (int i = 0; i < filez.length; i++) {
                                filez[i].delete();
                            }
                            //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket
                            deleteThis.delete();
                        }
                        File path3 = new File(installationPath + "/userdata/" + firstName + lastName + dob
                                + "/ProgressNotes");
                        File[] files3 = path3.listFiles();

                        for (int i = 0; i < files3.length; i++) {
                            files3[i].delete();
                        }
                        //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket
                        path3.delete();

                        File path2 = new File(installationPath + "/userdata/" + firstName + lastName + dob
                                + "/EvaluationForm");
                        File[] files2 = path2.listFiles();

                        for (int i = 0; i < files2.length; i++) {
                            files2[i].delete();
                        }
                        //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket
                        path2.delete();

                        File path = new File(installationPath + "/userdata/" + firstName + lastName + dob);
                        File[] files = path.listFiles();

                        for (int i = 0; i < files.length; i++) {
                            files[i].delete();
                        }
                        //the wedding nightmare: red, red, dark purple-brown; big-ol red wrap/red jacket
                        path.delete();
                        //deleteDirectory(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons);
                        //Files.delete(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + currRepNoColons);

                        //PUT A MESSAGE SAYING "DELETED" HERE
                        JOptionPane.showMessageDialog(null, "Deleted!");

                        toPatientSelectionNoDialog.fire();
                    } catch (Exception exception) {
                    }
                }

            }

        }
    });

    save.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            save();
        }
    });

    versionInfo.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            JOptionPane.showMessageDialog(null, "Patient Manager Version 5.0.6 \n Compatible with: Windows 7");
        }
    });

    howToUse.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            JOptionPane.showMessageDialog(null,
                    "Help: \n\n\n Print- sends the document to the default printer. Requires no passwords. \n\n Print with Settings- opens the evaluation or progress report in word so that the document can be printed using word's built-in dialog. Because the word document will be open to modification, 'print with settings' requires the physician's password. \n\n Export to- save an evaluation or progress note to the location of your choice, rather than to the default location. Requires the physician/admin's password. \n\n Enable Backdoor Modifications- allows the physician or physician's assistant(s) to reopen the forms for modification post-signing. If the physician's password is used, only his signature will become undone. If the physician's assistant(s)' password is used, both the physician's signature (if relevant) and the assitant's signature will become undone (since the physician will need to review the new modifications before re-signing his approval). \n\n Create/Load/Delete a progress note- the create & load functions are accessible directly from the interface. Deletion can only be accessed from the drop-down menu. Select a progress report prior to clicking 'load' or 'delete' \n\n Speech Options- most speech options are still a WIP, HOWEVER, you can click 'launch windows 7 native dictation' from either the interface OR the menu bar, in order to quickly access Windows' built-in dictation capabilities. \n\n Version info can be found in 'About' in the 'Help' drop-down menu on the main menu bar.");
        }
    });

    launchWindowsDictation.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            launchSpeechRecognition();
        }
    });

    exit.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            int result = JOptionPane.showConfirmDialog(null,
                    "Do you want to save any unsaved changes before exiting?", "Save changes?",
                    JOptionPane.YES_NO_CANCEL_OPTION);

            if (result == 0) {
                saveEval();

                //some idiocy goes here
                /*try
                {
                    Audio audio = Audio.getInstance();
                    InputStream sound = audio.getAudio("Have a nice day!", Language.ENGLISH);
                    audio.play(sound);
                }
                catch(Exception excep)
                {System.out.println(excep);}*/

                System.exit(0);
            }
            if (result == 1) {
                //some idiocy goes here
                /*try
                {
                    Audio audio = Audio.getInstance();
                    InputStream sound = audio.getAudio("Have a nice day!", Language.ENGLISH);
                    audio.play(sound);
                }
                catch(Exception excep)
                {System.out.println(excep);}*/

                System.exit(0);
            }
            if (result == 2) {

            }

        }
    });

    enableBackdoorModifications.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            enableBackdoorModifications();
        }
    });

    deleteProgressReport.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            deleteProgressReport();
        }
    });

    //<MenuItem fx:id="loadProgressReport" onAction="#loadProgressReport" />

    loadProgressReport.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            load.fire();
        }
    });

    createProgressReport.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            createPN.fire();
        }
    }); //read to me menu, dictation menu- select a document to read aloud, read this passage aloud, launch windows in-built dictation, download brainac dictation online

    export.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            final Stage dialog = new Stage();
            dialog.initModality(Modality.APPLICATION_MODAL);

            final TextField textField = new TextField();
            Button submit = new Button();
            Button cancel = new Button();
            final Label label = new Label();

            cancel.setText("Cancel");
            cancel.setAlignment(Pos.CENTER);
            submit.setText("Submit");
            submit.setAlignment(Pos.BOTTOM_RIGHT);

            final VBox dialogVbox = new VBox(20);
            dialogVbox.getChildren().add(new Text("Enter the master password: "));
            dialogVbox.getChildren().add(textField);
            dialogVbox.getChildren().add(submit);
            dialogVbox.getChildren().add(cancel);
            dialogVbox.getChildren().add(label);

            Scene dialogScene = new Scene(dialogVbox, 300, 200);
            dialog.setScene(dialogScene);
            dialog.setTitle("Security/Physician Authentication");
            dialog.show();

            submit.setOnAction(new EventHandler<ActionEvent>() {

                public void handle(ActionEvent anEvent) {
                    String password = textField.getText();

                    if (password.equalsIgnoreCase("protooncogene")) {
                        dialog.close();

                        export();

                    } else {
                        label.setText("The password you entered is incorrect. Please try again.");
                    }

                }
            });

            cancel.setOnAction(new EventHandler<ActionEvent>() {

                public void handle(ActionEvent anEvent) {
                    dialog.close();
                    //close the window here
                }
            });

        }
    });

    print.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            print();
        }
    });
    printWithSettings.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            printAdv();
        }
    });
    logout.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            toPatientSelection.fire();
        }
    });

    ///"sometime during s-y lol."

}

From source file:UI.MainStageController.java

/**
 * method for the quit button/* w  ww .  ja v a  2  s. co  m*/
 * opens an alert box
 * asks whether to save/quit/continue running the program
 */
private void confirmQuit() {
    confirmQuitAlert = new Alert(Alert.AlertType.CONFIRMATION);
    confirmQuitAlert.setTitle("Remember to save your files!");
    confirmQuitAlert.setHeaderText("Quit?");
    confirmQuitAlert.setContentText("Do you really want to quit?");

    ButtonType quitButton = new ButtonType("Quit");
    ButtonType saveAndQuitButton = new ButtonType("Save and quit");
    ButtonType cancelButton = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);

    confirmQuitAlert.initModality(Modality.APPLICATION_MODAL);
    confirmQuitAlert.initOwner(getPrimaryStage());
    confirmQuitAlert.getButtonTypes().setAll(quitButton, saveAndQuitButton, cancelButton);

    Optional<ButtonType> result = confirmQuitAlert.showAndWait();

    if (result.get() == quitButton) {
        Platform.exit();
    } else if (result.get() == saveAndQuitButton) {
        confirmQuitAlert.close();
    } else {
        confirmQuitAlert.close();
    }
}

From source file:snpviewer.SnpViewer.java

public void removeSamples(ActionEvent event) {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("RemoveSamplesInterface.fxml"));
    try {//from  w  ww  .j av a 2s . c  om
        Pane pane = (Pane) loader.load();
        RemoveSamplesInterfaceController removeController = (RemoveSamplesInterfaceController) loader
                .getController();
        Scene scene = new Scene(pane);
        Stage stage = new Stage();
        stage.setScene(scene);
        scene.getStylesheets().add(SnpViewer.class.getResource("SnpViewerStyleSheet.css").toExternalForm());
        stage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png")));
        stage.setTitle("Remove Samples");
        removeController.setSamples(affObserve, unObserve);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.showAndWait();
        List<Integer> indicesToRemove = removeController.getSamplesToRemove();
        //System.out.println(indicesToRemove.toString());
        if (indicesToRemove.isEmpty()) {
            return;
        }
        ArrayList<Integer> affsToRemove = new ArrayList<>();
        ArrayList<Integer> unsToRemove = new ArrayList<>();
        for (Integer r : indicesToRemove) {
            if (r < affObserve.size()) {//index corresponds to affFiles
                affsToRemove.add(r);
            } else {//index corresponds to unFiles
                r -= affObserve.size();
                unsToRemove.add(r);
            }
        }
        ArrayList<File> dirsToDelete = new ArrayList<>();
        if (!affsToRemove.isEmpty()) {
            Collections.sort(affsToRemove, Collections.reverseOrder());
            for (int i : affsToRemove) {
                dirsToDelete.add(affObserve.get(i).getOutputDirectory());
                affObserve.remove(i);
            }
        }
        if (!unsToRemove.isEmpty()) {
            Collections.sort(unsToRemove, Collections.reverseOrder());
            for (int i : unsToRemove) {
                dirsToDelete.add(unObserve.get(i).getOutputDirectory());
                unObserve.remove(i);
            }
        }
        if (affObserve.isEmpty() && unObserve.isEmpty()) {
            resetView();
        } else {
            refreshView(null, false);
        }
        saveProject();
        for (File dir : dirsToDelete) {
            FileUtils.deleteDirectory(dir);
        }
    } catch (Exception ex) {
        Dialogs.showErrorDialog(null,
                "Sample removal failed - please see " + "details for stack trace and report this error.",
                "Remove Samples Failed!", "SnpViewer", ex);
    }
}

From source file:patientmanagerv1.HomeController.java

public void enableBackdoorModifications() {
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);

    final TextField textField = new TextField();
    Button submit = new Button();
    Button cancel = new Button();
    final Label label = new Label();

    cancel.setText("Cancel");
    cancel.setAlignment(Pos.CENTER);/*from   w  ww .j  av  a2  s  .c  om*/
    submit.setText("Submit");
    submit.setAlignment(Pos.BOTTOM_RIGHT);

    final VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren().add(new Text(
            "Only the physician can open this document for modification. Please Enter the master password: "));
    dialogVbox.getChildren().add(textField);
    dialogVbox.getChildren().add(submit);
    dialogVbox.getChildren().add(cancel);
    dialogVbox.getChildren().add(label);

    Scene dialogScene = new Scene(dialogVbox, 300, 200);
    dialog.setScene(dialogScene);
    dialog.setTitle("Security/Physician Authentication");
    dialog.show();

    submit.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            String password = textField.getText();

            if (password.equalsIgnoreCase("protooncogene")) {
                dialog.close();

                sign.setVisible(true);
                saveButton.setDisable(false);
                signature.setText("This document has been digitally signed by David Zhvikov MD");
                signature.setVisible(false);
                signature2.setVisible(false);

                //update the "signed" status document here, checked the "signed" status in the initialize() method and enable/disable the buttons and message accordingly onLoad...when the signed document is first created, it should be set to false (f) by default
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/signed.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("false");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }

                ap.setDisable(false);

                //System.out.println(engaged.isSelected());
            } else if (password.equalsIgnoreCase("siberianplatypus")) {
                dialog.close();

                sign.setVisible(true);
                assistantsign.setVisible(true);
                assistantsign.setDisable(false);
                saveButton.setDisable(false);
                //signature.setText("This document has been digitally signed by David Zhvikov MD");
                assistantsignature.setVisible(false);
                signature.setVisible(false);
                signature2.setVisible(false);

                //update the "signed" status document here, checked the "signed" status in the initialize() method and enable/disable the buttons and message accordingly onLoad...when the signed document is first created, it should be set to false (f) by default
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/signed.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("false");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/assistantsigned.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("false");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }

                ap.setDisable(false);

                //System.out.println(engaged.isSelected());
            }

            else {
                label.setText("The password you entered is incorrect. Please try again.");
            }

            //adds files to file tracker

        }
    });

    cancel.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            dialog.close();
            //close the window here
        }
    });

}

From source file:patientmanagerv1.HomeController.java

public void assistantSign() {
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);

    final TextField textField = new TextField();
    Button submit = new Button();
    Button cancel = new Button();
    final Label label = new Label();

    cancel.setText("Cancel");
    cancel.setAlignment(Pos.CENTER);//from w  w w  . j av  a2s  . c om
    submit.setText("Submit");
    submit.setAlignment(Pos.BOTTOM_RIGHT);

    final VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren().add(new Text("Please enter the physician's assistant password: "));
    dialogVbox.getChildren().add(textField);
    dialogVbox.getChildren().add(submit);
    dialogVbox.getChildren().add(cancel);
    dialogVbox.getChildren().add(label);

    Scene dialogScene = new Scene(dialogVbox, 300, 200);
    dialog.setScene(dialogScene);
    dialog.setTitle("Security/Physician's Assistant Authentication");
    dialog.show();

    submit.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            String password = textField.getText();

            if (password.equalsIgnoreCase("siberianplatypus")) {
                partnerSigned = true;

                dialog.close();

                assistantsign.setVisible(false);
                saveButton.setDisable(true);
                //signature.setText("This document has been digitally signed by David Zhvikov MD");
                //signature.setVisible(true);
                //signature2.setVisible(true);
                assistantsignature.setVisible(true);

                //update the "signed" status document here, checked the "signed" status in the initialize() method and enable/disable the buttons and message accordingly onLoad...when the signed document is first created, it should be set to false (f) by default
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/assistantsigned.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("true");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }

                ap.setDisable(true);

                //System.out.println(engaged.isSelected());
            } else {
                label.setText("The password you entered is incorrect. Please try again.");
            }

            //adds files to file tracker

        }
    });

    cancel.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            dialog.close();
            //close the window here
        }
    });
}

From source file:patientmanagerv1.HomeController.java

public void signEvaluation() {
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);

    final TextField textField = new TextField();
    Button submit = new Button();
    Button cancel = new Button();
    final Label label = new Label();

    cancel.setText("Cancel");
    cancel.setAlignment(Pos.CENTER);/*w  ww .  j  ava 2s  .  c  o m*/
    submit.setText("Submit");
    submit.setAlignment(Pos.BOTTOM_RIGHT);

    final VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren()
            .add(new Text("Only the physician can sign this document. Please enter the master password: "));
    dialogVbox.getChildren().add(textField);
    dialogVbox.getChildren().add(submit);
    dialogVbox.getChildren().add(cancel);
    dialogVbox.getChildren().add(label);

    Scene dialogScene = new Scene(dialogVbox, 300, 200);
    dialog.setScene(dialogScene);
    dialog.setTitle("Security/Physician Authentication");
    dialog.show();

    submit.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            String password = textField.getText();

            if (password.equalsIgnoreCase("protooncogene")) {
                dccSigned = true;

                dialog.close();

                sign.setVisible(false);
                saveButton.setDisable(true);
                signature.setText("This document has been digitally signed by David Zhvikov MD");
                signature.setVisible(true);
                signature2.setVisible(true);

                //update the "signed" status document here, checked the "signed" status in the initialize() method and enable/disable the buttons and message accordingly onLoad...when the signed document is first created, it should be set to false (f) by default
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/signed.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("true");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }

                ap.setDisable(true);

                //System.out.println(engaged.isSelected());
            } else {
                label.setText("The password you entered is incorrect. Please try again.");
            }

            //adds files to file tracker

        }
    });

    cancel.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            dialog.close();
            //close the window here
        }
    });

    //"save as document" (exporting) should become enabled after signing? (ask dcc if he wants this) --> it should automatically convert the generated word document to a pdf
}

From source file:snpviewer.SnpViewer.java

public void autoFindRegions() {
    if (affObserve.isEmpty()) {
        Dialogs.showErrorDialog(null,//  w  ww .j  a  v a  2 s .  c o m
                "Find Regions can only be run when there "
                        + "is at least one Affected sample in the project.  Use the "
                        + "'Add Affected' button/menu item to add  Affected samples.",
                "No Affected samples to analyze!", "SnpViewer");
        return;
    }
    Stage stage = new Stage();
    FXMLLoader loader = new FXMLLoader(getClass().getResource("FindRegionsInterface.fxml"));
    try {
        Pane page = (Pane) loader.load();
        FindRegionsInterfaceController findReg = (FindRegionsInterfaceController) loader.getController();
        Scene scene = new Scene(page);
        stage.setScene(scene);
        scene.getStylesheets().add(SnpViewer.class.getResource("SnpViewerStyleSheet.css").toExternalForm());
        setProgressMode(true);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png")));
        stage.showAndWait();
        if (findReg.getCancelled()) {
            setProgressMode(false);
            return;
        }

        //int w, double r, boolean con, int refWind, double refCut,
        //int minReportSize, int minReportRun, double het, double dischord)
        int window = Integer.parseInt(findReg.getWindow());
        double regionLength = Double.parseDouble(findReg.getRegionLength());
        boolean checkConcordant = findReg.getCheckConcordance();
        int refineWindow = Integer.parseInt(findReg.getRefineSize());
        double refineTolerance = Double.parseDouble(findReg.getRefineTolerance());
        int minReport = Integer.parseInt(findReg.getReportLength());
        int minReportRun = Integer.parseInt(findReg.getReportMinSnps());
        double hetTolerance = Double.parseDouble(findReg.getHetTolerance());
        double dischordTolerance = Double.parseDouble(findReg.getDischordTolerance());
        boolean autosomesOnly = findReg.getAutosomesOnly();
        LinkedHashSet<String> c = new LinkedHashSet();
        for (Object item : chromosomeSelector.getItems()) {
            if (item instanceof String) {
                String chrom = (String) item;
                if (autosomesOnly) {
                    if (chrom.matches("\\d+")) {//only add autosomes
                        c.add(chrom);
                    }
                } else {
                    c.add(chrom);
                }
            }
        }

        final RegionFinder regionFinder = new RegionFinder(c, affFiles, unFiles, window, regionLength,
                checkConcordant, refineWindow, refineTolerance, minReport, minReportRun, hetTolerance,
                dischordTolerance);

        regionFinder.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
            @Override
            public void handle(WorkerStateEvent t) {
                progressBar.progressProperty().unbind();
                progressMessage.textProperty().unbind();
                progressMessage.setText("Done");
                progressTitle.textProperty().unbind();
                setProgressMode(false);
                Object result = t.getSource().getValue();
                ArrayList<RegionSummary> foundRegions = new ArrayList<>();
                if (result instanceof ArrayList) {
                    for (Object r : (ArrayList) result) {
                        if (r instanceof RegionSummary) {
                            RegionSummary reg = (RegionSummary) r;
                            foundRegions.add(reg);
                        }
                    }
                    if (foundRegions.size() > 0) {
                        FXMLLoader tableLoader = new FXMLLoader(
                                getClass().getResource("MultiRegionReporter.fxml"));
                        try {
                            Pane tablePane = (Pane) tableLoader.load();
                            MultiRegionReporterController multiReg = (MultiRegionReporterController) tableLoader
                                    .getController();
                            Scene tableScene = new Scene(tablePane);
                            Stage tableStage = new Stage();
                            tableStage.setScene(tableScene);
                            tableScene.getStylesheets().add(
                                    SnpViewer.class.getResource("SnpViewerStyleSheet.css").toExternalForm());
                            multiReg.displayData(foundRegions);
                            tableStage.setTitle("Find Regions Results");
                            tableStage.getIcons()
                                    .add(new Image(this.getClass().getResourceAsStream("icon.png")));
                            tableStage.initModality(Modality.NONE);
                            tableStage.show();
                        } catch (Exception ex) {
                            Dialogs.showErrorDialog(null,
                                    "Error displaying" + " results from Find Regions Method.",
                                    "Find Regions Error!", "SnpViewer", ex);
                        }
                    } else {
                        Dialogs.showInformationDialog(null, "No regions " + "found.", "Find Regions",
                                "SnpViewer");
                    }
                    savedRegions.addAll(foundRegions);
                    RegionSummary sorter = new RegionSummary();
                    sorter.mergeRegionsByPosition(savedRegions);
                }
                saveProject();
                int c = chromosomeSelector.getSelectionModel().getSelectedIndex();
                if (c > -1) {
                    selectionOverlayPane.getChildren().clear();
                    selectionOverlayPane.getChildren().add(dragSelectRectangle);
                    drawSavedRegions((String) chromosomeBoxList[c]);
                }
                progressMessage.setText("");
                progressTitle.setText("");
                progressBar.progressProperty().set(0);
            }
        });
        regionFinder.setOnFailed(new EventHandler<WorkerStateEvent>() {
            @Override
            public void handle(WorkerStateEvent t) {
                progressBar.progressProperty().unbind();
                progressMessage.textProperty().unbind();
                progressMessage.setText("Failed!");
                progressTitle.textProperty().unbind();
                Dialogs.showErrorDialog(null, "Find Regions method failed.", "Error!", "SnpViewer",
                        t.getSource().getException());
                setProgressMode(false);
                progressMessage.setText("");
                progressTitle.setText("");
                progressBar.progressProperty().set(0);
            }
        });
        regionFinder.setOnCancelled(new EventHandler<WorkerStateEvent>() {
            @Override
            public void handle(WorkerStateEvent t) {
                progressBar.progressProperty().unbind();
                progressMessage.textProperty().unbind();
                progressMessage.setText("Cancelled");
                progressTitle.textProperty().unbind();
                Dialogs.showErrorDialog(null, "Find Regions method Cancelled.", "Cancelled", "SnpViewer");
                setProgressMode(false);
                progressMessage.setText("");
                progressTitle.setText("");
                progressBar.progressProperty().set(0);

            }
        });
        cancelButton.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                regionFinder.cancel();

            }
        });
        progressBar.progressProperty().unbind();
        progressMessage.textProperty().unbind();
        progressTitle.textProperty().unbind();
        progressBar.progressProperty().bind(regionFinder.progressProperty());
        progressMessage.textProperty().bind(regionFinder.messageProperty());
        progressTitle.textProperty().bind(regionFinder.titleProperty());
        regionFinder.start();

    } catch (IOException ex) {
        Dialogs.showErrorDialog(null, "Error starting Find Regions method.", "Error!", "SnpViewer", ex);
        progressBar.progressProperty().unbind();
        progressMessage.textProperty().unbind();
        progressTitle.textProperty().unbind();
        setProgressMode(false);
    }

}