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

The following examples show how to use javafx.scene.control.TableView#setColumnResizePolicy() . 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: WidgetInfoDialog.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
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);
}
 
Example 2
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 3
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 4
Source File: WidgetInfoDialog.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
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);
}
 
Example 5
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 6
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 7
Source File: WidgetInfoDialog.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
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);
}
 
Example 8
Source File: GUI.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
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;
}
 
Example 9
Source File: OpenAbout.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
@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;
}
 
Example 10
Source File: ClientList.java    From Maus with GNU General Public License v3.0 4 votes vote down vote up
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;
    }
 
Example 11
Source File: FeatureTable.java    From sis with Apache License 2.0 4 votes vote down vote up
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);
            }
        }
    }
}