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

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

源代码1 项目: phoebus   文件: WidgetInfoDialog.java
private Tab createMacros(final Macros orig_macros)
{
    final Macros macros = (orig_macros == null) ? new Macros() : orig_macros;
    // Use text field to allow copying the name and value
    // Table uses list of macro names as input
    // Name column just displays the macro name,..
    final TableColumn<String, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
    name.setCellFactory(col -> new ReadOnlyTextCell<>());
    name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue()));

    // .. value column fetches the macro value
    final TableColumn<String, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
    value.setCellFactory(col -> new ReadOnlyTextCell<>());
    value.setCellValueFactory(param -> new ReadOnlyStringWrapper(macros.getValue(param.getValue())));

    final TableView<String> table =
        new TableView<>(FXCollections.observableArrayList(macros.getNames()));
    table.getColumns().add(name);
    table.getColumns().add(value);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    return new Tab(Messages.WidgetInfoDialog_TabMacros, table);
}
 
源代码2 项目: 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;
}
 
源代码3 项目: 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;
}
 
源代码4 项目: phoebus   文件: WidgetInfoDialog.java
private Tab createProperties(final Widget widget)
 {
     // Use text field to allow copying the name (for use in scripts)
     // and value, but not the localized description and category
     // which are just for information
     final TableColumn<WidgetProperty<?>, String> cat = new TableColumn<>(Messages.WidgetInfoDialog_Category);
     cat.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getCategory().getDescription()));

     final TableColumn<WidgetProperty<?>, String> descr = new TableColumn<>(Messages.WidgetInfoDialog_Property);
     descr.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getDescription()));

     final TableColumn<WidgetProperty<?>, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
     name.setCellFactory(col -> new ReadOnlyTextCell<>());
     name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getName()));

     final TableColumn<WidgetProperty<?>, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
     value.setCellFactory(col -> new ReadOnlyTextCell<>());
     value.setCellValueFactory(param -> new ReadOnlyStringWrapper(Objects.toString(param.getValue().getValue())));

     final TableView<WidgetProperty<?>> table =
         new TableView<>(FXCollections.observableArrayList(widget.getProperties()));
     table.getColumns().add(cat);
     table.getColumns().add(descr);
     table.getColumns().add(name);
     table.getColumns().add(value);
     table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

     return new Tab(Messages.WidgetInfoDialog_TabProperties, table);
}
 
源代码5 项目: 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;
}
 
源代码6 项目: 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()));
}
 
源代码7 项目: phoebus   文件: WidgetInfoDialog.java
private Tab createPVs(final Collection<NameStateValue> pvs)
{
    // Use text field to allow users to copy the name, value to clipboard
    final TableColumn<NameStateValue, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
    name.setCellFactory(col -> new ReadOnlyTextCell<>());
    name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().name));

    final TableColumn<NameStateValue, String> state = new TableColumn<>(Messages.WidgetInfoDialog_State);
    state.setCellFactory(col -> new ReadOnlyTextCell<>());
    state.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().state));

    final TableColumn<NameStateValue, String> path = new TableColumn<>(Messages.WidgetInfoDialog_Path);
    path.setCellFactory(col -> new ReadOnlyTextCell<>());
    path.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().path));

    final TableColumn<NameStateValue, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
    value.setCellFactory(col -> new AlarmColoredCell());
    value.setCellValueFactory(param ->
    {
        String text;
        final VType vtype = param.getValue().value;
        if (vtype == null)
            text = Messages.WidgetInfoDialog_Disconnected;
        else
        {   // Formatting arrays can be very slow,
            // so only show the basic type info
            if (vtype instanceof VNumberArray)
                text = vtype.toString();
            else
                text = VTypeUtil.getValueString(vtype, true);
            final Alarm alarm = Alarm.alarmOf(vtype);
            if (alarm != null  &&  alarm.getSeverity() != AlarmSeverity.NONE)
                text = text + " [" + alarm.getSeverity().toString() + ", " +
                                     alarm.getName() + "]";
        }
        return new ReadOnlyStringWrapper(text);
    });

    final ObservableList<NameStateValue> pv_data = FXCollections.observableArrayList(pvs);
    pv_data.sort((a, b) -> a.name.compareTo(b.name));
    final TableView<NameStateValue> table = new TableView<>(pv_data);
    table.getColumns().add(name);
    table.getColumns().add(state);
    table.getColumns().add(value);
    table.getColumns().add(path);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    return new Tab(Messages.WidgetInfoDialog_TabPVs, table);
}
 
源代码8 项目: phoebus   文件: GUI.java
private TableView<Instance> createTable()
{
    final TableView<Instance> table = new TableView<>(FXCollections.observableList(model.getInstances()));
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    table.getSelectionModel().setCellSelectionEnabled(true);

    table.setEditable(true);

    TableColumn<Instance, String> col = new TableColumn<>(Messages.SystemColumn);
    col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().getName()));
    table.getColumns().add(col);

    int col_index = 0;
    for (Column column : model.getColumns())
    {
        final int the_col_index = col_index;
        col = new TableColumn<>(column.getName());
        col.setCellFactory(info -> new PACETableCell());
        col.setCellValueFactory(cell -> cell.getValue().getCell(the_col_index).getObservable());
        table.getColumns().add(col);

        if (column.isReadonly())
            col.setEditable(false);
        else
        {
            col.setOnEditCommit(event ->
            {
                event.getRowValue().getCell(the_col_index).setUserValue(event.getNewValue());
                final int row = event.getTablePosition().getRow();
                // Start to edit same column in next row
                if (row < table.getItems().size() - 1)
                    Platform.runLater(() ->  table.edit(row+1, event.getTableColumn()));
            });
        }

        ++col_index;
    }

    return table;
}
 
源代码9 项目: phoebus   文件: OpenAbout.java
@Override
public Void call()
{
    dialog = new Alert(AlertType.INFORMATION);
    dialog.setTitle(Messages.HelpAboutTitle);
    dialog.setHeaderText(Messages.HelpAboutHdr);

    // Table with Name, Value columns
    final ObservableList<List<String>> infos = FXCollections.observableArrayList();
    // Start with most user-specific to most generic: User location, install, JDK, ...
    // Note that OpenFileBrowserCell is hard-coded to add a "..." button for the first few rows.
    infos.add(Arrays.asList(Messages.HelpAboutUser, Locations.user().toString()));
    infos.add(Arrays.asList(Messages.HelpAboutInst, Locations.install().toString()));
    infos.add(Arrays.asList(Messages.HelpAboutUserDir, System.getProperty("user.dir")));
    infos.add(Arrays.asList(Messages.HelpJavaHome, System.getProperty("java.home")));
    infos.add(Arrays.asList(Messages.AppVersionHeader, Messages.AppVersion));
    infos.add(Arrays.asList(Messages.HelpAboutJava, System.getProperty("java.specification.vendor") + " " + System.getProperty("java.runtime.version")));
    infos.add(Arrays.asList(Messages.HelpAboutJfx, System.getProperty("javafx.runtime.version")));
    infos.add(Arrays.asList(Messages.HelpAboutPID, Long.toString(ProcessHandle.current().pid())));

    // Display in TableView
    final TableView<List<String>> info_table = new TableView<>(infos);
    info_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    info_table.setPrefHeight(290.0);

    final TableColumn<List<String>, String> name_col = new TableColumn<>(Messages.HelpAboutColName);
    name_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(0)));
    info_table.getColumns().add(name_col);

    final TableColumn<List<String>, String> value_col = new TableColumn<>(Messages.HelpAboutColValue);
    value_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(1)));
    value_col.setCellFactory(col -> new ReadOnlyTextCell<>());
    info_table.getColumns().add(value_col);

    final TableColumn<List<String>, String> link_col = new TableColumn<>();
    link_col.setMinWidth(50);
    link_col.setMaxWidth(50);
    link_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(1)));
    link_col.setCellFactory(col ->  new OpenFileBrowserCell());
    info_table.getColumns().add(link_col);

    dialog.getDialogPane().setContent(info_table);

    // Info for expandable "Show Details" section
    dialog.getDialogPane().setExpandableContent(createDetailSection());

    dialog.setResizable(true);
    dialog.getDialogPane().setPrefWidth(800);
    DialogHelper.positionDialog(dialog, DockPane.getActiveDockPane(), -400, -300);

    dialog.showAndWait();
    // Indicate that dialog is closed; allow GC
    dialog = null;

    return null;
}
 
源代码10 项目: Maus   文件: ClientList.java
public TableView getClientList() {

        tableView = new TableView();
        tableView.setEditable(true);
        tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
        tableView.getStylesheets().add(getClass().getResource("/css/global.css").toExternalForm());

        TableColumn<String, String> onlineStatus = new TableColumn<>("Status");
        onlineStatus.setMaxWidth(70);
        onlineStatus.setResizable(false);
        onlineStatus.setCellValueFactory(
                new PropertyValueFactory<>("onlineStatus"));

        TableColumn<ClientObject, String> nickName = new TableColumn<>("Nickname");
        nickName.setMinWidth(150);
        nickName.setMaxWidth(200);
        nickName.setResizable(false);
        nickName.setCellValueFactory(new PropertyValueFactory<>("nickName"));
        nickName.setCellFactory(TextFieldTableCell.forTableColumn());
        nickName.setOnEditCommit(
                t -> t.getTableView().getItems().get(
                        t.getTablePosition().getRow()).setNickName(t.getNewValue())
        );

        TableColumn<ClientObject, String> IP = new TableColumn<>("IP");
        IP.setMinWidth(600);
        IP.setResizable(false);
        IP.setCellValueFactory(new PropertyValueFactory<>("IP"));
        IP.setCellFactory(col -> {
            final TableCell<ClientObject, String> cell = new TableCell<>();
            cell.textProperty().bind(cell.itemProperty());
            cell.setOnMouseClicked(event -> {
                if (event.getButton().equals(MouseButton.SECONDARY) && cell.getTableView().getSelectionModel().getSelectedItem() != null && cell.getTableView().getSelectionModel().getSelectedItem().getClient().isConnected()) {
                    IPContextMenu.getIPContextMenu(cell, event);
                }
            });
            return cell;
        });
        ObservableList<ClientObject> list = FXCollections.observableArrayList();
        list.addAll(CONNECTIONS.values());
        tableView.setItems(list);
        tableView.getColumns().addAll(onlineStatus, nickName, IP);

        return tableView;
    }
 
源代码11 项目: sis   文件: FeatureTable.java
public FeatureTable(Resource res, int i) throws DataStoreException {
    TableView<AbstractFeature> ttv = new TableView<>();
    final ScrollPane scroll = new ScrollPane(ttv);
    scroll.setFitToHeight(true);
    scroll.setFitToWidth(true);
    ttv.setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY);
    ttv.setTableMenuButtonVisible(true);
    ttv.setFixedCellSize(100);
    scroll.setPrefSize(600, 400);
    scroll.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    setCenter(scroll);
    final List<AbstractFeature> list;
    if (res instanceof FeatureSet) {
        try (Stream<AbstractFeature> stream = ((FeatureSet) res).features(false)) {
            list = stream.collect(Collectors.toList());
            ttv.setItems(FXCollections.observableArrayList(list));
            for (AbstractIdentifiedType pt : list.get(0).getType().getProperties(false)) {
                final TableColumn<AbstractFeature, BorderPane> column = new TableColumn<>(generateFinalColumnName(pt));
                column.setCellValueFactory((TableColumn.CellDataFeatures<AbstractFeature, BorderPane> param) -> {
                    final Object val = param.getValue().getPropertyValue(pt.getName().toString());
                    if (val instanceof Geometry) {
                        return new SimpleObjectProperty<>(new BorderPane(new Label("{geometry}")));
                    } else {
                        SimpleObjectProperty<BorderPane> sop = new SimpleObjectProperty<>();
                        if (val instanceof CheckedArrayList<?>) {
                            Iterator<String> it = ((CheckedArrayList<String>) val).iterator();
                            TreeItem<String> ti = new TreeItem<>(it.next());
                            while (it.hasNext()) {
                                ti.getChildren().add(new TreeItem<>(it.next()));
                            }
                            BorderPane bp = new BorderPane(new TreeView<>(ti));
                            sop.setValue(bp);
                            return sop;
                        } else {
                            sop.setValue(new BorderPane(new Label(String.valueOf(val))));
                            return sop;
                        }
                    }
                });
                ttv.getColumns().add(column);
            }
        }
    }
}