From a3c4df8dc32364855c1134311fac79df7bcc0e24 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 26 Aug 2014 10:10:59 +0200 Subject: [PATCH] Adjust line wrapping by hand --- src/main/java/io/bitsquare/BitSquare.java | 8 +- src/main/java/io/bitsquare/SeedNode.java | 7 +- .../btc/AddressBasedCoinSelector.java | 2 +- src/main/java/io/bitsquare/btc/FeePolicy.java | 4 +- .../java/io/bitsquare/btc/WalletFacade.java | 63 +++-- .../io/bitsquare/crypto/CryptoFacade.java | 4 +- .../java/io/bitsquare/di/BitSquareModule.java | 4 +- .../java/io/bitsquare/gui/MainController.java | 24 +- .../profile/ArbitratorProfileController.java | 4 +- .../ArbitratorRegistrationController.java | 47 ++-- .../io/bitsquare/gui/components/Popups.java | 39 ++- .../gui/components/ValidatingTextField.java | 4 +- .../gui/components/btc/AddressTextField.java | 4 +- .../gui/components/btc/BalanceTextField.java | 4 +- .../skin/ConfidenceProgressIndicatorSkin.java | 106 ++++---- .../processbar/ProcessStepItem.java | 4 +- .../bitsquare/gui/funds/FundsController.java | 5 +- .../gui/funds/deposit/DepositController.java | 96 +++---- .../transactions/TransactionsController.java | 85 +++--- .../transactions/TransactionsListItem.java | 16 +- .../withdrawal/WithdrawalController.java | 161 +++++------ .../gui/orders/offer/OfferController.java | 96 +++---- .../gui/orders/offer/OfferListItem.java | 8 +- .../pending/PendingTradeController.java | 255 +++++++++--------- .../gui/settings/SettingsController.java | 18 +- .../bitsquare/gui/trade/TradeController.java | 8 +- .../createoffer/CreateOfferController.java | 8 +- .../trade/orderbook/OrderBookController.java | 192 ++++++------- .../trade/orderbook/OrderBookListItem.java | 8 +- .../trade/takeoffer/TakerOfferController.java | 50 ++-- .../io/bitsquare/gui/util/BtcValidator.java | 10 +- .../bitsquare/gui/util/ConfidenceDisplay.java | 4 +- .../io/bitsquare/gui/util/FiatValidator.java | 8 +- .../bitsquare/gui/util/ValidationHelper.java | 4 +- .../java/io/bitsquare/locale/CountryUtil.java | 38 +-- .../io/bitsquare/locale/LanguageUtil.java | 5 +- .../io/bitsquare/locale/Localisation.java | 4 +- .../msg/BootstrappedPeerFactory.java | 14 +- .../java/io/bitsquare/msg/MessageFacade.java | 20 +- src/main/java/io/bitsquare/msg/P2PNode.java | 8 +- .../java/io/bitsquare/trade/TradeManager.java | 4 +- .../bitsquare/trade/orderbook/OrderBook.java | 4 +- .../tasks/BroadCastOfferFeeTx.java | 10 +- .../protocol/offerer/CreateDepositTx.java | 8 +- .../offerer/HandleTakeOfferRequest.java | 5 +- .../offerer/ProtocolForOffererAsBuyer.java | 5 +- .../offerer/RequestTakerDepositPayment.java | 4 +- .../offerer/SendDepositTxIdToTaker.java | 5 +- .../protocol/offerer/SendSignedPayoutTx.java | 4 +- ...etupListenerForBlockChainConfirmation.java | 4 +- .../trade/protocol/taker/PayDeposit.java | 4 +- .../trade/protocol/taker/PayTakeOfferFee.java | 8 +- .../taker/ProtocolForTakerAsSeller.java | 4 +- .../protocol/taker/RequestTakeOffer.java | 22 +- .../taker/SendSignedTakerDepositTxAsHex.java | 4 +- .../io/bitsquare/util/StorageDirectory.java | 19 +- .../java/io/bitsquare/util/Utilities.java | 8 +- .../java/io/bitsquare/msg/P2PNodeTest.java | 11 +- src/test/java/io/bitsquare/msg/UtilsDHT2.java | 28 +- 59 files changed, 805 insertions(+), 805 deletions(-) diff --git a/src/main/java/io/bitsquare/BitSquare.java b/src/main/java/io/bitsquare/BitSquare.java index 11d8895ba7..12cee92025 100644 --- a/src/main/java/io/bitsquare/BitSquare.java +++ b/src/main/java/io/bitsquare/BitSquare.java @@ -82,8 +82,8 @@ public class BitSquare extends Application { Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> Popups.handleUncaughtExceptions (Throwables.getRootCause(throwable))); - StorageDirectory.setStorageDirectory(new File(StorageDirectory.getApplicationDirectory().getCanonicalPath() + - "/data")); + StorageDirectory.setStorageDirectory( + new File(StorageDirectory.getApplicationDirectory().getCanonicalPath() + "/data")); // currently there is not SystemTray support for java fx (planned for version 3) so we use the old AWT AWTSystemTray.createSystemTray(primaryStage); @@ -110,8 +110,8 @@ public class BitSquare extends Application { GuiceFXMLLoader.setInjector(injector); - final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(NavigationItem.MAIN.getFxmlUrl()), - false); + final GuiceFXMLLoader loader = + new GuiceFXMLLoader(getClass().getResource(NavigationItem.MAIN.getFxmlUrl()), false); final Parent view = loader.load(); final Scene scene = new Scene(view, 1000, 750); scene.getStylesheets().setAll(getClass().getResource("/io/bitsquare/gui/bitsquare.css").toExternalForm()); diff --git a/src/main/java/io/bitsquare/SeedNode.java b/src/main/java/io/bitsquare/SeedNode.java index 6c19a0325b..868c3389c2 100644 --- a/src/main/java/io/bitsquare/SeedNode.java +++ b/src/main/java/io/bitsquare/SeedNode.java @@ -42,8 +42,7 @@ import org.slf4j.LoggerFactory; * Well known node which is reachable for all peers for bootstrapping. * There will be several SeedNodes running on several servers. *

- * TODO: Alternative bootstrap methods will follow later (save locally list of known nodes reported form other peers, - * ...) + * TODO: Alternative bootstrap methods will follow later (save locally list of known nodes reported form other peers...) */ public class SeedNode extends Thread { private static final Logger log = LoggerFactory.getLogger(SeedNode.class); @@ -109,8 +108,8 @@ public class SeedNode extends Thread { public Peer startupPeer() { Peer peer = null; try { - peer = new PeerBuilder(Number160.createHash(seedNodeAddress.getId())).ports(seedNodeAddress.getPort()) - .start(); + peer = new PeerBuilder( + Number160.createHash(seedNodeAddress.getId())).ports(seedNodeAddress.getPort()).start(); // Need to add all features the clients will use (otherwise msg type is UNKNOWN_ID) new PeerBuilderDHT(peer).start(); diff --git a/src/main/java/io/bitsquare/btc/AddressBasedCoinSelector.java b/src/main/java/io/bitsquare/btc/AddressBasedCoinSelector.java index bc83b5afc7..8ebba62bbc 100644 --- a/src/main/java/io/bitsquare/btc/AddressBasedCoinSelector.java +++ b/src/main/java/io/bitsquare/btc/AddressBasedCoinSelector.java @@ -171,7 +171,7 @@ public class AddressBasedCoinSelector extends DefaultCoinSelector { confidence.getSource().equals(TransactionConfidence.Source.SELF) && // In regtest mode we expect to have only one peer, so we won't see transactions propagate. // TODO: The value 1 below dates from a time when transactions we broadcast *to* were - counted, set to 0 + // counted, set to 0 (confidence.numBroadcastPeers() > 1 || tx.getParams() == RegTestParams.get()); } */ diff --git a/src/main/java/io/bitsquare/btc/FeePolicy.java b/src/main/java/io/bitsquare/btc/FeePolicy.java index 5f530653b9..03c291972b 100644 --- a/src/main/java/io/bitsquare/btc/FeePolicy.java +++ b/src/main/java/io/bitsquare/btc/FeePolicy.java @@ -41,8 +41,8 @@ public class FeePolicy { this.params = params; } - //TODO other users or dev address? use donation option list? (dev, other users, wikileaks, tor, - // sub projects (bitcoinj, tomp2p,...)...) + //TODO other users or dev address? use donation option list? + // (dev, other users, wikileaks, tor, sub projects (bitcoinj, tomp2p,...)...) public Address getAddressForRegistrationFee() { try { diff --git a/src/main/java/io/bitsquare/btc/WalletFacade.java b/src/main/java/io/bitsquare/btc/WalletFacade.java index d604e2a71e..8fc97d3a9b 100644 --- a/src/main/java/io/bitsquare/btc/WalletFacade.java +++ b/src/main/java/io/bitsquare/btc/WalletFacade.java @@ -200,8 +200,8 @@ public class WalletFacade { List persistedAddressEntryList = (List) serializable; if (serializable instanceof List) { for (AddressEntry persistedAddressEntry : persistedAddressEntryList) { - persistedAddressEntry.setDeterministicKey((DeterministicKey) wallet.findKeyFromPubHash - (persistedAddressEntry.getPubKeyHash())); + persistedAddressEntry.setDeterministicKey( + (DeterministicKey) wallet.findKeyFromPubHash(persistedAddressEntry.getPubKeyHash())); } addressEntryList = persistedAddressEntryList; registrationAddressEntry = addressEntryList.get(0); @@ -279,8 +279,8 @@ public class WalletFacade { } public AddressEntry getAddressInfoByTradeID(String offerId) { - Optional addressEntry = getAddressEntryList().stream().filter(e -> offerId.equals(e.getOfferId - ())).findFirst(); + Optional addressEntry = getAddressEntryList().stream().filter(e -> + offerId.equals(e.getOfferId())).findFirst(); if (addressEntry.isPresent()) return addressEntry.get(); @@ -318,8 +318,8 @@ public class WalletFacade { List transactionConfidenceList = new ArrayList<>(); Set transactions = wallet.getTransactions(true); if (transactions != null) { - transactionConfidenceList.addAll(transactions.stream().map(tx -> getTransactionConfidence(tx, - address)).collect(Collectors.toList())); + transactionConfidenceList.addAll(transactions.stream().map(tx -> + getTransactionConfidence(tx, address)).collect(Collectors.toList())); /* same as: for (Transaction tx : transactions) { @@ -345,8 +345,8 @@ public class WalletFacade { List mergedOutputs = getOutputsWithConnectedOutputs(tx); List transactionConfidenceList = new ArrayList<>(); - mergedOutputs.stream().filter(e -> e.getScriptPubKey().isSentToAddress() || e.getScriptPubKey().isSentToP2SH - ()).forEach(transactionOutput -> { + mergedOutputs.stream().filter(e -> e.getScriptPubKey().isSentToAddress() || + e.getScriptPubKey().isSentToP2SH()).forEach(transactionOutput -> { Address outputAddress = transactionOutput.getScriptPubKey().getToAddress(params); if (address.equals(outputAddress)) { transactionConfidenceList.add(tx.getConfidence()); @@ -356,8 +356,8 @@ public class WalletFacade { same as: for (TransactionOutput transactionOutput : mergedOutputs) { - if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey() - .isSentToP2SH()) + if (transactionOutput.getScriptPubKey().isSentToAddress() || + transactionOutput.getScriptPubKey().isSentToP2SH()) { Address outputAddress = transactionOutput.getScriptPubKey().getToAddress(params); if (address.equals(outputAddress)) @@ -398,8 +398,8 @@ public class WalletFacade { if (transactionConfidence == null || confidence.getConfidenceType().equals(TransactionConfidence.ConfidenceType.PENDING) || (confidence.getConfidenceType().equals(TransactionConfidence.ConfidenceType.BUILDING) && - transactionConfidence.getConfidenceType().equals(TransactionConfidence.ConfidenceType - .BUILDING) && + transactionConfidence.getConfidenceType().equals( + TransactionConfidence.ConfidenceType.BUILDING) && confidence.getDepthInBlocks() < transactionConfidence.getDepthInBlocks())) { transactionConfidence = confidence; } @@ -415,8 +415,8 @@ public class WalletFacade { if (getRegistrationAddressEntry() != null) { transactionConfidence = getConfidenceForAddress(getRegistrationAddressEntry().getAddress()); } - return transactionConfidence != null && transactionConfidence.getConfidenceType().equals - (TransactionConfidence.ConfidenceType.BUILDING); + return transactionConfidence != null && + transactionConfidence.getConfidenceType().equals(TransactionConfidence.ConfidenceType.BUILDING); } @@ -507,12 +507,13 @@ public class WalletFacade { Transaction tx = new Transaction(params); - byte[] data = cryptoFacade.getEmbeddedAccountRegistrationData(getRegistrationAddressEntry().getKey(), - stringifiedBankAccounts); + byte[] data = cryptoFacade.getEmbeddedAccountRegistrationData( + getRegistrationAddressEntry().getKey(), stringifiedBankAccounts); tx.addOutput(Transaction.MIN_NONDUST_OUTPUT, new ScriptBuilder().op(OP_RETURN).data(data).build()); - Coin fee = FeePolicy.ACCOUNT_REGISTRATION_FEE.subtract(Transaction.MIN_NONDUST_OUTPUT).subtract(FeePolicy - .TX_FEE); + Coin fee = FeePolicy.ACCOUNT_REGISTRATION_FEE + .subtract(Transaction.MIN_NONDUST_OUTPUT) + .subtract(FeePolicy.TX_FEE); log.trace("fee: " + fee.toFriendlyString()); tx.addOutput(fee, feePolicy.getAddressForRegistrationFee()); @@ -842,16 +843,14 @@ public class WalletFacade { log.trace("offerersFirstTx = " + offerersFirstTx); // add input - Transaction offerersFirstTxConnOut = wallet.getTransaction(offerersFirstTx.getInput(0).getOutpoint().getHash - ()); // pass that around! - TransactionOutPoint offerersFirstTxOutPoint = new TransactionOutPoint(params, offererTxOutIndex, - offerersFirstTxConnOut); + Transaction offerersFirstTxConnOut = wallet.getTransaction(offerersFirstTx.getInput(0).getOutpoint().getHash()); + TransactionOutPoint offerersFirstTxOutPoint = + new TransactionOutPoint(params, offererTxOutIndex, offerersFirstTxConnOut); //TransactionInput offerersFirstTxInput = new TransactionInput(params, tx, // offerersFirstTx.getInput(0).getScriptBytes(), offerersFirstTxOutPoint); // pass that around! // getScriptBytes = // empty bytes array - TransactionInput offerersFirstTxInput = new TransactionInput(params, tx, new byte[]{}, - offerersFirstTxOutPoint); // pass that around! getScriptBytes = empty bytes array + TransactionInput offerersFirstTxInput = new TransactionInput(params, tx, new byte[]{}, offerersFirstTxOutPoint); offerersFirstTxInput.setParent(tx); tx.addInput(offerersFirstTxInput); @@ -863,10 +862,10 @@ public class WalletFacade { // add input Transaction takersSignedTxConnOut = new Transaction(params, Utils.parseAsHexOrBase58(takersSignedConnOutAsHex)); - TransactionOutPoint takersSignedTxOutPoint = new TransactionOutPoint(params, takerTxOutIndex, - takersSignedTxConnOut); - TransactionInput takersSignedTxInput = new TransactionInput(params, tx, - Utils.parseAsHexOrBase58(takersSignedScriptSigAsHex), takersSignedTxOutPoint); + TransactionOutPoint takersSignedTxOutPoint = + new TransactionOutPoint(params, takerTxOutIndex, takersSignedTxConnOut); + TransactionInput takersSignedTxInput = new TransactionInput( + params, tx, Utils.parseAsHexOrBase58(takersSignedScriptSigAsHex), takersSignedTxOutPoint); takersSignedTxInput.setParent(tx); tx.addInput(takersSignedTxInput); @@ -965,8 +964,8 @@ public class WalletFacade { Coin offererPaybackAmount, Coin takerPaybackAmount, String takerAddress, - String tradeID) throws - AddressFormatException { + String tradeID) + throws AddressFormatException { log.debug("offererCreatesAndSignsPayoutTx"); log.trace("inputs: "); log.trace("depositTxID=" + depositTxID); @@ -1028,8 +1027,8 @@ public class WalletFacade { ECKey.ECDSASignature takerSignature = getAddressInfoByTradeID(tradeID).getKey().sign(sigHash); TransactionSignature takerTxSig = new TransactionSignature(takerSignature, Transaction.SigHash.ALL, false); - ECKey.ECDSASignature offererSignature = new ECKey.ECDSASignature(new BigInteger(offererSignatureR), - new BigInteger(offererSignatureS)); + ECKey.ECDSASignature offererSignature = + new ECKey.ECDSASignature(new BigInteger(offererSignatureR), new BigInteger(offererSignatureS)); TransactionSignature offererTxSig = new TransactionSignature(offererSignature, Transaction.SigHash.ALL, false); Script inputScript = ScriptBuilder.createMultiSigInputScript(ImmutableList.of(offererTxSig, takerTxSig)); diff --git a/src/main/java/io/bitsquare/crypto/CryptoFacade.java b/src/main/java/io/bitsquare/crypto/CryptoFacade.java index 9ecdf516c3..1e133ab6f2 100644 --- a/src/main/java/io/bitsquare/crypto/CryptoFacade.java +++ b/src/main/java/io/bitsquare/crypto/CryptoFacade.java @@ -70,8 +70,8 @@ public class CryptoFacade { public byte[] getEmbeddedAccountRegistrationData(ECKey registrationKey, String stringifiedBankAccounts) { String signedBankAccountIDs = signMessage(registrationKey, stringifiedBankAccounts, null); - return Utils.sha256hash160(concatenateChunks(stringifiedBankAccounts, signedBankAccountIDs).getBytes(Charsets - .UTF_8)); + return Utils.sha256hash160( + concatenateChunks(stringifiedBankAccounts, signedBankAccountIDs).getBytes(Charsets.UTF_8)); } public String signContract(ECKey key, String contractAsJson) { diff --git a/src/main/java/io/bitsquare/di/BitSquareModule.java b/src/main/java/io/bitsquare/di/BitSquareModule.java index 21dd251d06..1b79e12198 100644 --- a/src/main/java/io/bitsquare/di/BitSquareModule.java +++ b/src/main/java/io/bitsquare/di/BitSquareModule.java @@ -74,8 +74,8 @@ public class BitSquareModule extends AbstractModule { // bind(Boolean.class).annotatedWith(Names.named("useDiskStorage")).toInstance(new Boolean(true)); bind(Boolean.class).annotatedWith(Names.named("useDiskStorage")).toInstance(new Boolean(false)); - bind(SeedNodeAddress.StaticSeedNodeAddresses.class).annotatedWith(Names.named("defaultSeedNode")).toInstance - (SeedNodeAddress.StaticSeedNodeAddresses.LOCALHOST); + bind(SeedNodeAddress.StaticSeedNodeAddresses.class).annotatedWith( + Names.named("defaultSeedNode")).toInstance(SeedNodeAddress.StaticSeedNodeAddresses.LOCALHOST); // bind(SeedNodeAddress.StaticSeedNodeAddresses.class).annotatedWith(Names.named("defaultSeedNode")) // .toInstance(SeedNodeAddress.StaticSeedNodeAddresses.DIGITAL_OCEAN); } diff --git a/src/main/java/io/bitsquare/gui/MainController.java b/src/main/java/io/bitsquare/gui/MainController.java index 5e7509b991..a5aae36f95 100644 --- a/src/main/java/io/bitsquare/gui/MainController.java +++ b/src/main/java/io/bitsquare/gui/MainController.java @@ -57,12 +57,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Holds the splash screen and the application views. - * It builds up all the views and initializes the facades. - * We use a sequence of Platform.runLater cascaded calls to make the startup more smooth, - * otherwise the rendering is frozen for too long. - * Pre-loading of views is not implemented yet, and after a quick test it seemed that it does not give much - * improvements. + * Holds the splash screen and the application views. It builds up all the views and initializes the facades. + * We use a sequence of Platform.runLater cascaded calls to make the startup more smooth, otherwise the rendering is + * frozen for too long. Pre-loading of views is not implemented yet, and after a quick test it seemed that it does not + * give much improvements. */ public class MainController extends ViewController { private static final Logger log = LoggerFactory.getLogger(MainController.class); @@ -282,11 +280,9 @@ public class MainController extends ViewController { user.getBankAccountsSizeProperty().addListener((observableValue, oldValue, newValue) -> { if ((int) newValue == 2) - viewBuilder.rightNavPane.getChildren().add(1, accountComboBoxHolder);// accountComboBoxHolder - // .setVisible(true); + viewBuilder.rightNavPane.getChildren().add(1, accountComboBoxHolder); else if ((int) newValue < 2) - viewBuilder.rightNavPane.getChildren().remove(accountComboBoxHolder);//accountComboBoxHolder - // .setVisible(false); + viewBuilder.rightNavPane.getChildren().remove(accountComboBoxHolder); }); settingsButton = addNavButton(viewBuilder.rightNavPane, "Settings", NavigationItem.SETTINGS); @@ -387,8 +383,8 @@ public class MainController extends ViewController { } private void addAccountComboBox(Pane parent) { - final ComboBox accountComboBox = new ComboBox<>(FXCollections.observableArrayList(user - .getBankAccounts())); + final ComboBox accountComboBox = + new ComboBox<>(FXCollections.observableArrayList(user.getBankAccounts())); accountComboBox.setId("nav-account-combo-box"); accountComboBox.setLayoutY(12); if (user.getCurrentBankAccount() != null) @@ -406,8 +402,8 @@ public class MainController extends ViewController { } }); - user.getSelectedBankAccountIndexProperty().addListener(observable -> accountComboBox.getSelectionModel() - .select(user.getCurrentBankAccount())); + user.getSelectedBankAccountIndexProperty().addListener(observable -> + accountComboBox.getSelectionModel().select(user.getCurrentBankAccount())); user.getBankAccountsSizeProperty().addListener(observable -> { accountComboBox.setItems(FXCollections.observableArrayList(user.getBankAccounts())); // need to delay it a bit otherwise it will not be set diff --git a/src/main/java/io/bitsquare/gui/arbitrators/profile/ArbitratorProfileController.java b/src/main/java/io/bitsquare/gui/arbitrators/profile/ArbitratorProfileController.java index c0a010be5a..10ed814263 100644 --- a/src/main/java/io/bitsquare/gui/arbitrators/profile/ArbitratorProfileController.java +++ b/src/main/java/io/bitsquare/gui/arbitrators/profile/ArbitratorProfileController.java @@ -133,8 +133,8 @@ public class ArbitratorProfileController extends CachedViewController { arbitrationFeeTextField.setText(String.valueOf(arbitrator.getArbitrationFee()) + " % (Min. " + String .valueOf(arbitrator.getMinArbitrationFee()) + " BTC)"); methodsTextField.setText(BitSquareFormatter.arbitrationMethodsToString(arbitrator.getArbitrationMethods())); - idVerificationsTextField.setText(BitSquareFormatter.arbitrationIDVerificationsToString(arbitrator - .getIdVerifications())); + idVerificationsTextField.setText( + BitSquareFormatter.arbitrationIDVerificationsToString(arbitrator.getIdVerifications())); webPageTextField.setText(arbitrator.getWebUrl()); descriptionTextArea.setText(arbitrator.getDescription()); } diff --git a/src/main/java/io/bitsquare/gui/arbitrators/registration/ArbitratorRegistrationController.java b/src/main/java/io/bitsquare/gui/arbitrators/registration/ArbitratorRegistrationController.java index c1a3d63c42..c608024921 100644 --- a/src/main/java/io/bitsquare/gui/arbitrators/registration/ArbitratorRegistrationController.java +++ b/src/main/java/io/bitsquare/gui/arbitrators/registration/ArbitratorRegistrationController.java @@ -138,8 +138,8 @@ public class ArbitratorRegistrationController extends CachedViewController { } }); - idTypeComboBox.setItems(FXCollections.observableArrayList(new ArrayList<>(EnumSet.allOf(Arbitrator.ID_TYPE - .class)))); + idTypeComboBox.setItems(FXCollections.observableArrayList( + new ArrayList<>(EnumSet.allOf(Arbitrator.ID_TYPE.class)))); idTypeComboBox.setConverter(new StringConverter() { @Override @@ -170,8 +170,8 @@ public class ArbitratorRegistrationController extends CachedViewController { } }); - idVerificationsComboBox.setItems(FXCollections.observableArrayList(new ArrayList<>(EnumSet.allOf(Arbitrator - .ID_VERIFICATION.class)))); + idVerificationsComboBox.setItems( + FXCollections.observableArrayList(new ArrayList<>(EnumSet.allOf(Arbitrator.ID_VERIFICATION.class)))); idVerificationsComboBox.setConverter(new StringConverter() { @Override @@ -300,8 +300,8 @@ public class ArbitratorRegistrationController extends CachedViewController { if (idVerification != null) { if (!idVerificationList.contains(idVerification)) { idVerificationList.add(idVerification); - idVerificationsTextField.setText(BitSquareFormatter.arbitrationIDVerificationsToString - (idVerificationList)); + idVerificationsTextField.setText( + BitSquareFormatter.arbitrationIDVerificationsToString(idVerificationList)); } } @@ -342,19 +342,16 @@ public class ArbitratorRegistrationController extends CachedViewController { /////////////////////////////////////////////////////////////////////////////////////////// private void setupPayCollateralScreen() { - infoLabel.setText("You need to pay 10 x the max. trading volume as collateral.\n\n" + - "That payment will be locked into a MultiSig fund and be refunded when you leave the arbitration pool" + - ".\n" + - "In case of fraud (collusion, not fulfilling the min. dispute quality requirements) you will lose " + - "your collateral.\n" + + infoLabel.setText("You need to pay 10 x the max. trading volume as collateral.\n\nThat payment will be " + + "locked into a MultiSig fund and be refunded when you leave the arbitration pool.\nIn case of fraud " + + "(collusion, not fulfilling the min. dispute quality requirements) you will lose your collateral.\n" + "If you have a negative feedback from your clients you will lose a part of the collateral,\n" + "depending on the overall relation of negative to positive ratings you received after a dispute " + - "resolution.\n\n" + - "Please pay in " + arbitrator.getMaxTradeVolume() * 10 + " BTC"); + "resolution.\n\nPlease pay in " + arbitrator.getMaxTradeVolume() * 10 + " BTC"); - String collateralAddress = walletFacade.getRegistrationAddressEntry() != null ? walletFacade - .getRegistrationAddressEntry().toString() : ""; + String collateralAddress = walletFacade.getRegistrationAddressEntry() != null ? + walletFacade.getRegistrationAddressEntry().toString() : ""; collateralAddressTextField.setText(collateralAddress); AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY); @@ -365,8 +362,8 @@ public class ArbitratorRegistrationController extends CachedViewController { clipboard.setContent(content); }); - confidenceDisplay = new ConfidenceDisplay(walletFacade.getWallet(), confirmationLabel, balanceTextField, - progressIndicator); + confidenceDisplay = new ConfidenceDisplay( + walletFacade.getWallet(), confirmationLabel, balanceTextField, progressIndicator); paymentDoneButton.setDisable(walletFacade.getArbitratorDepositBalance().isZero()); log.debug("getArbitratorDepositBalance " + walletFacade.getArbitratorDepositBalance()); walletFacade.getWallet().addEventListener(new WalletEventListener() { @@ -432,8 +429,8 @@ public class ArbitratorRegistrationController extends CachedViewController { arbitrationFeeTextField.setText(String.valueOf(arbitrator.getArbitrationFee())); minArbitrationFeeTextField.setText(String.valueOf(arbitrator.getMinArbitrationFee())); methodsTextField.setText(BitSquareFormatter.arbitrationMethodsToString(arbitrator.getArbitrationMethods())); - idVerificationsTextField.setText(BitSquareFormatter.arbitrationIDVerificationsToString(arbitrator - .getIdVerifications())); + idVerificationsTextField.setText( + BitSquareFormatter.arbitrationIDVerificationsToString(arbitrator.getIdVerifications())); webPageTextField.setText(arbitrator.getWebUrl()); descriptionTextArea.setText(arbitrator.getDescription()); @@ -447,13 +444,11 @@ public class ArbitratorRegistrationController extends CachedViewController { private Arbitrator getEditedArbitrator() { try { - BitSquareValidator.textFieldsNotEmptyWithReset(nameTextField, idTypeTextField, languagesTextField, - methodsTextField, idVerificationsTextField); - BitSquareValidator.textFieldsHasDoubleValueWithReset(maxTradeVolumeTextField, - passiveServiceFeeTextField, - minPassiveServiceFeeTextField, - arbitrationFeeTextField, - minArbitrationFeeTextField); + BitSquareValidator.textFieldsNotEmptyWithReset( + nameTextField, idTypeTextField, languagesTextField, methodsTextField, idVerificationsTextField); + BitSquareValidator.textFieldsHasDoubleValueWithReset( + maxTradeVolumeTextField, passiveServiceFeeTextField, minPassiveServiceFeeTextField, + arbitrationFeeTextField, minArbitrationFeeTextField); String pubKeyAsHex = walletFacade.getArbitratorDepositAddressEntry().getPubKeyAsHexString(); String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(user.getMessagePublicKey()); diff --git a/src/main/java/io/bitsquare/gui/components/Popups.java b/src/main/java/io/bitsquare/gui/components/Popups.java index 2353bfb492..3c14226245 100644 --- a/src/main/java/io/bitsquare/gui/components/Popups.java +++ b/src/main/java/io/bitsquare/gui/components/Popups.java @@ -38,7 +38,11 @@ public class Popups { } public static void openInformationPopup(String title, String message, String masthead) { - Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead) + Dialogs.create() + .owner(BitSquare.getPrimaryStage()) + .title(title) + .message(message) + .masthead(masthead) .showInformation(); } @@ -55,8 +59,13 @@ public class Popups { } public static Action openConfirmPopup(String title, String message, String masthead, List actions) { - return Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead) - .actions(actions).showConfirm(); + return Dialogs.create() + .owner(BitSquare.getPrimaryStage()) + .title(title) + .message(message) + .masthead(masthead) + .actions(actions) + .showConfirm(); } // Warning @@ -69,7 +78,11 @@ public class Popups { } public static void openWarningPopup(String title, String message, String masthead) { - Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead) + Dialogs.create() + .owner(BitSquare.getPrimaryStage()) + .title(title) + .message(message) + .masthead(masthead) .showWarning(); } @@ -83,7 +96,11 @@ public class Popups { } public static Action openErrorPopup(String title, String message, String masthead) { - return Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead) + return Dialogs.create() + .owner(BitSquare.getPrimaryStage()) + .title(title) + .message(message) + .masthead(masthead) .showError(); } @@ -97,7 +114,11 @@ public class Popups { } public static Action openExceptionPopup(Throwable throwable, String title, String message, String masthead) { - return Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead) + return Dialogs.create() + .owner(BitSquare.getPrimaryStage()) + .title(title) + .message(message) + .masthead(masthead) .showException(throwable); } @@ -132,7 +153,11 @@ public class Popups { public static Action openRegistrationMissingPopup(String title, String message, String masthead, List commandLinks, int selectedIndex) { - return Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead) + return Dialogs.create() + .owner(BitSquare.getPrimaryStage()) + .title(title) + .message(message) + .masthead(masthead) .showCommandLinks(commandLinks.get(selectedIndex), commandLinks); } } diff --git a/src/main/java/io/bitsquare/gui/components/ValidatingTextField.java b/src/main/java/io/bitsquare/gui/components/ValidatingTextField.java index 57dcbbe27c..a1b349a58a 100644 --- a/src/main/java/io/bitsquare/gui/components/ValidatingTextField.java +++ b/src/main/java/io/bitsquare/gui/components/ValidatingTextField.java @@ -135,8 +135,8 @@ public class ValidatingTextField extends TextField { }); focusedProperty().addListener((ov, oldValue, newValue) -> { - if (validateOnFocusOut && needsValidationOnFocusOut && !newValue && getScene() != null && getScene() - .getWindow().isFocused()) + if (validateOnFocusOut && needsValidationOnFocusOut && + !newValue && getScene() != null && getScene().getWindow().isFocused()) validate(getText()); }); diff --git a/src/main/java/io/bitsquare/gui/components/btc/AddressTextField.java b/src/main/java/io/bitsquare/gui/components/btc/AddressTextField.java index ef9ba7fe76..253ccfcaff 100644 --- a/src/main/java/io/bitsquare/gui/components/btc/AddressTextField.java +++ b/src/main/java/io/bitsquare/gui/components/btc/AddressTextField.java @@ -147,8 +147,8 @@ public class AddressTextField extends AnchorPane { private String getBitcoinURI() { Coin d = BitSquareFormatter.parseToCoin(amountToPay); - return BitcoinURI.convertToBitcoinURI(address, BitSquareFormatter.parseToCoin(amountToPay), - BitSquare.getAppName(), null); + return BitcoinURI.convertToBitcoinURI( + address, BitSquareFormatter.parseToCoin(amountToPay), BitSquare.getAppName(), null); } diff --git a/src/main/java/io/bitsquare/gui/components/btc/BalanceTextField.java b/src/main/java/io/bitsquare/gui/components/btc/BalanceTextField.java index 24ad91cdea..c52756fbd6 100644 --- a/src/main/java/io/bitsquare/gui/components/btc/BalanceTextField.java +++ b/src/main/java/io/bitsquare/gui/components/btc/BalanceTextField.java @@ -127,8 +127,8 @@ public class BalanceTextField extends AnchorPane { progressIndicator.setProgress(0); break; case PENDING: - progressIndicatorTooltip.setText("Seen by " + confidence.numBroadcastPeers() + " peer(s) / 0 " + - "confirmations"); + progressIndicatorTooltip.setText( + "Seen by " + confidence.numBroadcastPeers() + " peer(s) / 0 " + "confirmations"); progressIndicator.setProgress(-1.0); break; case BUILDING: diff --git a/src/main/java/io/bitsquare/gui/components/confidence/skin/ConfidenceProgressIndicatorSkin.java b/src/main/java/io/bitsquare/gui/components/confidence/skin/ConfidenceProgressIndicatorSkin.java index c40cfeeb0d..fce54b5c2c 100644 --- a/src/main/java/io/bitsquare/gui/components/confidence/skin/ConfidenceProgressIndicatorSkin.java +++ b/src/main/java/io/bitsquare/gui/components/confidence/skin/ConfidenceProgressIndicatorSkin.java @@ -227,7 +227,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase> STYLEABLES; - private static final CssMetaData PROGRESS_COLOR = new - CssMetaData("-fx-progress-color", - PaintConverter.getInstance(), - null) { + private static final CssMetaData PROGRESS_COLOR = + new CssMetaData( + "-fx-progress-color", PaintConverter.getInstance(), null) { - @Override - public boolean isSettable(ConfidenceProgressIndicator n) { - final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); - return skin.progressColor == null || !skin.progressColor.isBound(); - } + @Override + public boolean isSettable(ConfidenceProgressIndicator n) { + final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); + return skin.progressColor == null || !skin.progressColor.isBound(); + } - @Override - public StyleableProperty getStyleableProperty(ConfidenceProgressIndicator n) { - final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); - return (StyleableProperty) skin.progressColor; - } - }; + @Override + public StyleableProperty getStyleableProperty(ConfidenceProgressIndicator n) { + final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); + return (StyleableProperty) skin.progressColor; + } + }; - private static final CssMetaData INDETERMINATE_SEGMENT_COUNT = new - CssMetaData("-fx-indeterminate-segment-count", - SizeConverter.getInstance(), - 8) { + private static final CssMetaData INDETERMINATE_SEGMENT_COUNT = + new CssMetaData( + "-fx-indeterminate-segment-count", SizeConverter.getInstance(), 8) { - @Override - public void set(ConfidenceProgressIndicator node, Number value, StyleOrigin origin) { - super.set(node, value.intValue(), origin); - } + @Override + public void set(ConfidenceProgressIndicator node, Number value, StyleOrigin origin) { + super.set(node, value.intValue(), origin); + } - @Override - public boolean isSettable(ConfidenceProgressIndicator n) { - final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); - return skin.indeterminateSegmentCount == null || !skin.indeterminateSegmentCount.isBound(); - } + @Override + public boolean isSettable(ConfidenceProgressIndicator n) { + final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); + return skin.indeterminateSegmentCount == null || !skin.indeterminateSegmentCount.isBound(); + } - @Override - public StyleableProperty getStyleableProperty(ConfidenceProgressIndicator n) { - final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); - return (StyleableProperty) skin.indeterminateSegmentCount; - } - }; + @Override + public StyleableProperty getStyleableProperty(ConfidenceProgressIndicator n) { + final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) n.getSkin(); + return (StyleableProperty) skin.indeterminateSegmentCount; + } + }; private static final CssMetaData SPIN_ENABLED = new CssMetaData("-fx-spin-enabled", - BooleanConverter.getInstance(), - Boolean.FALSE) { + BooleanConverter.getInstance(), + Boolean.FALSE) { - @Override - public boolean isSettable(ConfidenceProgressIndicator node) { - final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) node.getSkin(); - return skin.spinEnabled == null || !skin.spinEnabled.isBound(); - } + @Override + public boolean isSettable(ConfidenceProgressIndicator node) { + final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) node.getSkin(); + return skin.spinEnabled == null || !skin.spinEnabled.isBound(); + } - @Override - public StyleableProperty getStyleableProperty(ConfidenceProgressIndicator node) { - final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) node.getSkin(); - return (StyleableProperty) skin.spinEnabled; - } - }; + @Override + public StyleableProperty getStyleableProperty(ConfidenceProgressIndicator node) { + final ConfidenceProgressIndicatorSkin skin = (ConfidenceProgressIndicatorSkin) node.getSkin(); + return (StyleableProperty) skin.spinEnabled; + } + }; static { - final List> styleables = new ArrayList<>(SkinBase.getClassCssMetaData - ()); + final List> styleables = + new ArrayList<>(SkinBase.getClassCssMetaData()); styleables.add(PROGRESS_COLOR); styleables.add(INDETERMINATE_SEGMENT_COUNT); styleables.add(SPIN_ENABLED); diff --git a/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepItem.java b/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepItem.java index c08f5d620e..b530307920 100644 --- a/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepItem.java +++ b/src/main/java/io/bitsquare/gui/components/processbar/ProcessStepItem.java @@ -33,8 +33,8 @@ public class ProcessStepItem { this(label, color, false); } - private ProcessStepItem(String label, Paint color, @SuppressWarnings("SameParameterValue") boolean - hasProgressIndicator) { + private ProcessStepItem(String label, Paint color, + @SuppressWarnings("SameParameterValue") boolean hasProgressIndicator) { this.label = label; this.color = color; this.progressIndicator = hasProgressIndicator; diff --git a/src/main/java/io/bitsquare/gui/funds/FundsController.java b/src/main/java/io/bitsquare/gui/funds/FundsController.java index b615671ec0..c0ddfafe80 100644 --- a/src/main/java/io/bitsquare/gui/funds/FundsController.java +++ b/src/main/java/io/bitsquare/gui/funds/FundsController.java @@ -54,8 +54,9 @@ public class FundsController extends CachedViewController { public void initialize(URL url, ResourceBundle rb) { super.initialize(url, rb); - ((CachingTabPane) root).initialize(this, persistence, NavigationItem.DEPOSIT.getFxmlUrl(), - NavigationItem.WITHDRAWAL.getFxmlUrl(), NavigationItem.TRANSACTIONS.getFxmlUrl()); + ((CachingTabPane) root).initialize( + this, persistence, NavigationItem.DEPOSIT.getFxmlUrl(), NavigationItem.WITHDRAWAL.getFxmlUrl(), + NavigationItem.TRANSACTIONS.getFxmlUrl()); } @Override diff --git a/src/main/java/io/bitsquare/gui/funds/deposit/DepositController.java b/src/main/java/io/bitsquare/gui/funds/deposit/DepositController.java index a58f30d255..3d831adc14 100644 --- a/src/main/java/io/bitsquare/gui/funds/deposit/DepositController.java +++ b/src/main/java/io/bitsquare/gui/funds/deposit/DepositController.java @@ -93,8 +93,8 @@ public class DepositController extends CachedViewController { List addressEntryList = walletFacade.getAddressEntryList(); addressList = FXCollections.observableArrayList(); - addressList.addAll(addressEntryList.stream().map(anAddressEntryList -> new DepositListItem - (anAddressEntryList, walletFacade)).collect(Collectors.toList())); + addressList.addAll(addressEntryList.stream().map(anAddressEntryList -> + new DepositListItem(anAddressEntryList, walletFacade)).collect(Collectors.toList())); tableView.setItems(addressList); } @@ -136,8 +136,8 @@ public class DepositController extends CachedViewController { Tooltip tooltip = new Tooltip(item.getAddressEntry().getOfferId()); Tooltip.install(hyperlink, tooltip); - hyperlink.setOnAction(event -> log.info("Show trade details " + item.getAddressEntry - ().getOfferId())); + hyperlink.setOnAction(event -> + log.info("Show trade details " + item.getAddressEntry().getOfferId())); } setGraphic(hyperlink); } else { @@ -152,63 +152,63 @@ public class DepositController extends CachedViewController { private void setBalanceColumnCellFactory() { balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); - balanceColumn.setCellFactory(new Callback, TableCell>() { + balanceColumn.setCellFactory( + new Callback, TableCell>() { - @Override - public TableCell call(TableColumn column) { - return new TableCell() { @Override - public void updateItem(final DepositListItem item, boolean empty) { - super.updateItem(item, empty); + public TableCell call(TableColumn column) { + return new TableCell() { + @Override + public void updateItem(final DepositListItem item, boolean empty) { + super.updateItem(item, empty); - if (item != null && !empty) { - setGraphic(item.getBalanceLabel()); - } else { - setGraphic(null); - } + if (item != null && !empty) { + setGraphic(item.getBalanceLabel()); + } else { + setGraphic(null); + } + } + }; } - }; - } - }); + }); } private void setCopyColumnCellFactory() { copyColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); - copyColumn.setCellFactory(new Callback, TableCell>() { - - @Override - public TableCell call(TableColumn column) { - return new TableCell() { - final Label copyIcon = new Label(); - - { - copyIcon.getStyleClass().add("copy-icon"); - AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY); - Tooltip.install(copyIcon, new Tooltip("Copy address to clipboard")); - } + copyColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final DepositListItem item, boolean empty) { - super.updateItem(item, empty); + public TableCell call(TableColumn column) { + return new TableCell() { + final Label copyIcon = new Label(); - if (item != null && !empty) { - setGraphic(copyIcon); - copyIcon.setOnMouseClicked(e -> { - Clipboard clipboard = Clipboard.getSystemClipboard(); - ClipboardContent content = new ClipboardContent(); - content.putString(item.addressStringProperty().get()); - clipboard.setContent(content); - }); + { + copyIcon.getStyleClass().add("copy-icon"); + AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY); + Tooltip.install(copyIcon, new Tooltip("Copy address to clipboard")); + } - } else { - setGraphic(null); - } + @Override + public void updateItem(final DepositListItem item, boolean empty) { + super.updateItem(item, empty); + + if (item != null && !empty) { + setGraphic(copyIcon); + copyIcon.setOnMouseClicked(e -> { + Clipboard clipboard = Clipboard.getSystemClipboard(); + ClipboardContent content = new ClipboardContent(); + content.putString(item.addressStringProperty().get()); + clipboard.setContent(content); + }); + + } else { + setGraphic(null); + } + } + }; } - }; - } - }); + }); } private void setConfidenceColumnCellFactory() { diff --git a/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsController.java b/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsController.java index d615536283..a97175c122 100644 --- a/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsController.java +++ b/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsController.java @@ -88,8 +88,8 @@ public class TransactionsController extends CachedViewController { List transactions = walletFacade.getWallet().getRecentTransactions(10000, true); transactionsListItems = FXCollections.observableArrayList(); - transactionsListItems.addAll(transactions.stream().map(transaction -> new TransactionsListItem(transaction, - walletFacade)).collect(Collectors.toList())); + transactionsListItems.addAll(transactions.stream().map(transaction -> + new TransactionsListItem(transaction, walletFacade)).collect(Collectors.toList())); tableView.setItems(transactionsListItems); } @@ -111,56 +111,59 @@ public class TransactionsController extends CachedViewController { private void setAddressColumnCellFactory() { addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); - addressColumn.setCellFactory(new Callback, TableCell>() { - - @Override - public TableCell call(TableColumn column) { - return new TableCell() { - Hyperlink hyperlink; + addressColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final TransactionsListItem item, boolean empty) { - super.updateItem(item, empty); + public TableCell call(TableColumn column) { + return new TableCell() { + Hyperlink hyperlink; - if (item != null && !empty) { - hyperlink = new Hyperlink(item.getAddressString()); - hyperlink.setId("id-link"); - hyperlink.setOnAction(event -> log.info("Show trade details " + item.getAddressString())); - setGraphic(hyperlink); - } else { - setGraphic(null); - setId(null); - } + @Override + public void updateItem(final TransactionsListItem item, boolean empty) { + super.updateItem(item, empty); + + if (item != null && !empty) { + hyperlink = new Hyperlink(item.getAddressString()); + hyperlink.setId("id-link"); + hyperlink.setOnAction(event -> log.info("Show trade details " + item + .getAddressString())); + setGraphic(hyperlink); + } else { + setGraphic(null); + setId(null); + } + } + }; } - }; - } - }); + }); } private void setConfidenceColumnCellFactory() { - confidenceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue - ())); - confidenceColumn.setCellFactory(new Callback, TableCell>() { - - @Override - public TableCell call(TableColumn column) { - return new TableCell() { + confidenceColumn.setCellValueFactory((addressListItem) -> + new ReadOnlyObjectWrapper(addressListItem.getValue())); + confidenceColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final TransactionsListItem item, boolean empty) { - super.updateItem(item, empty); + public TableCell call(TableColumn column) { + return new TableCell() { - if (item != null && !empty) { - setGraphic(item.getProgressIndicator()); - } else { - setGraphic(null); - } + @Override + public void updateItem(final TransactionsListItem item, boolean empty) { + super.updateItem(item, empty); + + if (item != null && !empty) { + setGraphic(item.getProgressIndicator()); + } else { + setGraphic(null); + } + } + }; } - }; - } - }); + }); } } diff --git a/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsListItem.java b/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsListItem.java index e95eb94076..5fd40da94c 100644 --- a/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsListItem.java +++ b/src/main/java/io/bitsquare/gui/funds/transactions/TransactionsListItem.java @@ -56,10 +56,10 @@ public class TransactionsListItem { if (!transactionOutput.isMine(walletFacade.getWallet())) { type.set("Sent to"); - if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey() - .isPayToScriptHash()) { - address = transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams - ()); + if (transactionOutput.getScriptPubKey().isSentToAddress() || + transactionOutput.getScriptPubKey().isPayToScriptHash()) { + address = + transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams()); addressString = address.toString(); } else { addressString = "No sent to address script used."; @@ -73,10 +73,10 @@ public class TransactionsListItem { for (TransactionOutput transactionOutput : transaction.getOutputs()) { if (transactionOutput.isMine(walletFacade.getWallet())) { - if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey() - .isPayToScriptHash()) { - address = transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams - ()); + if (transactionOutput.getScriptPubKey().isSentToAddress() || + transactionOutput.getScriptPubKey().isPayToScriptHash()) { + address = + transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams()); addressString = address.toString(); } else { addressString = "No sent to address script used."; diff --git a/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalController.java b/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalController.java index 4d6d75f256..b8e2788e65 100644 --- a/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalController.java +++ b/src/main/java/io/bitsquare/gui/funds/withdrawal/WithdrawalController.java @@ -107,8 +107,8 @@ public class WithdrawalController extends CachedViewController { tableView.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { if (newValue != null) { - BitSquareValidator.resetTextFields(withdrawFromTextField, withdrawToTextField, amountTextField, - changeAddressTextField); + BitSquareValidator.resetTextFields( + withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField); if (Coin.ZERO.compareTo(newValue.getBalance()) <= 0) { amountTextField.setText(newValue.getBalance().toPlainString()); @@ -125,8 +125,8 @@ public class WithdrawalController extends CachedViewController { List addressEntryList = walletFacade.getAddressEntryList(); addressList = FXCollections.observableArrayList(); - addressList.addAll(addressEntryList.stream().map(anAddressEntryList -> new WithdrawalListItem - (anAddressEntryList, walletFacade)).collect(Collectors.toList())); + addressList.addAll(addressEntryList.stream().map(anAddressEntryList -> + new WithdrawalListItem(anAddressEntryList, walletFacade)).collect(Collectors.toList())); tableView.setItems(addressList); } @@ -139,8 +139,8 @@ public class WithdrawalController extends CachedViewController { @FXML public void onWithdraw() { try { - BitSquareValidator.textFieldsNotEmpty(amountTextField, withdrawFromTextField, withdrawToTextField, - changeAddressTextField); + BitSquareValidator.textFieldsNotEmpty( + amountTextField, withdrawFromTextField, withdrawToTextField, changeAddressTextField); BitSquareValidator.textFieldsHasDoubleValueWithReset(amountTextField); Coin amount = BitSquareFormatter.parseToCoin(amountTextField.getText()); @@ -148,8 +148,8 @@ public class WithdrawalController extends CachedViewController { FutureCallback callback = new FutureCallback() { @Override public void onSuccess(@javax.annotation.Nullable Transaction transaction) { - BitSquareValidator.resetTextFields(withdrawFromTextField, withdrawToTextField, - amountTextField, changeAddressTextField); + BitSquareValidator.resetTextFields( + withdrawFromTextField, withdrawToTextField, amountTextField, changeAddressTextField); if (transaction != null) { log.info("onWithdraw onSuccess txid:" + transaction.getHashAsString()); } @@ -161,22 +161,23 @@ public class WithdrawalController extends CachedViewController { } }; - Action response = Popups.openConfirmPopup("Withdrawal request", "Confirm your request", - "Your withdrawal request:\n\n" + - "Amount: " + amountTextField.getText() + " BTC\n" + - "Sending address: " + withdrawFromTextField.getText() + "\n" + - "Receiving address: " + withdrawToTextField.getText() + "\n" + - "Transaction fee: " + BitSquareFormatter.formatCoinWithCode(FeePolicy.TX_FEE) + "\n" + - "You receive in total: " + BitSquareFormatter.formatCoinWithCode(amount.subtract(FeePolicy - .TX_FEE)) + " BTC\n\n" + - "Are you sure you withdraw that amount?"); + Action response = Popups.openConfirmPopup( + "Withdrawal request", "Confirm your request", + "Your withdrawal request:\n\n" + "Amount: " + amountTextField.getText() + " BTC\n" + "Sending" + + " address: " + withdrawFromTextField.getText() + "\n" + "Receiving address: " + + withdrawToTextField.getText() + "\n" + "Transaction fee: " + + BitSquareFormatter.formatCoinWithCode(FeePolicy.TX_FEE) + "\n" + + "You receive in total: " + + BitSquareFormatter.formatCoinWithCode(amount.subtract(FeePolicy.TX_FEE)) + " BTC\n\n" + + "Are you sure you withdraw that amount?"); if (response == Dialog.Actions.OK) { try { - walletFacade.sendFunds(withdrawFromTextField.getText(), withdrawToTextField.getText(), + walletFacade.sendFunds( + withdrawFromTextField.getText(), withdrawToTextField.getText(), changeAddressTextField.getText(), amount, callback); } catch (AddressFormatException e) { - Popups.openErrorPopup("Address invalid", "The address is not correct. Please check the " + - "address format."); + Popups.openErrorPopup("Address invalid", + "The address is not correct. Please check the address format."); } catch (InsufficientMoneyException e) { Popups.openInsufficientMoneyPopup(); @@ -186,8 +187,8 @@ public class WithdrawalController extends CachedViewController { } } else { - Popups.openErrorPopup("Insufficient amount", "The amount to transfer is lower the the transaction fee" + - " and the min. possible tx value."); + Popups.openErrorPopup("Insufficient amount", + "The amount to transfer is lower the the transaction fee and the min. possible tx value."); } } catch (BitSquareValidator.ValidationException e) { @@ -243,83 +244,83 @@ public class WithdrawalController extends CachedViewController { private void setBalanceColumnCellFactory() { balanceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); - balanceColumn.setCellFactory(new Callback, TableCell>() { + balanceColumn.setCellFactory( + new Callback, TableCell>() { - @Override - public TableCell call(TableColumn column) { - return new TableCell() { @Override - public void updateItem(final WithdrawalListItem item, boolean empty) { - super.updateItem(item, empty); - setGraphic((item != null && !empty) ? item.getBalanceLabel() : null); + public TableCell call(TableColumn column) { + return new TableCell() { + @Override + public void updateItem(final WithdrawalListItem item, boolean empty) { + super.updateItem(item, empty); + setGraphic((item != null && !empty) ? item.getBalanceLabel() : null); + } + }; } - }; - } - }); + }); } private void setCopyColumnCellFactory() { copyColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue())); - copyColumn.setCellFactory(new Callback, TableCell>() { - - @Override - public TableCell call(TableColumn column) { - return new TableCell() { - final Label copyIcon = new Label(); - - { - copyIcon.getStyleClass().add("copy-icon"); - AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY); - Tooltip.install(copyIcon, new Tooltip("Copy address to clipboard")); - } + copyColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final WithdrawalListItem item, boolean empty) { - super.updateItem(item, empty); + public TableCell call(TableColumn column) { + return new TableCell() { + final Label copyIcon = new Label(); - if (item != null && !empty) { - setGraphic(copyIcon); - copyIcon.setOnMouseClicked(e -> { - Clipboard clipboard = Clipboard.getSystemClipboard(); - ClipboardContent content = new ClipboardContent(); - content.putString(item.addressStringProperty().get()); - clipboard.setContent(content); - }); + { + copyIcon.getStyleClass().add("copy-icon"); + AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY); + Tooltip.install(copyIcon, new Tooltip("Copy address to clipboard")); + } - } else { - setGraphic(null); - } + @Override + public void updateItem(final WithdrawalListItem item, boolean empty) { + super.updateItem(item, empty); + + if (item != null && !empty) { + setGraphic(copyIcon); + copyIcon.setOnMouseClicked(e -> { + Clipboard clipboard = Clipboard.getSystemClipboard(); + ClipboardContent content = new ClipboardContent(); + content.putString(item.addressStringProperty().get()); + clipboard.setContent(content); + }); + + } else { + setGraphic(null); + } + } + }; } - }; - } - }); + }); } private void setConfidenceColumnCellFactory() { - confidenceColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper(addressListItem.getValue - ())); - confidenceColumn.setCellFactory(new Callback, TableCell>() { - - @Override - public TableCell call(TableColumn column) { - return new TableCell() { + confidenceColumn.setCellValueFactory((addressListItem) -> + new ReadOnlyObjectWrapper(addressListItem.getValue())); + confidenceColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final WithdrawalListItem item, boolean empty) { - super.updateItem(item, empty); + public TableCell call(TableColumn column) { + return new TableCell() { - if (item != null && !empty) { - setGraphic(item.getProgressIndicator()); - } else { - setGraphic(null); - } + @Override + public void updateItem(final WithdrawalListItem item, boolean empty) { + super.updateItem(item, empty); + + if (item != null && !empty) { + setGraphic(item.getProgressIndicator()); + } else { + setGraphic(null); + } + } + }; } - }; - } - }); + }); } } diff --git a/src/main/java/io/bitsquare/gui/orders/offer/OfferController.java b/src/main/java/io/bitsquare/gui/orders/offer/OfferController.java index a5458ee57e..ebe1233d10 100644 --- a/src/main/java/io/bitsquare/gui/orders/offer/OfferController.java +++ b/src/main/java/io/bitsquare/gui/orders/offer/OfferController.java @@ -117,66 +117,66 @@ public class OfferController extends CachedViewController { private void setOfferIdColumnColumnCellFactory() { offerIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper(offerListItem.getValue())); - offerIdColumn.setCellFactory(new Callback, TableCell>() { - - @Override - public TableCell call(TableColumn column) { - return new TableCell() { - Hyperlink hyperlink; + offerIdColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final OfferListItem item, boolean empty) { - super.updateItem(item, empty); + public TableCell call(TableColumn column) { + return new TableCell() { + Hyperlink hyperlink; - if (item != null && !empty) { - hyperlink = new Hyperlink(item.getOfferId()); - //hyperlink.getStyleClass().setAll("aaa"); - Tooltip tooltip = new Tooltip(item.getOfferId()); - Tooltip.install(hyperlink, tooltip); - hyperlink.setOnAction(event -> openOfferDetails(item)); - setGraphic(hyperlink); - } else { - setGraphic(null); - setId(null); - } + @Override + public void updateItem(final OfferListItem item, boolean empty) { + super.updateItem(item, empty); + + if (item != null && !empty) { + hyperlink = new Hyperlink(item.getOfferId()); + //hyperlink.getStyleClass().setAll("aaa"); + Tooltip tooltip = new Tooltip(item.getOfferId()); + Tooltip.install(hyperlink, tooltip); + hyperlink.setOnAction(event -> openOfferDetails(item)); + setGraphic(hyperlink); + } else { + setGraphic(null); + setId(null); + } + } + }; } - }; - } - }); + }); } private void setRemoveColumnCellFactory() { removeColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper(offerListItem.getValue())); - removeColumn.setCellFactory(new Callback, TableCell>() { - - @Override - public TableCell call(TableColumn directionColumn) { - return new TableCell() { - final ImageView iconView = ImageUtil.getIconImageView(ImageUtil.REMOVE); - final Button button = new Button(); - - { - button.setText("Remove"); - button.setGraphic(iconView); - button.setMinWidth(70); - } + removeColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final OfferListItem offerListItem, boolean empty) { - super.updateItem(offerListItem, empty); + public TableCell call(TableColumn directionColumn) { + return new TableCell() { + final ImageView iconView = ImageUtil.getIconImageView(ImageUtil.REMOVE); + final Button button = new Button(); - if (offerListItem != null) { - button.setOnAction(event -> removeOffer(offerListItem)); - setGraphic(button); - } else { - setGraphic(null); - } + { + button.setText("Remove"); + button.setGraphic(iconView); + button.setMinWidth(70); + } + + @Override + public void updateItem(final OfferListItem offerListItem, boolean empty) { + super.updateItem(offerListItem, empty); + + if (offerListItem != null) { + button.setOnAction(event -> removeOffer(offerListItem)); + setGraphic(button); + } else { + setGraphic(null); + } + } + }; } - }; - } - }); + }); } } diff --git a/src/main/java/io/bitsquare/gui/orders/offer/OfferListItem.java b/src/main/java/io/bitsquare/gui/orders/offer/OfferListItem.java index 3e76643945..5b87fc4b45 100644 --- a/src/main/java/io/bitsquare/gui/orders/offer/OfferListItem.java +++ b/src/main/java/io/bitsquare/gui/orders/offer/OfferListItem.java @@ -37,10 +37,10 @@ public class OfferListItem { this.date.set(BitSquareFormatter.formatDateTime(offer.getCreationDate())); this.price.set(BitSquareFormatter.formatPrice(offer.getPrice())); - this.amount.set(BitSquareFormatter.formatCoin(offer.getAmount()) + " (" + BitSquareFormatter.formatCoin(offer - .getMinAmount()) + ")"); - this.volume.set(BitSquareFormatter.formatVolumeWithMinVolume(offer.getOfferVolume(), - offer.getMinOfferVolume())); + this.amount.set(BitSquareFormatter.formatCoin( + offer.getAmount()) + " (" + BitSquareFormatter.formatCoin(offer.getMinAmount()) + ")"); + this.volume.set(BitSquareFormatter.formatVolumeWithMinVolume( + offer.getOfferVolume(), offer.getMinOfferVolume())); this.offerId = offer.getId(); } diff --git a/src/main/java/io/bitsquare/gui/orders/pending/PendingTradeController.java b/src/main/java/io/bitsquare/gui/orders/pending/PendingTradeController.java index 0eed27036b..f10b5984a0 100644 --- a/src/main/java/io/bitsquare/gui/orders/pending/PendingTradeController.java +++ b/src/main/java/io/bitsquare/gui/orders/pending/PendingTradeController.java @@ -72,23 +72,17 @@ public class PendingTradeController extends CachedViewController { private Image sellIcon = ImageUtil.getIconImage(ImageUtil.SELL); private ConfidenceDisplay confidenceDisplay; - @FXML - private TableView openTradesTable; - @FXML - private TableColumn directionColumn, countryColumn, bankAccountTypeColumn, + @FXML private TableView openTradesTable; + @FXML private TableColumn directionColumn, countryColumn, bankAccountTypeColumn, priceColumn, amountColumn, volumeColumn, statusColumn, selectColumn; - @FXML - private ConfidenceProgressIndicator progressIndicator; - @FXML - private Label txTitleLabel, txHeaderLabel, confirmationLabel, txIDCopyIcon, holderNameCopyIcon, + @FXML private ConfidenceProgressIndicator progressIndicator; + @FXML private Label txTitleLabel, txHeaderLabel, confirmationLabel, txIDCopyIcon, holderNameCopyIcon, primaryBankAccountIDCopyIcon, secondaryBankAccountIDCopyIcon, bankAccountDetailsHeaderLabel, bankAccountTypeTitleLabel, holderNameTitleLabel, primaryBankAccountIDTitleLabel, secondaryBankAccountIDTitleLabel; - @FXML - private TextField txTextField, bankAccountTypeTextField, holderNameTextField, primaryBankAccountIDTextField, + @FXML private TextField txTextField, bankAccountTypeTextField, holderNameTextField, primaryBankAccountIDTextField, secondaryBankAccountIDTextField; - @FXML - private Button bankTransferInitedButton; + @FXML private Button bankTransferInitedButton; /////////////////////////////////////////////////////////////////////////////////////////// @@ -136,8 +130,7 @@ public class PendingTradeController extends CachedViewController { openTradesTable.setItems(tradeItems); openTradesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); - openTradesTable.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, - newValue) -> { + openTradesTable.getSelectionModel().selectedItemProperty().addListener((obsValue, oldValue, newValue) -> { if (newValue instanceof PendingTradesListItem) { showTradeDetails((PendingTradesListItem) newValue); } @@ -153,10 +146,9 @@ public class PendingTradeController extends CachedViewController { initCopyIcons(); // select - Optional currentTradeItemOptional = tradeItems.stream() - .filter((e) -> tradeManager.getPendingTrade() != null && e.getTrade().getId().equals(tradeManager - .getPendingTrade().getId())) - .findFirst(); + Optional currentTradeItemOptional = tradeItems.stream().filter((e) -> + tradeManager.getPendingTrade() != null && + e.getTrade().getId().equals(tradeManager.getPendingTrade().getId())).findFirst(); if (currentTradeItemOptional.isPresent()) { openTradesTable.getSelectionModel().select(currentTradeItemOptional.get()); } @@ -193,8 +185,8 @@ public class PendingTradeController extends CachedViewController { private void updateTx(Transaction transaction) { txTextField.setText(transaction.getHashAsString()); - confidenceDisplay = new ConfidenceDisplay(walletFacade.getWallet(), confirmationLabel, transaction, - progressIndicator); + confidenceDisplay = + new ConfidenceDisplay(walletFacade.getWallet(), confirmationLabel, transaction, progressIndicator); int depthInBlocks = transaction.getConfidence().getDepthInBlocks(); bankTransferInitedButton.setDisable(depthInBlocks == 0); @@ -238,8 +230,8 @@ public class PendingTradeController extends CachedViewController { currentTrade = trade; Transaction transaction = trade.getDepositTransaction(); if (transaction == null) { - trade.depositTxChangedProperty().addListener((observableValue, aBoolean, - aBoolean2) -> updateTx(trade.getDepositTransaction())); + trade.depositTxChangedProperty().addListener((observableValue, aBoolean, aBoolean2) -> + updateTx(trade.getDepositTransaction())); } else { updateTx(trade.getDepositTransaction()); } @@ -260,8 +252,8 @@ public class PendingTradeController extends CachedViewController { Transaction transaction = trade.getPayoutTransaction(); confidenceDisplay.destroy(); - confidenceDisplay = new ConfidenceDisplay(walletFacade.getWallet(), confirmationLabel, transaction, - progressIndicator); + confidenceDisplay = + new ConfidenceDisplay(walletFacade.getWallet(), confirmationLabel, transaction, progressIndicator); txTextField.setText(transaction.getHashAsString()); @@ -276,8 +268,8 @@ public class PendingTradeController extends CachedViewController { bankAccountTypeTextField.setText(BitSquareFormatter.formatCoinWithCode(trade.getTradeAmount())); holderNameTextField.setText(BitSquareFormatter.formatVolume(trade.getTradeVolume())); - primaryBankAccountIDTextField.setText(BitSquareFormatter.formatCoinWithCode(FeePolicy.CREATE_OFFER_FEE - .add(FeePolicy.TX_FEE))); + primaryBankAccountIDTextField.setText( + BitSquareFormatter.formatCoinWithCode(FeePolicy.CREATE_OFFER_FEE.add(FeePolicy.TX_FEE))); secondaryBankAccountIDTextField.setText(BitSquareFormatter.formatCoinWithCode(trade.getCollateralAmount())); holderNameCopyIcon.setVisible(false); @@ -339,137 +331,138 @@ public class PendingTradeController extends CachedViewController { private void setCountryColumnCellFactory() { countryColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue())); - countryColumn.setCellFactory(new Callback, TableCell>() { - @Override - public TableCell call(TableColumn directionColumn) { - return new TableCell() { - final HBox hBox = new HBox(); - - { - hBox.setSpacing(3); - hBox.setAlignment(Pos.CENTER); - setGraphic(hBox); - } - + countryColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty) { - super.updateItem(tradesTableItem, empty); + public TableCell call( + TableColumn directionColumn) { + return new TableCell() { + final HBox hBox = new HBox(); - hBox.getChildren().clear(); - if (tradesTableItem != null) { - Country country = tradesTableItem.getTrade().getOffer().getBankAccountCountry(); - try { - hBox.getChildren().add(ImageUtil.getIconImageView("/images/countries/" + country - .getCode().toLowerCase() + ".png")); - - } catch (Exception e) { - log.warn("Country icon not found: " + "/images/countries/" + country.getCode() - .toLowerCase() + ".png country name: " + country.getName()); + { + hBox.setSpacing(3); + hBox.setAlignment(Pos.CENTER); + setGraphic(hBox); } - Tooltip.install(this, new Tooltip(country.getName())); - } + + @Override + public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty) { + super.updateItem(tradesTableItem, empty); + + hBox.getChildren().clear(); + if (tradesTableItem != null) { + Country country = tradesTableItem.getTrade().getOffer().getBankAccountCountry(); + try { + hBox.getChildren().add(ImageUtil.getIconImageView( + "/images/countries/" + country.getCode().toLowerCase() + ".png")); + + } catch (Exception e) { + log.warn("Country icon not found: /images/countries/" + + country.getCode().toLowerCase() + ".png country name: " + + country.getName()); + } + Tooltip.install(this, new Tooltip(country.getName())); + } + } + }; } - }; - } - }); + }); } private void setBankAccountTypeColumnCellFactory() { bankAccountTypeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue())); - bankAccountTypeColumn.setCellFactory(new Callback, - TableCell>() { - @Override - public TableCell call(TableColumn directionColumn) { - return new TableCell() { + bankAccountTypeColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty) { - super.updateItem(tradesTableItem, empty); + public TableCell call( + TableColumn directionColumn) { + return new TableCell() { + @Override + public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty) { + super.updateItem(tradesTableItem, empty); - if (tradesTableItem != null) { - BankAccountType bankAccountType = tradesTableItem.getTrade().getOffer() - .getBankAccountType(); - setText(Localisation.get(bankAccountType.toString())); - } else { - setText(""); - } + if (tradesTableItem != null) { + BankAccountType bankAccountType = tradesTableItem.getTrade().getOffer() + .getBankAccountType(); + setText(Localisation.get(bankAccountType.toString())); + } else { + setText(""); + } + } + }; } - }; - } - }); + }); } private void setDirectionColumnCellFactory() { directionColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue())); - directionColumn.setCellFactory(new Callback, TableCell>() { - @Override - public TableCell call(TableColumn directionColumn) { - return new TableCell() { - final ImageView iconView = new ImageView(); - final Button button = new Button(); - - { - button.setGraphic(iconView); - button.setMinWidth(70); - } - + directionColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty) { - super.updateItem(tradesTableItem, empty); + public TableCell call( + TableColumn directionColumn) { + return new TableCell() { + final ImageView iconView = new ImageView(); + final Button button = new Button(); - if (tradesTableItem != null) { - String title; - Image icon; - Offer offer = tradesTableItem.getTrade().getOffer(); - - if (offer.getDirection() == Direction.SELL) { - icon = buyIcon; - title = BitSquareFormatter.formatDirection(Direction.BUY, true); - } else { - icon = sellIcon; - title = BitSquareFormatter.formatDirection(Direction.SELL, true); + { + button.setGraphic(iconView); + button.setMinWidth(70); } - button.setDisable(true); - iconView.setImage(icon); - button.setText(title); - setGraphic(button); - } else { - setGraphic(null); - } + + @Override + public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty) { + super.updateItem(tradesTableItem, empty); + + if (tradesTableItem != null) { + String title; + Image icon; + Offer offer = tradesTableItem.getTrade().getOffer(); + + if (offer.getDirection() == Direction.SELL) { + icon = buyIcon; + title = BitSquareFormatter.formatDirection(Direction.BUY, true); + } else { + icon = sellIcon; + title = BitSquareFormatter.formatDirection(Direction.SELL, true); + } + button.setDisable(true); + iconView.setImage(icon); + button.setText(title); + setGraphic(button); + } else { + setGraphic(null); + } + } + }; } - }; - } - }); + }); } private void setSelectColumnCellFactory() { selectColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue())); - selectColumn.setCellFactory(new Callback, TableCell>() { - @Override - public TableCell call(TableColumn directionColumn) { - return new TableCell() { - final Button button = new Button("Select"); - + selectColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty) { - super.updateItem(tradesTableItem, empty); + public TableCell call( + TableColumn directionColumn) { + return new TableCell() { + final Button button = new Button("Select"); - if (tradesTableItem != null) { - button.setOnAction(event -> showTradeDetails(tradesTableItem)); - setGraphic(button); - } else { - setGraphic(null); - } + @Override + public void updateItem(final PendingTradesListItem tradesTableItem, boolean empty) { + super.updateItem(tradesTableItem, empty); + + if (tradesTableItem != null) { + button.setOnAction(event -> showTradeDetails(tradesTableItem)); + setGraphic(button); + } else { + setGraphic(null); + } + } + }; } - }; - } - }); + }); } } diff --git a/src/main/java/io/bitsquare/gui/settings/SettingsController.java b/src/main/java/io/bitsquare/gui/settings/SettingsController.java index 452b2480c9..64755663a5 100644 --- a/src/main/java/io/bitsquare/gui/settings/SettingsController.java +++ b/src/main/java/io/bitsquare/gui/settings/SettingsController.java @@ -252,8 +252,8 @@ public class SettingsController extends CachedViewController { public void onSelectBankAccountRegion() { bankAccountCountryComboBox.setVisible(true); Region selectedBankAccountRegion = bankAccountRegionComboBox.getSelectionModel().getSelectedItem(); - bankAccountCountryComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllCountriesFor - (selectedBankAccountRegion))); + bankAccountCountryComboBox.setItems( + FXCollections.observableArrayList(CountryUtil.getAllCountriesFor(selectedBankAccountRegion))); } @FXML @@ -522,8 +522,8 @@ public class SettingsController extends CachedViewController { bankAccountCurrencyComboBox.getSelectionModel().selectFirst(); bankAccountRegionComboBox.getSelectionModel().select(3); - Optional country = bankAccountCountryComboBox.getItems().stream().filter(e -> e.getCode().equals - (CountryUtil.getDefaultCountry().getCode())).findFirst(); + Optional country = bankAccountCountryComboBox.getItems().stream().filter(e -> + e.getCode().equals(CountryUtil.getDefaultCountry().getCode())).findFirst(); if (country.isPresent()) bankAccountCountryComboBox.getSelectionModel().select(country.get()); @@ -703,7 +703,8 @@ public class SettingsController extends CachedViewController { private boolean verifyBankAccountData() { try { - BitSquareValidator.textFieldsNotEmptyWithReset(bankAccountTitleTextField, bankAccountHolderNameTextField, + BitSquareValidator.textFieldsNotEmptyWithReset( + bankAccountTitleTextField, bankAccountHolderNameTextField, bankAccountPrimaryIDTextField, bankAccountSecondaryIDTextField); BankAccountType bankAccountTypeInfo = bankAccountTypesComboBox.getSelectionModel().getSelectedItem(); @@ -712,10 +713,8 @@ public class SettingsController extends CachedViewController { bankAccountTypeInfo); return bankAccountTypesComboBox.getSelectionModel().getSelectedItem() != null && - bankAccountCountryComboBox.getSelectionModel() - .getSelectedItem() != null && bankAccountCurrencyComboBox.getSelectionModel() - .getSelectedItem() != - null; + bankAccountCountryComboBox.getSelectionModel().getSelectedItem() != null && + bankAccountCurrencyComboBox.getSelectionModel().getSelectedItem() != null; } catch (BitSquareValidator.ValidationException e) { return false; } @@ -762,6 +761,5 @@ public class SettingsController extends CachedViewController { } } - } diff --git a/src/main/java/io/bitsquare/gui/trade/TradeController.java b/src/main/java/io/bitsquare/gui/trade/TradeController.java index 78e989f234..b4a2dff7ac 100644 --- a/src/main/java/io/bitsquare/gui/trade/TradeController.java +++ b/src/main/java/io/bitsquare/gui/trade/TradeController.java @@ -73,8 +73,8 @@ public class TradeController extends CachedViewController { // TODO find better solution // Textfield focus out triggers validation, use runLater as quick fix... - ((TabPane) root).getSelectionModel().selectedIndexProperty().addListener((observableValue) -> Platform - .runLater(() -> ValidatingTextField.hidePopover())); + ((TabPane) root).getSelectionModel().selectedIndexProperty().addListener((observableValue) -> + Platform.runLater(() -> ValidatingTextField.hidePopover())); } @@ -88,8 +88,8 @@ public class TradeController extends CachedViewController { if (navigationItem == NavigationItem.ORDER_BOOK) { checkArgument(orderBookLoader == null); // Orderbook must not be cached by GuiceFXMLLoader as we use 2 instances for sell and buy screens. - orderBookLoader = new GuiceFXMLLoader(getClass().getResource(NavigationItem.ORDER_BOOK.getFxmlUrl()), - false); + orderBookLoader = + new GuiceFXMLLoader(getClass().getResource(NavigationItem.ORDER_BOOK.getFxmlUrl()), false); try { final Parent view = orderBookLoader.load(); final Tab tab = new Tab("Orderbook"); diff --git a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferController.java b/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferController.java index 40b26eee45..3903db785b 100644 --- a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferController.java +++ b/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferController.java @@ -107,8 +107,8 @@ public class CreateOfferController extends CachedViewController { viewModel.bankAccountCounty.set(bankAccount.getCountry().getName()); } viewModel.acceptedCountries.set(BitSquareFormatter.countryLocalesToString(settings.getAcceptedCountries())); - viewModel.acceptedLanguages.set(BitSquareFormatter.languageLocalesToString(settings - .getAcceptedLanguageLocales())); + viewModel.acceptedLanguages.set( + BitSquareFormatter.languageLocalesToString(settings.getAcceptedLanguageLocales())); viewModel.feeLabel.set(BitSquareFormatter.formatCoinWithCode(FeePolicy.CREATE_OFFER_FEE.add(FeePolicy.TX_FEE))); offerId = UUID.randomUUID().toString(); @@ -221,8 +221,8 @@ public class CreateOfferController extends CachedViewController { double price = BitSquareFormatter.parseToDouble(viewModel.price.get()); double volume = amount * price; viewModel.volume.set(BitSquareFormatter.formatVolume(volume)); - viewModel.totals.set(BitSquareFormatter.formatTotalsAsBtc(viewModel.amount.get(), collateral, - FeePolicy.CREATE_OFFER_FEE.add(FeePolicy.TX_FEE))); + viewModel.totals.set(BitSquareFormatter.formatTotalsAsBtc( + viewModel.amount.get(), collateral, FeePolicy.CREATE_OFFER_FEE.add(FeePolicy.TX_FEE))); viewModel.collateral.set(BitSquareFormatter.formatCollateralAsBtc(viewModel.amount.get(), collateral)); }); diff --git a/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookController.java b/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookController.java index 28d7feed6f..c69a50a627 100644 --- a/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookController.java +++ b/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookController.java @@ -332,8 +332,8 @@ public class OrderBookController extends CachedViewController { private void takeOffer(Offer offer) { if (isRegistered()) { - TakerOfferController takerOfferController = (TakerOfferController) parentController - .loadViewAndGetChildController(NavigationItem.TAKE_OFFER); + TakerOfferController takerOfferController = + (TakerOfferController) parentController.loadViewAndGetChildController(NavigationItem.TAKE_OFFER); Coin requestedAmount; if (!"".equals(amount.getText())) { @@ -357,8 +357,8 @@ public class OrderBookController extends CachedViewController { private void applyOffers() { orderBook.applyFilter(orderBookFilter); - priceColumn.setSortType((orderBookFilter.getDirection() == Direction.BUY) ? TableColumn.SortType.ASCENDING : - TableColumn.SortType.DESCENDING); + priceColumn.setSortType((orderBookFilter.getDirection() == Direction.BUY) ? + TableColumn.SortType.ASCENDING : TableColumn.SortType.DESCENDING); orderBookTable.sort(); if (orderBookTable.getItems() != null) { @@ -386,120 +386,124 @@ public class OrderBookController extends CachedViewController { private void setDirectionColumnCellFactory() { directionColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue())); - directionColumn.setCellFactory(new Callback, TableCell>() { - - @Override - public TableCell call(TableColumn directionColumn) { - return new TableCell() { - final ImageView iconView = new ImageView(); - final Button button = new Button(); - - { - button.setGraphic(iconView); - button.setMinWidth(70); - } + directionColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final OrderBookListItem orderBookListItem, boolean empty) { - super.updateItem(orderBookListItem, empty); + public TableCell call( + TableColumn directionColumn) { + return new TableCell() { + final ImageView iconView = new ImageView(); + final Button button = new Button(); - if (orderBookListItem != null) { - String title; - Image icon; - Offer offer = orderBookListItem.getOffer(); - - if (offer.getMessagePublicKey().equals(user.getMessagePublicKey())) { - icon = ImageUtil.getIconImage(ImageUtil.REMOVE); - title = "Remove"; - button.setOnAction(event -> removeOffer(orderBookListItem.getOffer())); - } else { - if (offer.getDirection() == Direction.SELL) { - icon = buyIcon; - title = BitSquareFormatter.formatDirection(Direction.BUY, true); - } else { - icon = sellIcon; - title = BitSquareFormatter.formatDirection(Direction.SELL, true); - } - - button.setDefaultButton(getIndex() == 0); - button.setOnAction(event -> takeOffer(orderBookListItem.getOffer())); + { + button.setGraphic(iconView); + button.setMinWidth(70); } + @Override + public void updateItem(final OrderBookListItem orderBookListItem, boolean empty) { + super.updateItem(orderBookListItem, empty); - iconView.setImage(icon); - button.setText(title); - setGraphic(button); - } else { - setGraphic(null); - } + if (orderBookListItem != null) { + String title; + Image icon; + Offer offer = orderBookListItem.getOffer(); + + if (offer.getMessagePublicKey().equals(user.getMessagePublicKey())) { + icon = ImageUtil.getIconImage(ImageUtil.REMOVE); + title = "Remove"; + button.setOnAction(event -> removeOffer(orderBookListItem.getOffer())); + } else { + if (offer.getDirection() == Direction.SELL) { + icon = buyIcon; + title = BitSquareFormatter.formatDirection(Direction.BUY, true); + } else { + icon = sellIcon; + title = BitSquareFormatter.formatDirection(Direction.SELL, true); + } + + button.setDefaultButton(getIndex() == 0); + button.setOnAction(event -> takeOffer(orderBookListItem.getOffer())); + } + + + iconView.setImage(icon); + button.setText(title); + setGraphic(button); + } else { + setGraphic(null); + } + } + }; } - }; - } - }); + }); } private void setCountryColumnCellFactory() { countryColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue())); - countryColumn.setCellFactory(new Callback, TableCell>() { - - @Override - public TableCell call(TableColumn directionColumn) { - return new TableCell() { - final HBox hBox = new HBox(); - - { - hBox.setSpacing(3); - hBox.setAlignment(Pos.CENTER); - setGraphic(hBox); - } + countryColumn.setCellFactory( + new Callback, TableCell>() { @Override - public void updateItem(final OrderBookListItem orderBookListItem, boolean empty) { - super.updateItem(orderBookListItem, empty); + public TableCell call( + TableColumn directionColumn) { + return new TableCell() { + final HBox hBox = new HBox(); - hBox.getChildren().clear(); - if (orderBookListItem != null) { - Country country = orderBookListItem.getOffer().getBankAccountCountry(); - try { - hBox.getChildren().add(ImageUtil.getIconImageView("/images/countries/" + country - .getCode().toLowerCase() + ".png")); - - } catch (Exception e) { - log.warn("Country icon not found: " + "/images/countries/" + country.getCode() - .toLowerCase() + ".png country name: " + country.getName()); + { + hBox.setSpacing(3); + hBox.setAlignment(Pos.CENTER); + setGraphic(hBox); } - Tooltip.install(this, new Tooltip(country.getName())); - } + + @Override + public void updateItem(final OrderBookListItem orderBookListItem, boolean empty) { + super.updateItem(orderBookListItem, empty); + + hBox.getChildren().clear(); + if (orderBookListItem != null) { + Country country = orderBookListItem.getOffer().getBankAccountCountry(); + try { + hBox.getChildren().add(ImageUtil.getIconImageView( + "/images/countries/" + country.getCode().toLowerCase() + ".png")); + + } catch (Exception e) { + log.warn("Country icon not found: /images/countries/" + + country.getCode().toLowerCase() + ".png country name: " + + country.getName()); + } + Tooltip.install(this, new Tooltip(country.getName())); + } + } + }; } - }; - } - }); + }); } private void setBankAccountTypeColumnCellFactory() { bankAccountTypeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue())); - bankAccountTypeColumn.setCellFactory(new Callback, TableCell>() { + bankAccountTypeColumn.setCellFactory( + new Callback, TableCell>() { - @Override - public TableCell call(TableColumn directionColumn) { - return new TableCell() { @Override - public void updateItem(final OrderBookListItem orderBookListItem, boolean empty) { - super.updateItem(orderBookListItem, empty); + public TableCell call( + TableColumn directionColumn) { + return new TableCell() { + @Override + public void updateItem(final OrderBookListItem orderBookListItem, boolean empty) { + super.updateItem(orderBookListItem, empty); - if (orderBookListItem != null) { - BankAccountType bankAccountType = orderBookListItem.getOffer().getBankAccountType(); - setText(Localisation.get(bankAccountType.toString())); - } else { - setText(""); - } + if (orderBookListItem != null) { + BankAccountType bankAccountType = orderBookListItem.getOffer().getBankAccountType(); + setText(Localisation.get(bankAccountType.toString())); + } else { + setText(""); + } + } + }; } - }; - } - }); + }); } diff --git a/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookListItem.java b/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookListItem.java index 61be7c307a..ad35cbeb92 100644 --- a/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookListItem.java +++ b/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookListItem.java @@ -34,10 +34,10 @@ public class OrderBookListItem { public OrderBookListItem(Offer offer) { this.offer = offer; this.price.set(BitSquareFormatter.formatPrice(offer.getPrice())); - this.amount.set(BitSquareFormatter.formatCoin(offer.getAmount()) + " (" + BitSquareFormatter.formatCoin(offer - .getMinAmount()) + ")"); - this.volume.set(BitSquareFormatter.formatVolumeWithMinVolume(offer.getOfferVolume(), - offer.getMinOfferVolume())); + this.amount.set(BitSquareFormatter.formatCoin( + offer.getAmount()) + " (" + BitSquareFormatter.formatCoin(offer.getMinAmount()) + ")"); + this.volume.set(BitSquareFormatter.formatVolumeWithMinVolume( + offer.getOfferVolume(), offer.getMinOfferVolume())); } diff --git a/src/main/java/io/bitsquare/gui/trade/takeoffer/TakerOfferController.java b/src/main/java/io/bitsquare/gui/trade/takeoffer/TakerOfferController.java index 64dd0e50c4..2e20201528 100644 --- a/src/main/java/io/bitsquare/gui/trade/takeoffer/TakerOfferController.java +++ b/src/main/java/io/bitsquare/gui/trade/takeoffer/TakerOfferController.java @@ -56,22 +56,16 @@ public class TakerOfferController extends CachedViewController { private String tradeId; private String depositTxId; - @FXML - private Accordion accordion; - @FXML - private TitledPane takeOfferTitledPane, waitBankTxTitledPane, summaryTitledPane; - @FXML - private ValidatedTextField amountTextField; - @FXML - private TextField priceTextField, volumeTextField, collateralTextField, feeTextField, totalTextField, + @FXML private Accordion accordion; + @FXML private TitledPane takeOfferTitledPane, waitBankTxTitledPane, summaryTitledPane; + @FXML private ValidatedTextField amountTextField; + @FXML private TextField priceTextField, volumeTextField, collateralTextField, feeTextField, totalTextField, bankAccountTypeTextField, countryTextField, arbitratorsTextField, supportedLanguagesTextField, supportedCountriesTextField, depositTxIdTextField, summaryPaidTextField, summaryReceivedTextField, summaryFeesTextField, summaryCollateralTextField, summaryDepositTxIdTextField, summaryPayoutTxIdTextField; - @FXML - private Label infoLabel, headLineLabel, collateralLabel; - @FXML - private Button takeOfferButton, receivedFiatButton; + @FXML private Label infoLabel, headLineLabel, collateralLabel; + @FXML private Button takeOfferButton, receivedFiatButton; /////////////////////////////////////////////////////////////////////////////////////////// // Constructor @@ -122,8 +116,8 @@ public class TakerOfferController extends CachedViewController { public void applyData() { amountTextField.setText(requestedAmount.toPlainString()); - amountTextField.setPromptText(BitSquareFormatter.formatCoinWithCode(offer.getMinAmount()) + " - " + - BitSquareFormatter.formatCoinWithCode(offer.getAmount())); + amountTextField.setPromptText(BitSquareFormatter.formatCoinWithCode( + offer.getMinAmount()) + " - " + BitSquareFormatter.formatCoinWithCode(offer.getAmount())); priceTextField.setText(BitSquareFormatter.formatPrice(offer.getPrice())); applyVolume(); collateralLabel.setText("Collateral (" + getCollateralAsPercent() + "):"); @@ -138,8 +132,8 @@ public class TakerOfferController extends CachedViewController { //todo list // arbitratorsTextField.setText(offer.getArbitrator().getName()); - supportedLanguagesTextField.setText(BitSquareFormatter.languageLocalesToString(offer - .getAcceptedLanguageLocales())); + supportedLanguagesTextField.setText(BitSquareFormatter.languageLocalesToString( + offer.getAcceptedLanguageLocales())); supportedCountriesTextField.setText(BitSquareFormatter.countryLocalesToString(offer.getAcceptedCountries())); amountTextField.textProperty().addListener(e -> { @@ -162,14 +156,14 @@ public class TakerOfferController extends CachedViewController { if (amountTextField.isInvalid()) { Popups.openErrorPopup("Invalid input", "The requested amount you entered is not a valid amount."); } else if (BitSquareValidator.tradeAmountOutOfRange(amount, offer)) { - Popups.openErrorPopup("Invalid input", "The requested amount you entered is outside of the range of the " + - "offered amount."); - } else if (addressEntry == null || getTotal().compareTo(walletFacade.getBalanceForAddress(addressEntry - .getAddress())) > 0) { + Popups.openErrorPopup( + "Invalid input", "The requested amount you entered is outside of the range of the offered amount."); + } else if (addressEntry == null || + getTotal().compareTo(walletFacade.getBalanceForAddress(addressEntry.getAddress())) > 0) { Popups.openErrorPopup("Insufficient money", "You don't have enough funds for that trade."); } else if (tradeManager.isOfferAlreadyInTrades(offer)) { - Popups.openErrorPopup("Offer previously accepted", "You have that offer already taken. Open the offer " + - "section to find that trade."); + Popups.openErrorPopup("Offer previously accepted", + "You have that offer already taken. Open the offer section to find that trade."); } else { takeOfferButton.setDisable(true); amountTextField.setEditable(false); @@ -198,10 +192,10 @@ public class TakerOfferController extends CachedViewController { summaryPaidTextField.setText(BitSquareFormatter.formatCoinWithCode(trade.getTradeAmount())); summaryReceivedTextField.setText(BitSquareFormatter.formatVolume(trade.getTradeVolume())); - summaryFeesTextField.setText(BitSquareFormatter.formatCoinWithCode(FeePolicy.TAKE_OFFER_FEE.add - (FeePolicy.TX_FEE))); - summaryCollateralTextField.setText(BitSquareFormatter.formatCoinWithCode(trade - .getCollateralAmount())); + summaryFeesTextField.setText(BitSquareFormatter.formatCoinWithCode( + FeePolicy.TAKE_OFFER_FEE.add(FeePolicy.TX_FEE))); + summaryCollateralTextField.setText(BitSquareFormatter.formatCoinWithCode( + trade.getCollateralAmount())); summaryDepositTxIdTextField.setText(depositTxId); summaryPayoutTxIdTextField.setText(payoutTxId); } @@ -209,8 +203,8 @@ public class TakerOfferController extends CachedViewController { @Override public void onFault(Throwable throwable, ProtocolForTakerAsSeller.State state) { log.error("Error while executing trade process at state: " + state + " / " + throwable); - Popups.openErrorPopup("Error while executing trade process", "Error while executing trade process" + - " at state: " + state + " / " + throwable); + Popups.openErrorPopup("Error while executing trade process", + "Error while executing trade process at state: " + state + " / " + throwable); } @Override diff --git a/src/main/java/io/bitsquare/gui/util/BtcValidator.java b/src/main/java/io/bitsquare/gui/util/BtcValidator.java index c296d88eae..75dc8bebbb 100644 --- a/src/main/java/io/bitsquare/gui/util/BtcValidator.java +++ b/src/main/java/io/bitsquare/gui/util/BtcValidator.java @@ -78,8 +78,10 @@ public class BtcValidator extends NumberValidator { BigDecimal bd = new BigDecimal(input); final BigDecimal satoshis = bd.movePointRight(8); if (satoshis.scale() > 0) - return new ValidationResult(false, "Input results in a Bitcoin value with a fraction of the smallest unit" + - " (Satoshi).", ErrorType.FRACTIONAL_SATOSHI); + return new ValidationResult( + false, + "Input results in a Bitcoin value with a fraction of the smallest unit (Satoshi).", + ErrorType.FRACTIONAL_SATOSHI); else return new ValidationResult(true); } @@ -88,7 +90,9 @@ public class BtcValidator extends NumberValidator { BigDecimal bd = new BigDecimal(input); final BigDecimal satoshis = bd.movePointRight(8); if (satoshis.longValue() > NetworkParameters.MAX_MONEY.longValue()) - return new ValidationResult(false, "Input larger as maximum possible Bitcoin value is not allowed.", + return new ValidationResult( + false, + "Input larger as maximum possible Bitcoin value is not allowed.", ErrorType.EXCEEDS_MAX_BTC_VALUE); else return new ValidationResult(true); diff --git a/src/main/java/io/bitsquare/gui/util/ConfidenceDisplay.java b/src/main/java/io/bitsquare/gui/util/ConfidenceDisplay.java index 35313758d8..705ada2e78 100644 --- a/src/main/java/io/bitsquare/gui/util/ConfidenceDisplay.java +++ b/src/main/java/io/bitsquare/gui/util/ConfidenceDisplay.java @@ -186,8 +186,8 @@ public class ConfidenceDisplay { latestTransaction = transaction; } } - if (latestTransaction != null && (transaction == null || latestTransaction.getHashAsString().equals - (transaction.getHashAsString()))) { + if (latestTransaction != null && (transaction == null || + latestTransaction.getHashAsString().equals(transaction.getHashAsString()))) { updateConfidence(latestTransaction); } } diff --git a/src/main/java/io/bitsquare/gui/util/FiatValidator.java b/src/main/java/io/bitsquare/gui/util/FiatValidator.java index 0bdee80295..8e44838c14 100644 --- a/src/main/java/io/bitsquare/gui/util/FiatValidator.java +++ b/src/main/java/io/bitsquare/gui/util/FiatValidator.java @@ -63,7 +63,9 @@ public class FiatValidator extends NumberValidator { protected ValidationResult validateIfNotExceedsMinFiatValue(String input) { double d = Double.parseDouble(input); if (d < MIN_FIAT_VALUE) - return new ValidationResult(false, "Input smaller as minimum possible Fiat value is not allowed..", + return new ValidationResult( + false, + "Input smaller as minimum possible Fiat value is not allowed..", ErrorType.UNDERCUT_MIN_FIAT_VALUE); else return new ValidationResult(true); @@ -72,7 +74,9 @@ public class FiatValidator extends NumberValidator { protected ValidationResult validateIfNotExceedsMaxFiatValue(String input) { double d = Double.parseDouble(input); if (d > MAX_FIAT_VALUE) - return new ValidationResult(false, "Input larger as maximum possible Fiat value is not allowed.", + return new ValidationResult( + false, + "Input larger as maximum possible Fiat value is not allowed.", ErrorType.EXCEEDS_MAX_FIAT_VALUE); else return new ValidationResult(true); diff --git a/src/main/java/io/bitsquare/gui/util/ValidationHelper.java b/src/main/java/io/bitsquare/gui/util/ValidationHelper.java index dab462e471..76496e2259 100644 --- a/src/main/java/io/bitsquare/gui/util/ValidationHelper.java +++ b/src/main/java/io/bitsquare/gui/util/ValidationHelper.java @@ -55,8 +55,8 @@ public class ValidationHelper { minAmountTextField.focusedProperty().addListener((ov, oldValue, newValue) -> { // only on focus out and ignore focus loss from window - if (!newValue && minAmountTextField.getScene() != null && minAmountTextField.getScene().getWindow() - .isFocused()) + if (!newValue && minAmountTextField.getScene() != null && + minAmountTextField.getScene().getWindow().isFocused()) validateMinAmount(amountTextField, minAmountTextField, amount, diff --git a/src/main/java/io/bitsquare/locale/CountryUtil.java b/src/main/java/io/bitsquare/locale/CountryUtil.java index 94b2c550ca..d8140fdfae 100644 --- a/src/main/java/io/bitsquare/locale/CountryUtil.java +++ b/src/main/java/io/bitsquare/locale/CountryUtil.java @@ -25,23 +25,24 @@ import java.util.stream.Collectors; public class CountryUtil { private static final String[] countryCodes = new String[]{"AE", "AL", "AR", "AT", "AU", "BA", "BE", "BG", "BH", - "BO", "BR", "BY", "CA", "CH", "CL", "CN", "CO", "CR", "CS", "CU", "CY", "CZ", - "DE", "DK", "DO", "DZ", "EC", "EE", "EG", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HR", "HU", - "ID", "IE", "IL", "IN", "IQ", "IS", "IT", "JO", "JP", "KR", "KW", "LB", "LT", "LU", - "LV", "LY", "MA", "ME", "MK", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "OM", "PA", "PE", "PH", "PL", - "PR", "PT", "PY", "QA", "RO", "RS", "RU", "SA", "SD", "SE", "SG", "SI", "SK", "SV", - "SY", "TH", "TN", "TR", "TW", "UA", "US", "UY", "VE", "VN", "YE", "ZA"}; + "BO", "BR", "BY", "CA", "CH", "CL", "CN", "CO", "CR", "CS", "CU", "CY", "CZ", "DE", "DK", "DO", "DZ", + "EC", "EE", "EG", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HR", "HU", "ID", "IE", "IL", "IN", + "IQ", "IS", "IT", "JO", "JP", "KR", "KW", "LB", "LT", "LU", "LV", "LY", "MA", "ME", "MK", "MT", "MX", + "MY", "NI", "NL", "NO", "NZ", "OM", "PA", "PE", "PH", "PL", "PR", "PT", "PY", "QA", "RO", "RS", "RU", + "SA", "SD", "SE", "SG", "SI", "SK", "SV", "SY", "TH", "TN", "TR", "TW", "UA", "US", "UY", "VE", "VN", + "YE", "ZA"}; private static final List countryCodeList = Arrays.asList(countryCodes); private static final String[] regionCodes = new String[]{"AS", "EU", "SA", "EU", "OC", "EU", "EU", "EU", "AS", - "SA", "SA", "EU", "NA", "EU", "SA", "AS", "SA", "NA", "EU", "NA", "AS", "EU", - "EU", "EU", "NA", "AF", "SA", "EU", "AF", "EU", "EU", "EU", "EU", "EU", "NA", "AS", "NA", "EU", "EU", - "AS", "EU", "AS", "AS", "AS", "EU", "EU", "AS", "AS", "AS", "AS", "AS", "EU", "EU", - "EU", "AF", "AF", "EU", "EU", "EU", "NA", "AS", "NA", "EU", "EU", "OC", "AS", "NA", "SA", "AS", "EU", - "NA", "EU", "SA", "AS", "EU", "EU", "EU", "AS", "AF", "EU", "AS", "EU", "EU", "NA", - "AS", "AS", "AF", "AS", "AS", "EU", "NA", "SA", "SA", "AS", "AS", "AF"}; + "SA", "SA", "EU", "NA", "EU", "SA", "AS", "SA", "NA", "EU", "NA", "AS", "EU", "EU", "EU", "NA", "AF", + "SA", "EU", "AF", "EU", "EU", "EU", "EU", "EU", "NA", "AS", "NA", "EU", "EU", "AS", "EU", "AS", "AS", + "AS", "EU", "EU", "AS", "AS", "AS", "AS", "AS", "EU", "EU", "EU", "AF", "AF", "EU", "EU", "EU", "NA", + "AS", "NA", "EU", "EU", "OC", "AS", "NA", "SA", "AS", "EU", "NA", "EU", "SA", "AS", "EU", "EU", "EU", + "AS", "AF", "EU", "AS", "EU", "EU", "NA", "AS", "AS", "AF", "AS", "AS", "EU", "NA", "SA", "SA", "AS", + "AS", "AF"}; private static final List regionCodeList = Arrays.asList(regionCodes); - private static final String[][] regionCodeToName = new String[][]{{"NA", "North America"}, {"SA", - "South America"}, {"AF", "Africa"}, {"EU", "Europe"}, {"AS", "Asia"}, {"OC", "Oceania"}}; + private static final String[][] regionCodeToName = new String[][]{ + {"NA", "North America"}, {"SA", "South America"}, {"AF", "Africa"}, {"EU", "Europe"}, {"AS", "Asia"}, + {"OC", "Oceania"}}; public static List getAllRegions() { @@ -75,8 +76,8 @@ public class CountryUtil { } public static List getAllCountriesFor(Region selectedRegion) { - return Lists.newArrayList(Collections2.filter(getAllCountries(), country -> selectedRegion != null && country - != null && selectedRegion.equals(country.getRegion()))); + return Lists.newArrayList(Collections2.filter(getAllCountries(), country -> + selectedRegion != null && country != null && selectedRegion.equals(country.getRegion()))); } @@ -112,8 +113,9 @@ public class CountryUtil { private static List getAllCountryLocales() { List allLocales = Arrays.asList(Locale.getAvailableLocales()); - Set allLocalesAsSet = allLocales.stream().filter(locale -> !"".equals(locale.getCountry())).map - (locale -> new Locale("", locale.getCountry(), "")).collect(Collectors.toSet()); + Set allLocalesAsSet = + allLocales.stream().filter(locale -> !"".equals(locale.getCountry())).map(locale -> + new Locale("", locale.getCountry(), "")).collect(Collectors.toSet()); /* same as: Set allLocalesAsSet = new HashSet<>(); diff --git a/src/main/java/io/bitsquare/locale/LanguageUtil.java b/src/main/java/io/bitsquare/locale/LanguageUtil.java index a5d93cfd97..999c02b983 100644 --- a/src/main/java/io/bitsquare/locale/LanguageUtil.java +++ b/src/main/java/io/bitsquare/locale/LanguageUtil.java @@ -41,8 +41,9 @@ public class LanguageUtil { public static List getAllLanguageLocales() { List allLocales = Arrays.asList(Locale.getAvailableLocales()); - final Set allLocalesAsSet = allLocales.stream().filter(locale -> !"".equals(locale.getLanguage())) - .map(locale -> new Locale(locale.getLanguage(), "")).collect(Collectors.toSet()); + final Set allLocalesAsSet = + allLocales.stream().filter(locale -> !"".equals(locale.getLanguage())).map(locale -> + new Locale(locale.getLanguage(), "")).collect(Collectors.toSet()); allLocales = new ArrayList<>(); allLocales.addAll(allLocalesAsSet); allLocales.sort((locale1, locale2) -> locale1.getDisplayLanguage().compareTo(locale2.getDisplayLanguage())); diff --git a/src/main/java/io/bitsquare/locale/Localisation.java b/src/main/java/io/bitsquare/locale/Localisation.java index 92b45ed315..626524830c 100644 --- a/src/main/java/io/bitsquare/locale/Localisation.java +++ b/src/main/java/io/bitsquare/locale/Localisation.java @@ -57,8 +57,8 @@ public class Localisation { class UTF8Control extends ResourceBundle.Control { - public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, - boolean reload) throws IllegalAccessException, InstantiationException, IOException { + public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) + throws IllegalAccessException, InstantiationException, IOException { // The below is a copy of the default implementation. final String bundleName = toBundleName(baseName, locale); final String resourceName = toResourceName(bundleName, "properties"); diff --git a/src/main/java/io/bitsquare/msg/BootstrappedPeerFactory.java b/src/main/java/io/bitsquare/msg/BootstrappedPeerFactory.java index 02944e4f29..02e12baf29 100644 --- a/src/main/java/io/bitsquare/msg/BootstrappedPeerFactory.java +++ b/src/main/java/io/bitsquare/msg/BootstrappedPeerFactory.java @@ -53,6 +53,8 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static io.bitsquare.msg.SeedNodeAddress.StaticSeedNodeAddresses; + /** * Creates a DHT peer and bootstrap to a seed node */ @@ -73,8 +75,8 @@ public class BootstrappedPeerFactory { /////////////////////////////////////////////////////////////////////////////////////////// @Inject - public BootstrappedPeerFactory(Persistence persistence, @Named("defaultSeedNode") SeedNodeAddress - .StaticSeedNodeAddresses defaultStaticSeedNodeAddresses) { + public BootstrappedPeerFactory(Persistence persistence, + @Named("defaultSeedNode") StaticSeedNodeAddresses defaultStaticSeedNodeAddresses) { this.persistence = persistence; this.seedNodeAddress = new SeedNodeAddress(defaultStaticSeedNodeAddresses); } @@ -154,8 +156,8 @@ public class BootstrappedPeerFactory { bootstrapWithRelay(peerDHT, nodeBehindNat); break; case "startPortForwarding": - FutureDiscover futureDiscover = peerDHT.peer().discover().peerAddress(getBootstrapAddress()) - .start(); + FutureDiscover futureDiscover = + peerDHT.peer().discover().peerAddress(getBootstrapAddress()).start(); bootstrapWithPortForwarding(peerDHT, futureDiscover); break; case "default": @@ -227,8 +229,8 @@ public class BootstrappedPeerFactory { public void operationComplete(BaseFuture future) throws Exception { if (future.isSuccess()) { // Port forwarding has succeed - log.debug("Port forwarding was successful. My address visible to the outside is " + futureNAT - .peerAddress()); + log.debug("Port forwarding was successful. My address visible to the outside is " + + futureNAT.peerAddress()); requestBootstrapPeerMap(); settableFuture.set(peerDHT); diff --git a/src/main/java/io/bitsquare/msg/MessageFacade.java b/src/main/java/io/bitsquare/msg/MessageFacade.java index ebd9967968..0a50ad0225 100644 --- a/src/main/java/io/bitsquare/msg/MessageFacade.java +++ b/src/main/java/io/bitsquare/msg/MessageFacade.java @@ -172,8 +172,8 @@ public class MessageFacade implements MessageBroker { if (future.isSuccess()) { Platform.runLater(() -> { addOfferListener.onComplete(); - orderBookListeners.stream().forEach(listener -> listener.onOfferAdded(data, - future.isSuccess())); + orderBookListeners.stream().forEach(listener -> + listener.onOfferAdded(data, future.isSuccess())); // TODO will be removed when we don't use polling anymore setDirty(locationKey); @@ -214,8 +214,8 @@ public class MessageFacade implements MessageBroker { @Override public void operationComplete(BaseFuture future) throws Exception { Platform.runLater(() -> { - orderBookListeners.stream().forEach(orderBookListener -> orderBookListener.onOfferRemoved - (data, future.isSuccess())); + orderBookListeners.stream().forEach(orderBookListener -> + orderBookListener.onOfferRemoved(data, future.isSuccess())); setDirty(locationKey); }); if (future.isSuccess()) { @@ -293,8 +293,8 @@ public class MessageFacade implements MessageBroker { addFuture.addListener(new BaseFutureAdapter() { @Override public void operationComplete(BaseFuture future) throws Exception { - Platform.runLater(() -> arbitratorListeners.stream().forEach(listener -> listener - .onArbitratorAdded(arbitratorData, addFuture.isSuccess()))); + Platform.runLater(() -> arbitratorListeners.stream().forEach(listener -> + listener.onArbitratorAdded(arbitratorData, addFuture.isSuccess()))); if (addFuture.isSuccess()) { log.trace("Add arbitrator to DHT was successful. Stored data: [key: " + locationKey + ", " + "values: " + arbitratorData + "]"); @@ -317,8 +317,8 @@ public class MessageFacade implements MessageBroker { removeFuture.addListener(new BaseFutureAdapter() { @Override public void operationComplete(BaseFuture future) throws Exception { - Platform.runLater(() -> arbitratorListeners.stream().forEach(listener -> listener.onArbitratorRemoved - (arbitratorData, removeFuture.isSuccess()))); + Platform.runLater(() -> arbitratorListeners.stream().forEach(listener -> + listener.onArbitratorRemoved(arbitratorData, removeFuture.isSuccess()))); if (removeFuture.isSuccess()) { log.trace("Remove arbitrator from DHT was successful. Stored data: [key: " + locationKey + ", " + "values: " + arbitratorData + "]"); @@ -472,8 +472,8 @@ public class MessageFacade implements MessageBroker { public void handleMessage(Object message, PeerAddress peerAddress) { if (message instanceof TradeMessage) { log.error("####################"); - Platform.runLater(() -> incomingTradeMessageListeners.stream().forEach(e -> e.onMessage((TradeMessage) - message, peerAddress))); + Platform.runLater(() -> incomingTradeMessageListeners.stream().forEach(e -> + e.onMessage((TradeMessage) message, peerAddress))); } } } diff --git a/src/main/java/io/bitsquare/msg/P2PNode.java b/src/main/java/io/bitsquare/msg/P2PNode.java index 37ae90523d..dce0af0789 100644 --- a/src/main/java/io/bitsquare/msg/P2PNode.java +++ b/src/main/java/io/bitsquare/msg/P2PNode.java @@ -161,8 +161,8 @@ public class P2PNode { /////////////////////////////////////////////////////////////////////////////////////////// // The data and the domain are protected by that key pair. - public FuturePut putDomainProtectedData(Number160 locationKey, Data data) throws IOException, - ClassNotFoundException { + public FuturePut putDomainProtectedData(Number160 locationKey, Data data) + throws IOException, ClassNotFoundException { data.protectEntry(keyPair); final Number160 ownerKeyHash = Utils.makeSHAHash(keyPair.getPublic().getEncoded()); return peerDHT.put(locationKey).data(data).keyPair(keyPair).domainKey(ownerKeyHash).protectDomain().start(); @@ -174,8 +174,8 @@ public class P2PNode { } // Not public readable. Only users with the public key of the peer who stored the data can read that data - public FutureGet getDomainProtectedData(Number160 locationKey, PublicKey publicKey) throws IOException, - ClassNotFoundException { + public FutureGet getDomainProtectedData(Number160 locationKey, PublicKey publicKey) + throws IOException, ClassNotFoundException { final Number160 ownerKeyHash = Utils.makeSHAHash(publicKey.getEncoded()); return peerDHT.get(locationKey).domainKey(ownerKeyHash).start(); } diff --git a/src/main/java/io/bitsquare/trade/TradeManager.java b/src/main/java/io/bitsquare/trade/TradeManager.java index cf80fc968a..25680d8123 100644 --- a/src/main/java/io/bitsquare/trade/TradeManager.java +++ b/src/main/java/io/bitsquare/trade/TradeManager.java @@ -214,8 +214,8 @@ public class TradeManager { Trade trade = createTrade(offer); trade.setTradeAmount(amount); - ProtocolForTakerAsSeller protocolForTakerAsSeller = new ProtocolForTakerAsSeller(trade, listener, - messageFacade, walletFacade, blockChainFacade, cryptoFacade, user); + ProtocolForTakerAsSeller protocolForTakerAsSeller = new ProtocolForTakerAsSeller( + trade, listener, messageFacade, walletFacade, blockChainFacade, cryptoFacade, user); takerAsSellerProtocolMap.put(trade.getId(), protocolForTakerAsSeller); protocolForTakerAsSeller.start(); diff --git a/src/main/java/io/bitsquare/trade/orderbook/OrderBook.java b/src/main/java/io/bitsquare/trade/orderbook/OrderBook.java index 31a1a27642..f51487b9e4 100644 --- a/src/main/java/io/bitsquare/trade/orderbook/OrderBook.java +++ b/src/main/java/io/bitsquare/trade/orderbook/OrderBook.java @@ -118,8 +118,8 @@ public class OrderBook implements OrderBookListener { boolean countryResult = countryInList(offer.getBankAccountCountry(), settings.getAcceptedCountries()); // One of the supported languages from the settings must match one of the offer languages (n to n) - boolean languageResult = languagesInList(settings.getAcceptedLanguageLocales(), - offer.getAcceptedLanguageLocales()); + boolean languageResult = + languagesInList(settings.getAcceptedLanguageLocales(), offer.getAcceptedLanguageLocales()); // Apply applyFilter only if there is a valid value set // The requested amount must be lower or equal then the offer amount diff --git a/src/main/java/io/bitsquare/trade/protocol/createoffer/tasks/BroadCastOfferFeeTx.java b/src/main/java/io/bitsquare/trade/protocol/createoffer/tasks/BroadCastOfferFeeTx.java index 38a8b0adb0..0e8b22913f 100644 --- a/src/main/java/io/bitsquare/trade/protocol/createoffer/tasks/BroadCastOfferFeeTx.java +++ b/src/main/java/io/bitsquare/trade/protocol/createoffer/tasks/BroadCastOfferFeeTx.java @@ -44,8 +44,8 @@ public class BroadCastOfferFeeTx { faultHandler.onFault("Offer fee payment failed.", e); } } else { - faultHandler.onFault("Offer fee payment failed.", new Exception("Offer fee payment failed. " + - "Transaction = null.")); + faultHandler.onFault("Offer fee payment failed.", + new Exception("Offer fee payment failed. Transaction = null.")); } } @@ -55,10 +55,10 @@ public class BroadCastOfferFeeTx { } }); } catch (InsufficientMoneyException e) { - faultHandler.onFault("Offer fee payment failed because there is insufficient money in the trade pocket. " + - "", e); + faultHandler.onFault( + "Offer fee payment failed because there is insufficient money in the trade pocket.", e); } catch (Throwable t) { - faultHandler.onFault("Offer fee payment failed because of an exception occurred. ", t); + faultHandler.onFault("Offer fee payment failed because an exception occurred.", t); } } } diff --git a/src/main/java/io/bitsquare/trade/protocol/offerer/CreateDepositTx.java b/src/main/java/io/bitsquare/trade/protocol/offerer/CreateDepositTx.java index 90b0c2e0ea..a8a5a75966 100644 --- a/src/main/java/io/bitsquare/trade/protocol/offerer/CreateDepositTx.java +++ b/src/main/java/io/bitsquare/trade/protocol/offerer/CreateDepositTx.java @@ -39,8 +39,8 @@ public class CreateDepositTx { log.trace("Run task"); try { String offererPubKey = walletFacade.getAddressInfoByTradeID(tradeId).getPubKeyAsHexString(); - Transaction transaction = walletFacade.offererCreatesMSTxAndAddPayment(offererInputAmount, offererPubKey, - takerMultiSigPubKey, arbitratorPubKeyAsHex, tradeId); + Transaction transaction = walletFacade.offererCreatesMSTxAndAddPayment( + offererInputAmount, offererPubKey, takerMultiSigPubKey, arbitratorPubKeyAsHex, tradeId); String preparedOffererDepositTxAsHex = Utils.HEX.encode(transaction.bitcoinSerialize()); long offererTxOutIndex = transaction.getInput(0).getOutpoint().getIndex(); @@ -48,8 +48,8 @@ public class CreateDepositTx { resultHandler.onResult(offererPubKey, preparedOffererDepositTxAsHex, offererTxOutIndex); } catch (InsufficientMoneyException e) { log.error("Create deposit tx faultHandler.onFault due InsufficientMoneyException " + e); - exceptionHandler.onError(new Exception("Create deposit tx faultHandler.onFault due " + - "InsufficientMoneyException " + e)); + exceptionHandler.onError( + new Exception("Create deposit tx faultHandler.onFault due InsufficientMoneyException " + e)); } } diff --git a/src/main/java/io/bitsquare/trade/protocol/offerer/HandleTakeOfferRequest.java b/src/main/java/io/bitsquare/trade/protocol/offerer/HandleTakeOfferRequest.java index 40602898b7..230ce23850 100644 --- a/src/main/java/io/bitsquare/trade/protocol/offerer/HandleTakeOfferRequest.java +++ b/src/main/java/io/bitsquare/trade/protocol/offerer/HandleTakeOfferRequest.java @@ -35,8 +35,9 @@ public class HandleTakeOfferRequest { if (!takeOfferRequestAccepted) { log.info("Received take offer request but the offer not marked as open anymore."); } - messageFacade.sendTradeMessage(peerAddress, new RespondToTakeOfferRequestMessage(tradeId, - takeOfferRequestAccepted), new OutgoingTradeMessageListener() { + RespondToTakeOfferRequestMessage tradeMessage = + new RespondToTakeOfferRequestMessage(tradeId, takeOfferRequestAccepted); + messageFacade.sendTradeMessage(peerAddress, tradeMessage, new OutgoingTradeMessageListener() { @Override public void onResult() { log.trace("RespondToTakeOfferRequestMessage successfully arrived at peer"); diff --git a/src/main/java/io/bitsquare/trade/protocol/offerer/ProtocolForOffererAsBuyer.java b/src/main/java/io/bitsquare/trade/protocol/offerer/ProtocolForOffererAsBuyer.java index a855649592..0a1d22cf57 100644 --- a/src/main/java/io/bitsquare/trade/protocol/offerer/ProtocolForOffererAsBuyer.java +++ b/src/main/java/io/bitsquare/trade/protocol/offerer/ProtocolForOffererAsBuyer.java @@ -354,8 +354,8 @@ public class ProtocolForOffererAsBuyer { log.debug("state " + state); // validation - checkState(state.ordinal() >= State.SignAndPublishDepositTx.ordinal() && state.ordinal() <= State - .onResultSetupListenerForBlockChainConfirmation.ordinal()); + checkState(state.ordinal() >= State.SignAndPublishDepositTx.ordinal() && + state.ordinal() <= State.onResultSetupListenerForBlockChainConfirmation.ordinal()); state = State.onUIEventBankTransferInited; @@ -423,5 +423,4 @@ public class ProtocolForOffererAsBuyer { listener.onFault(throwable, state); } - } diff --git a/src/main/java/io/bitsquare/trade/protocol/offerer/RequestTakerDepositPayment.java b/src/main/java/io/bitsquare/trade/protocol/offerer/RequestTakerDepositPayment.java index 50bf5572a3..10e2fc9f7f 100644 --- a/src/main/java/io/bitsquare/trade/protocol/offerer/RequestTakerDepositPayment.java +++ b/src/main/java/io/bitsquare/trade/protocol/offerer/RequestTakerDepositPayment.java @@ -40,8 +40,8 @@ public class RequestTakerDepositPayment { String preparedOffererDepositTxAsHex, long offererTxOutIndex) { log.trace("Run task"); - RequestTakerDepositPaymentMessage tradeMessage = new RequestTakerDepositPaymentMessage(tradeId, bankAccount, - accountId, offererPubKey, preparedOffererDepositTxAsHex, offererTxOutIndex); + RequestTakerDepositPaymentMessage tradeMessage = new RequestTakerDepositPaymentMessage( + tradeId, bankAccount, accountId, offererPubKey, preparedOffererDepositTxAsHex, offererTxOutIndex); messageFacade.sendTradeMessage(peerAddress, tradeMessage, new OutgoingTradeMessageListener() { @Override public void onResult() { diff --git a/src/main/java/io/bitsquare/trade/protocol/offerer/SendDepositTxIdToTaker.java b/src/main/java/io/bitsquare/trade/protocol/offerer/SendDepositTxIdToTaker.java index 7f1b77ed70..c246b80a69 100644 --- a/src/main/java/io/bitsquare/trade/protocol/offerer/SendDepositTxIdToTaker.java +++ b/src/main/java/io/bitsquare/trade/protocol/offerer/SendDepositTxIdToTaker.java @@ -33,8 +33,9 @@ public class SendDepositTxIdToTaker { public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, PeerAddress peerAddress, MessageFacade messageFacade, String tradeId, Transaction depositTransaction) { log.trace("Run task"); - DepositTxPublishedMessage tradeMessage = new DepositTxPublishedMessage(tradeId, - Utils.HEX.encode(depositTransaction.bitcoinSerialize())); + DepositTxPublishedMessage tradeMessage = + new DepositTxPublishedMessage(tradeId, Utils.HEX.encode(depositTransaction.bitcoinSerialize())); + messageFacade.sendTradeMessage(peerAddress, tradeMessage, new OutgoingTradeMessageListener() { @Override public void onResult() { diff --git a/src/main/java/io/bitsquare/trade/protocol/offerer/SendSignedPayoutTx.java b/src/main/java/io/bitsquare/trade/protocol/offerer/SendSignedPayoutTx.java index 73f7da7274..2a2ff5a3aa 100644 --- a/src/main/java/io/bitsquare/trade/protocol/offerer/SendSignedPayoutTx.java +++ b/src/main/java/io/bitsquare/trade/protocol/offerer/SendSignedPayoutTx.java @@ -48,8 +48,8 @@ public class SendSignedPayoutTx { Coin offererPaybackAmount = tradeAmount.add(collateral); Coin takerPaybackAmount = collateral; - Pair result = walletFacade.offererCreatesAndSignsPayoutTx - (depositTransactionId, offererPaybackAmount, takerPaybackAmount, takerPayoutAddress, tradeId); + Pair result = walletFacade.offererCreatesAndSignsPayoutTx( + depositTransactionId, offererPaybackAmount, takerPaybackAmount, takerPayoutAddress, tradeId); ECKey.ECDSASignature offererSignature = result.getKey(); String offererSignatureR = offererSignature.r.toString(); diff --git a/src/main/java/io/bitsquare/trade/protocol/offerer/SetupListenerForBlockChainConfirmation.java b/src/main/java/io/bitsquare/trade/protocol/offerer/SetupListenerForBlockChainConfirmation.java index 74af060bd1..69dbfe2a69 100644 --- a/src/main/java/io/bitsquare/trade/protocol/offerer/SetupListenerForBlockChainConfirmation.java +++ b/src/main/java/io/bitsquare/trade/protocol/offerer/SetupListenerForBlockChainConfirmation.java @@ -40,8 +40,8 @@ public class SetupListenerForBlockChainConfirmation { if (reason == ChangeReason.SEEN_PEERS) { listener.onDepositTxConfirmedUpdate(tx.getConfidence()); } - if (reason == ChangeReason.TYPE && tx.getConfidence().getConfidenceType() == TransactionConfidence - .ConfidenceType.BUILDING) { + if (reason == ChangeReason.TYPE && + tx.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) { listener.onDepositTxConfirmedInBlockchain(); depositTransaction.getConfidence().removeEventListener(this); log.trace("Tx is in blockchain"); diff --git a/src/main/java/io/bitsquare/trade/protocol/taker/PayDeposit.java b/src/main/java/io/bitsquare/trade/protocol/taker/PayDeposit.java index eb662c8991..1231391cce 100644 --- a/src/main/java/io/bitsquare/trade/protocol/taker/PayDeposit.java +++ b/src/main/java/io/bitsquare/trade/protocol/taker/PayDeposit.java @@ -55,8 +55,8 @@ public class PayDeposit { resultHandler.onResult(signedTakerDepositTx); } catch (InsufficientMoneyException e) { log.error("Pay deposit faultHandler.onFault due InsufficientMoneyException " + e); - exceptionHandler.onError(new Exception("Pay deposit faultHandler.onFault due InsufficientMoneyException " - + e)); + exceptionHandler.onError( + new Exception("Pay deposit faultHandler.onFault due InsufficientMoneyException " + e)); } } diff --git a/src/main/java/io/bitsquare/trade/protocol/taker/PayTakeOfferFee.java b/src/main/java/io/bitsquare/trade/protocol/taker/PayTakeOfferFee.java index ebcbd36f73..d8c6bafabf 100644 --- a/src/main/java/io/bitsquare/trade/protocol/taker/PayTakeOfferFee.java +++ b/src/main/java/io/bitsquare/trade/protocol/taker/PayTakeOfferFee.java @@ -42,14 +42,14 @@ public class PayTakeOfferFee { @Override public void onFailure(Throwable t) { log.error("Take offer fee paid faultHandler.onFault with exception: " + t); - exceptionHandler.onError(new Exception("Take offer fee paid faultHandler.onFault with exception: " + - "" + t)); + exceptionHandler.onError( + new Exception("Take offer fee paid faultHandler.onFault with exception: " + t)); } }); } catch (InsufficientMoneyException e) { log.error("Take offer fee paid faultHandler.onFault due InsufficientMoneyException " + e); - exceptionHandler.onError(new Exception("Take offer fee paid faultHandler.onFault due " + - "InsufficientMoneyException " + e)); + exceptionHandler.onError( + new Exception("Take offer fee paid faultHandler.onFault due to InsufficientMoneyException " + e)); } } diff --git a/src/main/java/io/bitsquare/trade/protocol/taker/ProtocolForTakerAsSeller.java b/src/main/java/io/bitsquare/trade/protocol/taker/ProtocolForTakerAsSeller.java index 5e19187169..ff2eba0247 100644 --- a/src/main/java/io/bitsquare/trade/protocol/taker/ProtocolForTakerAsSeller.java +++ b/src/main/java/io/bitsquare/trade/protocol/taker/ProtocolForTakerAsSeller.java @@ -318,8 +318,8 @@ public class ProtocolForTakerAsSeller { log.debug("onBankTransferInitedMessage called " + step++); log.debug("state " + state); // validate - checkState(state.ordinal() >= State.SendSignedTakerDepositTxAsHex.ordinal() && state.ordinal() < State - .SignAndPublishPayoutTx.ordinal()); + checkState(state.ordinal() >= State.SendSignedTakerDepositTxAsHex.ordinal() && + state.ordinal() < State.SignAndPublishPayoutTx.ordinal()); checkArgument(tradeId.equals(message.getTradeId())); String depositTxAsHex = nonEmptyStringOf(message.getDepositTxAsHex()); String offererSignatureR = nonEmptyStringOf(message.getOffererSignatureR()); diff --git a/src/main/java/io/bitsquare/trade/protocol/taker/RequestTakeOffer.java b/src/main/java/io/bitsquare/trade/protocol/taker/RequestTakeOffer.java index 65fdc084ef..f8fa5b14b5 100644 --- a/src/main/java/io/bitsquare/trade/protocol/taker/RequestTakeOffer.java +++ b/src/main/java/io/bitsquare/trade/protocol/taker/RequestTakeOffer.java @@ -33,17 +33,17 @@ public class RequestTakeOffer { log.trace("Run task"); messageFacade.sendTradeMessage(peerAddress, new RequestTakeOfferMessage(tradeId), new OutgoingTradeMessageListener() { - @Override - public void onResult() { - log.trace("RequestTakeOfferMessage successfully arrived at peer"); - resultHandler.onResult(); - } + @Override + public void onResult() { + log.trace("RequestTakeOfferMessage successfully arrived at peer"); + resultHandler.onResult(); + } - @Override - public void onFailed() { - log.error("RequestTakeOfferMessage did not arrive at peer"); - exceptionHandler.onError(new Exception("RequestTakeOfferMessage did not arrive at peer")); - } - }); + @Override + public void onFailed() { + log.error("RequestTakeOfferMessage did not arrive at peer"); + exceptionHandler.onError(new Exception("RequestTakeOfferMessage did not arrive at peer")); + } + }); } } diff --git a/src/main/java/io/bitsquare/trade/protocol/taker/SendSignedTakerDepositTxAsHex.java b/src/main/java/io/bitsquare/trade/protocol/taker/SendSignedTakerDepositTxAsHex.java index 9be58e1c7f..8bcc5f81c1 100644 --- a/src/main/java/io/bitsquare/trade/protocol/taker/SendSignedTakerDepositTxAsHex.java +++ b/src/main/java/io/bitsquare/trade/protocol/taker/SendSignedTakerDepositTxAsHex.java @@ -76,8 +76,8 @@ public class SendSignedTakerDepositTxAsHex { @Override public void onFailed() { log.error("RequestOffererDepositPublicationMessage did not arrive at peer"); - exceptionHandler.onError(new Exception("RequestOffererDepositPublicationMessage did not arrive at " + - "peer")); + exceptionHandler.onError( + new Exception("RequestOffererDepositPublicationMessage did not arrive at peer")); } }); } diff --git a/src/main/java/io/bitsquare/util/StorageDirectory.java b/src/main/java/io/bitsquare/util/StorageDirectory.java index b886a6b008..32a0ba1cb4 100644 --- a/src/main/java/io/bitsquare/util/StorageDirectory.java +++ b/src/main/java/io/bitsquare/util/StorageDirectory.java @@ -52,22 +52,21 @@ public class StorageDirectory { } public static File getApplicationDirectory() { - File executionRoot = new File(StorageDirectory.class.getProtectionDomain().getCodeSource().getLocation() - .getFile()); + File executionRoot = + new File(StorageDirectory.class.getProtectionDomain().getCodeSource().getLocation().getFile()); try { log.trace("executionRoot " + executionRoot.getCanonicalPath()); - // check if it is packed into a mac app (e.g.: "/Users/mk/Desktop/bitsquare.app/Contents/Java/bitsquare - // .jar") - if (executionRoot.getCanonicalPath().endsWith(".app/Contents/Java/bitsquare.jar") && System.getProperty - ("os.name").startsWith("Mac")) + // check if it is packed into a mac app (e.g.: "$HOME/Desktop/bitsquare.app/Contents/Java/bitsquare.jar") + if (executionRoot.getCanonicalPath().endsWith(".app/Contents/Java/bitsquare.jar") && + System.getProperty("os.name").startsWith("Mac")) return executionRoot.getParentFile().getParentFile().getParentFile().getParentFile(); else if (executionRoot.getCanonicalPath().endsWith(File.separator + "target" + File.separator + "classes")) return executionRoot.getParentFile(); // dev e.g.: - // /Users/mk/Documents/_intellij/bitsquare/target/classes -> use target as root + // $HOME/Documents/_intellij/bitsquare/target/classes -> use target as root else if (executionRoot.getCanonicalPath().endsWith(File.separator + "bitsquare.jar")) return executionRoot.getParentFile(); // dev with jar e.g.: - // Users/mk/Documents/_intellij/bitsquare/out/artifacts/bitsquare2/bitsquare.jar -> use target as root + // $HOME/Documents/_intellij/bitsquare/out/artifacts/bitsquare2/bitsquare.jar -> use target as root else return executionRoot; } catch (IOException e) { @@ -91,8 +90,8 @@ public class StorageDirectory { if (!storageDirectory.exists()) { boolean created = storageDirectory.mkdir(); if (!created) - throw new RuntimeException("Could not create the application data directory of '" + storageDirectory - + "'"); + throw new RuntimeException( + "Could not create the application data directory of '" + storageDirectory + "'"); } } } diff --git a/src/main/java/io/bitsquare/util/Utilities.java b/src/main/java/io/bitsquare/util/Utilities.java index 23d9e68150..15a6eaff2b 100644 --- a/src/main/java/io/bitsquare/util/Utilities.java +++ b/src/main/java/io/bitsquare/util/Utilities.java @@ -35,14 +35,14 @@ public class Utilities { private static long lastTimeStamp = System.currentTimeMillis(); public static String objectToJson(Object object) { - Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).setPrettyPrinting() - .create(); + Gson gson = + new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).setPrettyPrinting().create(); return gson.toJson(object); } public static T jsonToObject(String jsonString, Class classOfT) { - Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).setPrettyPrinting() - .create(); + Gson gson = + new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).setPrettyPrinting().create(); return gson.fromJson(jsonString, classOfT); } diff --git a/src/test/java/io/bitsquare/msg/P2PNodeTest.java b/src/test/java/io/bitsquare/msg/P2PNodeTest.java index 4fb72e49c2..fa3359cb0f 100644 --- a/src/test/java/io/bitsquare/msg/P2PNodeTest.java +++ b/src/test/java/io/bitsquare/msg/P2PNodeTest.java @@ -146,8 +146,8 @@ public class P2PNodeTest { data.protectEntry(keyPairOtherPeer); // he use the pub key from the client final Number160 keyHash = Utils.makeSHAHash(keyPairClient.getPublic().getEncoded()); - futurePut = otherPeer.put(locationKey).data(data).keyPair(keyPairOtherPeer).domainKey(keyHash).protectDomain - ().start(); + futurePut = otherPeer.put(locationKey).data(data).keyPair(keyPairOtherPeer).domainKey(keyHash) + .protectDomain().start(); futurePut.awaitUninterruptibly(); assertFalse(futurePut.isSuccess()); @@ -169,8 +169,7 @@ public class P2PNodeTest { } @Test - public void testChangeEntryProtectionKey() throws IOException, ClassNotFoundException, NoSuchAlgorithmException, - InterruptedException, InvalidKeyException, SignatureException { + public void testChangeEntryProtectionKey() throws Exception { KeyPairGenerator gen = KeyPairGenerator.getInstance("DSA"); KeyPair keyPair1 = gen.generateKeyPair(); @@ -191,8 +190,8 @@ public class P2PNodeTest { Data data2 = new Data().protectEntry(keyPair2); data2.publicKey(keyPair2.getPublic()); - FuturePut fp3 = p1.put(Number160.createHash("key1")).sign().putMeta().data(data2).start() - .awaitUninterruptibly(); + FuturePut fp3 = + p1.put(Number160.createHash("key1")).sign().putMeta().data(data2).start().awaitUninterruptibly(); Assert.assertTrue(fp3.isSuccess()); FuturePut fp4 = p2.put(Number160.createHash("key1")).sign().data(data).start().awaitUninterruptibly(); diff --git a/src/test/java/io/bitsquare/msg/UtilsDHT2.java b/src/test/java/io/bitsquare/msg/UtilsDHT2.java index 707e828741..ad6f3c6031 100644 --- a/src/test/java/io/bitsquare/msg/UtilsDHT2.java +++ b/src/test/java/io/bitsquare/msg/UtilsDHT2.java @@ -1,20 +1,3 @@ -/* - * This file is part of Bitsquare. - * - * Bitsquare is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bitsquare is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bitsquare. If not, see . - */ - /* * Copyright 2012 Thomas Bocek * @@ -90,9 +73,8 @@ public class UtilsDHT2 { return createAddress(new Number160(id), "127.0.0.1", 8005, 8006, false, false); } - public static PeerAddress createAddress(Number160 idSender, String inetSender, int tcpPortSender, - int udpPortSender, boolean firewallUDP, - boolean firewallTCP) throws UnknownHostException { + public static PeerAddress createAddress(Number160 idSender, String inetSender, int tcpPortSender, int udpPortSender, + boolean firewallUDP, boolean firewallTCP) throws UnknownHostException { InetAddress inetSend = InetAddress.getByName(inetSender); PeerSocketAddress peerSocketAddress = new PeerSocketAddress(inetSend, tcpPortSender, udpPortSender); PeerAddress n1 = new PeerAddress(idSender, peerSocketAddress, firewallTCP, firewallUDP, false, @@ -102,10 +84,8 @@ public class UtilsDHT2 { public static Message createDummyMessage(Number160 idSender, String inetSender, int tcpPortSendor, int udpPortSender, Number160 idRecipien, String inetRecipient, - int tcpPortRecipient, - int udpPortRecipient, byte command, Type type, boolean firewallUDP, - boolean firewallTCP) - throws UnknownHostException { + int tcpPortRecipient, int udpPortRecipient, byte command, Type type, + boolean firewallUDP, boolean firewallTCP) throws UnknownHostException { Message message = new Message(); PeerAddress n1 = createAddress(idSender, inetSender, tcpPortSendor, udpPortSender, firewallUDP, firewallTCP);