Java Code Examples for javafx.scene.control.TableView#setPlaceholder()

The following examples show how to use javafx.scene.control.TableView#setPlaceholder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobViewer.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private Node create()
{
    final TableView<JobInfo> table = new TableView<>(job_infos);
    table.setPlaceholder(new Label(Messages.JobPlaceholder));
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    final TableColumn<JobInfo, String> name_col = new TableColumn<>(Messages.JobName);
    name_col.setCellValueFactory(cell -> cell.getValue().name);
    table.getColumns().add(name_col);

    final TableColumn<JobInfo, String> status_col = new TableColumn<>(Messages.JobStatus);
    status_col.setCellValueFactory(cell -> cell.getValue().status);
    table.getColumns().add(status_col);

    final TableColumn<JobInfo, Boolean> stop_col = new TableColumn<>("");
    stop_col.setCellFactory(col -> new CancelTableCell());
    table.getColumns().add(stop_col);

    updateJobs();

    return table;
}
 
Example 2
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static <T> TableView<T> addTableViewWithHeader(GridPane gridPane,
                                                      int rowIndex,
                                                      String headerText,
                                                      int top,
                                                      String groupStyle) {
    TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, rowIndex, 1, headerText, top);

    if (groupStyle != null) titledGroupBg.getStyleClass().add(groupStyle);

    TableView<T> tableView = new TableView<>();
    GridPane.setRowIndex(tableView, rowIndex);
    GridPane.setMargin(tableView, new Insets(top + 30, -10, 5, -10));
    gridPane.getChildren().add(tableView);
    tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    return tableView;
}
 
Example 3
Source File: ProposalResultsWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private GridPane createVotesTable() {
    GridPane votesGridPane = new GridPane();
    votesGridPane.setHgap(5);
    votesGridPane.setVgap(5);
    votesGridPane.setPadding(new Insets(15));

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.ALWAYS);
    votesGridPane.getColumnConstraints().addAll(columnConstraints1);

    int gridRow = 0;

    TableGroupHeadline votesTableHeader = new TableGroupHeadline(Res.get("dao.results.proposals.voting.detail.header"));
    GridPane.setRowIndex(votesTableHeader, gridRow);
    GridPane.setMargin(votesTableHeader, new Insets(8, 0, 0, 0));
    GridPane.setColumnSpan(votesTableHeader, 2);
    votesGridPane.getChildren().add(votesTableHeader);

    TableView<VoteListItem> votesTableView = new TableView<>();
    votesTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
    votesTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    createColumns(votesTableView);
    GridPane.setRowIndex(votesTableView, gridRow);
    GridPane.setMargin(votesTableView, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0));
    GridPane.setColumnSpan(votesTableView, 2);
    GridPane.setVgrow(votesTableView, Priority.ALWAYS);
    votesGridPane.getChildren().add(votesTableView);

    votesTableView.setItems(sortedVotes);

    addCloseButton(votesGridPane, ++gridRow);

    return votesGridPane;
}
 
Example 4
Source File: ManageMarketAlertsWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addContent() {
    TableView<MarketAlertFilter> tableView = new TableView<>();
    GridPane.setRowIndex(tableView, ++rowIndex);
    GridPane.setColumnSpan(tableView, 2);
    GridPane.setMargin(tableView, new Insets(10, 0, 0, 0));
    gridPane.getChildren().add(tableView);
    Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noData"));
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);
    tableView.setPrefHeight(300);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    setColumns(tableView);
    tableView.setItems(FXCollections.observableArrayList(marketAlerts.getMarketAlertFilters()));
}
 
Example 5
Source File: AlarmTableUI.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
private TableView<AlarmInfoRow> createTable(final ObservableList<AlarmInfoRow> rows,
                                            final boolean active)
{
    final SortedList<AlarmInfoRow> sorted = new SortedList<>(rows);
    final TableView<AlarmInfoRow> table = new TableView<>(sorted);

    // Ensure that the sorted rows are always updated as the column sorting
    // of the TableView is changed by the user clicking on table headers.
    sorted.comparatorProperty().bind(table.comparatorProperty());

    TableColumn<AlarmInfoRow, SeverityLevel> sevcol = new TableColumn<>(/* Icon */);
    sevcol.setPrefWidth(25);
    sevcol.setReorderable(false);
    sevcol.setResizable(false);
    sevcol.setCellValueFactory(cell -> cell.getValue().severity);
    sevcol.setCellFactory(c -> new SeverityIconCell());
    table.getColumns().add(sevcol);

    final TableColumn<AlarmInfoRow, String> pv_col = new TableColumn<>("PV");
    pv_col.setPrefWidth(240);
    pv_col.setReorderable(false);
    pv_col.setCellValueFactory(cell -> cell.getValue().pv);
    pv_col.setCellFactory(c -> new DragPVCell());
    pv_col.setComparator(CompareNatural.INSTANCE);
    table.getColumns().add(pv_col);

    TableColumn<AlarmInfoRow, String> col = new TableColumn<>("Description");
    col.setPrefWidth(400);
    col.setReorderable(false);
    col.setCellValueFactory(cell -> cell.getValue().description);
    col.setCellFactory(c -> new DragPVCell());
    col.setComparator(CompareNatural.INSTANCE);
    table.getColumns().add(col);

    sevcol = new TableColumn<>("Alarm Severity");
    sevcol.setPrefWidth(130);
    sevcol.setReorderable(false);
    sevcol.setCellValueFactory(cell -> cell.getValue().severity);
    sevcol.setCellFactory(c -> new SeverityLevelCell());
    table.getColumns().add(sevcol);

    col = new TableColumn<>("Alarm Status");
    col.setPrefWidth(130);
    col.setReorderable(false);
    col.setCellValueFactory(cell -> cell.getValue().status);
    col.setCellFactory(c -> new DragPVCell());
    table.getColumns().add(col);

    TableColumn<AlarmInfoRow, Instant> timecol = new TableColumn<>("Alarm Time");
    timecol.setPrefWidth(200);
    timecol.setReorderable(false);
    timecol.setCellValueFactory(cell -> cell.getValue().time);
    timecol.setCellFactory(c -> new TimeCell());
    table.getColumns().add(timecol);

    col = new TableColumn<>("Alarm Value");
    col.setPrefWidth(100);
    col.setReorderable(false);
    col.setCellValueFactory(cell -> cell.getValue().value);
    col.setCellFactory(c -> new DragPVCell());
    table.getColumns().add(col);

    sevcol = new TableColumn<>("PV Severity");
    sevcol.setPrefWidth(130);
    sevcol.setReorderable(false);
    sevcol.setCellValueFactory(cell -> cell.getValue().pv_severity);
    sevcol.setCellFactory(c -> new SeverityLevelCell());
    table.getColumns().add(sevcol);

    col = new TableColumn<>("PV Status");
    col.setPrefWidth(130);
    col.setReorderable(false);
    col.setCellValueFactory(cell -> cell.getValue().pv_status);
    col.setCellFactory(c -> new DragPVCell());
    table.getColumns().add(col);

    // Initially, sort on PV name
    // - restore(Memento) might change that
    table.getSortOrder().setAll(List.of(pv_col));
    pv_col.setSortType(SortType.ASCENDING);

    table.setPlaceholder(new Label(active ? "No active alarms" : "No acknowledged alarms"));
    table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    createContextMenu(table, active);

    // Double-click to acknowledge or un-acknowledge
    table.setRowFactory(tv ->
    {
        final TableRow<AlarmInfoRow> row = new TableRow<>();
        row.setOnMouseClicked(event ->
        {
            if (event.getClickCount() == 2  &&  !row.isEmpty())
                JobManager.schedule("ack", monitor ->  client.acknowledge(row.getItem().item, active));
        });
        return row;
    });

    return table;
}
 
Example 6
Source File: AnimatedTableRow.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

    stage.setTitle("Table View Sample");
    stage.setWidth(900);
    stage.setHeight(500);

    final ObservableList<Person> data =
        FXCollections.observableArrayList(
            new Person("Jacob", "Smith", "[email protected]"),
            new Person("Isabella", "Johnson", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"),
            new Person("Michael", "Brown", "[email protected]")
        );

    final TableView<Person> contactTable = createTable();
    contactTable.setPlaceholder(new Label("No more contacts to select"));
    contactTable.setItems(data);

    final Node contactContainer = createTableContainer("Address Book", contactTable);

    final TableView<Person> toTable = createTable();
    toTable.setPlaceholder(new Label("No contacts selected"));

    final Node toContainer = createTableContainer("Selected Contacts: ", toTable);

    final BorderPane root = new BorderPane();
    final SplitPane splitPane = new SplitPane();
    splitPane.getItems().addAll(contactContainer, toContainer);
    root.setCenter(splitPane);
    final Scene scene = new Scene(root);

    contactTable.setRowFactory(new Callback<TableView<Person>, TableRow<Person>>() {
        @Override
        public TableRow<Person> call(TableView<Person> tableView) {
            final TableRow<Person> row = new TableRow<>();
            row.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
                @Override
                public void handle(MouseEvent event) {
                    if (event.getClickCount() == 2 && row.getItem() != null) {
                        moveDataWithAnimation(contactTable, toTable, root, row);
                    }
                }
            });
            return row ;
        }
    });

    stage.setScene(scene);
    stage.show();
}