use of javafx.scene.control.TextField in project bisq-desktop by bisq-network.
the class TakeOfferView method addAmountPriceFields.
private void addAmountPriceFields() {
// amountBox
Tuple3<HBox, InputTextField, Label> amountValueCurrencyBoxTuple = getAmountCurrencyBox(Res.get("takeOffer.amount.prompt"));
HBox amountValueCurrencyBox = amountValueCurrencyBoxTuple.first;
amountTextField = amountValueCurrencyBoxTuple.second;
amountCurrency = amountValueCurrencyBoxTuple.third;
Tuple2<Label, VBox> amountInputBoxTuple = getTradeInputBox(amountValueCurrencyBox, model.getAmountDescription());
amountDescriptionLabel = amountInputBoxTuple.first;
VBox amountBox = amountInputBoxTuple.second;
// x
Label xLabel = new AutoTooltipLabel("x");
xLabel.setFont(Font.font("Helvetica-Bold", 20));
xLabel.setPadding(new Insets(14, 3, 0, 3));
// price
Tuple3<HBox, TextField, Label> priceValueCurrencyBoxTuple = getNonEditableValueCurrencyBox();
HBox priceValueCurrencyBox = priceValueCurrencyBoxTuple.first;
priceTextField = priceValueCurrencyBoxTuple.second;
priceCurrencyLabel = priceValueCurrencyBoxTuple.third;
Tuple2<Label, VBox> priceInputBoxTuple = getTradeInputBox(priceValueCurrencyBox, Res.get("takeOffer.amountPriceBox.priceDescription"));
priceDescriptionLabel = priceInputBoxTuple.first;
VBox priceBox = priceInputBoxTuple.second;
// =
Label resultLabel = new AutoTooltipLabel("=");
resultLabel.setFont(Font.font("Helvetica-Bold", 20));
resultLabel.setPadding(new Insets(14, 2, 0, 2));
// volume
Tuple3<HBox, TextField, Label> volumeValueCurrencyBoxTuple = getNonEditableValueCurrencyBox();
HBox volumeValueCurrencyBox = volumeValueCurrencyBoxTuple.first;
volumeTextField = volumeValueCurrencyBoxTuple.second;
volumeCurrencyLabel = volumeValueCurrencyBoxTuple.third;
Tuple2<Label, VBox> volumeInputBoxTuple = getTradeInputBox(volumeValueCurrencyBox, model.volumeDescriptionLabel.get());
volumeDescriptionLabel = volumeInputBoxTuple.first;
VBox volumeBox = volumeInputBoxTuple.second;
HBox hBox = new HBox();
hBox.setSpacing(5);
hBox.setAlignment(Pos.CENTER_LEFT);
hBox.getChildren().addAll(amountBox, xLabel, priceBox, resultLabel, volumeBox);
GridPane.setRowIndex(hBox, gridRow);
GridPane.setColumnIndex(hBox, 1);
GridPane.setMargin(hBox, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, 10, 0, 0));
GridPane.setColumnSpan(hBox, 2);
gridPane.getChildren().add(hBox);
}
use of javafx.scene.control.TextField in project bisq-desktop by bisq-network.
the class TradeDetailsWindow method addContent.
private void addContent() {
Offer offer = trade.getOffer();
Contract contract = trade.getContract();
int rows = 5;
addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("tradeDetailsWindow.headline"));
boolean myOffer = tradeManager.isMyOffer(offer);
String fiatDirectionInfo;
String btcDirectionInfo;
String toReceive = " " + Res.get("shared.toReceive");
String toSpend = " " + Res.get("shared.toSpend");
String offerType = Res.getWithCol("shared.offerType");
if (tradeManager.isBuyer(offer)) {
addLabelTextField(gridPane, rowIndex, offerType, formatter.getDirectionForBuyer(myOffer, offer.getCurrencyCode()), Layout.FIRST_ROW_DISTANCE);
fiatDirectionInfo = toSpend;
btcDirectionInfo = toReceive;
} else {
addLabelTextField(gridPane, rowIndex, offerType, formatter.getDirectionForSeller(myOffer, offer.getCurrencyCode()), Layout.FIRST_ROW_DISTANCE);
fiatDirectionInfo = toReceive;
btcDirectionInfo = toSpend;
}
addLabelTextField(gridPane, ++rowIndex, Res.get("shared.btcAmount") + btcDirectionInfo, formatter.formatCoinWithCode(trade.getTradeAmount()));
addLabelTextField(gridPane, ++rowIndex, formatter.formatVolumeLabel(offer.getCurrencyCode()) + fiatDirectionInfo, formatter.formatVolumeWithCode(trade.getTradeVolume()));
addLabelTextField(gridPane, ++rowIndex, Res.get("shared.tradePrice"), formatter.formatPrice(trade.getTradePrice()));
addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.paymentMethod"), Res.get(offer.getPaymentMethod().getId()));
// second group
rows = 6;
PaymentAccountPayload buyerPaymentAccountPayload = null;
PaymentAccountPayload sellerPaymentAccountPayload = null;
if (contract != null) {
rows++;
buyerPaymentAccountPayload = contract.getBuyerPaymentAccountPayload();
sellerPaymentAccountPayload = contract.getSellerPaymentAccountPayload();
if (buyerPaymentAccountPayload != null)
rows++;
if (sellerPaymentAccountPayload != null)
rows++;
if (buyerPaymentAccountPayload == null && sellerPaymentAccountPayload == null)
rows++;
}
if (trade.getTakerFeeTxId() != null)
rows++;
if (trade.getDepositTx() != null)
rows++;
if (trade.getPayoutTx() != null)
rows++;
boolean showDisputedTx = disputeManager.findOwnDispute(trade.getId()).isPresent() && disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId() != null;
if (showDisputedTx)
rows++;
if (trade.hasFailed())
rows += 2;
if (trade.getTradingPeerNodeAddress() != null)
rows++;
addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("shared.details"), Layout.GROUP_DISTANCE);
addLabelTextFieldWithCopyIcon(gridPane, rowIndex, Res.get("shared.tradeId"), trade.getId(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradeDate"), formatter.formatDateTime(trade.getDate()));
String securityDeposit = Res.getWithColAndCap("shared.buyer") + " " + formatter.formatCoinWithCode(offer.getBuyerSecurityDeposit()) + " / " + Res.getWithColAndCap("shared.seller") + " " + formatter.formatCoinWithCode(offer.getSellerSecurityDeposit());
addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.securityDeposit"), securityDeposit);
String txFee = Res.get("shared.makerTxFee", formatter.formatCoinWithCode(offer.getTxFee())) + " / " + Res.get("shared.takerTxFee", formatter.formatCoinWithCode(offer.getTxFee().multiply(3L)));
addLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.txFee"), txFee);
if (trade.getArbitratorNodeAddress() != null)
addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.arbitrator"), trade.getArbitratorNodeAddress().getFullAddress());
if (trade.getTradingPeerNodeAddress() != null)
addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradingPeersOnion"), trade.getTradingPeerNodeAddress().getFullAddress());
if (contract != null) {
if (buyerPaymentAccountPayload != null) {
TextFieldWithCopyIcon tf = addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.paymentDetails", Res.get("shared.buyer")), buyerPaymentAccountPayload.getPaymentDetails()).second;
tf.setTooltip(new Tooltip(tf.getText()));
}
if (sellerPaymentAccountPayload != null) {
TextFieldWithCopyIcon tf = addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.paymentDetails", Res.get("shared.seller")), sellerPaymentAccountPayload.getPaymentDetails()).second;
tf.setTooltip(new Tooltip(tf.getText()));
}
if (buyerPaymentAccountPayload == null && sellerPaymentAccountPayload == null)
addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.paymentMethod"), Res.get(contract.getPaymentMethodId()));
}
addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.makerFeeTxId"), offer.getOfferFeePaymentTxId());
if (trade.getTakerFeeTxId() != null)
addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.takerFeeTxId"), trade.getTakerFeeTxId());
if (trade.getDepositTx() != null)
addLabelTxIdTextField(gridPane, ++rowIndex, Res.getWithCol("shared.depositTransactionId"), trade.getDepositTx().getHashAsString());
if (trade.getPayoutTx() != null)
addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.payoutTxId"), trade.getPayoutTx().getHashAsString());
if (showDisputedTx)
addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.disputedPayoutTxId"), disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId());
if (contract != null) {
Button viewContractButton = addLabelButton(gridPane, ++rowIndex, Res.get("shared.contractAsJson"), Res.get("shared.viewContractAsJson"), 0).second;
viewContractButton.setDefaultButton(false);
viewContractButton.setOnAction(e -> {
TextArea textArea = new TextArea();
textArea.setText(trade.getContractAsJson());
String contractAsJson = trade.getContractAsJson();
contractAsJson += "\n\nBuyerMultiSigPubKeyHex: " + Utils.HEX.encode(contract.getBuyerMultiSigPubKey());
contractAsJson += "\nSellerMultiSigPubKeyHex: " + Utils.HEX.encode(contract.getSellerMultiSigPubKey());
textArea.setText(contractAsJson);
textArea.setPrefHeight(50);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setPrefSize(800, 600);
Scene viewContractScene = new Scene(textArea);
Stage viewContractStage = new Stage();
viewContractStage.setTitle(Res.get("shared.contract.title", trade.getShortId()));
viewContractStage.setScene(viewContractScene);
if (owner == null)
owner = MainView.getRootContainer();
Scene rootScene = owner.getScene();
viewContractStage.initOwner(rootScene.getWindow());
viewContractStage.initModality(Modality.NONE);
viewContractStage.initStyle(StageStyle.UTILITY);
viewContractStage.show();
Window window = rootScene.getWindow();
double titleBarHeight = window.getHeight() - rootScene.getHeight();
viewContractStage.setX(Math.round(window.getX() + (owner.getWidth() - viewContractStage.getWidth()) / 2) + 200);
viewContractStage.setY(Math.round(window.getY() + titleBarHeight + (owner.getHeight() - viewContractStage.getHeight()) / 2) + 50);
});
}
if (trade.hasFailed()) {
textArea = addLabelTextArea(gridPane, ++rowIndex, Res.get("shared.errorMessage"), "").second;
textArea.setText(trade.getErrorMessage());
textArea.setEditable(false);
IntegerProperty count = new SimpleIntegerProperty(20);
int rowHeight = 10;
textArea.prefHeightProperty().bindBidirectional(count);
changeListener = (ov, old, newVal) -> {
if (newVal.intValue() > rowHeight)
count.setValue(count.get() + newVal.intValue() + 10);
};
textArea.scrollTopProperty().addListener(changeListener);
textArea.setScrollTop(30);
TextField state = addLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradeState")).second;
state.setText(trade.getState().getPhase().name());
}
Button closeButton = addButtonAfterGroup(gridPane, ++rowIndex, Res.get("shared.close"));
// TODO app wide focus
// closeButton.requestFocus();
closeButton.setOnAction(e -> {
closeHandlerOptional.ifPresent(Runnable::run);
hide();
});
}
use of javafx.scene.control.TextField in project bisq-desktop by bisq-network.
the class FormBuilder method addLabelComboBoxLabel.
public static Tuple3<Label, ComboBox, TextField> addLabelComboBoxLabel(GridPane gridPane, int rowIndex, String title, String textFieldText, double top) {
Label label = addLabel(gridPane, rowIndex, title, top);
HBox hBox = new HBox();
hBox.setSpacing(10);
ComboBox comboBox = new ComboBox();
TextField textField = new TextField(textFieldText);
textField.setEditable(false);
textField.setMouseTransparent(true);
textField.setFocusTraversable(false);
hBox.getChildren().addAll(comboBox, textField);
GridPane.setRowIndex(hBox, rowIndex);
GridPane.setColumnIndex(hBox, 1);
GridPane.setMargin(hBox, new Insets(top, 0, 0, 0));
gridPane.getChildren().add(hBox);
return new Tuple3<>(label, comboBox, textField);
}
use of javafx.scene.control.TextField in project org.csstudio.display.builder by kasemir.
the class TextEntryRepresentation method createJFXNode.
@Override
public TextInputControl createJFXNode() throws Exception {
value_text = computeText(null);
// Note implementation selection:
// "multi_line" and "wrap_words" cannot change at runtime.
// In editor, there is no visible difference,
// and at runtime changes are simply not supported.
final TextInputControl text;
if (model_widget.propMultiLine().getValue()) {
final TextArea area = new TextArea();
area.setWrapText(model_widget.propWrapWords().getValue());
text = area;
} else
text = new TextField();
text.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
text.getStyleClass().add("text_entry");
if (!toolkit.isEditMode()) {
// Initially used 'focus' to activate the widget, but
// when a display is opened, one of the text fields likely has the focus.
// That widget will then NOT show any value, because we're active as if the
// user just navigated into the field to edit it.
// Now requiring key press, including use of cursor keys, to activate.
text.setOnKeyPressed(event -> {
switch(event.getCode()) {
case ESCAPE:
if (active) {
// Revert original value, leave active state
restore();
setActive(false);
}
break;
case ENTER:
case UNDEFINED:
// --> Handle in onKeyTyped for both cases
break;
default:
// Any other key results in active state
setActive(true);
}
});
text.setOnKeyTyped(event -> {
final String typed = event.getCharacter();
if (typed.length() == 1 && event.getCharacter().charAt(0) == 13) {
// Multi line mode requires Control-ENTER.
if (!isMultiLine() || event.isControlDown()) {
// Submit value, leave active state
submit();
setActive(false);
}
}
});
// Clicking into widget also activates
text.setOnMouseClicked(event -> setActive(true));
// While getting the focus does not activate the widget
// (first need to type something or click),
// _loosing_ focus de-activates the widget.
// Otherwise widget where one moves the cursor, then clicks
// someplace else would remain active and not show any updates
text.focusedProperty().addListener((prop, old, focused) -> {
if (active && !focused) {
restore();
setActive(false);
}
});
}
return text;
}
use of javafx.scene.control.TextField 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;
}
Aggregations