Search in sources :

Example 26 with ReadOnlyObjectWrapper

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

the class FailedTradesView method setTradeIdColumnCellFactory.

private void setTradeIdColumnCellFactory() {
    tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
    tradeIdColumn.setCellFactory(new Callback<TableColumn<FailedTradesListItem, FailedTradesListItem>, TableCell<FailedTradesListItem, FailedTradesListItem>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final FailedTradesListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        field = new HyperlinkWithIcon(model.getTradeId(item));
                        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 : TradeDetailsWindow(bisq.desktop.main.overlays.windows.TradeDetailsWindow) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) VBox(javafx.scene.layout.VBox) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) FXML(javafx.fxml.FXML) TableCell(javafx.scene.control.TableCell) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Res(bisq.core.locale.Res) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) SortedList(javafx.collections.transformation.SortedList) TableCell(javafx.scene.control.TableCell) Tooltip(javafx.scene.control.Tooltip) TableColumn(javafx.scene.control.TableColumn) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon)

Example 27 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project blue by kunstmusik.

the class ParameterLineView method editPoints.

private void editPoints() {
    TableView<LinePoint> table = new TableView<>();
    TableColumn<LinePoint, Double> xCol = new TableColumn<>("x");
    TableColumn<LinePoint, Double> yCol = new TableColumn<>("y");
    table.getColumns().setAll(xCol, yCol);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setItems(getSelectedLine().getObservableList());
    table.setEditable(true);
    xCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<LinePoint, Double>, ObservableValue<Double>>() {

        @Override
        public ObservableValue<Double> call(TableColumn.CellDataFeatures<LinePoint, Double> param) {
            return new ReadOnlyObjectWrapper<>(param.getValue().getX() * getDuration() + getStartTime());
        }
    });
    xCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    xCol.setOnEditCommit(te -> {
        LinePoint lp = te.getRowValue();
        ObservableList<LinePoint> lpList = getSelectedLine().getObservableList();
        if (getSelectedLine().getLinePoint(0) == lp || getSelectedLine().getLinePoint(getSelectedLine().size() - 1) == lp) {
            return;
        }
        int index = lpList.indexOf(lp);
        double v = (te.getNewValue() - getStartTime()) / getDuration();
        lp.setX(Utils.clamp(lpList.get(index - 1).getX(), v, lpList.get(index + 1).getX()));
    });
    xCol.setEditable(true);
    yCol.setCellValueFactory(new PropertyValueFactory<>("y"));
    yCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    yCol.setOnEditCommit(te -> {
        te.getRowValue().setY(Utils.clamp(getSelectedLine().getMin(), te.getNewValue(), getSelectedLine().getMax()));
    });
    yCol.setEditable(true);
    Dialog<ButtonType> d = new Dialog<>();
    d.initOwner(getScene().getWindow());
    d.initModality(Modality.APPLICATION_MODAL);
    d.getDialogPane().setContent(new ScrollPane(table));
    d.getDialogPane().getStylesheets().add(BlueFX.getBlueFxCss());
    d.getDialogPane().getButtonTypes().setAll(ButtonType.OK);
    d.setTitle("Edit Points");
    TableModelListener tml = tme -> {
        repaint();
    };
    getSelectedLine().addTableModelListener(tml);
    Optional<ButtonType> res = d.showAndWait();
    getSelectedLine().removeTableModelListener(tml);
}
Also used : DoubleStringConverter(javafx.util.converter.DoubleStringConverter) NumberUtilities(blue.utility.NumberUtilities) ButtonType(javafx.scene.control.ButtonType) LineList(blue.components.lines.LineList) Glow(javafx.scene.effect.Glow) MouseEvent(javafx.scene.input.MouseEvent) DoubleProperty(javafx.beans.property.DoubleProperty) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) TableModelListener(javax.swing.event.TableModelListener) LinePoint(blue.components.lines.LinePoint) TableColumn(javafx.scene.control.TableColumn) DragDirection(blue.components.DragDirection) Utils(org.controlsfx.tools.Utils) BlueFX(blue.jfx.BlueFX) ScrollPane(javafx.scene.control.ScrollPane) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) ContextMenu(javafx.scene.control.ContextMenu) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) Modality(javafx.stage.Modality) Dialog(javafx.scene.control.Dialog) MenuItem(javafx.scene.control.MenuItem) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) GraphicsContext(javafx.scene.canvas.GraphicsContext) Canvas(javafx.scene.canvas.Canvas) Line(blue.components.lines.Line) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Optional(java.util.Optional) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) DoubleStringConverter(javafx.util.converter.DoubleStringConverter) ObservableValue(javafx.beans.value.ObservableValue) TableColumn(javafx.scene.control.TableColumn) LinePoint(blue.components.lines.LinePoint) LinePoint(blue.components.lines.LinePoint) Dialog(javafx.scene.control.Dialog) ScrollPane(javafx.scene.control.ScrollPane) TableModelListener(javax.swing.event.TableModelListener) ButtonType(javafx.scene.control.ButtonType) TableView(javafx.scene.control.TableView)

Example 28 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project JFoenix by jfoenixadmin.

the class JFXDatePicker method initialize.

private void initialize() {
    this.getStyleClass().add(DEFAULT_STYLE_CLASS);
    try {
        editorProperty();
        Field editorField = DatePicker.class.getDeclaredField("editor");
        editorField.setAccessible(true);
        ReadOnlyObjectWrapper<TextField> editor = (ReadOnlyObjectWrapper<TextField>) editorField.get(this);
        final FakeFocusJFXTextField editorNode = new FakeFocusJFXTextField();
        this.focusedProperty().addListener((obj, oldVal, newVal) -> {
            if (getEditor() != null) {
                editorNode.setFakeFocus(newVal);
            }
        });
        editorNode.activeValidatorWritableProperty().bind(activeValidatorProperty());
        editor.set(editorNode);
    } catch (NoSuchFieldException e) {
    } catch (IllegalAccessException e) {
    }
}
Also used : TextField(javafx.scene.control.TextField) Field(java.lang.reflect.Field) TextField(javafx.scene.control.TextField) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper)

Example 29 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project Retrospector by NonlinearFruit.

the class ListsTabController method initListTab.

private void initListTab() {
    // Include
    for (String category : DataManager.getCategories()) {
        Stroolean c = new Stroolean(category);
        c.booleanProperty().addListener((observe, old, neo) -> updateListTab());
        strooleans.add(c);
        listIncludeList.getItems().add(c);
    }
    listIncludeList.setCellFactory(CheckBoxListCell.forListView(Stroolean::booleanProperty));
    listIncludeList.setOnMouseClicked(e -> {
        if (e.getClickCount() == 2) {
            Stroolean me = listIncludeList.getSelectionModel().getSelectedItem();
            for (Stroolean stroolean : strooleans) {
                stroolean.setBoolean(false);
            }
            me.setBoolean(true);
        }
    });
    // Group By
    listGroupCreator.setSelected(true);
    listGroupCreator.selectedProperty().addListener((observe, old, neo) -> {
        if (neo) {
        // Nothing to select, top of the food chain
        } else {
            listGroupTitle.setSelected(false);
            listGroupSeason.setSelected(false);
            listGroupEpisode.setSelected(false);
        }
        updateListTab();
    });
    listGroupTitle.selectedProperty().addListener((observe, old, neo) -> {
        if (neo) {
            listGroupCreator.setSelected(true);
        } else {
            listGroupSeason.setSelected(false);
            listGroupEpisode.setSelected(false);
        }
        updateListTab();
    });
    listGroupSeason.selectedProperty().addListener((observe, old, neo) -> {
        if (neo) {
            listGroupCreator.setSelected(true);
            listGroupTitle.setSelected(true);
        } else {
            listGroupEpisode.setSelected(false);
        }
        updateListTab();
    });
    listGroupEpisode.selectedProperty().addListener((observe, old, neo) -> {
        if (neo) {
            listGroupCreator.setSelected(true);
            listGroupTitle.setSelected(true);
            listGroupSeason.setSelected(true);
        } else {
        // Nothing to deselect, bottom of the food chain
        }
        updateListTab();
    });
    // Top 10/0/0
    listTop10.setSelected(true);
    listTop10.selectedProperty().addListener((observe, old, neo) -> {
        updateListTab();
        if (neo) {
            listTop25.setSelected(false);
            listTop50.setSelected(false);
            listTop100.setSelected(false);
            listTop500.setSelected(false);
            listTop1000.setSelected(false);
        }
    });
    listTop25.selectedProperty().addListener((observe, old, neo) -> {
        updateListTab();
        if (neo) {
            listTop10.setSelected(false);
            listTop50.setSelected(false);
            listTop100.setSelected(false);
            listTop500.setSelected(false);
            listTop1000.setSelected(false);
        }
    });
    listTop50.selectedProperty().addListener((observe, old, neo) -> {
        updateListTab();
        if (neo) {
            listTop10.setSelected(false);
            listTop25.setSelected(false);
            listTop100.setSelected(false);
            listTop500.setSelected(false);
            listTop1000.setSelected(false);
        }
    });
    listTop100.selectedProperty().addListener((observe, old, neo) -> {
        updateListTab();
        if (neo) {
            listTop10.setSelected(false);
            listTop25.setSelected(false);
            listTop50.setSelected(false);
            listTop500.setSelected(false);
            listTop1000.setSelected(false);
        }
    });
    listTop500.selectedProperty().addListener((observe, old, neo) -> {
        updateListTab();
        if (neo) {
            listTop10.setSelected(false);
            listTop25.setSelected(false);
            listTop50.setSelected(false);
            listTop100.setSelected(false);
            listTop1000.setSelected(false);
        }
    });
    listTop1000.selectedProperty().addListener((observe, old, neo) -> {
        updateListTab();
        if (neo) {
            listTop10.setSelected(false);
            listTop25.setSelected(false);
            listTop50.setSelected(false);
            listTop100.setSelected(false);
            listTop500.setSelected(false);
        }
    });
    // Dates
    listYear.setText(String.valueOf(LocalDate.now().getYear()));
    listYear.setOnAction(e -> updateListTab());
    listStartDate.setValue(LocalDate.now().withMonth(1).withDayOfMonth(1));
    listStartDate.valueProperty().addListener((observe, old, neo) -> updateListTab());
    listEndDate.setValue(LocalDate.now().withMonth(12).withDayOfMonth(31));
    listEndDate.valueProperty().addListener((observe, old, neo) -> updateListTab());
    listUseAllTime.selectedProperty().addListener((observe, old, neo) -> updateListTab());
    listUseYear.selectedProperty().addListener((observe, old, neo) -> updateListTab());
    listCustomDateRange.selectedProperty().addListener((observe, old, neo) -> updateListTab());
    //  - Enable/Disble
    dateToggleGroup.getToggles().addAll(listUseYear, listUseAllTime, listCustomDateRange);
    dateToggleGroup.selectToggle(listUseAllTime);
    listYear.disableProperty().bind(Bindings.not(listUseYear.selectedProperty()));
    listStartDate.disableProperty().bind(Bindings.not(listCustomDateRange.selectedProperty()));
    listEndDate.disableProperty().bind(Bindings.not(listCustomDateRange.selectedProperty()));
    // User
    listUser.setText(DataManager.getDefaultUser());
    listUser.setOnAction(e -> updateListTab());
    // Table
    listTable.setItems(listTableData);
    // Link to Properties
    listTitleColumn.setCellValueFactory(new PropertyValueFactory<>("Title"));
    listCreatorColumn.setCellValueFactory(new PropertyValueFactory<>("Creator"));
    listSeasonColumn.setCellValueFactory(new PropertyValueFactory<>("SeasonId"));
    listEpisodeColumn.setCellValueFactory(new PropertyValueFactory<>("EpisodeId"));
    listCategoryColumn.setCellValueFactory(new PropertyValueFactory<>("Category"));
    // Special Table Cells
    listReviewsColumn.setCellValueFactory(p -> new ReadOnlyObjectWrapper(p.getValue().getReviews().size()));
    listRatingColumn.setCellValueFactory(p -> new ReadOnlyObjectWrapper(p.getValue().getAverageRating()));
    // Comparors for string columns
    listTitleColumn.setComparator(new NaturalOrderComparator());
    listCreatorColumn.setComparator(new NaturalOrderComparator());
    listSeasonColumn.setComparator(new NaturalOrderComparator());
    listEpisodeColumn.setComparator(new NaturalOrderComparator());
    listCategoryColumn.setComparator(new NaturalOrderComparator());
}
Also used : Stroolean(retrospector.util.Stroolean) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) NaturalOrderComparator(retrospector.util.NaturalOrderComparator)

Example 30 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project Gargoyle by callakrsos.

the class FilterTableExample method start.

@Override
public void start(Stage primaryStage) throws Exception {
    TableView<DataItem> tableView = new TableView<>();
    FxUtil.installClipboardKeyEvent(tableView);
    tableView.setItems(FXCollections.observableArrayList());
    IntStream.range(0, 20000).mapToObj(i -> new DataItem()).forEach(d -> tableView.getItems().add(d));
    TableColumn<DataItem, Integer> smallInt = new TableColumn<>("Small Int");
    smallInt.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getSmallIntValue()));
    TableColumn<DataItem, Integer> largeInt = new TableColumn<>("Large Int");
    largeInt.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getLargeIntValue()));
    TableColumn<DataItem, String> randomLetter = new TableColumn<>("Letter");
    randomLetter.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomLetter()));
    TableColumn<DataItem, String> randomString1 = new TableColumn<>("AlphaNum 1");
    randomString1.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomStr1()));
    TableColumn<DataItem, String> randomString2 = new TableColumn<>("AlphaNum 2");
    randomString1.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomStr2()));
    tableView.getColumns().addAll(smallInt, largeInt, randomLetter, randomString1, randomString2);
    Platform.runLater(() -> new TableFilter<>(tableView));
    GridPane grp = new GridPane();
    GridPane.setFillHeight(tableView, true);
    GridPane.setFillWidth(tableView, true);
    GridPane.setHgrow(tableView, Priority.ALWAYS);
    GridPane.setVgrow(tableView, Priority.ALWAYS);
    grp.getChildren().add(tableView);
    Scene scene = new Scene(grp);
    primaryStage.setScene(scene);
    primaryStage.show();
}
Also used : IntStream(java.util.stream.IntStream) Scene(javafx.scene.Scene) FXCollections(javafx.collections.FXCollections) Random(java.util.Random) UUID(java.util.UUID) TableColumn(javafx.scene.control.TableColumn) Application(javafx.application.Application) Platform(javafx.application.Platform) Priority(javafx.scene.layout.Priority) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Stage(javafx.stage.Stage) TableFilter(org.controlsfx.control.table.TableFilter) TableView(javafx.scene.control.TableView) GridPane(javafx.scene.layout.GridPane) GridPane(javafx.scene.layout.GridPane) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) TableView(javafx.scene.control.TableView)

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