* TODO: Alternative bootstrap methods will follow later (save locally list of known nodes reported form other peers...) */ public class SeedNode extends Thread { diff --git a/src/main/java/io/bitsquare/bank/BankAccount.java b/src/main/java/io/bitsquare/bank/BankAccount.java index 99a7923d65..65d75f3a31 100644 --- a/src/main/java/io/bitsquare/bank/BankAccount.java +++ b/src/main/java/io/bitsquare/bank/BankAccount.java @@ -35,12 +35,18 @@ public class BankAccount implements Serializable { private final String accountSecondaryID; // like BIC private final String accountHolderName; private final Country country; // where bank is registered + // The main currency if account support multiple currencies. // The user can create multiple bank accounts with same bank account but other currency if his bank account // support that. private final Currency currency; private final String accountTitle; + + /////////////////////////////////////////////////////////////////////////////////////////// + // Constructor + /////////////////////////////////////////////////////////////////////////////////////////// + public BankAccount(BankAccountType bankAccountType, Currency currency, Country country, String accountTitle, String accountHolderName, String accountPrimaryID, String accountSecondaryID) { this.bankAccountType = bankAccountType; @@ -52,18 +58,10 @@ public class BankAccount implements Serializable { this.accountSecondaryID = accountSecondaryID; } - public int hashCode() { - return Objects.hashCode(accountTitle); - } - - public boolean equals(Object obj) { - if (!(obj instanceof BankAccount)) return false; - if (obj == this) return true; - - final BankAccount other = (BankAccount) obj; - return accountTitle.equals(other.getUid()); - } + /////////////////////////////////////////////////////////////////////////////////////////// + // Getters/Setters + /////////////////////////////////////////////////////////////////////////////////////////// public String getAccountPrimaryID() { return accountPrimaryID; @@ -98,6 +96,25 @@ public class BankAccount implements Serializable { return accountTitle; } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////////////////////////// + + @Override + public int hashCode() { + return Objects.hashCode(accountTitle); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof BankAccount)) return false; + if (obj == this) return true; + + final BankAccount other = (BankAccount) obj; + return accountTitle.equals(other.getUid()); + } + @Override public String toString() { return "BankAccount{" + diff --git a/src/main/java/io/bitsquare/btc/AddressEntry.java b/src/main/java/io/bitsquare/btc/AddressEntry.java index 9a1889b267..077f7653b6 100644 --- a/src/main/java/io/bitsquare/btc/AddressEntry.java +++ b/src/main/java/io/bitsquare/btc/AddressEntry.java @@ -24,6 +24,10 @@ import com.google.bitcoin.crypto.DeterministicKey; import java.io.Serializable; +/** + * Is a minimalistic wallet abstraction used to separate transactions between different activities like: + * Registration, trade and arbiter deposit. + */ public class AddressEntry implements Serializable { private static final long serialVersionUID = 5501603992599920416L; private transient DeterministicKey key; diff --git a/src/main/java/io/bitsquare/btc/BtcValidator.java b/src/main/java/io/bitsquare/btc/BtcValidator.java index a21bf59544..50f8ce552f 100644 --- a/src/main/java/io/bitsquare/btc/BtcValidator.java +++ b/src/main/java/io/bitsquare/btc/BtcValidator.java @@ -23,6 +23,7 @@ import com.google.bitcoin.core.Transaction; import javax.inject.Inject; +// TODO will be probably removed public class BtcValidator { private static NetworkParameters params; diff --git a/src/main/java/io/bitsquare/btc/FeePolicy.java b/src/main/java/io/bitsquare/btc/FeePolicy.java index eee63e6f71..b8607c67b7 100644 --- a/src/main/java/io/bitsquare/btc/FeePolicy.java +++ b/src/main/java/io/bitsquare/btc/FeePolicy.java @@ -34,6 +34,8 @@ public class FeePolicy { public static final Coin CREATE_OFFER_FEE = Coin.MILLICOIN; // 0.001 public static final Coin TAKE_OFFER_FEE = CREATE_OFFER_FEE; private static final Logger log = LoggerFactory.getLogger(FeePolicy.class); + + // those are just dummy yet. trading fees will go probably to arbiters private static final String registrationFeeAddress = "mvkDXt4QmN4Nq9dRUsRigBCaovde9nLkZR"; private static final String createOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg"; private static final String takeOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg"; diff --git a/src/main/java/io/bitsquare/btc/listeners/ConfidenceListener.java b/src/main/java/io/bitsquare/btc/listeners/ConfidenceListener.java index 0acef12553..16674b8484 100644 --- a/src/main/java/io/bitsquare/btc/listeners/ConfidenceListener.java +++ b/src/main/java/io/bitsquare/btc/listeners/ConfidenceListener.java @@ -32,6 +32,5 @@ public class ConfidenceListener { } public void onTransactionConfidenceChanged(TransactionConfidence confidence) { - } } \ No newline at end of file diff --git a/src/main/java/io/bitsquare/di/GuiceFXMLLoader.java b/src/main/java/io/bitsquare/di/GuiceFXMLLoader.java index ff40d7af19..8344952bb2 100644 --- a/src/main/java/io/bitsquare/di/GuiceFXMLLoader.java +++ b/src/main/java/io/bitsquare/di/GuiceFXMLLoader.java @@ -103,7 +103,7 @@ public class GuiceFXMLLoader { * A JavaFX controller factory for constructing controllers via Guice DI. To * install this in the {@link javafx.fxml.FXMLLoader}, pass it as a parameter to * {@link javafx.fxml.FXMLLoader#setControllerFactory(javafx.util.Callback)}. - *
+ *
* Once set, make sure you do not use the static methods on
* {@link javafx.fxml.FXMLLoader} when creating your JavaFX node.
*/
diff --git a/src/main/java/io/bitsquare/gui/MainController.java b/src/main/java/io/bitsquare/gui/MainController.java
index 59213c366d..22262b7d49 100644
--- a/src/main/java/io/bitsquare/gui/MainController.java
+++ b/src/main/java/io/bitsquare/gui/MainController.java
@@ -400,7 +400,7 @@ public class MainController extends ViewController {
});
user.getSelectedBankAccountIndexProperty().addListener(observable ->
- accountComboBox.getSelectionModel().select(user.getCurrentBankAccount()));
+ 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/MainView.fxml b/src/main/java/io/bitsquare/gui/MainView.fxml
index 10d444e643..a87b4bc448 100644
--- a/src/main/java/io/bitsquare/gui/MainView.fxml
+++ b/src/main/java/io/bitsquare/gui/MainView.fxml
@@ -16,8 +16,7 @@
~ along with Bitsquare. If not, see
* That class implements just what we need for the moment. It is not intended as a general purpose library class.
*/
public class ValidatingTextField extends TextField {
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 15c8e0ed1e..9ced27f77d 100644
--- a/src/main/java/io/bitsquare/gui/components/btc/AddressTextField.java
+++ b/src/main/java/io/bitsquare/gui/components/btc/AddressTextField.java
@@ -149,7 +149,7 @@ public class AddressTextField extends AnchorPane {
this.paymentLabel = paymentLabel;
}
-
+
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/io/bitsquare/gui/components/confidence/ConfidenceProgressIndicator.java b/src/main/java/io/bitsquare/gui/components/confidence/ConfidenceProgressIndicator.java
index 2ee2c3d916..78ff21dfcf 100644
--- a/src/main/java/io/bitsquare/gui/components/confidence/ConfidenceProgressIndicator.java
+++ b/src/main/java/io/bitsquare/gui/components/confidence/ConfidenceProgressIndicator.java
@@ -43,22 +43,22 @@ import javafx.scene.control.*;
*
* ProgressIndicator sets focusTraversable to false.
*
+ *
* This first example creates a ProgressIndicator with an indeterminate value :
*
+ *
* This next example creates a ProgressIndicator which is 25% complete :
*
* Implementation of ProgressIndicator According to JavaFX UI Control API Specification
*
* @since JavaFX 2.0
@@ -81,7 +81,7 @@ public class ConfidenceProgressIndicator extends Control {
**************************************************************************/
/**
* Initialize the style class to 'progress-indicator'.
- *
* This is the selector class from which CSS can be used to style
* this control.
*/
diff --git a/src/main/java/io/bitsquare/gui/funds/FundsView.fxml b/src/main/java/io/bitsquare/gui/funds/FundsView.fxml
index 7bed50e485..d9acc082c2 100644
--- a/src/main/java/io/bitsquare/gui/funds/FundsView.fxml
+++ b/src/main/java/io/bitsquare/gui/funds/FundsView.fxml
@@ -17,9 +17,8 @@
-->
-
-
-
+
+
* Creates Presenter and passes Model from DI to Presenter. Does not hold a reference to Model
*
- * - Setup binding from Presenter to View elements (also bidirectional - Inputs). Binding are only to presenters properties, not logical bindings or cross-view element bindings.
+ * - Setup binding from Presenter to View elements (also bidirectional - Inputs). Binding are only to presenters
+ * properties, not logical bindings or cross-view element bindings.
* - Listen to UI events (Action) from View and call method in Presenter.
* - Is entry node for hierarchical view graphs. Passes method calls to Presenter. Calls methods on sub views.
* - Handle lifecycle and self removal from scene graph.
* - Non declarative (dynamic) view definitions (if it gets larger, then user a ViewBuilder)
*
* View:
- * - Mostly declared in FXML. Dynamic parts are declared in Controller. If more view elements need to be defined in code then use ViewBuilder.
+ * - Mostly declared in FXML. Dynamic parts are declared in Controller. If more view elements need to be defined in
+ * code then use ViewBuilder.
*
* Optional ViewBuilder:
* - Replacement for FXML view definitions.
*/
-public class CreateOfferCodeBehind extends CachedViewController
-{
+public class CreateOfferCodeBehind extends CachedViewController {
private static final Logger log = LoggerFactory.getLogger(CreateOfferCodeBehind.class);
private final CreateOfferPresenter presenter;
@@ -69,7 +68,9 @@ public class CreateOfferCodeBehind extends CachedViewController
@FXML private ValidatingTextField amountTextField, minAmountTextField, priceTextField, volumeTextField;
@FXML private Button placeOfferButton, closeButton;
- @FXML private TextField totalToPayTextField, collateralTextField, bankAccountTypeTextField, bankAccountCurrencyTextField, bankAccountCountyTextField, acceptedCountriesTextField, acceptedLanguagesTextField,
+ @FXML private TextField totalToPayTextField, collateralTextField, bankAccountTypeTextField,
+ bankAccountCurrencyTextField, bankAccountCountyTextField, acceptedCountriesTextField,
+ acceptedLanguagesTextField,
feeLabel, transactionIdTextField;
@FXML private ConfidenceProgressIndicator progressIndicator;
@FXML private AddressTextField addressTextField;
@@ -81,8 +82,7 @@ public class CreateOfferCodeBehind extends CachedViewController
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
- public CreateOfferCodeBehind(CreateOfferModel model)
- {
+ public CreateOfferCodeBehind(CreateOfferModel model) {
presenter = new CreateOfferPresenter(model);
}
@@ -92,23 +92,20 @@ public class CreateOfferCodeBehind extends CachedViewController
///////////////////////////////////////////////////////////////////////////////////////////
@Override
- public void initialize(URL url, ResourceBundle rb)
- {
+ public void initialize(URL url, ResourceBundle rb) {
super.initialize(url, rb);
presenter.onViewInitialized();
}
@Override
- public void deactivate()
- {
+ public void deactivate() {
super.deactivate();
presenter.deactivate();
((TradeController) parentController).onCreateOfferViewRemoved();
}
@Override
- public void activate()
- {
+ public void activate() {
super.activate();
presenter.activate();
@@ -129,8 +126,7 @@ public class CreateOfferCodeBehind extends CachedViewController
// Public methods
///////////////////////////////////////////////////////////////////////////////////////////
- public void setOrderBookFilter(OrderBookFilter orderBookFilter)
- {
+ public void setOrderBookFilter(OrderBookFilter orderBookFilter) {
presenter.setOrderBookFilter(orderBookFilter);
}
@@ -139,14 +135,12 @@ public class CreateOfferCodeBehind extends CachedViewController
///////////////////////////////////////////////////////////////////////////////////////////
@FXML
- public void onPlaceOffer()
- {
+ public void onPlaceOffer() {
presenter.placeOffer();
}
@FXML
- public void onClose()
- {
+ public void onClose() {
presenter.close();
TabPane tabPane = ((TabPane) (rootContainer.getParent().getParent()));
@@ -158,15 +152,19 @@ public class CreateOfferCodeBehind extends CachedViewController
// Private Methods
///////////////////////////////////////////////////////////////////////////////////////////
- private void setupListeners()
- {
- volumeTextField.focusedProperty().addListener((observableValue, oldValue, newValue) -> presenter.checkVolumeOnFocusOut(oldValue, newValue, volumeTextField.getText()));
- amountTextField.focusedProperty().addListener((observableValue, oldValue, newValue) -> presenter.onFocusOutAmountTextField(oldValue, newValue));
- priceTextField.focusedProperty().addListener((observableValue, oldValue, newValue) -> presenter.onFocusOutPriceTextField(oldValue, newValue));
+ private void setupListeners() {
+ volumeTextField.focusedProperty().addListener((observableValue, oldValue,
+ newValue) -> presenter.checkVolumeOnFocusOut(oldValue,
+ newValue, volumeTextField.getText()));
+ amountTextField.focusedProperty().addListener((observableValue, oldValue,
+ newValue) -> presenter.onFocusOutAmountTextField(oldValue,
+ newValue));
+ priceTextField.focusedProperty().addListener((observableValue, oldValue,
+ newValue) -> presenter.onFocusOutPriceTextField(oldValue,
+ newValue));
presenter.validateInput.addListener((o, oldValue, newValue) -> {
- if (newValue)
- {
+ if (newValue) {
amountTextField.reValidate();
minAmountTextField.reValidate();
volumeTextField.reValidate();
@@ -175,16 +173,15 @@ public class CreateOfferCodeBehind extends CachedViewController
});
presenter.showVolumeAdjustedWarning.addListener((o, oldValue, newValue) -> {
- if (newValue)
- {
- Popups.openWarningPopup("Warning", "The total volume you have entered leads to invalid fractional Bitcoin amounts.\nThe amount has been adjusted and a new total volume be calculated from it.");
+ if (newValue) {
+ Popups.openWarningPopup("Warning", "The total volume you have entered leads to invalid fractional " +
+ "Bitcoin amounts.\nThe amount has been adjusted and a new total volume be calculated from it.");
volumeTextField.setText(presenter.volume.get());
}
});
}
- private void setupBindings()
- {
+ private void setupBindings() {
buyLabel.textProperty().bind(presenter.directionLabel);
amountTextField.textProperty().bindBidirectional(presenter.amount);
priceTextField.textProperty().bindBidirectional(presenter.price);
@@ -221,8 +218,7 @@ public class CreateOfferCodeBehind extends CachedViewController
.and(priceTextField.isValidProperty()).not());*/
}
- private void setupTextFieldValidators()
- {
+ private void setupTextFieldValidators() {
/* BtcValidator amountValidator = new BtcValidator();
amountTextField.setNumberValidator(amountValidator);
amountTextField.setErrorPopupLayoutReference((Region) amountTextField.getParent());
diff --git a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferModel.java b/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferModel.java
index 4e377ee3f5..63b9f2b3d9 100644
--- a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferModel.java
+++ b/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferModel.java
@@ -59,8 +59,7 @@ import static com.google.common.base.Preconditions.checkArgument;
* - Holds domain data
* - Use Properties for bindable data
*/
-class CreateOfferModel
-{
+class CreateOfferModel {
private static final Logger log = LoggerFactory.getLogger(CreateOfferModel.class);
private final TradeManager tradeManager;
@@ -68,8 +67,7 @@ class CreateOfferModel
private final Settings settings;
private final User user;
- String getOfferId()
- {
+ String getOfferId() {
return offerId;
}
@@ -106,8 +104,7 @@ class CreateOfferModel
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
- CreateOfferModel(TradeManager tradeManager, WalletFacade walletFacade, Settings settings, User user)
- {
+ CreateOfferModel(TradeManager tradeManager, WalletFacade walletFacade, Settings settings, User user) {
this.tradeManager = tradeManager;
this.walletFacade = walletFacade;
this.settings = settings;
@@ -115,7 +112,8 @@ class CreateOfferModel
offerId = UUID.randomUUID().toString();
totalFeesAsCoin = FeePolicy.CREATE_OFFER_FEE.add(FeePolicy.TX_FEE);
- if (walletFacade != null && walletFacade.getWallet() != null) addressEntry = walletFacade.getAddressInfoByTradeID(offerId);
+ if (walletFacade != null && walletFacade.getWallet() != null)
+ addressEntry = walletFacade.getAddressInfoByTradeID(offerId);
}
@@ -123,13 +121,11 @@ class CreateOfferModel
// Methods
///////////////////////////////////////////////////////////////////////////////////////////
- void activate()
- {
+ void activate() {
collateralAsLong.set(settings.getCollateral());
BankAccount bankAccount = user.getCurrentBankAccount();
- if (bankAccount != null)
- {
+ if (bankAccount != null) {
bankAccountType.set(bankAccount.getBankAccountType().toString());
bankAccountCurrency.set(bankAccount.getCurrency().getCurrencyCode());
bankAccountCounty.set(bankAccount.getCountry().getName());
@@ -138,22 +134,21 @@ class CreateOfferModel
acceptedLanguages.setAll(settings.getAcceptedLanguageLocales());
}
- void placeOffer()
- {
+ void placeOffer() {
tradeManager.requestPlaceOffer(offerId,
- direction,
- priceAsFiat.value,
- amountAsCoin,
- minAmountAsCoin,
- (transaction) -> {
- requestPlaceOfferSuccess.set(true);
- transactionId.set(transaction.getHashAsString());
- },
- (errorMessage) -> {
- requestPlaceOfferFailed.set(true);
- requestPlaceOfferErrorMessage.set(errorMessage);
- }
- );
+ direction,
+ priceAsFiat.value,
+ amountAsCoin,
+ minAmountAsCoin,
+ (transaction) -> {
+ requestPlaceOfferSuccess.set(true);
+ transactionId.set(transaction.getHashAsString());
+ },
+ (errorMessage) -> {
+ requestPlaceOfferFailed.set(true);
+ requestPlaceOfferErrorMessage.set(errorMessage);
+ }
+ );
}
@@ -161,13 +156,11 @@ class CreateOfferModel
// Setter/Getter
///////////////////////////////////////////////////////////////////////////////////////////
- Direction getDirection()
- {
+ Direction getDirection() {
return direction;
}
- void setDirection(Direction direction)
- {
+ void setDirection(Direction direction) {
// direction must not be changed once it is initially set
checkArgument(this.direction == null);
this.direction = direction;
diff --git a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferPresenter.java b/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferPresenter.java
index 2fcc543fab..3e34ce1265 100644
--- a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferPresenter.java
+++ b/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferPresenter.java
@@ -45,11 +45,12 @@ import static javafx.beans.binding.Bindings.createStringBinding;
* Knows Model, does not know the View (CodeBehind)
*
* - Holds data and state of the View (formatted)
- * - Receive view input from Controller. Validates input, apply business logic, format to Presenter properties and convert input to Model.
- * - Listen to updates from Model, apply business logic and format it to Presenter properties. Model update handling can be done via Binding.
+ * - Receive view input from Controller. Validates input, apply business logic, format to Presenter properties and
+ * convert input to Model.
+ * - Listen to updates from Model, apply business logic and format it to Presenter properties. Model update handling
+ * can be done via Binding.
*/
-class CreateOfferPresenter
-{
+class CreateOfferPresenter {
private static final Logger log = LoggerFactory.getLogger(CreateOfferPresenter.class);
private CreateOfferModel model;
@@ -83,8 +84,7 @@ class CreateOfferPresenter
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
- CreateOfferPresenter(CreateOfferModel model)
- {
+ CreateOfferPresenter(CreateOfferModel model) {
this.model = model;
}
@@ -93,35 +93,35 @@ class CreateOfferPresenter
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
- void onViewInitialized()
- {
+ void onViewInitialized() {
totalFeesLabel.set(BSFormatter.formatBtc(model.totalFeesAsCoin));
paymentLabel.set("Bitsquare trade (" + model.getOfferId() + ")");
- // address.set(model.addressEntry.getAddress().toString());
+ // address.set(model.addressEntry.getAddress().toString());
setupInputListeners();
- collateralLabel.bind(Bindings.createStringBinding(() -> "Collateral (" + BSFormatter.formatCollateralPercent(model.collateralAsLong.get()) + "):", model.collateralAsLong));
- bankAccountType.bind(Bindings.createStringBinding(() -> Localisation.get(model.bankAccountType.get()), model.bankAccountType));
+ collateralLabel.bind(Bindings.createStringBinding(() -> "Collateral (" + BSFormatter.formatCollateralPercent
+ (model.collateralAsLong.get()) + "):", model.collateralAsLong));
+ bankAccountType.bind(Bindings.createStringBinding(() -> Localisation.get(model.bankAccountType.get()),
+ model.bankAccountType));
bankAccountCurrency.bind(model.bankAccountCurrency);
bankAccountCounty.bind(model.bankAccountCounty);
totalToPayAsCoin.bind(model.totalToPayAsCoin);
-
- model.acceptedCountries.addListener((Observable o) -> acceptedCountries.set(BSFormatter.countryLocalesToString(model.acceptedCountries)));
- model.acceptedLanguages.addListener((Observable o) -> acceptedLanguages.set(BSFormatter.languageLocalesToString(model.acceptedLanguages)));
+
+ model.acceptedCountries.addListener((Observable o) -> acceptedCountries.set(BSFormatter
+ .countryLocalesToString(model.acceptedCountries)));
+ model.acceptedLanguages.addListener((Observable o) -> acceptedLanguages.set(BSFormatter
+ .languageLocalesToString(model.acceptedLanguages)));
}
- void deactivate()
- {
+ void deactivate() {
}
- void activate()
- {
+ void activate() {
model.activate();
-
// totalToPay.addListener((ov) -> addressTextField.setAmountToPay(model.totalToPayAsCoin));
}
@@ -130,8 +130,7 @@ class CreateOfferPresenter
///////////////////////////////////////////////////////////////////////////////////////////
- void setOrderBookFilter(OrderBookFilter orderBookFilter)
- {
+ void setOrderBookFilter(OrderBookFilter orderBookFilter) {
// model
model.setDirection(orderBookFilter.getDirection());
model.amountAsCoin = orderBookFilter.getAmount();
@@ -151,8 +150,7 @@ class CreateOfferPresenter
// View Events
///////////////////////////////////////////////////////////////////////////////////////////
- void placeOffer()
- {
+ void placeOffer() {
model.amountAsCoin = parseToCoin(amount.get());
model.minAmountAsCoin = parseToCoin(minAmount.get());
model.priceAsFiat = parseToFiat(price.get());
@@ -162,8 +160,7 @@ class CreateOfferPresenter
//balanceTextField.getBalance()
- if (inputValid())
- {
+ if (inputValid()) {
model.placeOffer();
isPlaceOfferButtonDisabled.set(true);
placeOfferButtonVisible.set(true);
@@ -183,8 +180,7 @@ class CreateOfferPresenter
}
- void close()
- {
+ void close() {
}
@@ -192,14 +188,12 @@ class CreateOfferPresenter
//
///////////////////////////////////////////////////////////////////////////////////////////
- private boolean inputValid()
- {
+ private boolean inputValid() {
//TODO
return true;
}
- void setupInputListeners()
- {
+ void setupInputListeners() {
// bindBidirectional for amount, price, volume and minAmount
amount.addListener(ov -> {
@@ -225,25 +219,21 @@ class CreateOfferPresenter
}
- private void setVolume()
- {
+ private void setVolume() {
model.amountAsCoin = parseToCoin(amount.get());
model.priceAsFiat = parseToFiat(price.get());
- if (model.priceAsFiat != null && model.amountAsCoin != null && !model.amountAsCoin.isZero())
- {
+ if (model.priceAsFiat != null && model.amountAsCoin != null && !model.amountAsCoin.isZero()) {
model.tradeVolumeAsFiat = new ExchangeRate(model.priceAsFiat).coinToFiat(model.amountAsCoin);
volume.set(formatFiat(model.tradeVolumeAsFiat));
}
}
- private void setAmount()
- {
+ private void setAmount() {
model.tradeVolumeAsFiat = parseToFiat(volume.get());
model.priceAsFiat = parseToFiat(price.get());
- if (model.tradeVolumeAsFiat != null && model.priceAsFiat != null && !model.priceAsFiat.isZero())
- {
+ if (model.tradeVolumeAsFiat != null && model.priceAsFiat != null && !model.priceAsFiat.isZero()) {
model.amountAsCoin = new ExchangeRate(model.priceAsFiat).fiatToCoin(model.tradeVolumeAsFiat);
// If we got a btc value with more then 4 decimals we convert it to max 4 decimals
@@ -254,31 +244,26 @@ class CreateOfferPresenter
}
}
- private void setTotalToPay()
- {
+ private void setTotalToPay() {
setCollateral();
- if (model.collateralAsCoin != null)
- {
+ if (model.collateralAsCoin != null) {
model.totalToPayAsCoin.set(model.collateralAsCoin.add(model.totalFeesAsCoin));
- totalToPay.bind(createStringBinding(() -> formatBtcWithCode(model.totalToPayAsCoin.get()), model.totalToPayAsCoin));
+ totalToPay.bind(createStringBinding(() -> formatBtcWithCode(model.totalToPayAsCoin.get()),
+ model.totalToPayAsCoin));
}
}
- private void setCollateral()
- {
- if (model.amountAsCoin != null)
- {
+ private void setCollateral() {
+ if (model.amountAsCoin != null) {
model.collateralAsCoin = model.amountAsCoin.multiply(model.collateralAsLong.get()).divide(1000);
collateral.set(BSFormatter.formatBtcWithCode(model.collateralAsCoin));
}
}
// We adjust the volume if fractional coins result from volume/price division on focus out
- void checkVolumeOnFocusOut(Boolean oldValue, Boolean newValue, String volumeTextFieldText)
- {
- if (oldValue && !newValue)
- {
+ void checkVolumeOnFocusOut(Boolean oldValue, Boolean newValue, String volumeTextFieldText) {
+ if (oldValue && !newValue) {
setVolume();
if (!formatFiat(parseToFiat(volumeTextFieldText)).equals(volume.get()))
showVolumeAdjustedWarning.set(true);
@@ -291,15 +276,13 @@ class CreateOfferPresenter
amountTextField.reValidate();*/
}
- void onFocusOutAmountTextField(Boolean oldValue, Boolean newValue)
- {
+ void onFocusOutAmountTextField(Boolean oldValue, Boolean newValue) {
// only on focus out and ignore focus loss from window
/* if (!newValue && amountTextField.getScene() != null && amountTextField.getScene().getWindow().isFocused())
volumeTextField.reValidate();*/
}
- void onFocusOutPriceTextField(Boolean oldValue, Boolean newValue)
- {
+ void onFocusOutPriceTextField(Boolean oldValue, Boolean newValue) {
// only on focus out and ignore focus loss from window
/* if (!newValue && priceTextField.getScene() != null && priceTextField.getScene().getWindow().isFocused())
volumeTextField.reValidate();*/
diff --git a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml b/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml
index 55f4b13480..32ca4dbed8 100644
--- a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml
+++ b/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml
@@ -20,11 +20,11 @@
-
-
+
+
+
-
* That class implements just what we need for the moment. It is not intended as a general purpose library class.
*/
public class BtcValidator extends NumberValidator {
diff --git a/src/main/java/io/bitsquare/gui/util/FiatValidator.java b/src/main/java/io/bitsquare/gui/util/FiatValidator.java
index 8e44838c14..cd0c1a01de 100644
--- a/src/main/java/io/bitsquare/gui/util/FiatValidator.java
+++ b/src/main/java/io/bitsquare/gui/util/FiatValidator.java
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
/**
* FiatNumberValidator for validating fiat values.
- *
* That class implements just what we need for the moment. It is not intended as a general purpose library class.
*/
public class FiatValidator extends NumberValidator {
diff --git a/src/main/java/io/bitsquare/gui/util/NumberValidator.java b/src/main/java/io/bitsquare/gui/util/NumberValidator.java
index d8f671c1dd..e5597ddd1b 100644
--- a/src/main/java/io/bitsquare/gui/util/NumberValidator.java
+++ b/src/main/java/io/bitsquare/gui/util/NumberValidator.java
@@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
* Localisation not supported at the moment
* The decimal mark can be either "." or ",". Thousand separators are not supported yet,
* but might be added alter with Local support.
- *
* That class implements just what we need for the moment. It is not intended as a general purpose library class.
*/
public abstract class NumberValidator {
diff --git a/src/main/java/io/bitsquare/locale/Localisation.java b/src/main/java/io/bitsquare/locale/Localisation.java
index 6f8f794465..0a88d8038a 100644
--- a/src/main/java/io/bitsquare/locale/Localisation.java
+++ b/src/main/java/io/bitsquare/locale/Localisation.java
@@ -46,7 +46,7 @@ public class Localisation {
public static String get(String key) {
if (key == null)
return "";
-
+
try {
return Localisation.getResourceBundle().getString(key);
} catch (MissingResourceException e) {
diff --git a/src/main/java/io/bitsquare/msg/MessageFacade.java b/src/main/java/io/bitsquare/msg/MessageFacade.java
index 28e23a5653..4d0de8f905 100644
--- a/src/main/java/io/bitsquare/msg/MessageFacade.java
+++ b/src/main/java/io/bitsquare/msg/MessageFacade.java
@@ -67,7 +67,7 @@ import org.slf4j.LoggerFactory;
* It is the translating domain specific functionality to the messaging layer.
* The TomP2P library codebase shall not be used outside that facade.
* That way we limit the dependency of the TomP2P library only to that class (and it's sub components).
- *
* TODO: improve callbacks that Platform.runLater is not necessary. We call usually that methods form teh UI thread.
*/
public class MessageFacade implements MessageBroker {
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 e1ea294982..4a97445417 100644
--- a/src/main/java/io/bitsquare/trade/protocol/offerer/ProtocolForOffererAsBuyer.java
+++ b/src/main/java/io/bitsquare/trade/protocol/offerer/ProtocolForOffererAsBuyer.java
@@ -50,9 +50,9 @@ import static io.bitsquare.util.Validator.*;
/**
* Responsible for the correct execution of the sequence of tasks, message passing to the peer and message processing
* from the peer.
- *
* This class handles the role of the offerer as the Bitcoin buyer.
- *
* It uses sub tasks to not pollute the main class too much with all the async result/fault handling.
* Any data from incoming messages need to be validated before further processing.
*/
diff --git a/src/test/java/io/bitsquare/gui/trade/createoffer/CreateOfferPresenterTest.java b/src/test/java/io/bitsquare/gui/trade/createoffer/CreateOfferPresenterTest.java
index 3cc189ecd6..717b499d20 100644
--- a/src/test/java/io/bitsquare/gui/trade/createoffer/CreateOfferPresenterTest.java
+++ b/src/test/java/io/bitsquare/gui/trade/createoffer/CreateOfferPresenterTest.java
@@ -33,13 +33,11 @@ import org.slf4j.LoggerFactory;
import static org.junit.Assert.*;
-public class CreateOfferPresenterTest
-{
+public class CreateOfferPresenterTest {
private static final Logger log = LoggerFactory.getLogger(CreateOfferPresenterTest.class);
@Test
- public void testBindings()
- {
+ public void testBindings() {
CreateOfferModel model = new CreateOfferModel(null, null, null, null);
BSFormatter.setLocale(Locale.US);
@@ -54,7 +52,7 @@ public class CreateOfferPresenterTest
assertEquals(Coin.COIN, model.amountAsCoin);
assertEquals(Fiat.valueOf("EUR", 500 * 10000), model.priceAsFiat);
assertEquals(Fiat.valueOf("EUR", 500 * 10000), model.tradeVolumeAsFiat);
- assertEquals(Coin.parseCoin("0.1011"), model.totalToPayAsCoin);
+ assertEquals(Coin.parseCoin("0.1011"), model.totalToPayAsCoin.get());
presenter.price.set("500");
presenter.volume.set("500");
- *
- *
+ *
* import javafx.scene.control.ProgressIndicator;
* ProgressIndicator p1 = new ProgressIndicator();
*
- *
+ *
* import javafx.scene.control.ProgressIndicator;
* ProgressIndicator p2 = new ProgressIndicator();
* p2.setProgress(0.25F);
*