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);
}
}
};
}
});
}
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);
}
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) {
}
}
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());
}
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();
}
Aggregations