Example usage for javafx.scene.control TableColumn setCellValueFactory

List of usage examples for javafx.scene.control TableColumn setCellValueFactory

Introduction

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

Prototype

public final void setCellValueFactory(Callback<CellDataFeatures<S, T>, ObservableValue<T>> value) 

Source Link

Usage

From source file:com.bdb.weather.display.day.DayXYPlotPane.java

private void doConfigure(Menu menu) {
    List<SeriesControl> controls = configure(displayMenu);
    int tableColumn = 1;
    for (SeriesControl control : controls) {
        HistoricalSeriesInfo info = HistoricalSeriesInfo.find(control.name);
        if (info != null) {
            TimeSeries timeSeries = new TimeSeries(info.getSeriesName());
            CheckMenuItem menuItem = new CheckMenuItem(info.getSeriesName());
            menuItem.setSelected(control.displayInitially);
            SeriesEntry entry = new SeriesEntry(info, timeSeries, tableColumn, menuItem, control.leftAxis);
            entries.add(entry);//from w  ww.ja  va2  s.  co m

            TableColumn<HistoricalRecord, String> col = new TableColumn<>(entry.seriesInfo.getSeriesName());
            col.setCellValueFactory(entry);
            dataTable.getColumns().add(col);

            menu.getItems().add(menuItem);
            menuItem.setOnAction(this);
            tableColumn++;
        }
    }
}

From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java

public LogReaderEditor(final IMainWindow mainWindow) {
    super(Editor.Type.LOG_READER_CONFIG, mainWindow);

    this.parsedLogEntries = new TableView<>(this.parsedLogEntryItems);
    this.parsedLogEntries.setPlaceholder(new Text("No log entries to display."));
    final TableColumn<LogEntryTableRow, String> lineNoCol = new TableColumn<LogEntryTableRow, String>("LineNo");
    lineNoCol.setCellValueFactory(new PropertyValueFactory<>("lineNumber"));
    lineNoCol.setSortable(false);//from w  w  w .  j a  va  2s . c o m
    lineNoCol.setGraphic(Icons.getIconGraphics("key"));
    final TableColumn<LogEntryTableRow, String> timeCol = new TableColumn<LogEntryTableRow, String>("Time");
    timeCol.setCellValueFactory(new PropertyValueFactory<>("time"));
    timeCol.setSortable(false);
    timeCol.setGraphic(Icons.getIconGraphics("clock"));
    final TableColumn<LogEntryTableRow, String> channelCol = new TableColumn<LogEntryTableRow, String>(
            "Channel");
    channelCol.setCellValueFactory(new PropertyValueFactory<>("channel"));
    channelCol.setSortable(false);
    channelCol.setGraphic(Icons.getIconGraphics("connect"));
    final TableColumn<LogEntryTableRow, String> payloadCol = new TableColumn<LogEntryTableRow, String>(
            "Payload");
    payloadCol.setCellValueFactory(new PropertyValueFactory<>("payload"));
    payloadCol.setSortable(false);
    payloadCol.setGraphic(Icons.getIconGraphics("page_white_text_width"));
    this.parsedLogEntries.getColumns().add(lineNoCol);
    this.parsedLogEntries.getColumns().add(timeCol);
    this.parsedLogEntries.getColumns().add(channelCol);
    this.parsedLogEntries.getColumns().add(payloadCol);
}

From source file:ua.com.ecotep.debtprevention.VnaklController.java

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

    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");

    dateFieldFormatter = new TextFormatter(new LocalDateStringConverter(dateTimeFormatter, null));
    dateField.setTextFormatter(dateFieldFormatter);

    dateMaxFieldFormatter = new TextFormatter(new LocalDateStringConverter(dateTimeFormatter, null));
    dateMaxField.setTextFormatter(dateMaxFieldFormatter);

    TableColumn numCol = new TableColumn(".");
    numCol.setPrefWidth(100);//from   w  ww.ja v  a2s .  c  o  m
    numCol.setCellValueFactory(new PropertyValueFactory<DebPrevDetailBean, String>("num"));
    invTable.getColumns().add(numCol);

    TableColumn dateCol = new TableColumn("");
    dateCol.setPrefWidth(90);
    dateCol.setCellValueFactory(new PropertyValueFactory<DebPrevDetailBean, String>("date"));
    dateCol.setCellFactory(CellDateBox.forTableColumn(dateCol, CellDateBox.DATE_NORMAL_VIEW));
    invTable.getColumns().add(dateCol);

    TableColumn sumCol = new TableColumn("");
    sumCol.setPrefWidth(90);
    sumCol.setCellValueFactory(new PropertyValueFactory<DebPrevDetailBean, String>("sum"));
    sumCol.setCellFactory(CellMoneyBox.forTableColumn(sumCol, " ", 2));
    invTable.getColumns().add(sumCol);
    invTable.autosize();

    invTable.getItems().addListener(new ListChangeListener<DebPrevDetailBean>() {
        @Override
        public void onChanged(ListChangeListener.Change<? extends DebPrevDetailBean> c) {
            double sumDpm = 0;
            for (DebPrevDetailBean bean : c.getList()) {
                sumDpm += bean.getSum();
            }
            sumField.setText(String.format("%.2f ", sumDpm));
            if (sumDpm > 0) {
                saveButon.setDisable(false);
            } else {
                saveButon.setDisable(true);
            }
        }
    });

    TableColumn numVCol = new TableColumn(".");
    numVCol.setPrefWidth(100);
    numVCol.setCellValueFactory(new PropertyValueFactory<DebPrevDetailBean, String>("num"));
    vnaklTable.getColumns().add(numVCol);

    TableColumn dateVCol = new TableColumn("");
    dateVCol.setPrefWidth(90);
    dateVCol.setCellValueFactory(new PropertyValueFactory<DebPrevDetailBean, String>("date"));
    dateVCol.setCellFactory(CellDateBox.forTableColumn(dateVCol, CellDateBox.DATE_NORMAL_VIEW));
    vnaklTable.getColumns().add(dateVCol);

    TableColumn sumVCol = new TableColumn("");
    sumVCol.setPrefWidth(90);
    sumVCol.setCellValueFactory(new PropertyValueFactory<DebPrevDetailBean, String>("sum"));
    sumVCol.setCellFactory(CellMoneyBox.forTableColumn(sumVCol, " ", 2));
    vnaklTable.getColumns().add(sumVCol);
    vnaklTable.autosize();

    TextMaxLengthFieldInstaller mlControl = new TextMaxLengthFieldInstaller();
    mlControl.install(clientField, 150);

    try {

        dateFieldFormatter.setValue(currentDate);
        dateMaxFieldFormatter.setValue(currentDate);
    } catch (Exception ex) {
        Logger.getLogger(FilterController.class.getName()).log(Level.SEVERE, null, ex);
        AlertDialog.showSimpleMessage(" ?    !",
                AlertDialog.ICON_ERROR, parentInterface.getCurrentWindow());
    }

}

From source file:org.shiftedit.gui.preview.html.RemoteHTMLPreviewController.java

private void setupConnectionTable() {

    // Cell click handler
    tableCellMouseEventHandler = (MouseEvent t) -> {
        TableCell c = (TableCell) t.getSource();
        int index = c.getIndex();

        // Send ping request on double click
        if (t.getClickCount() == 2) {
            tableModel.get(index).ping();
        }/*from   w w w  .  j a  v  a 2 s. c  o  m*/
    };

    // Cell factory
    Callback<TableColumn, TableCell> cellFactory = (TableColumn p) -> {
        TextFieldTableCell cell = new TextFieldTableCell();
        cell.addEventFilter(MouseEvent.MOUSE_CLICKED, new WeakEventHandler<>(tableCellMouseEventHandler));
        return cell;
    };

    // Remote address
    TableColumn remoteAddressCol = new TableColumn(
            getResourceBundle().getString("builtin.plugin.preview.remote_html.remote_address"));
    remoteAddressCol.setMinWidth(100);
    remoteAddressCol.setCellValueFactory(new PropertyValueFactory<>("remoteAddress"));
    remoteAddressCol.setCellFactory(cellFactory);
    connectionTable.getColumns().add(remoteAddressCol);

    // User agent
    TableColumn userAgentCol = new TableColumn(
            getResourceBundle().getString("builtin.plugin.preview.remote_html.user_agent"));
    userAgentCol.setMinWidth(200);
    userAgentCol.setCellValueFactory(new PropertyValueFactory<>("userAgent"));
    userAgentCol.setCellFactory(cellFactory);
    connectionTable.getColumns().add(userAgentCol);

    // Rendering time
    TableColumn renderingTimeCol = new TableColumn(
            getResourceBundle().getString("builtin.plugin.preview.remote_html.rendering_time"));
    renderingTimeCol.setMinWidth(200);
    renderingTimeCol.setCellValueFactory(new PropertyValueFactory<>("renderingTime"));
    renderingTimeCol.setCellFactory(cellFactory);
    connectionTable.getColumns().add(renderingTimeCol);

    connectionTable.setPlaceholder(
            new Label(getResourceBundle().getString("builtin.plugin.preview.remote_html.no_connection")));

    connectionTable.setItems(tableModel);

}

From source file:Main.java

private TableView<Person> createEmployeeTableView(ObservableList<Person> teamMembers) {
    final TableView<Person> employeeTableView = new TableView<>();
    employeeTableView.setPrefWidth(300);

    employeeTableView.setItems(teamMembers);

    TableColumn<Person, String> aliasNameCol = new TableColumn<>("Alias");
    TableColumn<Person, String> firstNameCol = new TableColumn<>("First Name");
    TableColumn<Person, String> lastNameCol = new TableColumn<>("Last Name");

    aliasNameCol.setEditable(true);/*  www.java 2s .  c om*/

    aliasNameCol.setPrefWidth(employeeTableView.getPrefWidth() / 3);
    firstNameCol.setPrefWidth(employeeTableView.getPrefWidth() / 3);
    lastNameCol.setPrefWidth(employeeTableView.getPrefWidth() / 3);

    aliasNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("aliasName"));
    firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));
    lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));

    employeeTableView.getColumns().setAll(aliasNameCol, firstNameCol, lastNameCol);

    return employeeTableView;
}

From source file:org.craftercms.social.migration.controllers.MainController.java

private void configTable() {

    TableColumn dateCol = new TableColumn("Date");
    TableColumn messageCol = new TableColumn("Message");
    TableColumn sourceCol = new TableColumn("Source");
    dateCol.setMaxWidth(200);/*from w  w  w  .  j a v a  2s .  c  o  m*/
    dateCol.setPrefWidth(200);
    dateCol.setCellValueFactory(new PropertyValueFactory<UserLogEntry, String>("date"));
    messageCol.setMaxWidth(675);
    messageCol.setPrefWidth(675);
    messageCol.setCellValueFactory(new PropertyValueFactory<UserLogEntry, String>("message"));
    messageCol.setCellFactory(TextFieldTableCell.forTableColumn());
    sourceCol.setMaxWidth(150);
    sourceCol.setPrefWidth(150);
    sourceCol.setCellValueFactory(new PropertyValueFactory<UserLogEntry, String>("source"));
    logTable.getColumns().addAll(dateCol, messageCol, sourceCol);

}

From source file:com.ggvaidya.scinames.ui.DatasetDiffController.java

private TableColumn<DatasetRow, String> createTableColumnForDatasetRow(String colName,
        Function<DatasetRow, String> func) {
    TableColumn<DatasetRow, String> col = new TableColumn<>(colName);
    col.setCellValueFactory(cvf -> new ReadOnlyStringWrapper(func.apply(cvf.getValue())));
    return col;/*  ww w. j av a 2  s .c  om*/
}

From source file:context.ui.control.tabular.TabularViewController.java

private void initialTableData() {
    data.loadTableData();/*  w w w.  j a  va2s .c  o m*/
    //        double minWidth = tableView.getWidth() / data.getHeaders().size();
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    int index = 0;
    for (String header : data.getHeaders()) {
        final int j = index;
        TableColumn tableColumn = new TableColumn(header);

        tableColumn.setComparator(new Comparator<String>() {
            @Override
            public int compare(String s1, String s2) {
                if (NumberUtils.isNumber(s1) && NumberUtils.isNumber(s2)) {
                    return Double.compare(Double.parseDouble(s1), Double.parseDouble(s2));
                }
                return Collator.getInstance().compare(s1, s2);
            }
        });
        tableColumn.setCellValueFactory(
                new Callback<TableColumn.CellDataFeatures<List<String>, String>, ObservableValue<String>>() {
                    public ObservableValue<String> call(TableColumn.CellDataFeatures<List<String>, String> p) {
                        final String val = p.getValue().get(j);
                        if (isRoundDoubles() && NumberUtils.isNumber(val) && val.contains(".")) {
                            DecimalFormat df = new DecimalFormat("#.##");
                            Double d = Double.parseDouble(val);
                            return new SimpleStringProperty(df.format(d));
                        } else {
                            return new SimpleStringProperty(val);
                        }
                    }
                });
        index++;
        tableView.getColumns().add(tableColumn);
        //            if (index < data.getHeaders().size() - 1) {
        //                tableColumn.setMinWidth(minWidth);
        //            }
        //            System.out.println("width=" + tableColumn.getMinWidth());
    }
    System.out.println("columns Count:" + tableView.getColumns().size());
    //  which will make your table view dynamic 
    //        ObservableList<ObservableList> csvData = FXCollections.observableArrayList();
    //
    //        for (List<StringProperty> dataList : data.getRows()) {
    //            ObservableList<String> row = FXCollections.observableArrayList();
    //            for (StringProperty rowData : dataList) {
    //                row.add(rowData.get());
    //            }
    //            csvData.add(row); // add each row to cvsData
    //        }
    System.out.println("Rows Count=" + data.getRows().size());
    tableView.setItems(data.getRows()); // finally add data to tableview
    System.out.println("after Rows Count=" + tableView.getItems().size());

}

From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsView.java

private void addHeaders() {
    TableColumn colDate = new TableColumn(bundle.getString("colDate"));
    setMinMaxWidth(colDate, 75);/* w w w. j a va2  s .com*/
    colDate.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("date"));

    TableColumn colTime = new TableColumn(bundle.getString("colTime"));
    setMinMaxWidth(colTime, 75);
    colTime.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("time"));

    TableColumn colN = new TableColumn(bundle.getString("colN"));
    setMinMaxWidth(colN, 70);
    colN.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("nfiles"));

    TableColumn colFile = new TableColumn(bundle.getString("colFile"));
    setMinMaxWidth(colFile, 160);
    colFile.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("input"));

    TableColumn colErrors = new TableColumn(bundle.getString("colErrors"));
    setMinMaxWidth(colErrors, 65);
    colErrors.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("errors"));

    TableColumn colWarnings = new TableColumn(bundle.getString("colWarnings"));
    setMinMaxWidth(colWarnings, 85);
    colWarnings.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("warnings"));

    TableColumn colPassed = new TableColumn(bundle.getString("colPassed"));
    setMinMaxWidth(colPassed, 65);
    colPassed.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("passed"));

    colScore = new TableColumn(bundle.getString("colScore"));
    setMinMaxWidth(colScore, 75);
    colScore.setCellValueFactory(new PropertyValueFactory<ReportRow, String>("score"));

    colFormats = new TableColumn(bundle.getString("colFormats"));
    setMinMaxWidth(colFormats, 120);
    colFormats
            .setCellValueFactory(new PropertyValueFactory<ReportRow, ObservableMap<String, String>>("formats"));

    colDelete = new TableColumn(bundle.getString("colDelete"));
    setMinMaxWidth(colDelete, 30);
    colDelete.setVisible(true);
    colDelete.setCellValueFactory(new PropertyValueFactory<>("delete"));

    tabReports.skinProperty().addListener((obs, oldSkin, newSkin) -> {
        TableHeaderRow header = (TableHeaderRow) tabReports.lookup("TableHeaderRow");
        header.reorderingProperty().addListener((o, oldVal, newVal) -> header.setReordering(false));
    });

    tabReports.setPrefWidth(840.0);
    tabReports.setFixedCellSize(28.0);
    tabReports.getColumns().addAll(colDate, colTime, colN, colFile, colErrors, colWarnings, colPassed, colScore,
            colFormats, colDelete);
    tabReports.setCursor(Cursor.DEFAULT);
    tabReports.setEditable(false);
    tabReports.setMaxHeight(470.0);

    // Change column colors
    changeColumnTextColor(colDate, Color.LIGHTGRAY);
    changeColumnTextColor(colTime, Color.LIGHTGRAY);
    changeColumnTextColor(colFile, Color.LIGHTGRAY);
    changeColumnTextColor(colN, Color.CYAN);
    changeColumnTextColor(colErrors, Color.RED);
    changeColumnTextColor(colWarnings, Color.ORANGE);
    changeColumnTextColor(colPassed, Color.GREENYELLOW);
    changeColumnTextColor(colScore, Color.LIGHTGRAY);

    // Columns factories
    Bindings.size(tabReports.getItems()).addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            resizeTable();
        }
    });
    addChartScore();
    addFormatIcons();
    addDeleteIcon();
}

From source file:com.ggvaidya.scinames.ui.DatasetDiffController.java

@FXML
private void displayComparisonStats(ActionEvent e) {
    Dataset ds1 = dataset1ComboBox.getValue();
    Dataset ds2 = dataset2ComboBox.getValue();

    Table<String, Dataset, String> precalc = getComparisonStats(ds1, ds2);

    ObservableList<TableColumn> cols = comparisonTableView.getColumns();
    cols.clear();/*from   ww w. j a v a2  s  .  co m*/

    TableColumn<String, String> rowName = new TableColumn<>("");
    rowName.setCellValueFactory(cvf -> new ReadOnlyStringWrapper(cvf.getValue()));
    cols.add(rowName);

    for (Dataset ds : Arrays.asList(ds1, ds2)) {
        TableColumn<String, String> datasetCol = new TableColumn<>(ds.getName());
        datasetCol.setCellValueFactory(cvf -> new ReadOnlyStringWrapper(precalc.get(cvf.getValue(), ds)));
        cols.add(datasetCol);
    }

    // The "items" here are just the rows we've calculated.
    comparisonTableView.setItems(getComparisonStatRowHeaders());
}