use of javafx.scene.control.TableView in project bisq-desktop by bisq-network.
the class MyVotesView method createVoteColumns.
// /////////////////////////////////////////////////////////////////////////////////////////
// TableColumns
// /////////////////////////////////////////////////////////////////////////////////////////
private void createVoteColumns(TableView<VoteListItem> tableView) {
TableColumn<VoteListItem, VoteListItem> dateColumn = new AutoTooltipTableColumn<VoteListItem, VoteListItem>(Res.get("shared.dateTime")) {
{
setMinWidth(190);
setMaxWidth(190);
}
};
dateColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
dateColumn.setCellFactory(new Callback<TableColumn<VoteListItem, VoteListItem>, TableCell<VoteListItem, VoteListItem>>() {
@Override
public TableCell<VoteListItem, VoteListItem> call(TableColumn<VoteListItem, VoteListItem> column) {
return new TableCell<VoteListItem, VoteListItem>() {
@Override
public void updateItem(final VoteListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(bsqFormatter.formatDateTime(new Date(item.getMyVote().getDate())));
else
setText("");
}
};
}
});
dateColumn.setComparator(Comparator.comparing(o3 -> o3.getMyVote().getDate()));
dateColumn.setSortType(TableColumn.SortType.DESCENDING);
tableView.getColumns().add(dateColumn);
tableView.getSortOrder().add(dateColumn);
TableColumn<VoteListItem, VoteListItem> proposalListColumn = new AutoTooltipTableColumn<>(Res.get("dao.proposal.myVotes.proposalList"));
proposalListColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
proposalListColumn.setCellFactory(new Callback<TableColumn<VoteListItem, VoteListItem>, TableCell<VoteListItem, VoteListItem>>() {
@Override
public TableCell<VoteListItem, VoteListItem> call(TableColumn<VoteListItem, VoteListItem> column) {
return new TableCell<VoteListItem, VoteListItem>() {
@Override
public void updateItem(final VoteListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
ProposalList proposalList = item.getMyVote().getProposalList();
HyperlinkWithIcon field = new HyperlinkWithIcon(Res.get("dao.proposal.myVotes.showProposalList"), AwesomeIcon.INFO_SIGN);
field.setOnAction(event -> onShowProposalList(proposalList));
field.setTooltip(new Tooltip(Res.get("dao.proposal.myVotes.tooltip.showProposalList")));
setGraphic(field);
} else {
setGraphic(null);
}
}
};
}
});
proposalListColumn.setSortable(false);
tableView.getColumns().add(proposalListColumn);
TableColumn<VoteListItem, VoteListItem> stakeColumn = new AutoTooltipTableColumn<>(Res.get("dao.proposal.votes.stake"));
stakeColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
stakeColumn.setCellFactory(new Callback<TableColumn<VoteListItem, VoteListItem>, TableCell<VoteListItem, VoteListItem>>() {
@Override
public TableCell<VoteListItem, VoteListItem> call(TableColumn<VoteListItem, VoteListItem> column) {
return new TableCell<VoteListItem, VoteListItem>() {
@Override
public void updateItem(final VoteListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
textProperty().bind(item.getStakeAsStringProperty());
} else {
textProperty().unbind();
setText("");
}
}
};
}
});
stakeColumn.setComparator(Comparator.comparing(VoteListItem::getStake));
tableView.getColumns().add(stakeColumn);
TableColumn<VoteListItem, VoteListItem> txColumn = new AutoTooltipTableColumn<>(Res.get("dao.proposal.myVotes.tx"));
txColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
txColumn.setCellFactory(new Callback<TableColumn<VoteListItem, VoteListItem>, TableCell<VoteListItem, VoteListItem>>() {
@Override
public TableCell<VoteListItem, VoteListItem> call(TableColumn<VoteListItem, VoteListItem> column) {
return new TableCell<VoteListItem, VoteListItem>() {
@Override
public void updateItem(final VoteListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
String txId = item.getMyVote().getTxId();
HyperlinkWithIcon hyperlinkWithIcon = new HyperlinkWithIcon(txId, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon.setOnAction(event -> {
if (txId != null)
GUIUtil.openWebPage(preferences.getBlockChainExplorer().txUrl + txId);
});
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", txId)));
setGraphic(hyperlinkWithIcon);
} else {
setGraphic(null);
}
}
};
}
});
txColumn.setComparator(Comparator.comparing(o2 -> o2.getMyVote().getBlindVote().getTxId()));
tableView.getColumns().add(txColumn);
TableColumn<VoteListItem, VoteListItem> confidenceColumn = new TableColumn<>(Res.get("shared.confirmations"));
confidenceColumn.setMinWidth(130);
confidenceColumn.setMaxWidth(confidenceColumn.getMinWidth());
confidenceColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
confidenceColumn.setCellFactory(new Callback<TableColumn<VoteListItem, VoteListItem>, TableCell<VoteListItem, VoteListItem>>() {
@Override
public TableCell<VoteListItem, VoteListItem> call(TableColumn<VoteListItem, VoteListItem> column) {
return new TableCell<VoteListItem, VoteListItem>() {
@Override
public void updateItem(final VoteListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
setGraphic(item.getTxConfidenceIndicator());
} else {
setGraphic(null);
}
}
};
}
});
confidenceColumn.setComparator(Comparator.comparing(VoteListItem::getConfirmations));
tableView.getColumns().add(confidenceColumn);
}
use of javafx.scene.control.TableView in project bisq-desktop by bisq-network.
the class OfferBookView method initialize.
@Override
public void initialize() {
root.setPadding(new Insets(20, 25, 5, 25));
addTitledGroupBg(root, gridRow, 2, Res.get("offerbook.availableOffers"));
final Tuple3<HBox, AutoTooltipLabel, ComboBox> filterBoxTuple = addHBoxLabelComboBox(root, gridRow, Res.get("offerbook.filterByCurrency"), Layout.FIRST_ROW_DISTANCE);
final HBox filterBox = filterBoxTuple.first;
currencyComboBox = filterBoxTuple.third;
currencyComboBox.setPromptText(Res.get("list.currency.select"));
// noinspection unchecked
paymentMethodComboBox = new ComboBox<>();
final Label paymentMethodLabel = new AutoTooltipLabel(Res.getWithCol("offerbook.filterByPaymentMethod"));
paymentMethodLabel.setPadding(new Insets(0, 0, 0, 10));
filterBox.getChildren().addAll(paymentMethodLabel, paymentMethodComboBox);
paymentMethodComboBox.setPromptText(Res.get("shared.selectPaymentMethod"));
paymentMethodComboBox.setVisibleRowCount(20);
paymentMethodComboBox.setConverter(new StringConverter<PaymentMethod>() {
@Override
public String toString(PaymentMethod paymentMethod) {
String id = paymentMethod.getId();
if (id.equals(GUIUtil.SHOW_ALL_FLAG))
return "▶ " + Res.get("list.currency.showAll");
else if (paymentMethod.equals(PaymentMethod.BLOCK_CHAINS))
return "✦ " + Res.get(id);
else
return "★ " + Res.get(id);
}
@Override
public PaymentMethod fromString(String s) {
return null;
}
});
tableView = new TableView<>();
GridPane.setRowIndex(tableView, ++gridRow);
GridPane.setColumnIndex(tableView, 0);
GridPane.setColumnSpan(tableView, 2);
GridPane.setMargin(tableView, new Insets(10, -10, -10, -10));
GridPane.setVgrow(tableView, Priority.ALWAYS);
root.getChildren().add(tableView);
marketColumn = getMarketColumn();
priceColumn = getPriceColumn();
tableView.getColumns().add(priceColumn);
amountColumn = getAmountColumn();
tableView.getColumns().add(amountColumn);
volumeColumn = getVolumeColumn();
tableView.getColumns().add(volumeColumn);
TableColumn<OfferBookListItem, OfferBookListItem> paymentMethodColumn = getPaymentMethodColumn();
tableView.getColumns().add(paymentMethodColumn);
TableColumn<OfferBookListItem, OfferBookListItem> avatarColumn = getAvatarColumn();
tableView.getColumns().add(avatarColumn);
tableView.getColumns().add(getActionColumn());
tableView.getSortOrder().add(priceColumn);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.multipleOffers")));
placeholder.setWrapText(true);
tableView.setPlaceholder(placeholder);
marketColumn.setComparator((o1, o2) -> {
String str1 = formatter.getCurrencyPair(o1.getOffer().getCurrencyCode());
String str2 = formatter.getCurrencyPair(o2.getOffer().getCurrencyCode());
return str1 != null && str2 != null ? str1.compareTo(str2) : 0;
});
priceColumn.setComparator((o1, o2) -> {
Price price1 = o1.getOffer().getPrice();
Price price2 = o2.getOffer().getPrice();
return price1 != null && price2 != null ? price1.compareTo(price2) : 0;
});
amountColumn.setComparator(Comparator.comparing(o -> o.getOffer().getAmount()));
volumeColumn.setComparator((o1, o2) -> {
Volume offerVolume1 = o1.getOffer().getVolume();
Volume offerVolume2 = o2.getOffer().getVolume();
return offerVolume1 != null && offerVolume2 != null ? offerVolume1.compareTo(offerVolume2) : 0;
});
paymentMethodColumn.setComparator(Comparator.comparing(o -> o.getOffer().getPaymentMethod()));
avatarColumn.setComparator(Comparator.comparing(o -> o.getOffer().getOwnerNodeAddress().getFullAddress()));
nrOfOffersLabel = new AutoTooltipLabel("");
nrOfOffersLabel.setId("num-offers");
GridPane.setHalignment(nrOfOffersLabel, HPos.LEFT);
GridPane.setVgrow(nrOfOffersLabel, Priority.NEVER);
GridPane.setValignment(nrOfOffersLabel, VPos.TOP);
GridPane.setRowIndex(nrOfOffersLabel, ++gridRow);
GridPane.setColumnIndex(nrOfOffersLabel, 0);
GridPane.setMargin(nrOfOffersLabel, new Insets(10, 0, 0, -5));
root.getChildren().add(nrOfOffersLabel);
createOfferButton = addButton(root, gridRow, "");
createOfferButton.setMinHeight(40);
createOfferButton.setPadding(new Insets(0, 20, 0, 20));
createOfferButton.setGraphicTextGap(10);
GridPane.setMargin(createOfferButton, new Insets(15, 0, 0, 0));
GridPane.setHalignment(createOfferButton, HPos.RIGHT);
GridPane.setVgrow(createOfferButton, Priority.NEVER);
GridPane.setValignment(createOfferButton, VPos.TOP);
offerListListener = c -> nrOfOffersLabel.setText(Res.get("offerbook.nrOffers", model.getOfferList().size()));
// Fixes incorrect ordering of Available offers:
// https://github.com/bisq-network/exchange/issues/588
priceFeedUpdateCounterListener = (observable, oldValue, newValue) -> tableView.sort();
}
use of javafx.scene.control.TableView in project bisq-desktop by bisq-network.
the class OfferBookChartView method getOfferTable.
private Tuple4<TableView<OfferListItem>, VBox, Button, Label> getOfferTable(OfferPayload.Direction direction) {
TableView<OfferListItem> tableView = new TableView<>();
tableView.setMinHeight(initialOfferTableViewHeight);
tableView.setPrefHeight(121);
tableView.setMinWidth(480);
tableView.getStyleClass().add("offer-table");
// price
TableColumn<OfferListItem, OfferListItem> priceColumn = new TableColumn<>();
priceColumn.textProperty().bind(priceColumnLabel);
priceColumn.setMinWidth(115);
priceColumn.setMaxWidth(115);
priceColumn.setSortable(false);
priceColumn.getStyleClass().add("number-column");
priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
priceColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
@Override
public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
return new TableCell<OfferListItem, OfferListItem>() {
private Offer offer;
final ChangeListener<Number> listener = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (offer != null && offer.getPrice() != null) {
setText("");
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getPrice(offer), model.getZeroDecimalsForPrice(offer)));
model.priceFeedService.updateCounterProperty().removeListener(listener);
}
}
};
@Override
public void updateItem(final OfferListItem offerListItem, boolean empty) {
super.updateItem(offerListItem, empty);
if (offerListItem != null && !empty) {
final Offer offer = offerListItem.offer;
if (offer.getPrice() == null) {
this.offer = offer;
model.priceFeedService.updateCounterProperty().addListener(listener);
setText(Res.get("shared.na"));
} else {
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getPrice(offer), model.getZeroDecimalsForPrice(offer)));
}
} else {
if (listener != null)
model.priceFeedService.updateCounterProperty().removeListener(listener);
this.offer = null;
setText("");
setGraphic(null);
}
}
};
}
});
// volume
TableColumn<OfferListItem, OfferListItem> volumeColumn = new TableColumn<>();
volumeColumn.setMinWidth(115);
volumeColumn.setSortable(false);
volumeColumn.textProperty().bind(volumeColumnLabel);
volumeColumn.getStyleClass().add("number-column");
volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
volumeColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
@Override
public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
return new TableCell<OfferListItem, OfferListItem>() {
private Offer offer;
final ChangeListener<Number> listener = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (offer != null && offer.getPrice() != null) {
setText("");
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offer), model.getMaxNumberOfPriceZeroDecimalsToColorize(offer)));
model.priceFeedService.updateCounterProperty().removeListener(listener);
}
}
};
@Override
public void updateItem(final OfferListItem offerListItem, boolean empty) {
super.updateItem(offerListItem, empty);
if (offerListItem != null && !empty) {
this.offer = offerListItem.offer;
if (offer.getPrice() == null) {
this.offer = offerListItem.offer;
model.priceFeedService.updateCounterProperty().addListener(listener);
setText(Res.get("shared.na"));
} else {
setText("");
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offer), model.getMaxNumberOfPriceZeroDecimalsToColorize(offer)));
}
} else {
if (listener != null)
model.priceFeedService.updateCounterProperty().removeListener(listener);
this.offer = null;
setText("");
setGraphic(null);
}
}
};
}
});
// amount
TableColumn<OfferListItem, OfferListItem> amountColumn = new AutoTooltipTableColumn<>(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode()));
amountColumn.setMinWidth(115);
amountColumn.setSortable(false);
amountColumn.getStyleClass().add("number-column");
amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
amountColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
@Override
public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
return new TableCell<OfferListItem, OfferListItem>() {
@Override
public void updateItem(final OfferListItem offerListItem, boolean empty) {
super.updateItem(offerListItem, empty);
if (offerListItem != null && !empty) {
setGraphic(new ColoredDecimalPlacesWithZerosText(formatter.formatCoin(offerListItem.offer.getAmount(), 4), GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
} else {
setGraphic(null);
}
}
};
}
});
tableView.getColumns().add(volumeColumn);
tableView.getColumns().add(amountColumn);
tableView.getColumns().add(priceColumn);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.multipleOffers")));
placeholder.setWrapText(true);
tableView.setPlaceholder(placeholder);
Label titleLabel = new AutoTooltipLabel();
titleLabel.getStyleClass().add("table-title");
UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty()));
boolean isSellOffer = direction == OfferPayload.Direction.SELL;
Button button = new AutoTooltipButton();
ImageView iconView = new ImageView();
iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
button.setGraphic(iconView);
button.setGraphicTextGap(10);
button.setText(isSellOffer ? Res.get("market.offerBook.buy") : Res.get("market.offerBook.sell"));
button.setMinHeight(40);
button.setId(isSellOffer ? "buy-button-big" : "sell-button-big");
button.setOnAction(e -> {
if (isSellOffer) {
model.preferences.setBuyScreenCurrencyCode(model.getCurrencyCode());
// noinspection unchecked
navigation.navigateTo(MainView.class, BuyOfferView.class);
} else {
model.preferences.setSellScreenCurrencyCode(model.getCurrencyCode());
// noinspection unchecked
navigation.navigateTo(MainView.class, SellOfferView.class);
}
});
VBox vBox = new VBox();
vBox.setSpacing(10);
vBox.setFillWidth(true);
vBox.setMinHeight(190);
vBox.setVgrow(tableView, Priority.ALWAYS);
vBox.getChildren().addAll(titleLabel, tableView, button);
button.prefWidthProperty().bind(vBox.widthProperty());
return new Tuple4<>(tableView, vBox, button, titleLabel);
}
use of javafx.scene.control.TableView in project org.csstudio.display.builder by kasemir.
the class RulesDialog method createRulesTable.
/**
* @return Node for UI elements that edit the rules
*/
private Node createRulesTable() {
// Create table with editable rule 'name' column
final TableColumn<RuleItem, String> name_col = new TableColumn<>(Messages.RulesDialog_ColName);
name_col.setCellValueFactory(new PropertyValueFactory<RuleItem, String>("name"));
name_col.setCellFactory(list -> new TextFieldTableCell<RuleItem, String>(new DefaultStringConverter()) {
private final ChangeListener<? super Boolean> focusedListener = (ob, o, n) -> {
if (!n)
cancelEdit();
};
@Override
public void cancelEdit() {
((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
super.cancelEdit();
}
@Override
public void commitEdit(final String newValue) {
((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
super.commitEdit(newValue);
Platform.runLater(() -> btn_add_pv.requestFocus());
}
@Override
public void startEdit() {
super.startEdit();
((TextField) getGraphic()).focusedProperty().addListener(focusedListener);
}
});
name_col.setOnEditCommit(event -> {
final int row = event.getTablePosition().getRow();
rule_items.get(row).name.set(event.getNewValue());
fixupRules(row);
});
rules_table = new TableView<>(rule_items);
rules_table.getColumns().add(name_col);
rules_table.setEditable(true);
rules_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
rules_table.setTooltip(new Tooltip(Messages.RulesDialog_RulesTT));
rules_table.setPlaceholder(new Label(Messages.RulesDialog_NoRules));
// Buttons
btn_add_rule = new Button(Messages.Add, JFXUtil.getIcon("add.png"));
btn_add_rule.setMaxWidth(Double.MAX_VALUE);
btn_add_rule.setAlignment(Pos.CENTER_LEFT);
btn_add_rule.setOnAction(event -> {
final RuleItem newItem = new RuleItem(attached_widget, selected_rule_item == null ? ((propinfo_ls.size() == 0) ? "" : propinfo_ls.get(0).getPropID()) : selected_rule_item.prop_id.get());
rule_items.add(newItem);
rules_table.getSelectionModel().select(newItem);
final int newRow = rules_table.getSelectionModel().getSelectedIndex();
ModelThreadPool.getTimer().schedule(() -> {
Platform.runLater(() -> rules_table.edit(newRow, name_col));
}, 123, TimeUnit.MILLISECONDS);
});
btn_remove_rule = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
btn_remove_rule.setMaxWidth(Double.MAX_VALUE);
btn_remove_rule.setAlignment(Pos.CENTER_LEFT);
btn_remove_rule.setDisable(true);
btn_remove_rule.setOnAction(event -> {
final int sel = rules_table.getSelectionModel().getSelectedIndex();
if (sel >= 0) {
rule_items.remove(sel);
fixupRules(sel);
}
});
btn_move_rule_up = new Button(Messages.MoveUp, JFXUtil.getIcon("up.png"));
btn_move_rule_up.setMaxWidth(Double.MAX_VALUE);
btn_move_rule_up.setAlignment(Pos.CENTER_LEFT);
btn_move_rule_up.setDisable(true);
btn_move_rule_up.setOnAction(event -> TableHelper.move_item_up(rules_table, rule_items));
btn_move_rule_down = new Button(Messages.MoveDown, JFXUtil.getIcon("down.png"));
btn_move_rule_down.setMaxWidth(Double.MAX_VALUE);
btn_move_rule_down.setAlignment(Pos.CENTER_LEFT);
btn_move_rule_down.setDisable(true);
btn_move_rule_down.setOnAction(event -> TableHelper.move_item_down(rules_table, rule_items));
btn_dup_rule = new Button(Messages.Duplicate, JFXUtil.getIcon("file-duplicate.png"));
btn_dup_rule.setMaxWidth(Double.MAX_VALUE);
btn_dup_rule.setAlignment(Pos.CENTER_LEFT);
btn_dup_rule.setDisable(true);
btn_dup_rule.setOnAction(event -> {
if (selected_rule_item != null) {
final RuleItem newItem = RuleItem.forInfo(attached_widget, selected_rule_item.getRuleInfo(), undo);
if (!newItem.nameProperty().get().endsWith(" (duplicate)"))
newItem.nameProperty().set(newItem.nameProperty().get() + " (duplicate)");
rule_items.add(newItem);
rules_table.getSelectionModel().select(newItem);
final int newRow = rules_table.getSelectionModel().getSelectedIndex();
ModelThreadPool.getTimer().schedule(() -> {
Platform.runLater(() -> rules_table.edit(newRow, name_col));
}, 123, TimeUnit.MILLISECONDS);
}
});
btn_show_script = new Button(Messages.RulesDialog_ShowScript, JFXUtil.getIcon("file.png"));
btn_show_script.setMaxWidth(Double.MAX_VALUE);
btn_show_script.setMinWidth(120);
btn_dup_rule.setAlignment(Pos.CENTER_LEFT);
btn_show_script.setDisable(true);
btn_show_script.setOnAction(event -> {
final int sel = rules_table.getSelectionModel().getSelectedIndex();
if (sel >= 0) {
final String content = rule_items.get(sel).getRuleInfo().getTextPy(attached_widget);
final SyntaxHighlightedMultiLineInputDialog dialog = new SyntaxHighlightedMultiLineInputDialog(btn_show_script, content, Language.Python, false);
DialogHelper.positionDialog(dialog, btn_show_script, -200, -300);
dialog.setTextHeight(600);
dialog.show();
}
});
final VBox buttons = new VBox(10, btn_add_rule, btn_remove_rule, btn_move_rule_up, btn_move_rule_down, new Pane(), btn_dup_rule, btn_show_script);
final HBox content = new HBox(10, rules_table, buttons);
HBox.setHgrow(rules_table, Priority.ALWAYS);
HBox.setHgrow(buttons, Priority.NEVER);
return content;
}
use of javafx.scene.control.TableView in project org.csstudio.display.builder by kasemir.
the class WidgetInfoDialog method createProperties.
private Tab createProperties(final Widget widget) {
// Use text field to allow copying the name (for use in scripts)
// and value, but not the localized description and category
// which are just for information
final TableColumn<WidgetProperty<?>, String> cat = new TableColumn<>(Messages.WidgetInfoDialog_Category);
cat.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getCategory().getDescription()));
final TableColumn<WidgetProperty<?>, String> descr = new TableColumn<>(Messages.WidgetInfoDialog_Property);
descr.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getDescription()));
final TableColumn<WidgetProperty<?>, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
name.setCellFactory(TextFieldTableCell.forTableColumn());
name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getName()));
final TableColumn<WidgetProperty<?>, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
value.setCellFactory(TextFieldTableCell.forTableColumn());
value.setCellValueFactory(param -> new ReadOnlyStringWrapper(Objects.toString(param.getValue().getValue())));
final TableView<WidgetProperty<?>> table = new TableView<>(FXCollections.observableArrayList(widget.getProperties()));
table.getColumns().add(cat);
table.getColumns().add(descr);
table.getColumns().add(name);
table.getColumns().add(value);
table.setEditable(true);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
return new Tab(Messages.WidgetInfoDialog_TabProperties, table);
}
Aggregations