javafx.scene.control.TableView#setPlaceholder ( )源码实例Demo

下面列出了javafx.scene.control.TableView#setPlaceholder ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: phoebus   文件: JobViewer.java
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;
}
 
源代码2 项目: bisq   文件: FormBuilder.java
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;
}
 
源代码3 项目: bisq   文件: ProposalResultsWindow.java
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;
}
 
源代码4 项目: bisq   文件: ManageMarketAlertsWindow.java
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()));
}
 
源代码5 项目: phoebus   文件: AlarmTableUI.java
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;
}
 
源代码6 项目: mars-sim   文件: AnimatedTableRow.java
@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();
}