Java Code Examples for javafx.scene.control.TableColumn#setComparator()
The following examples show how to use
javafx.scene.control.TableColumn#setComparator() .
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: SpreadView.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
@Override public void initialize() { tableView = new TableView<>(); int gridRow = 0; GridPane.setRowIndex(tableView, gridRow); GridPane.setVgrow(tableView, Priority.ALWAYS); GridPane.setHgrow(tableView, Priority.ALWAYS); root.getChildren().add(tableView); Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noData")); placeholder.setWrapText(true); tableView.setPlaceholder(placeholder); TableColumn<SpreadItem, SpreadItem> currencyColumn = getCurrencyColumn(); tableView.getColumns().add(currencyColumn); numberOfOffersColumn = getNumberOfOffersColumn(); tableView.getColumns().add(numberOfOffersColumn); numberOfBuyOffersColumn = getNumberOfBuyOffersColumn(); tableView.getColumns().add(numberOfBuyOffersColumn); numberOfSellOffersColumn = getNumberOfSellOffersColumn(); tableView.getColumns().add(numberOfSellOffersColumn); totalAmountColumn = getTotalAmountColumn(); tableView.getColumns().add(totalAmountColumn); TableColumn<SpreadItem, SpreadItem> spreadColumn = getSpreadColumn(); tableView.getColumns().add(spreadColumn); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); currencyColumn.setComparator(Comparator.comparing(o -> CurrencyUtil.getNameByCode(o.currencyCode))); numberOfOffersColumn.setComparator(Comparator.comparingInt(o3 -> o3.numberOfOffers)); numberOfBuyOffersColumn.setComparator(Comparator.comparingInt(o3 -> o3.numberOfBuyOffers)); numberOfSellOffersColumn.setComparator(Comparator.comparingInt(o2 -> o2.numberOfSellOffers)); totalAmountColumn.setComparator(Comparator.comparing(o -> o.totalAmount)); spreadColumn.setComparator(Comparator.comparingDouble(o -> o.percentageValue)); numberOfOffersColumn.setSortType(TableColumn.SortType.DESCENDING); tableView.getSortOrder().add(numberOfOffersColumn); itemListChangeListener = c -> updateHeaders(); }
Example 2
Source File: ScansTable.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private void createTable() { // Don't really allow editing, just copying from some of the text fields scan_table.setEditable(true); final TableColumn<ScanInfoProxy, Number> id_col = new TableColumn<>("ID"); id_col.setPrefWidth(40); id_col.setStyle("-fx-alignment: CENTER-RIGHT;"); id_col.setCellValueFactory(cell -> cell.getValue().id); scan_table.getColumns().add(id_col); final TableColumn<ScanInfoProxy, Instant> create_col = new TableColumn<>("Created"); create_col.setCellValueFactory(cell -> cell.getValue().created); create_col.setCellFactory(cell -> new InstantCell()); scan_table.getColumns().add(create_col); final TableColumn<ScanInfoProxy, String> name_col = new TableColumn<>("Name"); name_col.setCellValueFactory(cell -> cell.getValue().name); name_col.setCellFactory(info -> new TextCopyCell()); name_col.setEditable(true); scan_table.getColumns().add(name_col); final TableColumn<ScanInfoProxy, ScanState> state_col = new TableColumn<>("State"); state_col.setPrefWidth(210); state_col.setCellValueFactory(cell -> cell.getValue().state); state_col.setCellFactory(cell -> new StateCell(scan_client)); state_col.setComparator((a, b) -> rankState(a) - rankState(b)); scan_table.getColumns().add(state_col); final TableColumn<ScanInfoProxy, Number> perc_col = new TableColumn<>("%"); perc_col.setPrefWidth(50); perc_col.setCellValueFactory(cell -> cell.getValue().percent); perc_col.setCellFactory(cell -> new PercentCell()); scan_table.getColumns().add(perc_col); final TableColumn<ScanInfoProxy, String> rt_col = new TableColumn<>("Runtime"); rt_col.setCellValueFactory(cell -> cell.getValue().runtime); scan_table.getColumns().add(rt_col); final TableColumn<ScanInfoProxy, Instant> finish_col = new TableColumn<>("Finish"); finish_col.setCellValueFactory(cell -> cell.getValue().finish); finish_col.setCellFactory(cell -> new InstantCell()); scan_table.getColumns().add(finish_col); final TableColumn<ScanInfoProxy, String> cmd_col = new TableColumn<>("Command"); cmd_col.setPrefWidth(200); cmd_col.setCellValueFactory(cell -> cell.getValue().command); cmd_col.setCellFactory(info -> new TextCopyCell()); cmd_col.setEditable(true); scan_table.getColumns().add(cmd_col); TableColumn<ScanInfoProxy, String> err_col = new TableColumn<>("Error"); err_col.setCellValueFactory(cell -> cell.getValue().error); err_col.setCellFactory(info -> new TextCopyCell()); err_col.setEditable(true); scan_table.getColumns().add(err_col); // Last column fills remaining space err_col.prefWidthProperty().bind(scan_table.widthProperty() .subtract(id_col.widthProperty()) .subtract(create_col.widthProperty()) .subtract(name_col.widthProperty()) .subtract(state_col.widthProperty()) .subtract(perc_col.widthProperty()) .subtract(rt_col.widthProperty()) .subtract(finish_col.widthProperty()) .subtract(cmd_col.widthProperty()) .subtract(2)); scan_table.setPlaceholder(new Label("No Scans")); scan_table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); sorted_scans.comparatorProperty().bind(scan_table.comparatorProperty()); }
Example 3
Source File: SelectionTableColumn.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Override default TableColumn<SelectionTableRowData, T> getTableColumn() { TableColumn<SelectionTableRowData, T> tableColumn = new TableColumn<>(getColumnTitle()); tableColumn.setCellFactory(cellFactory()); tableColumn.setCellValueFactory(cellValueFactory()); tableColumn.setComparator(comparator()); return tableColumn; }
Example 4
Source File: LoadingColumn.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Override public TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> getTableColumn() { TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> tableColumn = new TableColumn<>(getColumnTitle()); tableColumn.setCellFactory(cellFactory()); tableColumn.setCellValueFactory(cellValueFactory()); tableColumn.setComparator(null); tableColumn.setSortable(false); tableColumn.setMaxWidth(26); tableColumn.setMinWidth(26); return tableColumn; }
Example 5
Source File: PVTable.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private void createTableColumns() { // Selected column final TableColumn<TableItemProxy, Boolean> sel_col = new TableColumn<>(Messages.Selected); sel_col.setCellValueFactory(cell -> cell.getValue().selected); sel_col.setCellFactory(column -> new BooleanTableCell()); table.getColumns().add(sel_col); // PV Name TableColumn<TableItemProxy, String> col = new TableColumn<>(Messages.PV); col.setPrefWidth(250); col.setCellValueFactory(cell_data_features -> cell_data_features.getValue().name); col.setCellFactory(column -> new PVNameTableCell()); col.setOnEditCommit(event -> { final String new_name = event.getNewValue().trim(); final TableItemProxy proxy = event.getRowValue(); if (proxy == TableItemProxy.NEW_ITEM) { if (!new_name.isEmpty()) model.addItem(new_name); // else: No name entered, do nothing } else { // Set name, even if empty, assuming user wants to continue // editing the existing row. // To remove row, use context menu. proxy.getItem().updateName(new_name); proxy.update(proxy.getItem()); // Content of model changed. // Triggers full table update. model.fireModelChange(); } }); // Use natural order for PV name col.setComparator(CompareNatural.INSTANCE); table.getColumns().add(col); // Description if (Settings.show_description) { col = new TableColumn<>(Messages.Description); col.setCellValueFactory(cell -> cell.getValue().desc_value); table.getColumns().add(col); } // Time Stamp col = new TableColumn<>(Messages.Time); col.setCellValueFactory(cell -> cell.getValue().time); table.getColumns().add(col); // Editable value col = new TableColumn<>(Messages.Value); col.setCellValueFactory(cell -> cell.getValue().value); col.setCellFactory(column -> new ValueTableCell(model)); col.setOnEditCommit(event -> { event.getRowValue().getItem().setValue(event.getNewValue()); // Since updates were suppressed, refresh table model.performPendingUpdates(); }); col.setOnEditCancel(event -> { // Since updates were suppressed, refresh table model.performPendingUpdates(); }); // Use natural order for value col.setComparator(CompareNatural.INSTANCE); table.getColumns().add(col); // Alarm col = new TableColumn<>(Messages.Alarm); col.setCellValueFactory(cell -> cell.getValue().alarm); col.setCellFactory(column -> new AlarmTableCell()); table.getColumns().add(col); // Saved value col = new TableColumn<>(Messages.Saved); col.setCellValueFactory(cell -> cell.getValue().saved); // Use natural order for saved value col.setComparator(CompareNatural.INSTANCE); saved_value_col = col; table.getColumns().add(col); // Saved value's timestamp col = new TableColumn<>(Messages.Saved_Value_TimeStamp); col.setCellValueFactory(cell -> cell.getValue().time_saved); saved_time_col = col; table.getColumns().add(col); // Completion checkbox final TableColumn<TableItemProxy, Boolean> compl_col = new TableColumn<>(Messages.Completion); compl_col.setCellValueFactory(cell -> cell.getValue().use_completion); compl_col.setCellFactory(column -> new BooleanTableCell()); completion_col = compl_col; table.getColumns().add(compl_col); }
Example 6
Source File: AlarmTableUI.java From phoebus with Eclipse Public License 1.0 | 4 votes |
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 7
Source File: DisputeView.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
@Override public void initialize() { Label label = new AutoTooltipLabel(Res.get("support.filter")); HBox.setMargin(label, new Insets(5, 0, 0, 0)); filterTextField = new InputTextField(); filterTextField.setText("open"); filterTextFieldListener = (observable, oldValue, newValue) -> applyFilteredListPredicate(filterTextField.getText()); filterBox = new HBox(); filterBox.setSpacing(5); filterBox.getChildren().addAll(label, filterTextField); VBox.setVgrow(filterBox, Priority.NEVER); filterBox.setVisible(false); filterBox.setManaged(false); tableView = new TableView<>(); VBox.setVgrow(tableView, Priority.SOMETIMES); tableView.setMinHeight(150); root.getChildren().addAll(filterBox, tableView); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); Label placeholder = new AutoTooltipLabel(Res.get("support.noTickets")); placeholder.setWrapText(true); tableView.setPlaceholder(placeholder); tableView.getSelectionModel().clearSelection(); tableView.getColumns().add(getSelectColumn()); TableColumn<Dispute, Dispute> contractColumn = getContractColumn(); tableView.getColumns().add(contractColumn); TableColumn<Dispute, Dispute> dateColumn = getDateColumn(); tableView.getColumns().add(dateColumn); TableColumn<Dispute, Dispute> tradeIdColumn = getTradeIdColumn(); tableView.getColumns().add(tradeIdColumn); TableColumn<Dispute, Dispute> buyerOnionAddressColumn = getBuyerOnionAddressColumn(); tableView.getColumns().add(buyerOnionAddressColumn); TableColumn<Dispute, Dispute> sellerOnionAddressColumn = getSellerOnionAddressColumn(); tableView.getColumns().add(sellerOnionAddressColumn); TableColumn<Dispute, Dispute> marketColumn = getMarketColumn(); tableView.getColumns().add(marketColumn); TableColumn<Dispute, Dispute> roleColumn = getRoleColumn(); tableView.getColumns().add(roleColumn); TableColumn<Dispute, Dispute> stateColumn = getStateColumn(); tableView.getColumns().add(stateColumn); tradeIdColumn.setComparator(Comparator.comparing(Dispute::getTradeId)); dateColumn.setComparator(Comparator.comparing(Dispute::getOpeningDate)); buyerOnionAddressColumn.setComparator(Comparator.comparing(this::getBuyerOnionAddressColumnLabel)); sellerOnionAddressColumn.setComparator(Comparator.comparing(this::getSellerOnionAddressColumnLabel)); marketColumn.setComparator((o1, o2) -> CurrencyUtil.getCurrencyPair(o1.getContract().getOfferPayload().getCurrencyCode()).compareTo(o2.getContract().getOfferPayload().getCurrencyCode())); dateColumn.setSortType(TableColumn.SortType.DESCENDING); tableView.getSortOrder().add(dateColumn); selectedDisputeClosedPropertyListener = (observable, oldValue, newValue) -> chatView.setInputBoxVisible(!newValue); keyEventEventHandler = event -> { if (Utilities.isAltOrCtrlPressed(KeyCode.L, event)) { showFullReport(); } else if (Utilities.isAltOrCtrlPressed(KeyCode.K, event)) { showCompactReport(); } else if (Utilities.isAltOrCtrlPressed(KeyCode.U, event)) { // Hidden shortcut to re-open a dispute. Allow it also for traders not only arbitrator. if (selectedDispute != null) { if (selectedDisputeClosedPropertyListener != null) selectedDispute.isClosedProperty().removeListener(selectedDisputeClosedPropertyListener); selectedDispute.setIsClosed(false); } } else if (Utilities.isAltOrCtrlPressed(KeyCode.R, event)) { if (selectedDispute != null) { PubKeyRing pubKeyRing = selectedDispute.getTraderPubKeyRing(); NodeAddress nodeAddress; if (pubKeyRing.equals(selectedDispute.getContract().getBuyerPubKeyRing())) nodeAddress = selectedDispute.getContract().getBuyerNodeAddress(); else nodeAddress = selectedDispute.getContract().getSellerNodeAddress(); new SendPrivateNotificationWindow( privateNotificationManager, pubKeyRing, nodeAddress, useDevPrivilegeKeys ).show(); } } else { handleKeyPressed(event); } }; chatView = new ChatView(disputeManager, formatter); chatView.initialize(); }