javafx.scene.control.TableCell Java Examples

The following examples show how to use javafx.scene.control.TableCell. 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: JavaFXTableViewElementScrollTest.java    From marathonv5 with Apache License 2.0 7 votes vote down vote up
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
    Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
    TableRow<?> row = null;
    for (Node tableRow : tableRowCell) {
        TableRow<?> r = (TableRow<?>) tableRow;
        if (r.getIndex() == rowIndex) {
            row = r;
            break;
        }
    }
    Set<Node> cells = row.lookupAll(".table-cell");
    for (Node node : cells) {
        TableCell<?, ?> cell = (TableCell<?, ?>) node;
        if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
            Bounds bounds = cell.getBoundsInParent();
            Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
            Point2D rowLocal = row.localToScene(localToParent, true);
            return rowLocal;
        }
    }
    return null;
}
 
Example #2
Source File: PendingTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setDateColumnCellFactory() {
    dateColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    dateColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<PendingTradesListItem, PendingTradesListItem> call(
                        TableColumn<PendingTradesListItem, PendingTradesListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final PendingTradesListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            if (item != null && !empty) {
                                setGraphic(new AutoTooltipLabel(DisplayUtils.formatDateTime(item.getTrade().getDate())));
                            } else {
                                setGraphic(null);
                            }
                        }
                    };
                }
            });
}
 
Example #3
Source File: ClosedTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setTradeFeeColumnCellFactory() {
	tradeFeeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
	tradeFeeColumn.setCellFactory(
               new Callback<>() {
                   @Override
                   public TableCell<ClosedTradableListItem, ClosedTradableListItem> call(
                           TableColumn<ClosedTradableListItem, ClosedTradableListItem> column) {
                       return new TableCell<>() {
                           @Override
                           public void updateItem(final ClosedTradableListItem item, boolean empty) {
                               super.updateItem(item, empty);
                               setGraphic(new AutoTooltipLabel(model.getMakerFee(item)));
                           }
                       };
                   }
               });
}
 
Example #4
Source File: TableDoubleCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
    public TableCell<T, C> call(TableColumn<T, C> param) {

        TableCell<T, C> cell = new TableCell<T, C>() {
            @Override
            public void updateItem(C item, boolean empty) {
                super.updateItem(item, empty);
                setGraphic(null);
                if (empty || item == null) {
                    setText(null);
                    return;
                }
                Double v = (Double) item;
                setText(v + "");
//                if (v > Double.MIN_VALUE) {
//                    setText(v + "");
//                } else {
//                    setText(null);
//                }
            }
        };
        return cell;
    }
 
Example #5
Source File: TableImageCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public TableCell<T, Image> call(TableColumn<T, Image> param) {
    final ImageView imageview = new ImageView();
    imageview.setPreserveRatio(true);
    imageview.setFitWidth(100);
    imageview.setFitHeight(100);
    TableCell<T, Image> cell = new TableCell<T, Image>() {
        @Override
        public void updateItem(Image item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null) {
                setText(null);
                setGraphic(null);
                return;
            }
            javafx.scene.image.Image image = (javafx.scene.image.Image) item;
            imageview.setImage(image);
            setGraphic(imageview);
        }
    };
    return cell;
}
 
Example #6
Source File: ClosedTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setAmountColumnCellFactory() {
    amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    amountColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<ClosedTradableListItem, ClosedTradableListItem> call(
                        TableColumn<ClosedTradableListItem, ClosedTradableListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final ClosedTradableListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            setGraphic(new AutoTooltipLabel(model.getAmount(item)));
                        }
                    };
                }
            });
}
 
Example #7
Source File: OpenOffersView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setDateColumnCellFactory() {
    dateColumn.setCellValueFactory((openOfferListItem) -> new ReadOnlyObjectWrapper<>(openOfferListItem.getValue()));
    dateColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<OpenOfferListItem, OpenOfferListItem> call(
                        TableColumn<OpenOfferListItem, OpenOfferListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final OpenOfferListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            getStyleClass().removeAll("offer-disabled");
                            if (item != null) {
                                if (model.isDeactivated(item)) getStyleClass().add("offer-disabled");
                                setGraphic(new AutoTooltipLabel(model.getDate(item)));
                            } else {
                                setGraphic(null);
                            }
                        }
                    };
                }
            });
}
 
Example #8
Source File: TableMessageCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public TableCell<T, P> call(TableColumn<T, P> param) {

    TableCell<T, P> cell = new TableCell<T, P>() {
        @Override
        public void updateItem(P item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null) {
                setText(null);
                setGraphic(null);
                return;
            }
            setText(AppVariables.message((String) item));
            setGraphic(null);
        }
    };
    return cell;
}
 
Example #9
Source File: TableDateCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public TableCell<T, Long> call(TableColumn<T, Long> param) {
    TableCell<T, Long> cell = new TableCell<T, Long>() {
        private final Text text = new Text();

        @Override
        protected void updateItem(final Long item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null || (long) item <= 0) {
                setText(null);
                setGraphic(null);
                return;
            }
            text.setText(DateTools.datetimeToString((long) item));
            setGraphic(text);
        }
    };
    return cell;
}
 
Example #10
Source File: TableNumberCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public TableCell<T, Long> call(TableColumn<T, Long> param) {
    TableCell<T, Long> cell = new TableCell<T, Long>() {
        private final Text text = new Text();

        @Override
        protected void updateItem(final Long item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null || (long) item <= 0) {
                setText(null);
                setGraphic(null);
                return;
            }
            text.setText(StringTools.format((long) item));
            setGraphic(text);
        }
    };
    return cell;
}
 
Example #11
Source File: TablePercentageCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
    public TableCell<T, C> call(TableColumn<T, C> param) {

        TableCell<T, C> cell = new TableCell<T, C>() {
            @Override
            public void updateItem(C item, boolean empty) {
                super.updateItem(item, empty);
                setGraphic(null);
                if (empty || item == null) {
                    setText(null);
                    return;
                }
                Double v = (Double) item;
                setText(DoubleTools.scale(v * 100.0d, 2) + "");
//                if (v > Double.MIN_VALUE) {
//                    setText(v + "");
//                } else {
//                    setText(null);
//                }
            }
        };
        return cell;
    }
 
Example #12
Source File: FailedTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setVolumeColumnCellFactory() {
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<FailedTradesListItem, FailedTradesListItem> call(
                        TableColumn<FailedTradesListItem, FailedTradesListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final FailedTradesListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            if (item != null)
                                setGraphic(new AutoTooltipLabel(model.getVolume(item)));
                            else
                                setGraphic(null);
                        }
                    };
                }
            });
}
 
Example #13
Source File: EventTableContextMenu.java    From SONDY with GNU General Public License v3.0 6 votes vote down vote up
@Override
public TableCell call(TableColumn p) {
    TableCell cell = new TableCell() {
        @Override 
        protected void updateItem(Object item, boolean empty) {
             super.updateItem(item, empty);
             if(item != null) {
                 setText(item.toString());
                 setTooltip(new Tooltip(item.toString()));
             }
        }
   };
   if(menu != null) {
      cell.setContextMenu(menu);
   }
   if(click != null) {
      cell.setOnMouseClicked(click);
   }
   return cell;
}
 
Example #14
Source File: OpenOffersView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setVolumeColumnCellFactory() {
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<OpenOfferListItem, OpenOfferListItem> call(
                        TableColumn<OpenOfferListItem, OpenOfferListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final OpenOfferListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            getStyleClass().removeAll("offer-disabled");

                            if (item != null) {
                                if (model.isDeactivated(item)) getStyleClass().add("offer-disabled");
                                setGraphic(new AutoTooltipLabel(model.getVolume(item)));
                            } else {
                                setGraphic(null);
                            }
                        }
                    };
                }
            });
}
 
Example #15
Source File: PendingTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setAmountColumnCellFactory() {
    amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    amountColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<PendingTradesListItem, PendingTradesListItem> call(
                        TableColumn<PendingTradesListItem, PendingTradesListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final PendingTradesListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            if (item != null && !empty)
                                setGraphic(new AutoTooltipLabel(formatter.formatCoin(item.getTrade().getTradeAmount())));
                            else
                                setGraphic(null);
                        }
                    };
                }
            });
}
 
Example #16
Source File: JavaFXElementPropertyAccessor.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
    Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
    TableRow<?> row = null;
    for (Node tableRow : tableRowCell) {
        TableRow<?> r = (TableRow<?>) tableRow;
        if (!r.isEmpty() && r.getIndex() == rowIndex) {
            row = r;
            break;
        }
    }
    Set<Node> cells = row.lookupAll(".table-cell");
    for (Node node : cells) {
        TableCell<?, ?> cell = (TableCell<?, ?>) node;
        if (cell.isEmpty())
            continue;
        if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
            Bounds bounds = cell.getBoundsInParent();
            Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
            Point2D rowLocal = row.localToScene(localToParent, true);
            return rowLocal;
        }
    }
    return null;
}
 
Example #17
Source File: DepositView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setBalanceColumnCellFactory() {
    balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    balanceColumn.setCellFactory(new Callback<>() {

        @Override
        public TableCell<DepositListItem, DepositListItem> call(TableColumn<DepositListItem,
                DepositListItem> column) {
            return new TableCell<>() {

                @Override
                public void updateItem(final DepositListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        if (textProperty().isBound())
                            textProperty().unbind();

                        textProperty().bind(item.balanceProperty());
                    } else {
                        textProperty().unbind();
                        setText("");
                    }
                }
            };
        }
    });
}
 
Example #18
Source File: ClosedTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setSellerSecurityDepositColumnCellFactory() {
	sellerSecurityDepositColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
	sellerSecurityDepositColumn.setCellFactory(
               new Callback<>() {
                   @Override
                   public TableCell<ClosedTradableListItem, ClosedTradableListItem> call(
                           TableColumn<ClosedTradableListItem, ClosedTradableListItem> column) {
                       return new TableCell<>() {
                           @Override
                           public void updateItem(final ClosedTradableListItem item, boolean empty) {
                               super.updateItem(item, empty);
                               setGraphic(new AutoTooltipLabel(model.getSellerSecurityDeposit(item)));
                           }
                       };
                   }
               });
}
 
Example #19
Source File: WithdrawalView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setBalanceColumnCellFactory() {
    balanceColumn.getStyleClass().add("last-column");
    balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    balanceColumn.setCellFactory(
            new Callback<>() {

                @Override
                public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem,
                        WithdrawalListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final WithdrawalListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            setGraphic((item != null && !empty) ? item.getBalanceLabel() : null);
                        }
                    };
                }
            });
}
 
Example #20
Source File: FailedTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setMarketColumnCellFactory() {
    marketColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    marketColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<FailedTradesListItem, FailedTradesListItem> call(
                        TableColumn<FailedTradesListItem, FailedTradesListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final FailedTradesListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            setGraphic(new AutoTooltipLabel(model.getMarketLabel(item)));
                        }
                    };
                }
            });
}
 
Example #21
Source File: OpenOffersView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setMarketColumnCellFactory() {
    marketColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    marketColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<OpenOfferListItem, OpenOfferListItem> call(
                        TableColumn<OpenOfferListItem, OpenOfferListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final OpenOfferListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            getStyleClass().removeAll("offer-disabled");

                            if (item != null) {
                                if (model.isDeactivated(item)) getStyleClass().add("offer-disabled");
                                setGraphic(new AutoTooltipLabel(model.getMarketLabel(item)));
                            } else {
                                setGraphic(null);
                            }
                        }
                    };
                }
            });
}
 
Example #22
Source File: OpenOffersView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setAmountColumnCellFactory() {
    amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    amountColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<OpenOfferListItem, OpenOfferListItem> call(
                        TableColumn<OpenOfferListItem, OpenOfferListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final OpenOfferListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            getStyleClass().removeAll("offer-disabled");

                            if (item != null) {
                                if (model.isDeactivated(item)) getStyleClass().add("offer-disabled");
                                setGraphic(new AutoTooltipLabel(model.getAmount(item)));
                            } else {
                                setGraphic(null);
                            }
                        }
                    };
                }
            });
}
 
Example #23
Source File: AlarmTableUI.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Enable dragging the PV name from a table cell.
 *  @param cell Table cell
 */
static void enablePVDrag(TableCell<AlarmInfoRow, ?> cell)
{
    // Tried to use table.setOnDragDetected() to drag PV names
    // from all selected cells, but with drag enabled on the table
    // it is no longer possible to resize columns:
    // Moving a column divider starts a drag.
    // So now hooking drag to table cell.
    cell.setOnDragDetected(event ->
    {
        // Anything to drag?
        if (cell.getTableRow() == null  ||  cell.getTableRow().getItem() == null)
            return;

        final Dragboard db = cell.startDragAndDrop(TransferMode.COPY);
        final ClipboardContent content = new ClipboardContent();
        content.putString(cell.getTableRow().getItem().pv.get());
        db.setContent(content);
        event.consume();
    });
}
 
Example #24
Source File: ClosedTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setDateColumnCellFactory() {
    dateColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    dateColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<ClosedTradableListItem, ClosedTradableListItem> call(
                        TableColumn<ClosedTradableListItem, ClosedTradableListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final ClosedTradableListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            if (item != null)
                                setGraphic(new AutoTooltipLabel(model.getDate(item)));
                            else
                                setGraphic(null);
                        }
                    };
                }
            });
}
 
Example #25
Source File: LineNumberTableCellFactory.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public TableCell<T, E> call ( TableColumn<T, E> param ) {
    return new TableCell<T, E>() {

        /* Instance initializer. */
        {
            setAlignment(Pos.CENTER_LEFT);
        }

        @Override
        protected void updateItem ( E item, boolean empty ) {

            super.updateItem(item, empty);

            if ( !empty ) {
                setText(String.valueOf(getTableRow().getIndex() + ( startFromZero ? 0 : 1 )));
            } else {
                setText("");
            }

        }

    };
}
 
Example #26
Source File: PendingTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setVolumeColumnCellFactory() {
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<PendingTradesListItem, PendingTradesListItem> call(
                        TableColumn<PendingTradesListItem, PendingTradesListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final PendingTradesListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            if (item != null && !empty)
                                setGraphic(new AutoTooltipLabel(DisplayUtils.formatVolumeWithCode(item.getTrade().getTradeVolume())));
                            else
                                setGraphic(null);
                        }
                    };
                }
            });
}
 
Example #27
Source File: FailedTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setAmountColumnCellFactory() {
    amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    amountColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<FailedTradesListItem, FailedTradesListItem> call(
                        TableColumn<FailedTradesListItem, FailedTradesListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final FailedTradesListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            setGraphic(new AutoTooltipLabel(model.getAmount(item)));
                        }
                    };
                }
            });
}
 
Example #28
Source File: DepositView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setUsageColumnCellFactory() {
    usageColumn.getStyleClass().add("last-column");
    usageColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    usageColumn.setCellFactory(new Callback<>() {

        @Override
        public TableCell<DepositListItem, DepositListItem> call(TableColumn<DepositListItem,
                DepositListItem> column) {
            return new TableCell<>() {

                @Override
                public void updateItem(final DepositListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        setGraphic(new AutoTooltipLabel(item.getUsage()));
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
}
 
Example #29
Source File: FailedTradesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setDirectionColumnCellFactory() {
    directionColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    directionColumn.setCellFactory(
            new Callback<>() {
                @Override
                public TableCell<FailedTradesListItem, FailedTradesListItem> call(
                        TableColumn<FailedTradesListItem, FailedTradesListItem> column) {
                    return new TableCell<>() {
                        @Override
                        public void updateItem(final FailedTradesListItem item, boolean empty) {
                            super.updateItem(item, empty);
                            setGraphic(new AutoTooltipLabel(model.getDirectionLabel(item)));
                        }
                    };
                }
            });
}
 
Example #30
Source File: RFXTableView.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public String _getText() {
    TableView<?> tableView = (TableView<?>) node;
    if (row != -1 && column != -1) {
        TableCell<?, ?> tableCell = getCellAt(tableView, row, column);
        if (tableCell != null) {
            return tableCell.getText();
        }
    }
    return getSelection((TableView<?>) getComponent());
}