Search in sources :

Example 56 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project bisq-desktop by bisq-network.

the class OpenOffersView method setRemoveColumnCellFactory.

private void setRemoveColumnCellFactory() {
    removeItemColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
    removeItemColumn.setCellFactory(new Callback<TableColumn<OpenOfferListItem, OpenOfferListItem>, TableCell<OpenOfferListItem, OpenOfferListItem>>() {

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

                final ImageView iconView = new ImageView();

                Button button;

                @Override
                public void updateItem(final OpenOfferListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        if (button == null) {
                            button = new AutoTooltipButton(Res.get("shared.remove"));
                            button.setMinWidth(70);
                            iconView.setId("image-remove");
                            button.setGraphic(iconView);
                            setGraphic(button);
                        }
                        button.setOnAction(event -> onRemoveOpenOffer(item.getOpenOffer()));
                    } else {
                        setGraphic(null);
                        if (button != null) {
                            button.setOnAction(null);
                            button = null;
                        }
                    }
                }
            };
        }
    });
}
Also used : Button(javafx.scene.control.Button) OfferDetailsWindow(bisq.desktop.main.overlays.windows.OfferDetailsWindow) OpenOffer(bisq.core.offer.OpenOffer) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) VBox(javafx.scene.layout.VBox) Volume(bisq.core.monetary.Volume) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) WithdrawalView(bisq.desktop.main.funds.withdrawal.WithdrawalView) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Res(bisq.core.locale.Res) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) FundsView(bisq.desktop.main.funds.FundsView) Tooltip(javafx.scene.control.Tooltip) SortedList(javafx.collections.transformation.SortedList) Navigation(bisq.desktop.Navigation) Popup(bisq.desktop.main.overlays.popups.Popup) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) DontShowAgainLookup(bisq.core.user.DontShowAgainLookup) FXML(javafx.fxml.FXML) MainView(bisq.desktop.main.MainView) ImageView(javafx.scene.image.ImageView) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Price(bisq.core.monetary.Price) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) NotNull(org.jetbrains.annotations.NotNull) TableColumn(javafx.scene.control.TableColumn) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) TableCell(javafx.scene.control.TableCell) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) ImageView(javafx.scene.image.ImageView)

Example 57 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project bisq-desktop by bisq-network.

the class PendingTradesView method setTradeIdColumnCellFactory.

// /////////////////////////////////////////////////////////////////////////////////////////
// CellFactories
// /////////////////////////////////////////////////////////////////////////////////////////
private void setTradeIdColumnCellFactory() {
    tradeIdColumn.setCellValueFactory((pendingTradesListItem) -> new ReadOnlyObjectWrapper<>(pendingTradesListItem.getValue()));
    tradeIdColumn.setCellFactory(new Callback<TableColumn<PendingTradesListItem, PendingTradesListItem>, TableCell<PendingTradesListItem, PendingTradesListItem>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final PendingTradesListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        field = new HyperlinkWithIcon(item.getTrade().getShortId());
                        field.setOnAction(event -> tradeDetailsWindow.show(item.getTrade()));
                        field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
                        setGraphic(field);
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
}
Also used : EventHandler(javafx.event.EventHandler) Scene(javafx.scene.Scene) Utilities(bisq.common.util.Utilities) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) VBox(javafx.scene.layout.VBox) FxmlView(bisq.desktop.common.view.FxmlView) BSFormatter(bisq.desktop.util.BSFormatter) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) Insets(javafx.geometry.Insets) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Res(bisq.core.locale.Res) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) SortedList(javafx.collections.transformation.SortedList) KeyCode(javafx.scene.input.KeyCode) Popup(bisq.desktop.main.overlays.popups.Popup) Offer(bisq.core.offer.Offer) TradeDetailsWindow(bisq.desktop.main.overlays.windows.TradeDetailsWindow) Trade(bisq.core.trade.Trade) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Node(javafx.scene.Node) KeyEvent(javafx.scene.input.KeyEvent) Subscription(org.fxmisc.easybind.Subscription) PeerInfoIcon(bisq.desktop.components.PeerInfoIcon) FXML(javafx.fxml.FXML) Priority(javafx.scene.layout.Priority) EasyBind(org.fxmisc.easybind.EasyBind) NodeAddress(bisq.network.p2p.NodeAddress) AppOptionKeys(bisq.core.app.AppOptionKeys) Preferences(bisq.core.user.Preferences) UserThread(bisq.common.UserThread) Named(com.google.inject.name.Named) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) TableCell(javafx.scene.control.TableCell) Tooltip(javafx.scene.control.Tooltip) TableColumn(javafx.scene.control.TableColumn) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon)

Example 58 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project VocabHunter by VocabHunter.

the class FilterGridController method extractValue.

private ObservableValue<GridCell> extractValue(final CellDataFeatures<GridLine, GridCell> features, final int index) {
    List<GridCell> cells = features.getValue().getCells();
    GridCell cell = getCell(cells, index);
    return cellCache.computeIfAbsent(cell, ReadOnlyObjectWrapper::new);
}
Also used : ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) GridCell(io.github.vocabhunter.analysis.grid.GridCell)

Example 59 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project jvarkit by lindenb.

the class VcfStage method buildGenotypeTableRow.

/**
 * build Genotype table
 */
private TableView<Genotype> buildGenotypeTableRow(final VCFHeader header) {
    final TableView<Genotype> table = new TableView<Genotype>();
    /* sample */
    table.getColumns().add(makeColumn("Sample", G -> G.getSampleName()));
    for (final VCFFormatHeaderLine h : header.getFormatHeaderLines()) {
        final TableColumn<Genotype, String> newcol = new TableColumn<>(h.getID());
        newcol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Genotype, String>, ObservableValue<String>>() {

            @Override
            public ObservableValue<String> call(CellDataFeatures<Genotype, String> param) {
                final String delim;
                Object o;
                if (param.getTableColumn().getText().equals(VCFConstants.GENOTYPE_KEY)) {
                    delim = param.getValue().isPhased() ? "|" : "/";
                    o = param.getValue().getAlleles().stream().map(A -> allele2stringConverter.apply(A)).collect(Collectors.toList());
                } else {
                    delim = ",";
                    o = param.getValue().getAnyAttribute(param.getTableColumn().getText());
                }
                if (o == null) {
                    return new ReadOnlyObjectWrapper<String>(null);
                }
                if (o instanceof List) {
                    List<?> L = (List<?>) o;
                    o = L.stream().map(S -> String.valueOf(S)).collect(Collectors.joining(delim)).toString();
                }
                return new ReadOnlyObjectWrapper<String>(String.valueOf(o));
            }
        });
        table.getColumns().add(newcol);
    }
    /* type */
    table.getColumns().add(makeColumn("Type", G -> G.getType().name()));
    table.setPlaceholder(new Label("No Genotype."));
    return table;
}
Also used : Arrays(java.util.Arrays) VCFHeader(htsjdk.variant.vcf.VCFHeader) ChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.ChartFactory) VariantContextChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantContextChartFactory) ScrollPane(javafx.scene.control.ScrollPane) TabPane(javafx.scene.control.TabPane) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) VariantDepthChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantDepthChartFactory) Map(java.util.Map) AlleleFrequencyChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.AlleleFrequencyChartFactory) CloserUtil(htsjdk.samtools.util.CloserUtil) Rectangle2D(javafx.geometry.Rectangle2D) SplitPane(javafx.scene.control.SplitPane) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) GenotypeBuilder(htsjdk.variant.variantcontext.GenotypeBuilder) GraphicsContext(javafx.scene.canvas.GraphicsContext) AFByPopulationChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.AFByPopulationChartFactory) TiTvChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.TiTvChartFactory) Set(java.util.Set) Screen(javafx.stage.Screen) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) ArcType(javafx.scene.shape.ArcType) Separator(javafx.scene.control.Separator) PieChart(javafx.scene.chart.PieChart) BooleanProperty(javafx.beans.property.BooleanProperty) FlowPane(javafx.scene.layout.FlowPane) VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) Genotype(htsjdk.variant.variantcontext.Genotype) CloseableIterator(htsjdk.samtools.util.CloseableIterator) OutputType(htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder.OutputType) FXCollections(javafx.collections.FXCollections) TextFlow(javafx.scene.text.TextFlow) Supplier(java.util.function.Supplier) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) TabClosingPolicy(javafx.scene.control.TabPane.TabClosingPolicy) SequenceOntologyTree(com.github.lindenb.jvarkit.util.so.SequenceOntologyTree) VCFConstants(htsjdk.variant.vcf.VCFConstants) Counter(com.github.lindenb.jvarkit.util.Counter) Color(javafx.scene.paint.Color) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) AFBySexChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.AFBySexChartFactory) File(java.io.File) Menu(javafx.scene.control.Menu) FileChooser(javafx.stage.FileChooser) Tab(javafx.scene.control.Tab) CompiledScript(javax.script.CompiledScript) AnnPredictionParserFactory(com.github.lindenb.jvarkit.util.vcf.predictions.AnnPredictionParserFactory) VCFFormatHeaderLine(htsjdk.variant.vcf.VCFFormatHeaderLine) ObservableValue(javafx.beans.value.ObservableValue) VariantTypeChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantTypeChartFactory) EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) Allele(htsjdk.variant.variantcontext.Allele) VariantContextWriterBuilder(htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder) VBox(javafx.scene.layout.VBox) AlertType(javafx.scene.control.Alert.AlertType) ContextMenu(javafx.scene.control.ContextMenu) WindowEvent(javafx.stage.WindowEvent) TableView(javafx.scene.control.TableView) Orientation(javafx.geometry.Orientation) Alert(javafx.scene.control.Alert) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) PatternSyntaxException(java.util.regex.PatternSyntaxException) MenuItem(javafx.scene.control.MenuItem) Predicate(java.util.function.Predicate) VariantQualChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.VariantQualChartFactory) GenotypeType(htsjdk.variant.variantcontext.GenotypeType) Font(javafx.scene.text.Font) Collectors(java.util.stream.Collectors) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Text(javafx.scene.text.Text) List(java.util.List) Paint(javafx.scene.paint.Paint) Term(com.github.lindenb.jvarkit.util.so.SequenceOntologyTree.Term) VCFInfoHeaderLine(htsjdk.variant.vcf.VCFInfoHeaderLine) Optional(java.util.Optional) VariantContext(htsjdk.variant.variantcontext.VariantContext) Pattern(java.util.regex.Pattern) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VCFHeaderLine(htsjdk.variant.vcf.VCFHeaderLine) Scene(javafx.scene.Scene) AnnPredictionParser(com.github.lindenb.jvarkit.util.vcf.predictions.AnnPredictionParser) ButtonType(javafx.scene.control.ButtonType) Function(java.util.function.Function) TableColumn(javafx.scene.control.TableColumn) Interval(htsjdk.samtools.util.Interval) Insets(javafx.geometry.Insets) VepPredictionParser(com.github.lindenb.jvarkit.util.vcf.predictions.VepPredictionParser) VepPredictionParserFactory(com.github.lindenb.jvarkit.util.vcf.predictions.VepPredictionParserFactory) Callback(javafx.util.Callback) GenotypeTypeChartFactory(com.github.lindenb.jvarkit.tools.vcfviewgui.chart.GenotypeTypeChartFactory) VCFFilterHeaderLine(htsjdk.variant.vcf.VCFFilterHeaderLine) Label(javafx.scene.control.Label) ActionEvent(javafx.event.ActionEvent) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) Collections(java.util.Collections) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) ObservableValue(javafx.beans.value.ObservableValue) Label(javafx.scene.control.Label) Genotype(htsjdk.variant.variantcontext.Genotype) TableColumn(javafx.scene.control.TableColumn) ObservableList(javafx.collections.ObservableList) ArrayList(java.util.ArrayList) List(java.util.List) TableView(javafx.scene.control.TableView) VCFFormatHeaderLine(htsjdk.variant.vcf.VCFFormatHeaderLine)

Aggregations

ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)59 Callback (javafx.util.Callback)52 Inject (javax.inject.Inject)49 SortedList (javafx.collections.transformation.SortedList)44 VBox (javafx.scene.layout.VBox)39 ObservableList (javafx.collections.ObservableList)37 FXML (javafx.fxml.FXML)34 TableColumn (javafx.scene.control.TableColumn)34 TableView (javafx.scene.control.TableView)34 Res (bisq.core.locale.Res)30 FxmlView (bisq.desktop.common.view.FxmlView)30 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)30 AwesomeIcon (de.jensd.fx.fontawesome.AwesomeIcon)30 TableCell (javafx.scene.control.TableCell)30 Tooltip (javafx.scene.control.Tooltip)30 HyperlinkWithIcon (bisq.desktop.components.HyperlinkWithIcon)29 ListChangeListener (javafx.collections.ListChangeListener)25 Insets (javafx.geometry.Insets)25 Coin (org.bitcoinj.core.Coin)24 GUIUtil (bisq.desktop.util.GUIUtil)23