Format else statements on new line

Based on Manfred's existing IDEA settings
This commit is contained in:
Chris Beams 2014-08-26 15:28:18 +02:00
parent a3c4df8dc3
commit 424d4e8ff8
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
42 changed files with 284 additions and 142 deletions

View file

@ -9,6 +9,7 @@
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML> </XML>
<codeStyleSettings language="JAVA"> <codeStyleSettings language="JAVA">
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="WRAP_LONG_LINES" value="true" /> <option name="WRAP_LONG_LINES" value="true" />
<option name="FIELD_ANNOTATION_WRAP" value="0" /> <option name="FIELD_ANNOTATION_WRAP" value="0" />
</codeStyleSettings> </codeStyleSettings>

View file

@ -155,7 +155,8 @@ public class SeedNode extends Thread {
public void operationComplete(BaseFuture future) throws Exception { public void operationComplete(BaseFuture future) throws Exception {
if (future.isSuccess()) { if (future.isSuccess()) {
log.debug("peer online (TCP):" + peerAddress); log.debug("peer online (TCP):" + peerAddress);
} else { }
else {
log.debug("offline " + peerAddress); log.debug("offline " + peerAddress);
} }
} }
@ -172,7 +173,8 @@ public class SeedNode extends Thread {
public void operationComplete(BaseFuture future) throws Exception { public void operationComplete(BaseFuture future) throws Exception {
if (future.isSuccess()) { if (future.isSuccess()) {
log.debug("peer online (UDP):" + peerAddress); log.debug("peer online (UDP):" + peerAddress);
} else { }
else {
log.debug("offline " + peerAddress); log.debug("offline " + peerAddress);
} }
} }

View file

@ -110,7 +110,8 @@ public class AddressBasedCoinSelector extends DefaultCoinSelector {
protected boolean shouldSelect(Transaction tx) { protected boolean shouldSelect(Transaction tx) {
if (includePending) { if (includePending) {
return isInBlockChainOrPending(tx); return isInBlockChainOrPending(tx);
} else { }
else {
return isInBlockChain(tx); return isInBlockChain(tx);
} }
} }

View file

@ -129,7 +129,8 @@ public class WalletFacade {
// or progress widget to keep the user engaged whilst we initialise, but we don't. // or progress widget to keep the user engaged whilst we initialise, but we don't.
if (params == RegTestParams.get()) { if (params == RegTestParams.get()) {
walletAppKit.connectToLocalHost(); // You should run a regtest mode bitcoind locally. walletAppKit.connectToLocalHost(); // You should run a regtest mode bitcoind locally.
} else if (params == MainNetParams.get()) { }
else if (params == MainNetParams.get()) {
// Checkpoints are block headers that ship inside our app: for a new user, we pick the last header // Checkpoints are block headers that ship inside our app: for a new user, we pick the last header
// in the checkpoints file and then download the rest from the network. It makes things much faster. // in the checkpoints file and then download the rest from the network. It makes things much faster.
// Checkpoint files are made using the BuildCheckpoints tool and usually we have to download the // Checkpoint files are made using the BuildCheckpoints tool and usually we have to download the
@ -205,7 +206,8 @@ public class WalletFacade {
} }
addressEntryList = persistedAddressEntryList; addressEntryList = persistedAddressEntryList;
registrationAddressEntry = addressEntryList.get(0); registrationAddressEntry = addressEntryList.get(0);
} else { }
else {
lock.lock(); lock.lock();
DeterministicKey registrationKey = wallet.currentReceiveKey(); DeterministicKey registrationKey = wallet.currentReceiveKey();
registrationAddressEntry = new AddressEntry(registrationKey, params, registrationAddressEntry = new AddressEntry(registrationKey, params,
@ -782,9 +784,11 @@ public class WalletFacade {
TransactionSignature txSig = new TransactionSignature(ecSig, Transaction.SigHash.ALL, false); TransactionSignature txSig = new TransactionSignature(ecSig, Transaction.SigHash.ALL, false);
if (scriptPubKey.isSentToRawPubKey()) { if (scriptPubKey.isSentToRawPubKey()) {
input.setScriptSig(ScriptBuilder.createInputScript(txSig)); input.setScriptSig(ScriptBuilder.createInputScript(txSig));
} else if (scriptPubKey.isSentToAddress()) { }
else if (scriptPubKey.isSentToAddress()) {
input.setScriptSig(ScriptBuilder.createInputScript(txSig, sigKey)); input.setScriptSig(ScriptBuilder.createInputScript(txSig, sigKey));
} else { }
else {
throw new ScriptException("Don't know how to sign for this kind of scriptPubKey: " + scriptPubKey); throw new ScriptException("Don't know how to sign for this kind of scriptPubKey: " + scriptPubKey);
} }
@ -896,9 +900,11 @@ public class WalletFacade {
TransactionSignature txSig = new TransactionSignature(ecSig, Transaction.SigHash.ALL, false); TransactionSignature txSig = new TransactionSignature(ecSig, Transaction.SigHash.ALL, false);
if (scriptPubKey.isSentToRawPubKey()) { if (scriptPubKey.isSentToRawPubKey()) {
input.setScriptSig(ScriptBuilder.createInputScript(txSig)); input.setScriptSig(ScriptBuilder.createInputScript(txSig));
} else if (scriptPubKey.isSentToAddress()) { }
else if (scriptPubKey.isSentToAddress()) {
input.setScriptSig(ScriptBuilder.createInputScript(txSig, sigKey)); input.setScriptSig(ScriptBuilder.createInputScript(txSig, sigKey));
} else { }
else {
throw new ScriptException("Don't know how to sign for this kind of scriptPubKey: " + scriptPubKey); throw new ScriptException("Don't know how to sign for this kind of scriptPubKey: " + scriptPubKey);
} }
@ -1102,7 +1108,8 @@ public class WalletFacade {
for (TransactionInput input : tx.getInputs()) { for (TransactionInput input : tx.getInputs()) {
if (input.getConnectedOutput() != null) { if (input.getConnectedOutput() != null) {
log.trace(tracePrefix + " input value : " + input.getConnectedOutput().getValue().toFriendlyString()); log.trace(tracePrefix + " input value : " + input.getConnectedOutput().getValue().toFriendlyString());
} else { }
else {
log.trace(tracePrefix + ": " + "Transaction already has inputs but we don't have the connected " + log.trace(tracePrefix + ": " + "Transaction already has inputs but we don't have the connected " +
"outputs, so we don't know the value."); "outputs, so we don't know the value.");
} }

View file

@ -69,7 +69,8 @@ public class GuiceFXMLLoader {
item = cachedGUIItems.get(url); item = cachedGUIItems.get(url);
log.debug("loaded from cache " + url); log.debug("loaded from cache " + url);
return (T) cachedGUIItems.get(url).view; return (T) cachedGUIItems.get(url).view;
} else { }
else {
log.debug("load from disc " + url); log.debug("load from disc " + url);
T result = loader.load(); T result = loader.load();
item = new Item(result, loader.getController()); item = new Item(result, loader.getController());

View file

@ -160,7 +160,8 @@ public class ArbitratorOverviewController extends CachedViewController implement
e.printStackTrace(); e.printStackTrace();
} }
} }
} else { }
else {
allArbitrators.clear(); allArbitrators.clear();
} }

View file

@ -119,7 +119,8 @@ public class ArbitratorRegistrationController extends CachedViewController {
if (persistedArbitrator != null) { if (persistedArbitrator != null) {
arbitrator.applyPersistedArbitrator(persistedArbitrator); arbitrator.applyPersistedArbitrator(persistedArbitrator);
applyArbitrator(); applyArbitrator();
} else { }
else {
languageList.add(LanguageUtil.getDefaultLanguageLocale()); languageList.add(LanguageUtil.getDefaultLanguageLocale());
languagesTextField.setText(BitSquareFormatter.languageLocalesToString(languageList)); languagesTextField.setText(BitSquareFormatter.languageLocalesToString(languageList));
} }
@ -322,7 +323,8 @@ public class ArbitratorRegistrationController extends CachedViewController {
if (isEditMode) { if (isEditMode) {
close(); close();
} else { }
else {
setupPayCollateralScreen(); setupPayCollateralScreen();
accordion.setExpandedPane(payCollateralTitledPane); accordion.setExpandedPane(payCollateralTitledPane);
} }

View file

@ -133,7 +133,8 @@ public class Popups {
Action response = Popups.openErrorPopup("Application already running", Action response = Popups.openErrorPopup("Application already running",
"This application is already running and cannot be started twice.", ""); "This application is already running and cannot be started twice.", "");
if (response == Dialog.Actions.OK) Platform.exit(); if (response == Dialog.Actions.OK) Platform.exit();
} else { }
else {
Action response = Popups.openExceptionPopup(throwable, "Exception", "", Action response = Popups.openExceptionPopup(throwable, "Exception", "",
"A critical error has occurred.\nPlease copy the exception details and send a bug report to " + "A critical error has occurred.\nPlease copy the exception details and send a bug report to " +
"bugs@bitsquare.io."); "bugs@bitsquare.io.");

View file

@ -143,7 +143,8 @@ public class ValidatedTextField extends TextField {
if (t1) { if (t1) {
// setStyle("-fx-font-weight: bold; -fx-text-fill: red;"); // setStyle("-fx-font-weight: bold; -fx-text-fill: red;");
setEffect(invalidEffect); setEffect(invalidEffect);
} else { }
else {
// setStyle("-fx-font-weight: normal; -fx-text-fill: inherit;"); // setStyle("-fx-font-weight: normal; -fx-text-fill: inherit;");
setEffect(null); setEffect(null);
} }

View file

@ -156,7 +156,8 @@ public class ValidatingTextField extends TextField {
if (popOver != null) { if (popOver != null) {
popOver.hide(); popOver.hide();
} }
} else { }
else {
if (popOver == null) if (popOver == null)
createErrorPopOver(validationResult.errorMessage); createErrorPopOver(validationResult.errorMessage);
else else
@ -177,7 +178,8 @@ public class ValidatingTextField extends TextField {
if (errorPopupLayoutReference == null) { if (errorPopupLayoutReference == null) {
point = localToScene(0, 0); point = localToScene(0, 0);
x = point.getX() + window.getX() + getWidth() + 20; x = point.getX() + window.getX() + getWidth() + 20;
} else { }
else {
point = errorPopupLayoutReference.localToScene(0, 0); point = errorPopupLayoutReference.localToScene(0, 0);
x = point.getX() + window.getX() + errorPopupLayoutReference.getWidth() + 20; x = point.getX() + window.getX() + errorPopupLayoutReference.getWidth() + 20;
} }

View file

@ -236,7 +236,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
if (spinner != null) { if (spinner != null) {
if (getSkinnable().impl_isTreeVisible() && getSkinnable().getScene() != null) { if (getSkinnable().impl_isTreeVisible() && getSkinnable().getScene() != null) {
spinner.indeterminateTimeline.play(); spinner.indeterminateTimeline.play();
} else { }
else {
spinner.indeterminateTimeline.pause(); spinner.indeterminateTimeline.pause();
getChildren().remove(spinner); getChildren().remove(spinner);
spinner = null; spinner = null;
@ -258,7 +259,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
spinner = null; spinner = null;
timelineNulled = true; timelineNulled = true;
} }
} else { }
else {
if (getSkinnable().getScene() != null && getSkinnable().isIndeterminate()) { if (getSkinnable().getScene() != null && getSkinnable().isIndeterminate()) {
timelineNulled = false; timelineNulled = false;
spinner = new IndeterminateSpinner( spinner = new IndeterminateSpinner(
@ -301,7 +303,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
if (getSkinnable().impl_isTreeVisible()) { if (getSkinnable().impl_isTreeVisible()) {
spinner.indeterminateTimeline.play(); spinner.indeterminateTimeline.play();
} }
} else { }
else {
// clean up after spinner // clean up after spinner
if (spinner != null) { if (spinner != null) {
spinner.indeterminateTimeline.stop(); spinner.indeterminateTimeline.stop();
@ -329,7 +332,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
if (spinner != null && getSkinnable().isIndeterminate()) { if (spinner != null && getSkinnable().isIndeterminate()) {
spinner.layoutChildren(); spinner.layoutChildren();
spinner.resizeRelocate(0, 0, w, h); spinner.resizeRelocate(0, 0, w, h);
} else if (determinateIndicator != null) { }
else if (determinateIndicator != null) {
determinateIndicator.layoutChildren(); determinateIndicator.layoutChildren();
determinateIndicator.resizeRelocate(0, 0, w, h); determinateIndicator.resizeRelocate(0, 0, w, h);
} }
@ -433,7 +437,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
progress.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," + progress.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," +
"" + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," + "" + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," +
"" + c.getOpacity() + ");"); "" + c.getOpacity() + ");");
} else { }
else {
progress.setStyle(null); progress.setStyle(null);
} }
} }
@ -651,7 +656,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
if (indeterminateTimeline != null) { if (indeterminateTimeline != null) {
if (pause) { if (pause) {
indeterminateTimeline.pause(); indeterminateTimeline.pause();
} else { }
else {
indeterminateTimeline.play(); indeterminateTimeline.play();
} }
} }
@ -690,7 +696,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
region.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," + region.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," +
"" + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," + "" + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," +
"" + c.getOpacity() + ");"); "" + c.getOpacity() + ");");
} else { }
else {
region.setStyle(null); region.setStyle(null);
} }
pathsG.getChildren().add(region); pathsG.getChildren().add(region);
@ -719,7 +726,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
InvalidationListener treeVisibilityListener = valueModel -> { InvalidationListener treeVisibilityListener = valueModel -> {
if (piSkin.skin.getSkinnable().impl_isTreeVisible()) { if (piSkin.skin.getSkinnable().impl_isTreeVisible()) {
piSkin.pauseIndicator(false); piSkin.pauseIndicator(false);
} else { }
else {
piSkin.pauseIndicator(true); piSkin.pauseIndicator(true);
} }
}; };
@ -734,7 +742,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
Region region = (Region) child; Region region = (Region) child;
if (region.getShape() != null) { if (region.getShape() != null) {
w = Math.max(w, region.getShape().getLayoutBounds().getMaxX()); w = Math.max(w, region.getShape().getLayoutBounds().getMaxX());
} else { }
else {
w = Math.max(w, region.prefWidth(height)); w = Math.max(w, region.prefWidth(height));
} }
} }
@ -750,7 +759,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
Region region = (Region) child; Region region = (Region) child;
if (region.getShape() != null) { if (region.getShape() != null) {
h = Math.max(h, region.getShape().getLayoutBounds().getMaxY()); h = Math.max(h, region.getShape().getLayoutBounds().getMaxY());
} else { }
else {
h = Math.max(h, region.prefHeight(width)); h = Math.max(h, region.prefHeight(width));
} }
} }
@ -768,7 +778,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
region.resize(region.getShape().getLayoutBounds().getMaxX(), region.resize(region.getShape().getLayoutBounds().getMaxX(),
region.getShape().getLayoutBounds().getMaxY()); region.getShape().getLayoutBounds().getMaxY());
region.getTransforms().setAll(new Scale(scale, scale, 0, 0)); region.getTransforms().setAll(new Scale(scale, scale, 0, 0));
} else { }
else {
region.autosize(); region.autosize();
} }
}); });

View file

@ -140,7 +140,8 @@ public class DepositController extends CachedViewController {
log.info("Show trade details " + item.getAddressEntry().getOfferId())); log.info("Show trade details " + item.getAddressEntry().getOfferId()));
} }
setGraphic(hyperlink); setGraphic(hyperlink);
} else { }
else {
setGraphic(null); setGraphic(null);
setId(null); setId(null);
} }
@ -164,7 +165,8 @@ public class DepositController extends CachedViewController {
if (item != null && !empty) { if (item != null && !empty) {
setGraphic(item.getBalanceLabel()); setGraphic(item.getBalanceLabel());
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }
@ -202,7 +204,8 @@ public class DepositController extends CachedViewController {
clipboard.setContent(content); clipboard.setContent(content);
}); });
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }
@ -227,7 +230,8 @@ public class DepositController extends CachedViewController {
if (item != null && !empty) { if (item != null && !empty) {
setGraphic(item.getProgressIndicator()); setGraphic(item.getProgressIndicator());
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }

View file

@ -130,7 +130,8 @@ public class TransactionsController extends CachedViewController {
hyperlink.setOnAction(event -> log.info("Show trade details " + item hyperlink.setOnAction(event -> log.info("Show trade details " + item
.getAddressString())); .getAddressString()));
setGraphic(hyperlink); setGraphic(hyperlink);
} else { }
else {
setGraphic(null); setGraphic(null);
setId(null); setId(null);
} }
@ -157,7 +158,8 @@ public class TransactionsController extends CachedViewController {
if (item != null && !empty) { if (item != null && !empty) {
setGraphic(item.getProgressIndicator()); setGraphic(item.getProgressIndicator());
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }

View file

@ -61,12 +61,14 @@ public class TransactionsListItem {
address = address =
transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams()); transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams());
addressString = address.toString(); addressString = address.toString();
} else { }
else {
addressString = "No sent to address script used."; addressString = "No sent to address script used.";
} }
} }
} }
} else if (valueSentFromMe.isZero()) { }
else if (valueSentFromMe.isZero()) {
//TODO use BitSquareFormatter //TODO use BitSquareFormatter
amount.set(valueSentToMe.toFriendlyString()); amount.set(valueSentToMe.toFriendlyString());
type.set("Received with"); type.set("Received with");
@ -78,12 +80,14 @@ public class TransactionsListItem {
address = address =
transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams()); transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams());
addressString = address.toString(); addressString = address.toString();
} else { }
else {
addressString = "No sent to address script used."; addressString = "No sent to address script used.";
} }
} }
} }
} else { }
else {
//TODO use BitSquareFormatter //TODO use BitSquareFormatter
amount.set(valueSentToMe.subtract(valueSentFromMe).toFriendlyString()); amount.set(valueSentToMe.subtract(valueSentFromMe).toFriendlyString());
@ -96,7 +100,8 @@ public class TransactionsListItem {
address = transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams address = transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams
()); ());
addressString = address.toString(); addressString = address.toString();
} else { }
else {
addressString = "No sent to address script used."; addressString = "No sent to address script used.";
} }
} }
@ -104,7 +109,8 @@ public class TransactionsListItem {
if (outgoing) { if (outgoing) {
type.set("Sent to"); type.set("Sent to");
} else { }
else {
type.set("Internal (TX Fee)"); type.set("Internal (TX Fee)");
addressString = "Internal swap between addresses."; addressString = "Internal swap between addresses.";
} }

View file

@ -114,7 +114,8 @@ public class WithdrawalController extends CachedViewController {
amountTextField.setText(newValue.getBalance().toPlainString()); amountTextField.setText(newValue.getBalance().toPlainString());
withdrawFromTextField.setText(newValue.getAddressEntry().getAddressString()); withdrawFromTextField.setText(newValue.getAddressEntry().getAddressString());
changeAddressTextField.setText(newValue.getAddressEntry().getAddressString()); changeAddressTextField.setText(newValue.getAddressEntry().getAddressString());
} else { }
else {
withdrawFromTextField.setText(""); withdrawFromTextField.setText("");
withdrawFromTextField.setPromptText("No fund to withdrawal on that address."); withdrawFromTextField.setPromptText("No fund to withdrawal on that address.");
amountTextField.setText(""); amountTextField.setText("");
@ -186,7 +187,8 @@ public class WithdrawalController extends CachedViewController {
} }
} }
} else { }
else {
Popups.openErrorPopup("Insufficient amount", Popups.openErrorPopup("Insufficient amount",
"The amount to transfer is lower the the transaction fee and the min. possible tx value."); "The amount to transfer is lower the the transaction fee and the min. possible tx value.");
} }
@ -232,7 +234,8 @@ public class WithdrawalController extends CachedViewController {
().getOfferId())); ().getOfferId()));
} }
setGraphic(hyperlink); setGraphic(hyperlink);
} else { }
else {
setGraphic(null); setGraphic(null);
setId(null); setId(null);
} }
@ -289,7 +292,8 @@ public class WithdrawalController extends CachedViewController {
clipboard.setContent(content); clipboard.setContent(content);
}); });
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }
@ -314,7 +318,8 @@ public class WithdrawalController extends CachedViewController {
if (item != null && !empty) { if (item != null && !empty) {
setGraphic(item.getProgressIndicator()); setGraphic(item.getProgressIndicator());
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }

View file

@ -136,7 +136,8 @@ public class OfferController extends CachedViewController {
Tooltip.install(hyperlink, tooltip); Tooltip.install(hyperlink, tooltip);
hyperlink.setOnAction(event -> openOfferDetails(item)); hyperlink.setOnAction(event -> openOfferDetails(item));
setGraphic(hyperlink); setGraphic(hyperlink);
} else { }
else {
setGraphic(null); setGraphic(null);
setId(null); setId(null);
} }
@ -170,7 +171,8 @@ public class OfferController extends CachedViewController {
if (offerListItem != null) { if (offerListItem != null) {
button.setOnAction(event -> removeOffer(offerListItem)); button.setOnAction(event -> removeOffer(offerListItem));
setGraphic(button); setGraphic(button);
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }

View file

@ -232,14 +232,16 @@ public class PendingTradeController extends CachedViewController {
if (transaction == null) { if (transaction == null) {
trade.depositTxChangedProperty().addListener((observableValue, aBoolean, aBoolean2) -> trade.depositTxChangedProperty().addListener((observableValue, aBoolean, aBoolean2) ->
updateTx(trade.getDepositTransaction())); updateTx(trade.getDepositTransaction()));
} else { }
else {
updateTx(trade.getDepositTransaction()); updateTx(trade.getDepositTransaction());
} }
// back details // back details
if (trade.getContract() != null) { if (trade.getContract() != null) {
setBankData(trade); setBankData(trade);
} else { }
else {
trade.contractChangedProperty().addListener((observableValue, aBoolean, aBoolean2) -> setBankData(trade)); trade.contractChangedProperty().addListener((observableValue, aBoolean, aBoolean2) -> setBankData(trade));
} }
@ -385,7 +387,8 @@ public class PendingTradeController extends CachedViewController {
BankAccountType bankAccountType = tradesTableItem.getTrade().getOffer() BankAccountType bankAccountType = tradesTableItem.getTrade().getOffer()
.getBankAccountType(); .getBankAccountType();
setText(Localisation.get(bankAccountType.toString())); setText(Localisation.get(bankAccountType.toString()));
} else { }
else {
setText(""); setText("");
} }
} }
@ -422,7 +425,8 @@ public class PendingTradeController extends CachedViewController {
if (offer.getDirection() == Direction.SELL) { if (offer.getDirection() == Direction.SELL) {
icon = buyIcon; icon = buyIcon;
title = BitSquareFormatter.formatDirection(Direction.BUY, true); title = BitSquareFormatter.formatDirection(Direction.BUY, true);
} else { }
else {
icon = sellIcon; icon = sellIcon;
title = BitSquareFormatter.formatDirection(Direction.SELL, true); title = BitSquareFormatter.formatDirection(Direction.SELL, true);
} }
@ -430,7 +434,8 @@ public class PendingTradeController extends CachedViewController {
iconView.setImage(icon); iconView.setImage(icon);
button.setText(title); button.setText(title);
setGraphic(button); setGraphic(button);
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }
@ -456,7 +461,8 @@ public class PendingTradeController extends CachedViewController {
if (tradesTableItem != null) { if (tradesTableItem != null) {
button.setOnAction(event -> showTradeDetails(tradesTableItem)); button.setOnAction(event -> showTradeDetails(tradesTableItem));
setGraphic(button); setGraphic(button);
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }

View file

@ -105,7 +105,8 @@ public class SettingsController extends CachedViewController {
languageList = FXCollections.observableArrayList(settings.getAcceptedLanguageLocales()); languageList = FXCollections.observableArrayList(settings.getAcceptedLanguageLocales());
countryList = FXCollections.observableArrayList(settings.getAcceptedCountries()); countryList = FXCollections.observableArrayList(settings.getAcceptedCountries());
arbitratorList = FXCollections.observableArrayList(settings.getAcceptedArbitrators()); arbitratorList = FXCollections.observableArrayList(settings.getAcceptedArbitrators());
} else { }
else {
languageList = FXCollections.observableArrayList(new ArrayList<>()); languageList = FXCollections.observableArrayList(new ArrayList<>());
countryList = FXCollections.observableArrayList(new ArrayList<>()); countryList = FXCollections.observableArrayList(new ArrayList<>());
arbitratorList = FXCollections.observableArrayList(new ArrayList<>()); arbitratorList = FXCollections.observableArrayList(new ArrayList<>());
@ -314,7 +315,8 @@ public class SettingsController extends CachedViewController {
label.setText(item.getDisplayName()); label.setText(item.getDisplayName());
removeButton.setOnAction(actionEvent -> removeLanguage(item)); removeButton.setOnAction(actionEvent -> removeLanguage(item));
setGraphic(hBox); setGraphic(hBox);
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }
@ -384,7 +386,8 @@ public class SettingsController extends CachedViewController {
label.setText(item.getName()); label.setText(item.getName());
removeButton.setOnAction(actionEvent -> removeCountry(item)); removeButton.setOnAction(actionEvent -> removeCountry(item));
setGraphic(hBox); setGraphic(hBox);
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }
@ -441,7 +444,8 @@ public class SettingsController extends CachedViewController {
label.setText(item.getName()); label.setText(item.getName());
removeButton.setOnAction(actionEvent -> removeArbitrator(item)); removeButton.setOnAction(actionEvent -> removeArbitrator(item));
setGraphic(hBox); setGraphic(hBox);
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }
@ -503,7 +507,8 @@ public class SettingsController extends CachedViewController {
bankAccountPrimaryIDTextField.setPromptText(currentBankAccount.getBankAccountType().getPrimaryId()); bankAccountPrimaryIDTextField.setPromptText(currentBankAccount.getBankAccountType().getPrimaryId());
bankAccountSecondaryIDTextField.setText(currentBankAccount.getAccountSecondaryID()); bankAccountSecondaryIDTextField.setText(currentBankAccount.getAccountSecondaryID());
bankAccountSecondaryIDTextField.setPromptText(currentBankAccount.getBankAccountType().getSecondaryId()); bankAccountSecondaryIDTextField.setPromptText(currentBankAccount.getBankAccountType().getSecondaryId());
} else { }
else {
resetBankAccountInput(); resetBankAccountInput();
} }
} }
@ -553,7 +558,8 @@ public class SettingsController extends CachedViewController {
if (user.getBankAccounts().isEmpty()) { if (user.getBankAccounts().isEmpty()) {
bankAccountComboBox.setPromptText("No bank account available"); bankAccountComboBox.setPromptText("No bank account available");
bankAccountComboBox.setDisable(true); bankAccountComboBox.setDisable(true);
} else { }
else {
bankAccountComboBox.setPromptText("Select bank account"); bankAccountComboBox.setPromptText("Select bank account");
bankAccountComboBox.setDisable(false); bankAccountComboBox.setDisable(false);
bankAccountComboBox.setItems(FXCollections.observableArrayList(user.getBankAccounts())); bankAccountComboBox.setItems(FXCollections.observableArrayList(user.getBankAccounts()));

View file

@ -102,7 +102,8 @@ public class TradeController extends CachedViewController {
orderBookController = orderBookLoader.getController(); orderBookController = orderBookLoader.getController();
orderBookController.setParentController(this); orderBookController.setParentController(this);
return orderBookController; return orderBookController;
} else if (navigationItem == NavigationItem.CREATE_OFFER) { }
else if (navigationItem == NavigationItem.CREATE_OFFER) {
checkArgument(createOfferController == null); checkArgument(createOfferController == null);
// CreateOffer and TakeOffer must not be cached by GuiceFXMLLoader as we cannot use a view multiple times // CreateOffer and TakeOffer must not be cached by GuiceFXMLLoader as we cannot use a view multiple times
@ -121,7 +122,8 @@ public class TradeController extends CachedViewController {
log.error(e.getMessage()); log.error(e.getMessage());
} }
return null; return null;
} else if (navigationItem == NavigationItem.TAKE_OFFER) { }
else if (navigationItem == NavigationItem.TAKE_OFFER) {
checkArgument(takerOfferController == null); checkArgument(takerOfferController == null);
// CreateOffer and TakeOffer must not be cached by GuiceFXMLLoader as we cannot use a view multiple times // CreateOffer and TakeOffer must not be cached by GuiceFXMLLoader as we cannot use a view multiple times
@ -140,7 +142,8 @@ public class TradeController extends CachedViewController {
log.error(e.getMessage()); log.error(e.getMessage());
} }
return null; return null;
} else { }
else {
log.error("navigationItem not supported: " + navigationItem); log.error("navigationItem not supported: " + navigationItem);
return null; return null;
} }

View file

@ -226,7 +226,8 @@ public class OrderBookController extends CachedViewController {
ViewController nextController = parentController.loadViewAndGetChildController(NavigationItem.CREATE_OFFER); ViewController nextController = parentController.loadViewAndGetChildController(NavigationItem.CREATE_OFFER);
if (nextController != null) if (nextController != null)
((CreateOfferController) nextController).setOrderBookFilter(orderBookFilter); ((CreateOfferController) nextController).setOrderBookFilter(orderBookFilter);
} else { }
else {
showRegistrationDialog(); showRegistrationDialog();
} }
} }
@ -253,7 +254,8 @@ public class OrderBookController extends CachedViewController {
if (walletFacade.isRegistrationFeeBalanceSufficient()) { if (walletFacade.isRegistrationFeeBalanceSufficient()) {
if (walletFacade.isRegistrationFeeConfirmed()) { if (walletFacade.isRegistrationFeeConfirmed()) {
selectedIndex = 2; selectedIndex = 2;
} else { }
else {
Action response = Popups.openErrorPopup("Registration fee not confirmed yet", Action response = Popups.openErrorPopup("Registration fee not confirmed yet",
"The registration fee transaction has not been confirmed yet in the blockchain. " + "The registration fee transaction has not been confirmed yet in the blockchain. " +
"Please wait until it has at least 1 confirmation."); "Please wait until it has at least 1 confirmation.");
@ -261,7 +263,8 @@ public class OrderBookController extends CachedViewController {
MainController.GET_INSTANCE().loadViewAndGetChildController(NavigationItem.FUNDS); MainController.GET_INSTANCE().loadViewAndGetChildController(NavigationItem.FUNDS);
} }
} }
} else { }
else {
Action response = Popups.openErrorPopup("Missing registration fee", Action response = Popups.openErrorPopup("Missing registration fee",
"You have not funded the full registration fee of " + BitSquareFormatter "You have not funded the full registration fee of " + BitSquareFormatter
.formatCoinWithCode(FeePolicy.ACCOUNT_REGISTRATION_FEE) + " BTC."); .formatCoinWithCode(FeePolicy.ACCOUNT_REGISTRATION_FEE) + " BTC.");
@ -269,10 +272,12 @@ public class OrderBookController extends CachedViewController {
MainController.GET_INSTANCE().loadViewAndGetChildController(NavigationItem.FUNDS); MainController.GET_INSTANCE().loadViewAndGetChildController(NavigationItem.FUNDS);
} }
} }
} else { }
else {
selectedIndex = 1; selectedIndex = 1;
} }
} else { }
else {
selectedIndex = 0; selectedIndex = 0;
} }
@ -295,9 +300,11 @@ public class OrderBookController extends CachedViewController {
selectedIndex); selectedIndex);
if (registrationMissingAction == settingsCommandLink) { if (registrationMissingAction == settingsCommandLink) {
MainController.GET_INSTANCE().loadViewAndGetChildController(NavigationItem.SETTINGS); MainController.GET_INSTANCE().loadViewAndGetChildController(NavigationItem.SETTINGS);
} else if (registrationMissingAction == depositFeeCommandLink) { }
else if (registrationMissingAction == depositFeeCommandLink) {
MainController.GET_INSTANCE().loadViewAndGetChildController(NavigationItem.FUNDS); MainController.GET_INSTANCE().loadViewAndGetChildController(NavigationItem.FUNDS);
} else if (registrationMissingAction == sendRegistrationCommandLink) { }
else if (registrationMissingAction == sendRegistrationCommandLink) {
payRegistrationFee(); payRegistrationFee();
} }
} }
@ -338,14 +345,16 @@ public class OrderBookController extends CachedViewController {
Coin requestedAmount; Coin requestedAmount;
if (!"".equals(amount.getText())) { if (!"".equals(amount.getText())) {
requestedAmount = BitSquareFormatter.parseToCoin(amount.getText()); requestedAmount = BitSquareFormatter.parseToCoin(amount.getText());
} else { }
else {
requestedAmount = offer.getAmount(); requestedAmount = offer.getAmount();
} }
if (takerOfferController != null) { if (takerOfferController != null) {
takerOfferController.initWithData(offer, requestedAmount); takerOfferController.initWithData(offer, requestedAmount);
} }
} else { }
else {
showRegistrationDialog(); showRegistrationDialog();
} }
} }
@ -370,7 +379,8 @@ public class OrderBookController extends CachedViewController {
pollingTimer = Utilities.setInterval(1000, (animationTimer) -> { pollingTimer = Utilities.setInterval(1000, (animationTimer) -> {
if (user.getCurrentBankAccount() != null) { if (user.getCurrentBankAccount() != null) {
messageFacade.getDirtyFlag(user.getCurrentBankAccount().getCurrency()); messageFacade.getDirtyFlag(user.getCurrentBankAccount().getCurrency());
} else { }
else {
messageFacade.getDirtyFlag(CurrencyUtil.getDefaultCurrency()); messageFacade.getDirtyFlag(CurrencyUtil.getDefaultCurrency());
} }
return null; return null;
@ -414,11 +424,13 @@ public class OrderBookController extends CachedViewController {
icon = ImageUtil.getIconImage(ImageUtil.REMOVE); icon = ImageUtil.getIconImage(ImageUtil.REMOVE);
title = "Remove"; title = "Remove";
button.setOnAction(event -> removeOffer(orderBookListItem.getOffer())); button.setOnAction(event -> removeOffer(orderBookListItem.getOffer()));
} else { }
else {
if (offer.getDirection() == Direction.SELL) { if (offer.getDirection() == Direction.SELL) {
icon = buyIcon; icon = buyIcon;
title = BitSquareFormatter.formatDirection(Direction.BUY, true); title = BitSquareFormatter.formatDirection(Direction.BUY, true);
} else { }
else {
icon = sellIcon; icon = sellIcon;
title = BitSquareFormatter.formatDirection(Direction.SELL, true); title = BitSquareFormatter.formatDirection(Direction.SELL, true);
} }
@ -431,7 +443,8 @@ public class OrderBookController extends CachedViewController {
iconView.setImage(icon); iconView.setImage(icon);
button.setText(title); button.setText(title);
setGraphic(button); setGraphic(button);
} else { }
else {
setGraphic(null); setGraphic(null);
} }
} }
@ -497,7 +510,8 @@ public class OrderBookController extends CachedViewController {
if (orderBookListItem != null) { if (orderBookListItem != null) {
BankAccountType bankAccountType = orderBookListItem.getOffer().getBankAccountType(); BankAccountType bankAccountType = orderBookListItem.getOffer().getBankAccountType();
setText(Localisation.get(bankAccountType.toString())); setText(Localisation.get(bankAccountType.toString()));
} else { }
else {
setText(""); setText("");
} }
} }

View file

@ -155,16 +155,20 @@ public class TakerOfferController extends CachedViewController {
// TODO more validation (fee payment, blacklist,...) // TODO more validation (fee payment, blacklist,...)
if (amountTextField.isInvalid()) { if (amountTextField.isInvalid()) {
Popups.openErrorPopup("Invalid input", "The requested amount you entered is not a valid amount."); Popups.openErrorPopup("Invalid input", "The requested amount you entered is not a valid amount.");
} else if (BitSquareValidator.tradeAmountOutOfRange(amount, offer)) { }
else if (BitSquareValidator.tradeAmountOutOfRange(amount, offer)) {
Popups.openErrorPopup( Popups.openErrorPopup(
"Invalid input", "The requested amount you entered is outside of the range of the offered amount."); "Invalid input", "The requested amount you entered is outside of the range of the offered amount.");
} else if (addressEntry == null || }
else if (addressEntry == null ||
getTotal().compareTo(walletFacade.getBalanceForAddress(addressEntry.getAddress())) > 0) { getTotal().compareTo(walletFacade.getBalanceForAddress(addressEntry.getAddress())) > 0) {
Popups.openErrorPopup("Insufficient money", "You don't have enough funds for that trade."); Popups.openErrorPopup("Insufficient money", "You don't have enough funds for that trade.");
} else if (tradeManager.isOfferAlreadyInTrades(offer)) { }
else if (tradeManager.isOfferAlreadyInTrades(offer)) {
Popups.openErrorPopup("Offer previously accepted", Popups.openErrorPopup("Offer previously accepted",
"You have that offer already taken. Open the offer section to find that trade."); "You have that offer already taken. Open the offer section to find that trade.");
} else { }
else {
takeOfferButton.setDisable(true); takeOfferButton.setDisable(true);
amountTextField.setEditable(false); amountTextField.setEditable(false);
tradeManager.takeOffer(amount, offer, new ProtocolForTakerAsSellerListener() { tradeManager.takeOffer(amount, offer, new ProtocolForTakerAsSellerListener() {

View file

@ -103,7 +103,8 @@ public class BitSquareValidator {
textField.setEffect(invalidEffect); textField.setEffect(invalidEffect);
textField.setStyle(invalidStyle); textField.setStyle(invalidStyle);
throw new ValidationException(); throw new ValidationException();
} else { }
else {
double val = Double.parseDouble(input); double val = Double.parseDouble(input);
if (val <= 0) { if (val <= 0) {
textField.setEffect(invalidEffect); textField.setEffect(invalidEffect);

View file

@ -182,7 +182,8 @@ public class ConfidenceDisplay {
if (transaction.getUpdateTime().compareTo(latestTransaction.getUpdateTime()) > 0) { if (transaction.getUpdateTime().compareTo(latestTransaction.getUpdateTime()) > 0) {
latestTransaction = transaction; latestTransaction = transaction;
} }
} else { }
else {
latestTransaction = transaction; latestTransaction = transaction;
} }
} }

View file

@ -91,17 +91,20 @@ public class ValidationHelper {
"Amount cannot be smaller than minimum amount.", "Amount cannot be smaller than minimum amount.",
NumberValidator.ErrorType.AMOUNT_LESS_THAN_MIN_AMOUNT)); NumberValidator.ErrorType.AMOUNT_LESS_THAN_MIN_AMOUNT));
amountTextField.reValidate(); amountTextField.reValidate();
} else { }
else {
amountValidator.overrideResult(null); amountValidator.overrideResult(null);
minAmountTextField.reValidate(); minAmountTextField.reValidate();
} }
} else if (currentTextField == minAmountTextField) { }
else if (currentTextField == minAmountTextField) {
if (Double.parseDouble(minAmountCleaned) > Double.parseDouble(amountCleaned)) { if (Double.parseDouble(minAmountCleaned) > Double.parseDouble(amountCleaned)) {
minAmountValidator.overrideResult(new NumberValidator.ValidationResult(false, minAmountValidator.overrideResult(new NumberValidator.ValidationResult(false,
"Minimum amount cannot be larger than amount.", "Minimum amount cannot be larger than amount.",
NumberValidator.ErrorType.MIN_AMOUNT_LARGER_THAN_MIN_AMOUNT)); NumberValidator.ErrorType.MIN_AMOUNT_LARGER_THAN_MIN_AMOUNT));
minAmountTextField.reValidate(); minAmountTextField.reValidate();
} else { }
else {
minAmountValidator.overrideResult(null); minAmountValidator.overrideResult(null);
amountTextField.reValidate(); amountTextField.reValidate();
} }

View file

@ -137,7 +137,8 @@ public class CountryUtil {
private static String getRegionCode(String countryCode) { private static String getRegionCode(String countryCode) {
if (!countryCode.isEmpty() && countryCodeList.contains(countryCode)) { if (!countryCode.isEmpty() && countryCodeList.contains(countryCode)) {
return regionCodeList.get(countryCodeList.indexOf(countryCode)); return regionCodeList.get(countryCodeList.indexOf(countryCode));
} else { }
else {
return "Undefined"; return "Undefined";
} }
} }

View file

@ -73,7 +73,8 @@ class UTF8Control extends ResourceBundle.Control {
stream = connection.getInputStream(); stream = connection.getInputStream();
} }
} }
} else { }
else {
stream = loader.getResourceAsStream(resourceName); stream = loader.getResourceAsStream(resourceName);
} }
if (stream != null) { if (stream != null) {

View file

@ -200,7 +200,8 @@ public class BootstrappedPeerFactory {
settableFuture.set(peerDHT); settableFuture.set(peerDHT);
persistence.write(ref, "lastSuccessfulBootstrap", "default"); persistence.write(ref, "lastSuccessfulBootstrap", "default");
} else { }
else {
log.warn("Discover has failed. Reason: " + futureDiscover.failedReason()); log.warn("Discover has failed. Reason: " + futureDiscover.failedReason());
log.warn("We are probably behind a NAT and not reachable to other peers. We try port forwarding " + log.warn("We are probably behind a NAT and not reachable to other peers. We try port forwarding " +
"as next step."); "as next step.");
@ -235,7 +236,8 @@ public class BootstrappedPeerFactory {
settableFuture.set(peerDHT); settableFuture.set(peerDHT);
persistence.write(ref, "lastSuccessfulBootstrap", "portForwarding"); persistence.write(ref, "lastSuccessfulBootstrap", "portForwarding");
} else { }
else {
log.warn("Port forwarding has failed. Reason: " + futureNAT.failedReason()); log.warn("Port forwarding has failed. Reason: " + futureNAT.failedReason());
log.warn("We try to use a relay as next step."); log.warn("We try to use a relay as next step.");
@ -269,7 +271,8 @@ public class BootstrappedPeerFactory {
log.debug("Bootstrap was successful. bootstrapTo = " + futureBootstrap.bootstrapTo()); log.debug("Bootstrap was successful. bootstrapTo = " + futureBootstrap.bootstrapTo());
setupRelay(peerDHT, nodeBehindNat, getBootstrapAddress()); setupRelay(peerDHT, nodeBehindNat, getBootstrapAddress());
} else { }
else {
log.error("Bootstrap failed. Reason:" + futureBootstrap.failedReason()); log.error("Bootstrap failed. Reason:" + futureBootstrap.failedReason());
settableFuture.setException(new Exception(futureBootstrap.failedReason())); settableFuture.setException(new Exception(futureBootstrap.failedReason()));
} }
@ -293,7 +296,8 @@ public class BootstrappedPeerFactory {
futureRelay.relays().forEach(e -> log.debug("remotePeer = " + e.remotePeer())); futureRelay.relays().forEach(e -> log.debug("remotePeer = " + e.remotePeer()));
findNeighbors2(peerDHT, nodeBehindNat, bootstrapAddress); findNeighbors2(peerDHT, nodeBehindNat, bootstrapAddress);
} else { }
else {
log.error("setupRelay failed. Reason: " + futureRelay.failedReason()); log.error("setupRelay failed. Reason: " + futureRelay.failedReason());
log.error("Bootstrap failed. We give up..."); log.error("Bootstrap failed. We give up...");
settableFuture.setException(new Exception(futureRelay.failedReason())); settableFuture.setException(new Exception(futureRelay.failedReason()));
@ -326,7 +330,8 @@ public class BootstrappedPeerFactory {
settableFuture.set(peerDHT); settableFuture.set(peerDHT);
persistence.write(ref, "lastSuccessfulBootstrap", "relay"); persistence.write(ref, "lastSuccessfulBootstrap", "relay");
} else { }
else {
log.error("Bootstrap 2 failed. Reason:" + futureBootstrap2.failedReason()); log.error("Bootstrap 2 failed. Reason:" + futureBootstrap2.failedReason());
log.error("We give up..."); log.error("We give up...");
settableFuture.setException(new Exception(futureBootstrap2.failedReason())); settableFuture.setException(new Exception(futureBootstrap2.failedReason()));

View file

@ -141,7 +141,8 @@ public class MessageFacade implements MessageBroker {
if (baseFuture.isSuccess() && futureGet.data() != null) { if (baseFuture.isSuccess() && futureGet.data() != null) {
final PeerAddress peerAddress = (PeerAddress) futureGet.data().object(); final PeerAddress peerAddress = (PeerAddress) futureGet.data().object();
Platform.runLater(() -> listener.onResult(peerAddress)); Platform.runLater(() -> listener.onResult(peerAddress));
} else { }
else {
Platform.runLater(() -> listener.onFailed()); Platform.runLater(() -> listener.onFailed());
} }
} }
@ -180,7 +181,8 @@ public class MessageFacade implements MessageBroker {
log.trace("Add offer to DHT was successful. Stored data: [key: " + locationKey + ", " + log.trace("Add offer to DHT was successful. Stored data: [key: " + locationKey + ", " +
"value: " + data + "]"); "value: " + data + "]");
}); });
} else { }
else {
Platform.runLater(() -> { Platform.runLater(() -> {
addOfferListener.onFailed("Add offer to DHT failed.", addOfferListener.onFailed("Add offer to DHT failed.",
new Exception("Add offer to DHT failed. Reason: " + future.failedReason())); new Exception("Add offer to DHT failed. Reason: " + future.failedReason()));
@ -221,7 +223,8 @@ public class MessageFacade implements MessageBroker {
if (future.isSuccess()) { if (future.isSuccess()) {
log.trace("Remove offer from DHT was successful. Stored data: [key: " + locationKey + ", " + log.trace("Remove offer from DHT was successful. Stored data: [key: " + locationKey + ", " +
"value: " + data + "]"); "value: " + data + "]");
} else { }
else {
log.error("Remove offer from DHT failed. Reason: " + future.failedReason()); log.error("Remove offer from DHT failed. Reason: " + future.failedReason());
} }
} }
@ -247,7 +250,8 @@ public class MessageFacade implements MessageBroker {
if (baseFuture.isSuccess()) { if (baseFuture.isSuccess()) {
//log.trace("Get offers from DHT was successful. Stored data: [key: " + locationKey + ", //log.trace("Get offers from DHT was successful. Stored data: [key: " + locationKey + ",
// values: " + futureGet.dataMap() + "]"); // values: " + futureGet.dataMap() + "]");
} else { }
else {
log.error("Get offers from DHT failed with reason:" + baseFuture.failedReason()); log.error("Get offers from DHT failed with reason:" + baseFuture.failedReason());
} }
} }
@ -267,7 +271,8 @@ public class MessageFacade implements MessageBroker {
public void operationComplete(BaseFuture future) throws Exception { public void operationComplete(BaseFuture future) throws Exception {
if (futureDirect.isSuccess()) { if (futureDirect.isSuccess()) {
Platform.runLater(() -> listener.onResult()); Platform.runLater(() -> listener.onResult());
} else { }
else {
Platform.runLater(() -> listener.onFailed()); Platform.runLater(() -> listener.onFailed());
} }
} }
@ -298,7 +303,8 @@ public class MessageFacade implements MessageBroker {
if (addFuture.isSuccess()) { if (addFuture.isSuccess()) {
log.trace("Add arbitrator to DHT was successful. Stored data: [key: " + locationKey + ", " + log.trace("Add arbitrator to DHT was successful. Stored data: [key: " + locationKey + ", " +
"values: " + arbitratorData + "]"); "values: " + arbitratorData + "]");
} else { }
else {
log.error("Add arbitrator to DHT failed with reason:" + addFuture.failedReason()); log.error("Add arbitrator to DHT failed with reason:" + addFuture.failedReason());
} }
} }
@ -322,7 +328,8 @@ public class MessageFacade implements MessageBroker {
if (removeFuture.isSuccess()) { if (removeFuture.isSuccess()) {
log.trace("Remove arbitrator from DHT was successful. Stored data: [key: " + locationKey + ", " + log.trace("Remove arbitrator from DHT was successful. Stored data: [key: " + locationKey + ", " +
"values: " + arbitratorData + "]"); "values: " + arbitratorData + "]");
} else { }
else {
log.error("Remove arbitrators from DHT failed with reason:" + removeFuture.failedReason()); log.error("Remove arbitrators from DHT failed with reason:" + removeFuture.failedReason());
} }
} }
@ -340,7 +347,8 @@ public class MessageFacade implements MessageBroker {
if (baseFuture.isSuccess()) { if (baseFuture.isSuccess()) {
log.trace("Get arbitrators from DHT was successful. Stored data: [key: " + locationKey + ", " + log.trace("Get arbitrators from DHT was successful. Stored data: [key: " + locationKey + ", " +
"values: " + futureGet.dataMap() + "]"); "values: " + futureGet.dataMap() + "]");
} else { }
else {
log.error("Get arbitrators from DHT failed with reason:" + baseFuture.failedReason()); log.error("Get arbitrators from DHT failed with reason:" + baseFuture.failedReason());
} }
} }
@ -432,7 +440,8 @@ public class MessageFacade implements MessageBroker {
} }
if (lastTimeStamp > 0) { if (lastTimeStamp > 0) {
lastTimeStamp = timeStamp; lastTimeStamp = timeStamp;
} else { }
else {
lastTimeStamp++; lastTimeStamp++;
} }
} }

View file

@ -214,7 +214,8 @@ public class P2PNode {
public void operationComplete(BaseFuture future) throws Exception { public void operationComplete(BaseFuture future) throws Exception {
if (futureDirect.isSuccess()) { if (futureDirect.isSuccess()) {
log.debug("sendMessage completed"); log.debug("sendMessage completed");
} else { }
else {
log.error("sendData failed with Reason " + futureDirect.failedReason()); log.error("sendData failed with Reason " + futureDirect.failedReason());
} }
} }
@ -248,7 +249,8 @@ public class P2PNode {
if (future.isSuccess()) { if (future.isSuccess()) {
storedPeerAddress = peerDHT.peerAddress(); storedPeerAddress = peerDHT.peerAddress();
log.debug("storedPeerAddress = " + storedPeerAddress); log.debug("storedPeerAddress = " + storedPeerAddress);
} else { }
else {
log.error(""); log.error("");
} }
} }
@ -258,7 +260,8 @@ public class P2PNode {
log.error(t.toString()); log.error(t.toString());
} }
}); });
} else { }
else {
log.error("peerDHT is null"); log.error("peerDHT is null");
} }
} catch (IOException | ClassNotFoundException e) { } catch (IOException | ClassNotFoundException e) {
@ -325,7 +328,8 @@ public class P2PNode {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { }
else {
storage = new StorageMemory(); storage = new StorageMemory();
} }
} }

View file

@ -70,7 +70,8 @@ public class Persistence {
} finally { } finally {
lock.unlock(); lock.unlock();
} }
} else { }
else {
rootMap = map; rootMap = map;
} }
} finally { } finally {
@ -144,7 +145,8 @@ public class Persistence {
if (rootMap.containsKey(key)) { if (rootMap.containsKey(key)) {
// log.trace("Read object with key = " + key + " / value = " + rootMap.get(key)); // log.trace("Read object with key = " + key + " / value = " + rootMap.get(key));
return rootMap.get(key); return rootMap.get(key);
} else { }
else {
final Map<String, Serializable> map = readRootMap(); final Map<String, Serializable> map = readRootMap();
if (map != null) { if (map != null) {
rootMap = map; rootMap = map;
@ -152,7 +154,8 @@ public class Persistence {
if (rootMap.containsKey(key)) { if (rootMap.containsKey(key)) {
// log.trace("Read object with key = " + key + " / value = " + rootMap.get(key)); // log.trace("Read object with key = " + key + " / value = " + rootMap.get(key));
return rootMap.get(key); return rootMap.get(key);
} else { }
else {
log.info("Object with key = " + key + " not found."); log.info("Object with key = " + key + " not found.");
return null; return null;
} }
@ -174,11 +177,13 @@ public class Persistence {
if (object == null) { if (object == null) {
log.error("readRootMap returned null object."); log.error("readRootMap returned null object.");
return null; return null;
} else { }
else {
if (object instanceof Map) { if (object instanceof Map) {
//noinspection unchecked //noinspection unchecked
return (Map<String, Serializable>) object; return (Map<String, Serializable>) object;
} else { }
else {
log.error("Object is not type of Map<String, Serializable>"); log.error("Object is not type of Map<String, Serializable>");
return null; return null;
} }

View file

@ -97,14 +97,16 @@ public class TradeManager {
Object offersObject = persistence.read(this, "offers"); Object offersObject = persistence.read(this, "offers");
if (offersObject instanceof HashMap) { if (offersObject instanceof HashMap) {
offers = (Map<String, Offer>) offersObject; offers = (Map<String, Offer>) offersObject;
} else { }
else {
offers = new HashMap<>(); offers = new HashMap<>();
} }
Object tradesObject = persistence.read(this, "trades"); Object tradesObject = persistence.read(this, "trades");
if (tradesObject instanceof HashMap) { if (tradesObject instanceof HashMap) {
trades = (Map<String, Trade>) tradesObject; trades = (Map<String, Trade>) tradesObject;
} else { }
else {
trades = new HashMap<>(); trades = new HashMap<>();
} }
@ -164,7 +166,8 @@ public class TradeManager {
if (createOfferCoordinatorMap.containsKey(offer.getId())) { if (createOfferCoordinatorMap.containsKey(offer.getId())) {
errorMessageHandler.onFault("A createOfferCoordinator for the offer with the id " + offer.getId() + " " + errorMessageHandler.onFault("A createOfferCoordinator for the offer with the id " + offer.getId() + " " +
"already exists."); "already exists.");
} else { }
else {
CreateOfferCoordinator createOfferCoordinator = new CreateOfferCoordinator(persistence, CreateOfferCoordinator createOfferCoordinator = new CreateOfferCoordinator(persistence,
offer, offer,
walletFacade, walletFacade,
@ -332,14 +335,16 @@ public class TradeManager {
if (!offererAsBuyerProtocolMap.containsKey(trade.getId())) { if (!offererAsBuyerProtocolMap.containsKey(trade.getId())) {
offererAsBuyerProtocolMap.put(trade.getId(), protocolForOffererAsBuyer); offererAsBuyerProtocolMap.put(trade.getId(), protocolForOffererAsBuyer);
} else { }
else {
// We don't store the protocol in case we have already a pending offer. The protocol is only // We don't store the protocol in case we have already a pending offer. The protocol is only
// temporary used to reply with a reject message. // temporary used to reply with a reject message.
log.trace("offererAsBuyerProtocol not stored as offer is already pending."); log.trace("offererAsBuyerProtocol not stored as offer is already pending.");
} }
protocolForOffererAsBuyer.start(); protocolForOffererAsBuyer.start();
} else { }
else {
log.warn("Incoming offer take request does not match with any saved offer. We ignore that request."); log.warn("Incoming offer take request does not match with any saved offer. We ignore that request.");
} }
} }
@ -365,22 +370,29 @@ public class TradeManager {
if (tradeMessage instanceof RequestTakeOfferMessage) { if (tradeMessage instanceof RequestTakeOfferMessage) {
createOffererAsBuyerProtocol(tradeId, sender); createOffererAsBuyerProtocol(tradeId, sender);
takeOfferRequestListeners.stream().forEach(e -> e.onTakeOfferRequested(tradeId, sender)); takeOfferRequestListeners.stream().forEach(e -> e.onTakeOfferRequested(tradeId, sender));
} else if (tradeMessage instanceof RespondToTakeOfferRequestMessage) { }
else if (tradeMessage instanceof RespondToTakeOfferRequestMessage) {
takerAsSellerProtocolMap.get(tradeId).onRespondToTakeOfferRequestMessage( takerAsSellerProtocolMap.get(tradeId).onRespondToTakeOfferRequestMessage(
(RespondToTakeOfferRequestMessage) tradeMessage); (RespondToTakeOfferRequestMessage) tradeMessage);
} else if (tradeMessage instanceof TakeOfferFeePayedMessage) { }
else if (tradeMessage instanceof TakeOfferFeePayedMessage) {
offererAsBuyerProtocolMap.get(tradeId).onTakeOfferFeePayedMessage((TakeOfferFeePayedMessage) tradeMessage); offererAsBuyerProtocolMap.get(tradeId).onTakeOfferFeePayedMessage((TakeOfferFeePayedMessage) tradeMessage);
} else if (tradeMessage instanceof RequestTakerDepositPaymentMessage) { }
else if (tradeMessage instanceof RequestTakerDepositPaymentMessage) {
takerAsSellerProtocolMap.get(tradeId).onRequestTakerDepositPaymentMessage( takerAsSellerProtocolMap.get(tradeId).onRequestTakerDepositPaymentMessage(
(RequestTakerDepositPaymentMessage) tradeMessage); (RequestTakerDepositPaymentMessage) tradeMessage);
} else if (tradeMessage instanceof RequestOffererPublishDepositTxMessage) { }
else if (tradeMessage instanceof RequestOffererPublishDepositTxMessage) {
offererAsBuyerProtocolMap.get(tradeId).onRequestOffererPublishDepositTxMessage( offererAsBuyerProtocolMap.get(tradeId).onRequestOffererPublishDepositTxMessage(
(RequestOffererPublishDepositTxMessage) tradeMessage); (RequestOffererPublishDepositTxMessage) tradeMessage);
} else if (tradeMessage instanceof DepositTxPublishedMessage) { }
else if (tradeMessage instanceof DepositTxPublishedMessage) {
takerAsSellerProtocolMap.get(tradeId).onDepositTxPublishedMessage((DepositTxPublishedMessage) tradeMessage); takerAsSellerProtocolMap.get(tradeId).onDepositTxPublishedMessage((DepositTxPublishedMessage) tradeMessage);
} else if (tradeMessage instanceof BankTransferInitedMessage) { }
else if (tradeMessage instanceof BankTransferInitedMessage) {
takerAsSellerProtocolMap.get(tradeId).onBankTransferInitedMessage((BankTransferInitedMessage) tradeMessage); takerAsSellerProtocolMap.get(tradeId).onBankTransferInitedMessage((BankTransferInitedMessage) tradeMessage);
} else if (tradeMessage instanceof PayoutTxPublishedMessage) { }
else if (tradeMessage instanceof PayoutTxPublishedMessage) {
offererAsBuyerProtocolMap.get(tradeId).onPayoutTxPublishedMessage((PayoutTxPublishedMessage) tradeMessage); offererAsBuyerProtocolMap.get(tradeId).onPayoutTxPublishedMessage((PayoutTxPublishedMessage) tradeMessage);
} }
} }
@ -436,7 +448,8 @@ public class TradeManager {
public Trade getTrade(String tradeId) { public Trade getTrade(String tradeId) {
if (trades.containsKey(tradeId)) { if (trades.containsKey(tradeId)) {
return trades.get(trades); return trades.get(trades);
} else { }
else {
return null; return null;
} }
} }

View file

@ -93,7 +93,8 @@ public class OrderBook implements OrderBookListener {
public void loadOffers() { public void loadOffers() {
if (user.getCurrentBankAccount() != null) { if (user.getCurrentBankAccount() != null) {
messageFacade.getOffers(user.getCurrentBankAccount().getCurrency().getCurrencyCode()); messageFacade.getOffers(user.getCurrentBankAccount().getCurrency().getCurrencyCode());
} else { }
else {
messageFacade.getOffers(CurrencyUtil.getDefaultCurrency().getCurrencyCode()); messageFacade.getOffers(CurrencyUtil.getDefaultCurrency().getCurrencyCode());
} }
} }
@ -135,7 +136,8 @@ public class OrderBook implements OrderBookListener {
if (orderBookFilter.getPrice() > 0) { if (orderBookFilter.getPrice() > 0) {
if (offer.getDirection() == Direction.SELL) { if (offer.getDirection() == Direction.SELL) {
priceResult = orderBookFilter.getPrice() >= offer.getPrice(); priceResult = orderBookFilter.getPrice() >= offer.getPrice();
} else { }
else {
priceResult = orderBookFilter.getPrice() <= offer.getPrice(); priceResult = orderBookFilter.getPrice() <= offer.getPrice();
} }
} }
@ -216,7 +218,8 @@ public class OrderBook implements OrderBookListener {
e.printStackTrace(); e.printStackTrace();
} }
} }
} else { }
else {
allOffers.clear(); allOffers.clear();
} }
} }
@ -233,7 +236,8 @@ public class OrderBook implements OrderBookListener {
} catch (ClassNotFoundException | IOException e) { } catch (ClassNotFoundException | IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} }
} else { }
else {
log.warn("onOfferRemoved failed"); log.warn("onOfferRemoved failed");
} }
} }

View file

@ -43,7 +43,8 @@ public class BroadCastOfferFeeTx {
} catch (Exception e) { } catch (Exception e) {
faultHandler.onFault("Offer fee payment failed.", e); faultHandler.onFault("Offer fee payment failed.", e);
} }
} else { }
else {
faultHandler.onFault("Offer fee payment failed.", faultHandler.onFault("Offer fee payment failed.",
new Exception("Offer fee payment failed. Transaction = null.")); new Exception("Offer fee payment failed. Transaction = null."));
} }

View file

@ -170,7 +170,8 @@ public class ProtocolForOffererAsBuyer {
messageFacade.removeOffer(offer); messageFacade.removeOffer(offer);
listener.onOfferAccepted(offer); listener.onOfferAccepted(offer);
listener.onWaitingForPeerResponse(state); listener.onWaitingForPeerResponse(state);
} else { }
else {
log.info("Finish here as we have already the offer accepted."); log.info("Finish here as we have already the offer accepted.");
} }
} }

View file

@ -34,10 +34,12 @@ public class VerifyPeerAccount {
if (blockChainFacade.isAccountBlackListed(peersAccountId, peersBankAccount)) { if (blockChainFacade.isAccountBlackListed(peersAccountId, peersBankAccount)) {
log.error("Taker is blacklisted"); log.error("Taker is blacklisted");
exceptionHandler.onError(new Exception("Taker is blacklisted")); exceptionHandler.onError(new Exception("Taker is blacklisted"));
} else { }
else {
resultHandler.onResult(); resultHandler.onResult();
} }
} else { }
else {
log.error("Account registration validation for peer faultHandler.onFault."); log.error("Account registration validation for peer faultHandler.onFault.");
exceptionHandler.onError(new Exception("Account registration validation for peer faultHandler.onFault.")); exceptionHandler.onError(new Exception("Account registration validation for peer faultHandler.onFault."));
} }

View file

@ -185,7 +185,8 @@ public class ProtocolForTakerAsSeller {
if (message.isTakeOfferRequestAccepted()) { if (message.isTakeOfferRequestAccepted()) {
state = State.PayTakeOfferFee; state = State.PayTakeOfferFee;
PayTakeOfferFee.run(this::onResultPayTakeOfferFee, this::onFault, walletFacade, tradeId); PayTakeOfferFee.run(this::onResultPayTakeOfferFee, this::onFault, walletFacade, tradeId);
} else { }
else {
listener.onTakeOfferRequestRejected(trade); listener.onTakeOfferRequestRejected(trade);
// exit case // exit case
} }

View file

@ -107,7 +107,8 @@ public class Arbitrator implements Serializable {
public int hashCode() { public int hashCode() {
if (id != null) { if (id != null) {
return Objects.hashCode(id); return Objects.hashCode(id);
} else { }
else {
return 0; return 0;
} }
} }

View file

@ -64,7 +64,8 @@ public class User implements Serializable {
messageKeyPair = persistedUser.getMessageKeyPair(); messageKeyPair = persistedUser.getMessageKeyPair();
accountID = persistedUser.getAccountId(); accountID = persistedUser.getAccountId();
setCurrentBankAccount(persistedUser.getCurrentBankAccount()); setCurrentBankAccount(persistedUser.getCurrentBankAccount());
} else { }
else {
// First time // First time
bankAccounts = new ArrayList<>(); bankAccounts = new ArrayList<>();
messageKeyPair = DSAKeyUtil.generateKeyPair(); // DSAKeyUtil.getKeyPair() runs in same thread now messageKeyPair = DSAKeyUtil.generateKeyPair(); // DSAKeyUtil.getKeyPair() runs in same thread now

View file

@ -65,7 +65,8 @@ public class AWTSystemTray {
showGuiItem.setLabel("Open exchange window"); showGuiItem.setLabel("Open exchange window");
Platform.runLater(stage::hide); Platform.runLater(stage::hide);
isStageVisible = false; isStageVisible = false;
} else { }
else {
showGuiItem.setLabel("Close exchange window"); showGuiItem.setLabel("Close exchange window");
Platform.runLater(stage::show); Platform.runLater(stage::show);
isStageVisible = true; isStageVisible = true;
@ -82,7 +83,8 @@ public class AWTSystemTray {
} catch (AWTException e) { } catch (AWTException e) {
log.error("TrayIcon could not be added."); log.error("TrayIcon could not be added.");
} }
} else { }
else {
log.error("SystemTray is not supported"); log.error("SystemTray is not supported");
} }
} }

View file

@ -84,7 +84,8 @@ public class FileUtil {
if (!tempFile.renameTo(canonical)) { if (!tempFile.renameTo(canonical)) {
throw new IOException("Failed to rename " + tempFile + " to " + canonical); throw new IOException("Failed to rename " + tempFile + " to " + canonical);
} }
} else if (!tempFile.renameTo(file)) { }
else if (!tempFile.renameTo(file)) {
throw new IOException("Failed to rename " + tempFile + " to " + file); throw new IOException("Failed to rename " + tempFile + " to " + file);
} }

View file

@ -19,7 +19,7 @@ package io.bitsquare.gui.util;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
public class BitSquareConverterTest { public class BitSquareConverterTest {

View file

@ -134,7 +134,8 @@ public class UtilsDHT2 {
.externalBindings(bindings).peerMap(peerMap).start().addAutomaticFuture(automaticFuture); .externalBindings(bindings).peerMap(peerMap).start().addAutomaticFuture(automaticFuture);
peers[0] = new PeerBuilderDHT(master).start(); peers[0] = new PeerBuilderDHT(master).start();
} else { }
else {
Number160 peerId = new Number160(rnd); Number160 peerId = new Number160(rnd);
PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId)); PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId));
master = new PeerBuilder(peerId).enableMaintenance(maintenance).externalBindings(bindings) master = new PeerBuilder(peerId).enableMaintenance(maintenance).externalBindings(bindings)
@ -151,7 +152,8 @@ public class UtilsDHT2 {
.enableMaintenance(maintenance).enableMaintenance(maintenance).peerMap(peerMap) .enableMaintenance(maintenance).enableMaintenance(maintenance).peerMap(peerMap)
.externalBindings(bindings).start().addAutomaticFuture(automaticFuture); .externalBindings(bindings).start().addAutomaticFuture(automaticFuture);
peers[i] = new PeerBuilderDHT(peer).start(); peers[i] = new PeerBuilderDHT(peer).start();
} else { }
else {
Number160 peerId = new Number160(rnd); Number160 peerId = new Number160(rnd);
PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId).peerNoVerification()); PeerMap peerMap = new PeerMap(new PeerMapConfiguration(peerId).peerNoVerification());
Peer peer = new PeerBuilder(peerId).enableMaintenance(maintenance) Peer peer = new PeerBuilder(peerId).enableMaintenance(maintenance)
@ -239,7 +241,8 @@ public class UtilsDHT2 {
for (int i = 0; i < nr; i++) { for (int i = 0; i < nr; i++) {
if (i == 0) { if (i == 0) {
peers[0] = new PeerBuilder(new Number160(rnd)).ports(port).start(); peers[0] = new PeerBuilder(new Number160(rnd)).ports(port).start();
} else { }
else {
peers[i] = new PeerBuilder(new Number160(rnd)).masterPeer(peers[0]).start(); peers[i] = new PeerBuilder(new Number160(rnd)).masterPeer(peers[0]).start();
} }
} }