Example usage for javax.annotation.processing FilerException FilerException

List of usage examples for javax.annotation.processing FilerException FilerException

Introduction

In this page you can find the example usage for javax.annotation.processing FilerException FilerException.

Prototype

public FilerException(String s) 

Source Link

Document

Constructs an exception with the specified detail message.

Usage

From source file:com.github.douglasjunior.simpleCSVEditor.FXMLController.java

@FXML
private void onAbrirActionEvent(ActionEvent event) {
    File csvFile = null;/*from www.  j  a va2  s  . com*/
    try {
        if (!saved) {
            Alert a = new Alert(Alert.AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.NO);
            a.setHeaderText("Deseja descartar as alteraes??");
            a.initOwner(root.getScene().getWindow());
            Optional<ButtonType> result = a.showAndWait();
            if (result.get() != ButtonType.YES) {
                return;
            }
        }
        csvFile = openFileChooser();
        if (csvFile == null || !csvFile.exists()) {
            throw new FileNotFoundException("O arquivo selecionado no existe!");
        }
        ObservableList<CSVRow> rows = readFile(csvFile);
        if (rows == null || rows.isEmpty()) {
            throw new FilerException("O arquivo selecionado est vazio!");
        }
        updateTable(rows);
        this.file = csvFile;
        setSaved();
    } catch (Exception ex) {
        ex.printStackTrace();
        Alert d = new Alert(Alert.AlertType.ERROR);
        d.setHeaderText(
                "Ooops, no foi possvel abrir o arquivo " + (csvFile != null ? csvFile.getName() : "."));
        d.setContentText(ex.getMessage());
        d.setTitle("Erro");
        d.initOwner(root.getScene().getWindow());
        d.show();
    }
}