use of javafx.beans.property.SimpleIntegerProperty in project cryptomator by cryptomator.
the class InitializeController method initialize.
@Override
public void initialize() {
BooleanBinding passwordIsEmpty = passwordField.textProperty().isEmpty();
BooleanBinding passwordsDiffer = passwordField.textProperty().isNotEqualTo(retypePasswordField.textProperty());
okButton.disableProperty().bind(passwordIsEmpty.or(passwordsDiffer));
passwordStrength.bind(EasyBind.map(passwordField.textProperty(), strengthRater::computeRate));
passwordStrengthLevel0.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(0), strengthRater::getBackgroundWithStrengthColor));
passwordStrengthLevel1.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(1), strengthRater::getBackgroundWithStrengthColor));
passwordStrengthLevel2.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(2), strengthRater::getBackgroundWithStrengthColor));
passwordStrengthLevel3.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(3), strengthRater::getBackgroundWithStrengthColor));
passwordStrengthLevel4.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(4), strengthRater::getBackgroundWithStrengthColor));
passwordStrengthLabel.textProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrengthDescription));
}
use of javafx.beans.property.SimpleIntegerProperty in project bisq-desktop by bisq-network.
the class OfferBookViewModelTest method testMaxCharactersForPriceDistance.
@Test
public void testMaxCharactersForPriceDistance() {
OfferBook offerBook = mock(OfferBook.class);
OpenOfferManager openOfferManager = mock(OpenOfferManager.class);
PriceFeedService priceFeedService = mock(PriceFeedService.class);
final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
final Maker<OfferBookListItem> item = btcItem.but(with(useMarketBasedPrice, true));
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
when(priceFeedService.getMarketPrice(anyString())).thenReturn(null);
when(priceFeedService.updateCounterProperty()).thenReturn(new SimpleIntegerProperty());
final OfferBookListItem item1 = make(item);
item1.getOffer().setPriceFeedService(priceFeedService);
final OfferBookListItem item2 = make(item.but(with(marketPriceMargin, 0.0197)));
item2.getOffer().setPriceFeedService(priceFeedService);
final OfferBookListItem item3 = make(item.but(with(marketPriceMargin, 0.1)));
item3.getOffer().setPriceFeedService(priceFeedService);
final OfferBookListItem item4 = make(item.but(with(marketPriceMargin, -0.1)));
item4.getOffer().setPriceFeedService(priceFeedService);
offerBookListItems.addAll(item1, item2);
final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, priceFeedService, null, null, null, null, null, new BSFormatter());
model.activate();
// " (1.97%)"
assertEquals(8, model.maxPlacesForMarketPriceMargin.intValue());
offerBookListItems.addAll(item3);
// " (10.00%)"
assertEquals(9, model.maxPlacesForMarketPriceMargin.intValue());
offerBookListItems.addAll(item4);
// " (-10.00%)"
assertEquals(10, model.maxPlacesForMarketPriceMargin.intValue());
}
use of javafx.beans.property.SimpleIntegerProperty in project Board-Instrumentation-Framework by intel.
the class LedBargraphBuilder method ledColor.
public final B ledColor(final int INDEX, final Color COLOR) {
properties.put("ledColorIndex", new SimpleIntegerProperty(INDEX));
properties.put("ledColor", new SimpleObjectProperty<Color>(COLOR));
return (B) this;
}
use of javafx.beans.property.SimpleIntegerProperty 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.beans.property.SimpleIntegerProperty in project bisq-desktop by bisq-network.
the class OfferBookChartViewModelTest method testMaxCharactersForBuyPriceWithOfflinePriceFeedService.
@Test
public void testMaxCharactersForBuyPriceWithOfflinePriceFeedService() {
OfferBook offerBook = mock(OfferBook.class);
PriceFeedService priceFeedService = mock(PriceFeedService.class);
final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
final OfferBookListItem item = make(OfferBookListItemMaker.btcItem.but(with(OfferBookListItemMaker.useMarketBasedPrice, true)));
item.getOffer().setPriceFeedService(priceFeedService);
offerBookListItems.addAll(item);
when(priceFeedService.getMarketPrice(anyString())).thenReturn(null);
when(priceFeedService.updateCounterProperty()).thenReturn(new SimpleIntegerProperty());
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookChartViewModel model = new OfferBookChartViewModel(offerBook, empty, priceFeedService, null, new BSFormatter());
model.activate();
assertEquals(0, model.maxPlacesForBuyPrice.intValue());
}
Aggregations