Example usage for javafx.beans.property SimpleStringProperty getValue

List of usage examples for javafx.beans.property SimpleStringProperty getValue

Introduction

In this page you can find the example usage for javafx.beans.property SimpleStringProperty getValue.

Prototype

@Override
    public String getValue() 

Source Link

Usage

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

@FXML
private void onSalvarActionEvent(ActionEvent event) {
    try (PrintWriter pw = new PrintWriter(file); CSVPrinter print = csvFormat.print(pw)) {
        for (CSVRow row : tableView.getItems()) {
            if (row.isEmpty()) {
                print.println();//  www  .  jav a2  s.  c  o  m
            } else {
                for (SimpleStringProperty column : row.getColumns()) {
                    print.print(column.getValue());
                }
                print.println();
            }
        }
        print.flush();
        setSaved();
    } catch (Exception ex) {
        ex.printStackTrace();
        Alert d = new Alert(Alert.AlertType.ERROR);
        d.setHeaderText("Ooops, no foi possvel salvar o arquivo " + (file != null ? file.getName() : "."));
        d.setContentText(ex.getMessage());
        d.setTitle("Erro");
        d.initOwner(root.getScene().getWindow());
        d.show();
    }
}

From source file:de.ks.idnadrev.information.chart.ChartDataEditor.java

protected void onColumnsChanged(ListChangeListener.Change<? extends SimpleStringProperty> c) {
    while (c.next()) {
        List<? extends SimpleStringProperty> added = c.getAddedSubList();
        List<? extends SimpleStringProperty> removed = c.getRemoved();

        for (SimpleStringProperty column : added) {
            int columnIndex = columnHeaders.indexOf(column);
            addColumnConstraint();/*  www .ja  va2 s. c  o  m*/

            TextField title = new TextField();
            title.textProperty().bindBidirectional(column);
            title.getStyleClass().add("editorViewLabel");

            MenuItem deleteColumnItem = new MenuItem(Localized.get("column.delete"));
            deleteColumnItem.setOnAction(e -> {
                columnHeaders.remove(column);
            });
            title.setContextMenu(new ContextMenu(deleteColumnItem));

            headers.add(title);
            dataContainer.add(title, columnIndex + COLUMN_OFFSET, 0);

            for (int i = 0; i < rows.size(); i++) {
                ChartRow chartRow = rows.get(i);
                SimpleStringProperty value = chartRow.getValue(columnIndex);

                TextField editor = createValueEditor(chartRow, i, columnIndex);
                editor.textProperty().bindBidirectional(value);
            }
        }
        for (SimpleStringProperty column : removed) {
            Optional<Integer> first = dataContainer.getChildren().stream()
                    .filter(n -> GridPane.getRowIndex(n) == 0).map(n -> (TextField) n)
                    .filter(t -> t.getText().equals(column.getValue())).map(t -> GridPane.getColumnIndex(t))
                    .findFirst();
            if (first.isPresent()) {
                int columnIndex = first.get();
                rows.forEach(r -> {
                    SimpleStringProperty value = r.getValue(columnIndex);
                    value.set("");
                    value.unbind();
                });
                List<Node> childrenToRemove = dataContainer.getChildren().stream()
                        .filter(n -> GridPane.getColumnIndex(n) == columnIndex).collect(Collectors.toList());
                dataContainer.getChildren().removeAll(childrenToRemove);
                dataContainer.getColumnConstraints().remove(dataContainer.getColumnConstraints().size() - 1);
            }
        }

        sortGridPane();
    }
}

From source file:org.opendolphin.mvndemo.clientlazy.DemoController.java

private void createTableLazy(List<Map> data) {
    //Tabellen Spalten wieder sortieren.
    SortedMap<Integer, String> ms = new TreeMap<>(data.get(0));
    colNames = ms.values().toArray(colNames);
    // Model Listener
    initLazyModle(colNames);/*from   ww w .  j av  a2 s  . c  o m*/
    DemoApp.clientDolphin.addModelStoreListener(TYPE_LAZY, new ModelStoreListener() {

        @Override
        public void modelStoreChanged(ModelStoreEvent event) {
            PresentationModel pm = event.getPresentationModel();
            used.setValue(used.get() + 1);
            unused.setValue(lazyRows.size() - used.get());
            //
            int i = 0;
            for (Map<String, SimpleStringProperty> m : lazyModel) {
                String v = null;
                Attribute atr = pm.getAt(colNames[i]);
                if (atr != null) {
                    v = (String) atr.getValue();
                }
                m.get(pm.getId()).setValue(v);
                i++;
            }
        }
    });
    //Create table columns
    TableColumn<Integer, String> tableColID = new TableColumn<>("rowID");
    tableColID.setSortable(true);
    tableColID.setCellValueFactory(
            new Callback<TableColumn.CellDataFeatures<Integer, String>, ObservableValue<String>>() {

                @Override
                public ObservableValue<String> call(
                        TableColumn.CellDataFeatures<Integer, String> cellDataFeature) {
                    return new SimpleStringProperty(cellDataFeature.getValue().toString());
                }
            });
    tableLazy.getColumns().add(tableColID);

    for (int i = 0; i < colNames.length; i++) {
        TableColumn<Integer, String> tableCol = new TableColumn<>(colNames[i]);
        tableCol.setSortable(false);
        tableLazy.getColumns().add(tableCol);
        final int index = i;
        tableCol.setCellValueFactory(
                new Callback<TableColumn.CellDataFeatures<Integer, String>, ObservableValue<String>>() {

                    @Override
                    public ObservableValue<String> call(
                            TableColumn.CellDataFeatures<Integer, String> cellDataFeature) {
                        String lazyId = cellDataFeature.getValue().toString();
                        SimpleStringProperty placeholder = lazyModel.get(index).get(lazyId);
                        if ("...".equals(placeholder.getValue())) {
                            DemoApp.clientDolphin.getClientModelStore().withPresentationModel(lazyId, (pm) -> {
                                /*NOP*/
                            });
                            // Wrong Way
                            //                  GetPresentationModelCommand pmc = new GetPresentationModelCommand();
                            //                  pmc.setPmId(lazyId);
                            //                  MonitorApp.clientDolphin.getClientConnector().send(pmc);
                        }
                        return placeholder;
                    }
                });
    }
    //
    tableLazy.setItems(lazyRows);
}