Example usage for javafx.beans.value ObservableValue getValue

List of usage examples for javafx.beans.value ObservableValue getValue

Introduction

In this page you can find the example usage for javafx.beans.value ObservableValue getValue.

Prototype

T getValue();

Source Link

Document

Returns the current value of this ObservableValue

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 500, 250, Color.WHITE);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);//from  ww w.j  a  v a  2s . c o m
    gridpane.setVgap(10);
    root.setCenter(gridpane);

    ObservableList<Person> leaders = getPeople();
    final ObservableList<Person> teamMembers = FXCollections.observableArrayList();

    ListView<Person> leaderListView = createLeaderListView(leaders);
    TableView<Person> employeeTableView = createEmployeeTableView(teamMembers);

    Label bossesLbl = new Label("Boss");
    GridPane.setHalignment(bossesLbl, HPos.CENTER);
    gridpane.add(bossesLbl, 0, 0);
    gridpane.add(leaderListView, 0, 1);

    Label emplLbl = new Label("Employees");
    GridPane.setHalignment(emplLbl, HPos.CENTER);
    gridpane.add(emplLbl, 2, 0);
    gridpane.add(employeeTableView, 2, 1);

    leaderListView.getSelectionModel().selectedItemProperty()
            .addListener((ObservableValue<? extends Person> observable, Person oldValue, Person newValue) -> {
                if (observable != null && observable.getValue() != null) {
                    teamMembers.clear();
                    teamMembers.addAll(observable.getValue().employeesProperty());
                }
            });
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:com.ggvaidya.scinames.tabulardata.TabularDataViewController.java

/**
 * Provide an export of the data in the TableView as a "table". In its
 * simplest Java representation, that is a list of columns, with each
 * column starting with a column header and then all the rest of the data.
 * //from   w ww  . j av a2 s .co  m
 * Warning: this can be a long-running function!
 * 
 * @return A list of columns of data.
 */
public List<List<String>> getDataAsTable() {
    // What columns do we have?
    List<List<String>> result = new LinkedList<>();
    List<TableColumn> columns = tableView.getColumns();

    columns.forEach(col -> {
        List<String> column = new LinkedList<>();

        // Add the header.
        column.add(col.getText());

        // Add the data.
        for (int x = 0; x < tableView.getItems().size(); x++) {
            ObservableValue cellObservableValue = col.getCellObservableValue(x);
            Object val = cellObservableValue.getValue();
            if (val == null)
                column.add("NA");
            else
                column.add(val.toString());
        }

        result.add(column);
    });

    return result;
}

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

/**
 * Provide an export of the data in the TableView as a "table". In its
 * simplest Java representation, that is a list of columns, with each
 * column starting with a column header and then all the rest of the data.
 * // w  w w  . jav  a 2s .  c om
 * Warning: this can be a long-running function!
 * 
 * @return A list of columns of data.
 */
public List<List<String>> getDataAsTable() {
    // What columns do we have?
    List<List<String>> result = new LinkedList<>();
    List<TableColumn<PotentialChange, ?>> columns = changesTableView.getColumns();

    columns.forEach(col -> {
        List<String> column = new LinkedList<>();

        // Add the header.
        column.add(col.getText());

        // Add the data.
        for (int x = 0; x < changesTableView.getItems().size(); x++) {
            ObservableValue cellObservableValue = col.getCellObservableValue(x);
            Object val = cellObservableValue.getValue();
            if (val == null)
                column.add("NA");
            else
                column.add(val.toString());
        }

        result.add(column);
    });

    return result;
}

From source file:com.ggvaidya.scinames.complexquery.ComplexQueryViewController.java

/**
 * Provide an export of the data in the TableView as a "table". In its
 * simplest Java representation, that is a list of columns, with each
 * column starting with a column header and then all the rest of the data.
 * /*from   w ww.  j  a  va  2 s.c  o  m*/
 * Warning: this can be a long-running function!
 * 
 * @return A list of columns of data.
 */
public List<List<String>> getDataAsTable() {
    // What columns do we have?
    List<List<String>> result = new LinkedList<>();
    List<TableColumn<NameCluster, ?>> columns = dataTableView.getColumns();

    for (TableColumn<NameCluster, ?> col : columns) {
        List<String> column = new LinkedList<>();

        // Add the header.
        column.add(col.getText());

        // Add the data.
        for (int x = 0; x < dataTableView.getItems().size(); x++) {
            ObservableValue cellObservableValue = col.getCellObservableValue(x);
            column.add(cellObservableValue.getValue().toString());
        }

        result.add(column);
    }
    ;

    return result;
}

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

@FXML
void onTableClicked(MouseEvent event) {
    if (event.getClickCount() != 2)
        return;//from  w  w  w  . j a  v  a2s .c o m
    TableView tableView = ((TableView) event.getSource());
    TableView.TableViewFocusModel focusModel = (TableView.TableViewFocusModel) tableView.focusModelProperty()
            .getValue();
    TablePosition position = focusModel.getFocusedCell();
    if (position.getTableColumn() == null)
        return;
    ObservableValue value = position.getTableColumn().getCellObservableValue(position.getRow());
    String valueStr = value.getValue().toString();
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setHeaderText(String.format("Value at ID:%d  %s",
            ((LIMSData) tableView.getItems().get(position.getRow())).getId(),
            position.getTableColumn().getText()));
    if (valueStr.length() > 300)
        alert.setContentText(valueStr.substring(0, 300) + "...");
    else
        alert.setContentText(valueStr);

    TextArea textArea = new TextArea(valueStr);
    textArea.setEditable(false);
    alert.getDialogPane().setExpandableContent(textArea);

    event.consume();
    alert.show();
}

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

/**
 * Provide an export of the data in the TableView as a "table". In its
 * simplest Java representation, that is a list of columns, with each
 * column starting with a column header and then all the rest of the data.
 * //from  w ww  . j  a v  a  2s  . c o m
 * Warning: this can be a long-running function!
 * 
 * @return A list of columns of data.
 */
public List<List<String>> getDataAsTable() {
    // What columns do we have?
    List<List<String>> result = new LinkedList<>();
    List<TableColumn> columns = comparisonTableView.getColumns();

    columns.forEach(col -> {
        List<String> column = new LinkedList<>();

        // Add the header.
        column.add(col.getText());

        // Add the data.
        for (int x = 0; x < comparisonTableView.getItems().size(); x++) {
            ObservableValue cellObservableValue = col.getCellObservableValue(x);
            Object val = cellObservableValue.getValue();
            if (val == null)
                column.add("NA");
            else
                column.add(val.toString());
        }

        result.add(column);
    });

    return result;
}

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

/**
 * Provide an export of the data in the TableView as a "table". In its
 * simplest Java representation, that is a list of columns, with each
 * column starting with a column header and then all the rest of the data.
 * //from  ww w  . j  ava 2s  .c  om
 * Warning: this can be a long-running function!
 * 
 * @return A list of columns of data.
 */
public List<List<String>> getDataAsTable() {
    // What columns do we have?
    List<List<String>> result = new LinkedList<>();
    List<TableColumn<String, ?>> columns = dataTableView.getColumns();

    columns.forEach(col -> {
        List<String> column = new LinkedList<>();

        // Add the header.
        column.add(col.getText());

        // Add the data.
        for (int x = 0; x < dataTableView.getItems().size(); x++) {
            ObservableValue cellObservableValue = col.getCellObservableValue(x);
            column.add(cellObservableValue.getValue().toString());
        }

        result.add(column);
    });

    return result;
}

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

private TreeView<Object> createTreeView(Field listField, ObservableValue<String> filter) {
    TreeView<Object> elements = new TreeView<>();
    elements.setShowRoot(false);/*from   w  w  w.  java  2  s  . c o m*/
    elements.setContextMenu(createContextMenu(elements));

    InvalidationListener treeInvalidation = (observable) -> buildTree(editor.xdatObjectProperty().get(),
            listField, elements, filter.getValue());
    editor.xdatObjectProperty().addListener(treeInvalidation);
    xdatListeners.add(treeInvalidation);

    filter.addListener(treeInvalidation);

    return elements;
}

From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java

public List<List<String>> getDataAsTable(TableView tv) {
    // What columns do we have?
    List<List<String>> result = new LinkedList<>();
    List<TableColumn> columns = tv.getColumns();

    columns.forEach(col -> {// w  w w.j  a  va2  s  . co m
        List<String> column = new LinkedList<>();

        // Add the header.
        column.add(col.getText());

        // Add the data.
        for (int x = 0; x < tv.getItems().size(); x++) {
            ObservableValue cellObservableValue = col.getCellObservableValue(x);
            column.add(cellObservableValue.getValue().toString());
        }

        result.add(column);
    });

    return result;
}

From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java

public List<List<String>> getDataAsTable(TableView tv) {
    // What columns do we have?
    List<List<String>> result = new LinkedList<>();
    List<TableColumn> columns = tv.getColumns();

    columns.forEach(col -> {/*from w w w.  j a  v  a  2s  . c o m*/
        List<String> column = new LinkedList<>();

        // Add the header.
        column.add(col.getText());

        // Add the data.
        for (int x = 0; x < tv.getItems().size(); x++) {
            ObservableValue cellObservableValue = col.getCellObservableValue(x);
            Object val = (Object) cellObservableValue.getValue();
            if (val == null)
                column.add(""); // or NA?
            else
                column.add(val.toString());
        }

        result.add(column);
    });

    return result;
}