mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-15 10:29:43 -04:00
Change Currency to CurrencyCode
This commit is contained in:
parent
7750ae6e00
commit
d73a43271c
22 changed files with 150 additions and 158 deletions
|
@ -31,6 +31,7 @@ import java.security.PublicKey;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -71,7 +72,6 @@ public class Arbitrator implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
transient private Storage<Arbitrator> storage;
|
transient private Storage<Arbitrator> storage;
|
||||||
transient private boolean saveOnEveryUpdate;
|
|
||||||
|
|
||||||
// Persisted fields
|
// Persisted fields
|
||||||
private String id;
|
private String id;
|
||||||
|
@ -82,9 +82,8 @@ public class Arbitrator implements Serializable {
|
||||||
|
|
||||||
// editable
|
// editable
|
||||||
private ID_TYPE idType;
|
private ID_TYPE idType;
|
||||||
// TODO languages breaks something in serialisation with TomP2P when uing Locale. cannot remove an offer
|
|
||||||
private List<String> languages;
|
private List<String> languages;
|
||||||
|
|
||||||
private Coin fee;
|
private Coin fee;
|
||||||
private List<METHOD> arbitrationMethods;
|
private List<METHOD> arbitrationMethods;
|
||||||
private List<ID_VERIFICATION> idVerifications;
|
private List<ID_VERIFICATION> idVerifications;
|
||||||
|
@ -99,47 +98,43 @@ public class Arbitrator implements Serializable {
|
||||||
Arbitrator persisted = storage.initAndGetPersisted(this);
|
Arbitrator persisted = storage.initAndGetPersisted(this);
|
||||||
if (persisted != null) {
|
if (persisted != null) {
|
||||||
//TODO for mock arbitrator
|
//TODO for mock arbitrator
|
||||||
id = persisted.getName();
|
|
||||||
|
|
||||||
this.pubKey = persisted.getPubKey();
|
id = persisted.getId();
|
||||||
this.p2pSigPubKey = persisted.getP2pSigPubKey();
|
pubKey = persisted.getPubKey();
|
||||||
this.name = persisted.getName();
|
p2pSigPubKey = persisted.getP2pSigPubKey();
|
||||||
this.idType = persisted.getIdType();
|
name = persisted.getName();
|
||||||
this.languages = persisted.getLanguages();
|
idType = persisted.getIdType();
|
||||||
this.reputation = persisted.getReputation();
|
languages = persisted.getLanguages();
|
||||||
this.fee = persisted.getFee();
|
reputation = persisted.getReputation();
|
||||||
this.arbitrationMethods = persisted.getArbitrationMethods();
|
fee = persisted.getFee();
|
||||||
this.idVerifications = persisted.getIdVerifications();
|
arbitrationMethods = persisted.getArbitrationMethods();
|
||||||
this.webUrl = persisted.getWebUrl();
|
idVerifications = persisted.getIdVerifications();
|
||||||
this.description = persisted.getDescription();
|
webUrl = persisted.getWebUrl();
|
||||||
|
description = persisted.getDescription();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Mock
|
// Mock
|
||||||
id = "Manfred Karrer";
|
id = UUID.randomUUID().toString();
|
||||||
this.pubKey = new ECKey().getPubKey();
|
pubKey = new ECKey().getPubKey();
|
||||||
this.p2pSigPubKey = user.getP2PSigPubKey();
|
p2pSigPubKey = user.getP2PSigPubKey();
|
||||||
this.name = "Manfred Karrer";
|
name = "Mr. Default";
|
||||||
this.idType = Arbitrator.ID_TYPE.REAL_LIFE_ID;
|
idType = Arbitrator.ID_TYPE.REAL_LIFE_ID;
|
||||||
this.languages = Arrays.asList(LanguageUtil.getDefaultLanguageLocale().getISO3Language());
|
languages = Arrays.asList(LanguageUtil.getDefaultLanguageLocale().getISO3Language());
|
||||||
this.reputation = new Reputation();
|
reputation = new Reputation();
|
||||||
this.fee = Coin.parseCoin("0.1");
|
fee = Coin.parseCoin("0.1");
|
||||||
this.arbitrationMethods = Arrays.asList(Arbitrator.METHOD.TLS_NOTARY);
|
arbitrationMethods = Arrays.asList(Arbitrator.METHOD.TLS_NOTARY);
|
||||||
this.idVerifications = Arrays.asList(ID_VERIFICATION.PASSPORT);
|
idVerifications = Arrays.asList(ID_VERIFICATION.PASSPORT);
|
||||||
this.webUrl = "https://bitsquare.io";
|
webUrl = "https://bitsquare.io";
|
||||||
this.description = "Bla bla...";
|
description = "Bla bla...";
|
||||||
doSave();
|
save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
if (saveOnEveryUpdate)
|
|
||||||
doSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doSave() {
|
|
||||||
storage.save();
|
storage.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
|
@ -168,43 +163,39 @@ public class Arbitrator implements Serializable {
|
||||||
// Setters
|
// Setters
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public void setSaveOnEveryUpdate(boolean saveOnEveryUpdate) {
|
|
||||||
this.saveOnEveryUpdate = saveOnEveryUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
doSave();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIdType(ID_TYPE idType) {
|
public void setIdType(ID_TYPE idType) {
|
||||||
this.idType = idType;
|
this.idType = idType;
|
||||||
doSave();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLanguages(List<String> languages) {
|
public void setLanguages(List<String> languages) {
|
||||||
this.languages = languages;
|
this.languages = languages;
|
||||||
doSave();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFee(Coin fee) {
|
public void setFee(Coin fee) {
|
||||||
this.fee = fee;
|
this.fee = fee;
|
||||||
doSave();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArbitrationMethods(List<METHOD> arbitrationMethods) {
|
public void setArbitrationMethods(List<METHOD> arbitrationMethods) {
|
||||||
this.arbitrationMethods = arbitrationMethods;
|
this.arbitrationMethods = arbitrationMethods;
|
||||||
doSave();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIdVerifications(List<ID_VERIFICATION> idVerifications) {
|
public void setIdVerifications(List<ID_VERIFICATION> idVerifications) {
|
||||||
this.idVerifications = idVerifications;
|
this.idVerifications = idVerifications;
|
||||||
doSave();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWebUrl(String webUrl) {
|
public void setWebUrl(String webUrl) {
|
||||||
this.webUrl = webUrl;
|
this.webUrl = webUrl;
|
||||||
doSave();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import io.bitsquare.locale.Country;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import java.util.Currency;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
@ -40,17 +39,17 @@ public class FiatAccount implements Serializable {
|
||||||
// The main currency if account support multiple currencies.
|
// 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
|
// The user can create multiple bank accounts with same bank account but other currency if his bank account
|
||||||
// support that.
|
// support that.
|
||||||
private final Currency currency;
|
private final String currencyCode;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public FiatAccount(FiatAccountType fiatAccountType, Currency currency, Country country, String nameOfBank,
|
public FiatAccount(FiatAccountType fiatAccountType, String currencyCode, Country country, String nameOfBank,
|
||||||
String accountHolderName, String accountPrimaryID, String accountSecondaryID) {
|
String accountHolderName, String accountPrimaryID, String accountSecondaryID) {
|
||||||
this.fiatAccountType = fiatAccountType;
|
this.fiatAccountType = fiatAccountType;
|
||||||
this.currency = currency;
|
this.currencyCode = currencyCode;
|
||||||
this.country = country;
|
this.country = country;
|
||||||
this.nameOfBank = nameOfBank;
|
this.nameOfBank = nameOfBank;
|
||||||
this.accountHolderName = accountHolderName;
|
this.accountHolderName = accountHolderName;
|
||||||
|
@ -79,8 +78,8 @@ public class FiatAccount implements Serializable {
|
||||||
return fiatAccountType;
|
return fiatAccountType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Currency getCurrency() {
|
public String getCurrencyCode() {
|
||||||
return currency;
|
return currencyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Country getCountry() {
|
public Country getCountry() {
|
||||||
|
@ -123,7 +122,7 @@ public class FiatAccount implements Serializable {
|
||||||
", accountSecondaryID='" + accountSecondaryID + '\'' +
|
", accountSecondaryID='" + accountSecondaryID + '\'' +
|
||||||
", accountHolderName='" + accountHolderName + '\'' +
|
", accountHolderName='" + accountHolderName + '\'' +
|
||||||
", country=" + country +
|
", country=" + country +
|
||||||
", currency=" + currency +
|
", currency=" + currencyCode +
|
||||||
", accountTitle='" + nameOfBank + '\'' +
|
", accountTitle='" + nameOfBank + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import io.bitsquare.user.User;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import java.util.Currency;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
@ -192,7 +191,7 @@ class MainViewModel implements ViewModel {
|
||||||
// For alpha version
|
// For alpha version
|
||||||
if (!user.isRegistered()) {
|
if (!user.isRegistered()) {
|
||||||
FiatAccount fiatAccount = new FiatAccount(FiatAccountType.IRC,
|
FiatAccount fiatAccount = new FiatAccount(FiatAccountType.IRC,
|
||||||
Currency.getInstance("EUR"),
|
"EUR",
|
||||||
CountryUtil.getDefaultCountry(),
|
CountryUtil.getDefaultCountry(),
|
||||||
"Demo (Name of bank)",
|
"Demo (Name of bank)",
|
||||||
"Demo (Account holder name)",
|
"Demo (Account holder name)",
|
||||||
|
|
|
@ -244,15 +244,12 @@ public class ArbitratorRegistrationView extends ActivatableView<AnchorPane, Void
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void onSaveProfile() {
|
public void onSaveProfile() {
|
||||||
arbitrator.setSaveOnEveryUpdate(false);
|
|
||||||
arbitrator.setWebUrl(webPageTextField.getText());
|
arbitrator.setWebUrl(webPageTextField.getText());
|
||||||
arbitrator.setFee(formatter.parseToCoin(arbitrationFeeTextField.getText()));
|
arbitrator.setFee(formatter.parseToCoin(arbitrationFeeTextField.getText()));
|
||||||
arbitrator.setIdType(idType);
|
arbitrator.setIdType(idType);
|
||||||
arbitrator.setIdVerifications(idVerificationList);
|
arbitrator.setIdVerifications(idVerificationList);
|
||||||
// arbitrator.setLanguages(languageList);
|
// arbitrator.setLanguages(languageList);
|
||||||
arbitrator.setArbitrationMethods(methodList);
|
arbitrator.setArbitrationMethods(methodList);
|
||||||
|
|
||||||
arbitrator.setSaveOnEveryUpdate(true);
|
|
||||||
arbitrator.save();
|
arbitrator.save();
|
||||||
|
|
||||||
if (isEditMode) {
|
if (isEditMode) {
|
||||||
|
|
|
@ -30,8 +30,6 @@ import io.bitsquare.user.User;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import java.util.Currency;
|
|
||||||
|
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
@ -52,16 +50,16 @@ class FiatAccountDataModel implements Activatable, DataModel {
|
||||||
final StringProperty secondaryID = new SimpleStringProperty();
|
final StringProperty secondaryID = new SimpleStringProperty();
|
||||||
final StringProperty primaryIDPrompt = new SimpleStringProperty();
|
final StringProperty primaryIDPrompt = new SimpleStringProperty();
|
||||||
final StringProperty secondaryIDPrompt = new SimpleStringProperty();
|
final StringProperty secondaryIDPrompt = new SimpleStringProperty();
|
||||||
|
final StringProperty currencyCode = new SimpleStringProperty();
|
||||||
final BooleanProperty countryNotInAcceptedCountriesList = new SimpleBooleanProperty();
|
final BooleanProperty countryNotInAcceptedCountriesList = new SimpleBooleanProperty();
|
||||||
final ObjectProperty<FiatAccountType> type = new SimpleObjectProperty<>();
|
final ObjectProperty<FiatAccountType> type = new SimpleObjectProperty<>();
|
||||||
final ObjectProperty<Country> country = new SimpleObjectProperty<>();
|
final ObjectProperty<Country> country = new SimpleObjectProperty<>();
|
||||||
final ObjectProperty<Currency> currency = new SimpleObjectProperty<>();
|
|
||||||
|
|
||||||
final ObservableList<FiatAccountType> allTypes = FXCollections.observableArrayList(FiatAccountType
|
final ObservableList<FiatAccountType> allTypes = FXCollections.observableArrayList(FiatAccountType
|
||||||
.getAllBankAccountTypes());
|
.getAllBankAccountTypes());
|
||||||
final ObservableList<FiatAccount> allFiatAccounts = FXCollections.observableArrayList();
|
final ObservableList<FiatAccount> allFiatAccounts = FXCollections.observableArrayList();
|
||||||
final ObservableList<Currency> allCurrencies = FXCollections.observableArrayList(CurrencyUtil
|
final ObservableList<String> allCurrencyCodes = FXCollections.observableArrayList(CurrencyUtil
|
||||||
.getAllCurrencies());
|
.getAllCurrencyCodes());
|
||||||
final ObservableList<Region> allRegions = FXCollections.observableArrayList(CountryUtil.getAllRegions());
|
final ObservableList<Region> allRegions = FXCollections.observableArrayList(CountryUtil.getAllRegions());
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,7 +83,7 @@ class FiatAccountDataModel implements Activatable, DataModel {
|
||||||
|
|
||||||
void saveBankAccount() {
|
void saveBankAccount() {
|
||||||
FiatAccount fiatAccount = new FiatAccount(type.get(),
|
FiatAccount fiatAccount = new FiatAccount(type.get(),
|
||||||
currency.get(),
|
currencyCode.get(),
|
||||||
country.get(),
|
country.get(),
|
||||||
title.get(),
|
title.get(),
|
||||||
holderName.get(),
|
holderName.get(),
|
||||||
|
@ -123,7 +121,7 @@ class FiatAccountDataModel implements Activatable, DataModel {
|
||||||
|
|
||||||
type.set(fiatAccount.getFiatAccountType());
|
type.set(fiatAccount.getFiatAccountType());
|
||||||
country.set(fiatAccount.getCountry());
|
country.set(fiatAccount.getCountry());
|
||||||
currency.set(fiatAccount.getCurrency());
|
currencyCode.set(fiatAccount.getCurrencyCode());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
reset();
|
reset();
|
||||||
|
@ -153,8 +151,8 @@ class FiatAccountDataModel implements Activatable, DataModel {
|
||||||
this.country.set(country);
|
this.country.set(country);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrency(Currency currency) {
|
void setCurrencyCode(String currencyCode) {
|
||||||
this.currency.set(currency);
|
this.currencyCode.set(currencyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -168,6 +166,6 @@ class FiatAccountDataModel implements Activatable, DataModel {
|
||||||
|
|
||||||
type.set(null);
|
type.set(null);
|
||||||
country.set(null);
|
country.set(null);
|
||||||
currency.set(null);
|
currencyCode.set(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import io.bitsquare.locale.Country;
|
||||||
import io.bitsquare.locale.Region;
|
import io.bitsquare.locale.Region;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Currency;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -60,7 +59,7 @@ public class FiatAccountView extends ActivatableViewAndModel<GridPane, FiatAccou
|
||||||
@FXML Button saveButton, completedButton, removeBankAccountButton;
|
@FXML Button saveButton, completedButton, removeBankAccountButton;
|
||||||
@FXML ComboBox<FiatAccount> selectionComboBox;
|
@FXML ComboBox<FiatAccount> selectionComboBox;
|
||||||
@FXML ComboBox<FiatAccountType> typesComboBox;
|
@FXML ComboBox<FiatAccountType> typesComboBox;
|
||||||
@FXML ComboBox<Currency> currencyComboBox;
|
@FXML ComboBox<String> currencyComboBox;
|
||||||
|
|
||||||
private Wizard wizard;
|
private Wizard wizard;
|
||||||
|
|
||||||
|
@ -77,7 +76,7 @@ public class FiatAccountView extends ActivatableViewAndModel<GridPane, FiatAccou
|
||||||
typesComboBox.setItems(model.getAllTypes());
|
typesComboBox.setItems(model.getAllTypes());
|
||||||
typesComboBox.setConverter(model.getTypesConverter());
|
typesComboBox.setConverter(model.getTypesConverter());
|
||||||
selectionComboBox.setConverter(model.getSelectionConverter());
|
selectionComboBox.setConverter(model.getSelectionConverter());
|
||||||
currencyComboBox.setItems(model.getAllCurrencies());
|
currencyComboBox.setItems(model.getAllCurrencyCodes());
|
||||||
currencyComboBox.setConverter(model.getCurrencyConverter());
|
currencyComboBox.setConverter(model.getCurrencyConverter());
|
||||||
regionComboBox.setItems(model.getAllRegions());
|
regionComboBox.setItems(model.getAllRegions());
|
||||||
regionComboBox.setConverter(model.getRegionConverter());
|
regionComboBox.setConverter(model.getRegionConverter());
|
||||||
|
@ -120,7 +119,7 @@ public class FiatAccountView extends ActivatableViewAndModel<GridPane, FiatAccou
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void onSelectCurrency() {
|
void onSelectCurrency() {
|
||||||
model.setCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
|
model.setCurrencyCode(currencyComboBox.getSelectionModel().getSelectedItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -179,7 +178,7 @@ public class FiatAccountView extends ActivatableViewAndModel<GridPane, FiatAccou
|
||||||
typesComboBox.getSelectionModel().clearSelection();
|
typesComboBox.getSelectionModel().clearSelection();
|
||||||
});
|
});
|
||||||
|
|
||||||
model.currency.addListener((ov, oldValue, newValue) -> {
|
model.currencyCode.addListener((ov, oldValue, newValue) -> {
|
||||||
if (newValue != null)
|
if (newValue != null)
|
||||||
currencyComboBox.getSelectionModel().select(currencyComboBox.getItems().indexOf(newValue));
|
currencyComboBox.getSelectionModel().select(currencyComboBox.getItems().indexOf(newValue));
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,12 +25,11 @@ import io.bitsquare.gui.util.validation.BankAccountNumberValidator;
|
||||||
import io.bitsquare.gui.util.validation.InputValidator;
|
import io.bitsquare.gui.util.validation.InputValidator;
|
||||||
import io.bitsquare.locale.BSResources;
|
import io.bitsquare.locale.BSResources;
|
||||||
import io.bitsquare.locale.Country;
|
import io.bitsquare.locale.Country;
|
||||||
|
import io.bitsquare.locale.CurrencyUtil;
|
||||||
import io.bitsquare.locale.Region;
|
import io.bitsquare.locale.Region;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import java.util.Currency;
|
|
||||||
|
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
@ -52,11 +51,11 @@ class FiatAccountViewModel extends ActivatableWithDataModel<FiatAccountDataModel
|
||||||
final StringProperty primaryIDPrompt = new SimpleStringProperty();
|
final StringProperty primaryIDPrompt = new SimpleStringProperty();
|
||||||
final StringProperty secondaryIDPrompt = new SimpleStringProperty();
|
final StringProperty secondaryIDPrompt = new SimpleStringProperty();
|
||||||
final StringProperty selectionPrompt = new SimpleStringProperty();
|
final StringProperty selectionPrompt = new SimpleStringProperty();
|
||||||
|
final StringProperty currencyCode = new SimpleStringProperty();
|
||||||
final BooleanProperty selectionDisable = new SimpleBooleanProperty();
|
final BooleanProperty selectionDisable = new SimpleBooleanProperty();
|
||||||
final BooleanProperty saveButtonDisable = new SimpleBooleanProperty(true);
|
final BooleanProperty saveButtonDisable = new SimpleBooleanProperty(true);
|
||||||
final ObjectProperty<FiatAccountType> type = new SimpleObjectProperty<>();
|
final ObjectProperty<FiatAccountType> type = new SimpleObjectProperty<>();
|
||||||
final ObjectProperty<Country> country = new SimpleObjectProperty<>();
|
final ObjectProperty<Country> country = new SimpleObjectProperty<>();
|
||||||
final ObjectProperty<Currency> currency = new SimpleObjectProperty<>();
|
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -71,7 +70,7 @@ class FiatAccountViewModel extends ActivatableWithDataModel<FiatAccountDataModel
|
||||||
secondaryID.bindBidirectional(dataModel.secondaryID);
|
secondaryID.bindBidirectional(dataModel.secondaryID);
|
||||||
type.bindBidirectional(dataModel.type);
|
type.bindBidirectional(dataModel.type);
|
||||||
country.bindBidirectional(dataModel.country);
|
country.bindBidirectional(dataModel.country);
|
||||||
currency.bindBidirectional(dataModel.currency);
|
currencyCode.bindBidirectional(dataModel.currencyCode);
|
||||||
|
|
||||||
primaryIDPrompt.bind(dataModel.primaryIDPrompt);
|
primaryIDPrompt.bind(dataModel.primaryIDPrompt);
|
||||||
secondaryIDPrompt.bind(dataModel.secondaryIDPrompt);
|
secondaryIDPrompt.bind(dataModel.secondaryIDPrompt);
|
||||||
|
@ -141,17 +140,17 @@ class FiatAccountViewModel extends ActivatableWithDataModel<FiatAccountDataModel
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
StringConverter<Currency> getCurrencyConverter() {
|
StringConverter<String> getCurrencyConverter() {
|
||||||
return new StringConverter<Currency>() {
|
return new StringConverter<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(Currency currency) {
|
public String toString(String currencyCode) {
|
||||||
return currency.getCurrencyCode() + " (" + currency.getDisplayName() + ")";
|
return currencyCode+ " (" + CurrencyUtil.getDisplayName(currencyCode) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Currency fromString(String s) {
|
public String fromString(String s) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -194,8 +193,8 @@ class FiatAccountViewModel extends ActivatableWithDataModel<FiatAccountDataModel
|
||||||
return dataModel.allFiatAccounts;
|
return dataModel.allFiatAccounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObservableList<Currency> getAllCurrencies() {
|
ObservableList<String> getAllCurrencyCodes() {
|
||||||
return dataModel.allCurrencies;
|
return dataModel.allCurrencyCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObservableList<Region> getAllRegions() {
|
ObservableList<Region> getAllRegions() {
|
||||||
|
@ -225,8 +224,8 @@ class FiatAccountViewModel extends ActivatableWithDataModel<FiatAccountDataModel
|
||||||
validateInput();
|
validateInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrency(Currency currency) {
|
void setCurrencyCode(String currencyCode) {
|
||||||
dataModel.setCurrency(currency);
|
dataModel.setCurrencyCode(currencyCode);
|
||||||
validateInput();
|
validateInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +250,7 @@ class FiatAccountViewModel extends ActivatableWithDataModel<FiatAccountDataModel
|
||||||
if (result.isValid) {
|
if (result.isValid) {
|
||||||
result = bankAccountNumberValidator.validate(dataModel.secondaryID.get());
|
result = bankAccountNumberValidator.validate(dataModel.secondaryID.get());
|
||||||
if (result.isValid) {
|
if (result.isValid) {
|
||||||
if (dataModel.currency.get() == null)
|
if (dataModel.currencyCode.get() == null)
|
||||||
result = new InputValidator.ValidationResult(false,
|
result = new InputValidator.ValidationResult(false,
|
||||||
"You have not selected a currency");
|
"You have not selected a currency");
|
||||||
if (result.isValid) {
|
if (result.isValid) {
|
||||||
|
|
|
@ -27,8 +27,6 @@ import io.bitsquare.user.User;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import java.util.Currency;
|
|
||||||
|
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.beans.property.SimpleObjectProperty;
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
@ -41,12 +39,12 @@ class IrcAccountDataModel implements Activatable, DataModel {
|
||||||
private final User user;
|
private final User user;
|
||||||
|
|
||||||
final StringProperty nickName = new SimpleStringProperty();
|
final StringProperty nickName = new SimpleStringProperty();
|
||||||
|
final StringProperty currencyCode = new SimpleStringProperty();
|
||||||
final ObjectProperty<FiatAccountType> type = new SimpleObjectProperty<>();
|
final ObjectProperty<FiatAccountType> type = new SimpleObjectProperty<>();
|
||||||
final ObjectProperty<Currency> currency = new SimpleObjectProperty<>();
|
|
||||||
|
|
||||||
final ObservableList<FiatAccountType> allTypes =
|
final ObservableList<FiatAccountType> allTypes =
|
||||||
FXCollections.observableArrayList(FiatAccountType.getAllBankAccountTypes());
|
FXCollections.observableArrayList(FiatAccountType.getAllBankAccountTypes());
|
||||||
final ObservableList<Currency> allCurrencies = FXCollections.observableArrayList(CurrencyUtil.getAllCurrencies());
|
final ObservableList<String> allCurrencyCodes = FXCollections.observableArrayList(CurrencyUtil.getAllCurrencyCodes());
|
||||||
final ObservableList<FiatAccount> allFiatAccounts = FXCollections.observableArrayList();
|
final ObservableList<FiatAccount> allFiatAccounts = FXCollections.observableArrayList();
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,7 +65,7 @@ class IrcAccountDataModel implements Activatable, DataModel {
|
||||||
|
|
||||||
void saveBankAccount() {
|
void saveBankAccount() {
|
||||||
FiatAccount fiatAccount = new FiatAccount(type.get(),
|
FiatAccount fiatAccount = new FiatAccount(type.get(),
|
||||||
currency.get(),
|
currencyCode.get(),
|
||||||
CountryUtil.getDefaultCountry(),
|
CountryUtil.getDefaultCountry(),
|
||||||
nickName.get(),
|
nickName.get(),
|
||||||
nickName.get(),
|
nickName.get(),
|
||||||
|
@ -82,14 +80,14 @@ class IrcAccountDataModel implements Activatable, DataModel {
|
||||||
this.type.set(type);
|
this.type.set(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrency(Currency currency) {
|
void setCurrencyCode(String currencyCode) {
|
||||||
this.currency.set(currency);
|
this.currencyCode.set(currencyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reset() {
|
private void reset() {
|
||||||
nickName.set(null);
|
nickName.set(null);
|
||||||
|
|
||||||
type.set(null);
|
type.set(null);
|
||||||
currency.set(null);
|
currencyCode.set(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,9 @@ import io.bitsquare.gui.components.InputTextField;
|
||||||
import io.bitsquare.gui.components.Popups;
|
import io.bitsquare.gui.components.Popups;
|
||||||
import io.bitsquare.gui.main.help.Help;
|
import io.bitsquare.gui.main.help.Help;
|
||||||
import io.bitsquare.gui.main.help.HelpId;
|
import io.bitsquare.gui.main.help.HelpId;
|
||||||
|
import io.bitsquare.locale.CurrencyUtil;
|
||||||
import io.bitsquare.util.Utilities;
|
import io.bitsquare.util.Utilities;
|
||||||
|
|
||||||
import java.util.Currency;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
@ -47,7 +46,7 @@ public class IrcAccountView extends ActivatableViewAndModel<GridPane, IrcAccount
|
||||||
@FXML InputTextField ircNickNameTextField;
|
@FXML InputTextField ircNickNameTextField;
|
||||||
@FXML Button saveButton;
|
@FXML Button saveButton;
|
||||||
@FXML ComboBox<FiatAccountType> typesComboBox;
|
@FXML ComboBox<FiatAccountType> typesComboBox;
|
||||||
@FXML ComboBox<Currency> currencyComboBox;
|
@FXML ComboBox<String> currencyComboBox;
|
||||||
|
|
||||||
private Wizard wizard;
|
private Wizard wizard;
|
||||||
|
|
||||||
|
@ -87,25 +86,25 @@ public class IrcAccountView extends ActivatableViewAndModel<GridPane, IrcAccount
|
||||||
});
|
});
|
||||||
typesComboBox.getSelectionModel().select(0);
|
typesComboBox.getSelectionModel().select(0);
|
||||||
|
|
||||||
currencyComboBox.setItems(model.getAllCurrencies());
|
currencyComboBox.setItems(model.getAllCurrencyCodes());
|
||||||
currencyComboBox.setConverter(model.getCurrencyConverter());
|
currencyComboBox.setConverter(model.getCurrencyConverter());
|
||||||
// we use a custom cell for deactivating non EUR items, later we use the standard cell and the StringConverter
|
// we use a custom cell for deactivating non EUR items, later we use the standard cell and the StringConverter
|
||||||
currencyComboBox.setCellFactory(new Callback<ListView<Currency>, ListCell<Currency>>() {
|
currencyComboBox.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public ListCell<Currency> call(ListView<Currency> p) {
|
public ListCell<String> call(ListView<String> p) {
|
||||||
return new ListCell<Currency>() {
|
return new ListCell<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateItem(Currency currency, boolean empty) {
|
protected void updateItem(String currencyCode, boolean empty) {
|
||||||
super.updateItem(currency, empty);
|
super.updateItem(currencyCode, empty);
|
||||||
|
|
||||||
if (currency == null || empty) {
|
if (currencyCode == null || empty) {
|
||||||
setGraphic(null);
|
setGraphic(null);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setText(currency.getCurrencyCode() + " (" + currency.getDisplayName() + ")");
|
setText(currencyCode+ " (" + CurrencyUtil.getDisplayName(currencyCode) + ")");
|
||||||
|
|
||||||
if (!currency.getCurrencyCode().equals("EUR")) {
|
if (!currencyCode.equals("EUR")) {
|
||||||
setOpacity(0.3);
|
setOpacity(0.3);
|
||||||
setDisable(true);
|
setDisable(true);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +145,7 @@ public class IrcAccountView extends ActivatableViewAndModel<GridPane, IrcAccount
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void onSelectCurrency() {
|
void onSelectCurrency() {
|
||||||
model.setCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
|
model.setCurrencyCode(currencyComboBox.getSelectionModel().getSelectedItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -180,7 +179,7 @@ public class IrcAccountView extends ActivatableViewAndModel<GridPane, IrcAccount
|
||||||
typesComboBox.getSelectionModel().clearSelection();
|
typesComboBox.getSelectionModel().clearSelection();
|
||||||
});
|
});
|
||||||
|
|
||||||
model.currency.addListener((ov, oldValue, newValue) -> {
|
model.currencyCode.addListener((ov, oldValue, newValue) -> {
|
||||||
if (newValue != null)
|
if (newValue != null)
|
||||||
currencyComboBox.getSelectionModel().select(currencyComboBox.getItems().indexOf(newValue));
|
currencyComboBox.getSelectionModel().select(currencyComboBox.getItems().indexOf(newValue));
|
||||||
else
|
else
|
||||||
|
|
|
@ -23,11 +23,10 @@ import io.bitsquare.fiat.FiatAccountType;
|
||||||
import io.bitsquare.gui.util.validation.BankAccountNumberValidator;
|
import io.bitsquare.gui.util.validation.BankAccountNumberValidator;
|
||||||
import io.bitsquare.gui.util.validation.InputValidator;
|
import io.bitsquare.gui.util.validation.InputValidator;
|
||||||
import io.bitsquare.locale.BSResources;
|
import io.bitsquare.locale.BSResources;
|
||||||
|
import io.bitsquare.locale.CurrencyUtil;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import java.util.Currency;
|
|
||||||
|
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
@ -42,10 +41,9 @@ class IrcAccountViewModel extends ActivatableWithDataModel<IrcAccountDataModel>
|
||||||
private final InputValidator nickNameValidator;
|
private final InputValidator nickNameValidator;
|
||||||
|
|
||||||
final StringProperty ircNickName = new SimpleStringProperty();
|
final StringProperty ircNickName = new SimpleStringProperty();
|
||||||
|
final StringProperty currencyCode = new SimpleStringProperty();
|
||||||
final BooleanProperty saveButtonDisable = new SimpleBooleanProperty(true);
|
final BooleanProperty saveButtonDisable = new SimpleBooleanProperty(true);
|
||||||
final ObjectProperty<FiatAccountType> type = new SimpleObjectProperty<>();
|
final ObjectProperty<FiatAccountType> type = new SimpleObjectProperty<>();
|
||||||
final ObjectProperty<Currency> currency = new SimpleObjectProperty<>();
|
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public IrcAccountViewModel(IrcAccountDataModel dataModel, BankAccountNumberValidator nickNameValidator) {
|
public IrcAccountViewModel(IrcAccountDataModel dataModel, BankAccountNumberValidator nickNameValidator) {
|
||||||
|
@ -55,7 +53,7 @@ class IrcAccountViewModel extends ActivatableWithDataModel<IrcAccountDataModel>
|
||||||
// input
|
// input
|
||||||
ircNickName.bindBidirectional(dataModel.nickName);
|
ircNickName.bindBidirectional(dataModel.nickName);
|
||||||
type.bindBidirectional(dataModel.type);
|
type.bindBidirectional(dataModel.type);
|
||||||
currency.bindBidirectional(dataModel.currency);
|
currencyCode.bindBidirectional(dataModel.currencyCode);
|
||||||
|
|
||||||
dataModel.nickName.addListener((ov, oldValue, newValue) -> validateInput());
|
dataModel.nickName.addListener((ov, oldValue, newValue) -> validateInput());
|
||||||
}
|
}
|
||||||
|
@ -87,15 +85,15 @@ class IrcAccountViewModel extends ActivatableWithDataModel<IrcAccountDataModel>
|
||||||
return fiatAccountType != null ? BSResources.get(fiatAccountType.toString()) : "";
|
return fiatAccountType != null ? BSResources.get(fiatAccountType.toString()) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
StringConverter<Currency> getCurrencyConverter() {
|
StringConverter<String> getCurrencyConverter() {
|
||||||
return new StringConverter<Currency>() {
|
return new StringConverter<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String toString(Currency currency) {
|
public String toString(String currencyCode) {
|
||||||
return currency.getCurrencyCode() + " (" + currency.getDisplayName() + ")";
|
return currencyCode + " (" + CurrencyUtil.getDisplayName(currencyCode) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Currency fromString(String s) {
|
public String fromString(String s) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -106,8 +104,8 @@ class IrcAccountViewModel extends ActivatableWithDataModel<IrcAccountDataModel>
|
||||||
return dataModel.allTypes;
|
return dataModel.allTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObservableList<Currency> getAllCurrencies() {
|
ObservableList<String> getAllCurrencyCodes() {
|
||||||
return dataModel.allCurrencies;
|
return dataModel.allCurrencyCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputValidator getNickNameValidator() {
|
InputValidator getNickNameValidator() {
|
||||||
|
@ -120,15 +118,15 @@ class IrcAccountViewModel extends ActivatableWithDataModel<IrcAccountDataModel>
|
||||||
validateInput();
|
validateInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrency(Currency currency) {
|
void setCurrencyCode(String currencyCode) {
|
||||||
dataModel.setCurrency(currency);
|
dataModel.setCurrencyCode(currencyCode);
|
||||||
validateInput();
|
validateInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private InputValidator.ValidationResult validateInput() {
|
private InputValidator.ValidationResult validateInput() {
|
||||||
InputValidator.ValidationResult result = nickNameValidator.validate(dataModel.nickName.get());
|
InputValidator.ValidationResult result = nickNameValidator.validate(dataModel.nickName.get());
|
||||||
if (dataModel.currency.get() == null)
|
if (dataModel.currencyCode.get() == null)
|
||||||
result = new InputValidator.ValidationResult(false,
|
result = new InputValidator.ValidationResult(false,
|
||||||
"You have not selected a currency");
|
"You have not selected a currency");
|
||||||
if (result.isValid) {
|
if (result.isValid) {
|
||||||
|
|
|
@ -229,7 +229,7 @@ class PendingTradesDataModel implements Activatable, DataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
String getCurrencyCode() {
|
String getCurrencyCode() {
|
||||||
return selectedItem.getTrade().getOffer().getCurrency().getCurrencyCode();
|
return selectedItem.getTrade().getOffer().getCurrencyCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Offer.Direction getDirection(Offer offer) {
|
public Offer.Direction getDirection(Offer offer) {
|
||||||
|
|
|
@ -261,10 +261,10 @@ class CreateOfferDataModel implements Activatable, DataModel {
|
||||||
private void applyBankAccount(FiatAccount fiatAccount) {
|
private void applyBankAccount(FiatAccount fiatAccount) {
|
||||||
if (fiatAccount != null) {
|
if (fiatAccount != null) {
|
||||||
bankAccountType.set(fiatAccount.getFiatAccountType().toString());
|
bankAccountType.set(fiatAccount.getFiatAccountType().toString());
|
||||||
bankAccountCurrency.set(fiatAccount.getCurrency().getCurrencyCode());
|
bankAccountCurrency.set(fiatAccount.getCurrencyCode());
|
||||||
bankAccountCounty.set(fiatAccount.getCountry().getName());
|
bankAccountCounty.set(fiatAccount.getCountry().getName());
|
||||||
|
|
||||||
fiatCode.set(fiatAccount.getCurrency().getCurrencyCode());
|
fiatCode.set(fiatAccount.getCurrencyCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,12 +245,12 @@ class OfferBookDataModel implements Activatable, DataModel {
|
||||||
|
|
||||||
private void setBankAccount(FiatAccount fiatAccount) {
|
private void setBankAccount(FiatAccount fiatAccount) {
|
||||||
if (fiatAccount != null) {
|
if (fiatAccount != null) {
|
||||||
fiatCode.set(fiatAccount.getCurrency().getCurrencyCode());
|
fiatCode.set(fiatAccount.getCurrencyCode());
|
||||||
bankAccountCountry.set(fiatAccount.getCountry());
|
bankAccountCountry.set(fiatAccount.getCountry());
|
||||||
sortedItems.stream().forEach(e -> e.setBankAccountCountry(fiatAccount.getCountry()));
|
sortedItems.stream().forEach(e -> e.setBankAccountCountry(fiatAccount.getCountry()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fiatCode.set(CurrencyUtil.getDefaultCurrency().getCurrencyCode());
|
fiatCode.set(CurrencyUtil.getDefaultCurrencyAsCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import io.bitsquare.gui.util.BSFormatter;
|
||||||
import io.bitsquare.gui.util.validation.BtcValidator;
|
import io.bitsquare.gui.util.validation.BtcValidator;
|
||||||
import io.bitsquare.gui.util.validation.InputValidator;
|
import io.bitsquare.gui.util.validation.InputValidator;
|
||||||
import io.bitsquare.locale.BSResources;
|
import io.bitsquare.locale.BSResources;
|
||||||
|
import io.bitsquare.locale.CurrencyUtil;
|
||||||
import io.bitsquare.offer.Offer;
|
import io.bitsquare.offer.Offer;
|
||||||
|
|
||||||
import org.bitcoinj.core.Address;
|
import org.bitcoinj.core.Address;
|
||||||
|
@ -120,7 +121,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
||||||
directionLabel = direction == Offer.Direction.BUY ?
|
directionLabel = direction == Offer.Direction.BUY ?
|
||||||
BSResources.get("shared.buy") : BSResources.get("shared.sell");
|
BSResources.get("shared.buy") : BSResources.get("shared.sell");
|
||||||
|
|
||||||
fiatCode = offer.getCurrency().getCurrencyCode();
|
fiatCode = offer.getCurrencyCode();
|
||||||
if (!dataModel.isMinAmountLessOrEqualAmount()) {
|
if (!dataModel.isMinAmountLessOrEqualAmount()) {
|
||||||
amountValidationResult.set(new InputValidator.ValidationResult(false,
|
amountValidationResult.set(new InputValidator.ValidationResult(false,
|
||||||
BSResources.get("takeOffer.validation.amountSmallerThanMinAmount")));
|
BSResources.get("takeOffer.validation.amountSmallerThanMinAmount")));
|
||||||
|
@ -142,7 +143,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
||||||
acceptedLanguages = formatter.languageLocalesToString(offer.getAcceptedLanguageLocales());
|
acceptedLanguages = formatter.languageLocalesToString(offer.getAcceptedLanguageLocales());
|
||||||
acceptedArbitrators = formatter.arbitratorsToString(offer.getArbitrators());
|
acceptedArbitrators = formatter.arbitratorsToString(offer.getArbitrators());
|
||||||
bankAccountType = BSResources.get(offer.getFiatAccountType().toString());
|
bankAccountType = BSResources.get(offer.getFiatAccountType().toString());
|
||||||
bankAccountCurrency = BSResources.get(offer.getCurrency().getDisplayName());
|
bankAccountCurrency = BSResources.get(CurrencyUtil.getDisplayName(offer.getCurrencyCode()));
|
||||||
bankAccountCounty = BSResources.get(offer.getBankAccountCountry().getName());
|
bankAccountCounty = BSResources.get(offer.getBankAccountCountry().getName());
|
||||||
|
|
||||||
offer.stateProperty().addListener((ov, oldValue, newValue) -> applyOfferState(newValue));
|
offer.stateProperty().addListener((ov, oldValue, newValue) -> applyOfferState(newValue));
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class BSFormatter {
|
||||||
// no way to remove grouping separator). It seems to be not optimal for user input formatting.
|
// no way to remove grouping separator). It seems to be not optimal for user input formatting.
|
||||||
private MonetaryFormat coinFormat = MonetaryFormat.BTC.repeatOptionalDecimals(2, 2);
|
private MonetaryFormat coinFormat = MonetaryFormat.BTC.repeatOptionalDecimals(2, 2);
|
||||||
|
|
||||||
private String currencyCode = CurrencyUtil.getDefaultCurrency().getCurrencyCode();
|
private String currencyCode = CurrencyUtil.getDefaultCurrencyAsCode();
|
||||||
|
|
||||||
// format is like: 1,00 never more then 2 decimals
|
// format is like: 1,00 never more then 2 decimals
|
||||||
private final MonetaryFormat fiatFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0).code(0, currencyCode);
|
private final MonetaryFormat fiatFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0).code(0, currencyCode);
|
||||||
|
@ -76,13 +76,13 @@ public class BSFormatter {
|
||||||
@Inject
|
@Inject
|
||||||
public BSFormatter(User user) {
|
public BSFormatter(User user) {
|
||||||
if (user.currentFiatAccountProperty().get() == null)
|
if (user.currentFiatAccountProperty().get() == null)
|
||||||
setFiatCurrencyCode(CurrencyUtil.getDefaultCurrency().getCurrencyCode());
|
setFiatCurrencyCode(CurrencyUtil.getDefaultCurrencyAsCode());
|
||||||
else if (user.currentFiatAccountProperty().get() != null)
|
else if (user.currentFiatAccountProperty().get() != null)
|
||||||
setFiatCurrencyCode(user.currentFiatAccountProperty().get().getCurrency().getCurrencyCode());
|
setFiatCurrencyCode(user.currentFiatAccountProperty().get().getCurrencyCode());
|
||||||
|
|
||||||
user.currentFiatAccountProperty().addListener((ov, oldValue, newValue) -> {
|
user.currentFiatAccountProperty().addListener((ov, oldValue, newValue) -> {
|
||||||
if (newValue != null)
|
if (newValue != null)
|
||||||
setFiatCurrencyCode(newValue.getCurrency().getCurrencyCode());
|
setFiatCurrencyCode(newValue.getCurrencyCode());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,13 +40,13 @@ public final class FiatValidator extends NumberValidator {
|
||||||
public FiatValidator(User user) {
|
public FiatValidator(User user) {
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (user.currentFiatAccountProperty().get() == null)
|
if (user.currentFiatAccountProperty().get() == null)
|
||||||
setFiatCurrencyCode(CurrencyUtil.getDefaultCurrency().getCurrencyCode());
|
setFiatCurrencyCode(CurrencyUtil.getDefaultCurrencyAsCode());
|
||||||
else if (user.currentFiatAccountProperty().get() != null)
|
else if (user.currentFiatAccountProperty().get() != null)
|
||||||
setFiatCurrencyCode(user.currentFiatAccountProperty().get().getCurrency().getCurrencyCode());
|
setFiatCurrencyCode(user.currentFiatAccountProperty().get().getCurrencyCode());
|
||||||
|
|
||||||
user.currentFiatAccountProperty().addListener((ov, oldValue, newValue) -> {
|
user.currentFiatAccountProperty().addListener((ov, oldValue, newValue) -> {
|
||||||
if (newValue != null)
|
if (newValue != null)
|
||||||
setFiatCurrencyCode(newValue.getCurrency().getCurrencyCode());
|
setFiatCurrencyCode(newValue.getCurrencyCode());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,13 +40,13 @@ public final class OptionalFiatValidator extends NumberValidator {
|
||||||
public OptionalFiatValidator(User user) {
|
public OptionalFiatValidator(User user) {
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (user.currentFiatAccountProperty().get() == null)
|
if (user.currentFiatAccountProperty().get() == null)
|
||||||
setFiatCurrencyCode(CurrencyUtil.getDefaultCurrency().getCurrencyCode());
|
setFiatCurrencyCode(CurrencyUtil.getDefaultCurrencyAsCode());
|
||||||
else if (user.currentFiatAccountProperty().get() != null)
|
else if (user.currentFiatAccountProperty().get() != null)
|
||||||
setFiatCurrencyCode(user.currentFiatAccountProperty().get().getCurrency().getCurrencyCode());
|
setFiatCurrencyCode(user.currentFiatAccountProperty().get().getCurrencyCode());
|
||||||
|
|
||||||
user.currentFiatAccountProperty().addListener((ov, oldValue, newValue) -> {
|
user.currentFiatAccountProperty().addListener((ov, oldValue, newValue) -> {
|
||||||
if (newValue != null)
|
if (newValue != null)
|
||||||
setFiatCurrencyCode(newValue.getCurrency().getCurrencyCode());
|
setFiatCurrencyCode(newValue.getCurrencyCode());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,23 @@ import java.util.ArrayList;
|
||||||
import java.util.Currency;
|
import java.util.Currency;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CurrencyUtil {
|
public class CurrencyUtil {
|
||||||
|
|
||||||
public static List<Currency> getAllCurrencies() {
|
public static List<String> getAllCurrencyCodes() {
|
||||||
|
return getAllCurrencies().stream().map(e -> e.getCurrencyCode()).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDefaultCurrencyAsCode() {
|
||||||
|
return getDefaultCurrency().getCurrencyCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDisplayName(String currencyCode) {
|
||||||
|
return Currency.getInstance(currencyCode).getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Currency> getAllCurrencies() {
|
||||||
final ArrayList<Currency> mainCurrencies = new ArrayList<>();
|
final ArrayList<Currency> mainCurrencies = new ArrayList<>();
|
||||||
mainCurrencies.add(Currency.getInstance("EUR"));
|
mainCurrencies.add(Currency.getInstance("EUR"));
|
||||||
mainCurrencies.add(Currency.getInstance("USD"));
|
mainCurrencies.add(Currency.getInstance("USD"));
|
||||||
|
@ -52,9 +65,11 @@ public class CurrencyUtil {
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Currency getDefaultCurrency() {
|
private static Currency getDefaultCurrency() {
|
||||||
// TODO Only display EUR for the moment
|
// TODO Only display EUR for the moment
|
||||||
return Currency.getInstance("EUR");
|
return Currency.getInstance("EUR");
|
||||||
// return Currency.getInstance(Locale.getDefault());
|
// return Currency.getInstance(Locale.getDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import java.io.Serializable;
|
||||||
|
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
|
|
||||||
import java.util.Currency;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -60,7 +59,7 @@ public class Offer implements Serializable {
|
||||||
|
|
||||||
// key attributes for lookup
|
// key attributes for lookup
|
||||||
private final Direction direction;
|
private final Direction direction;
|
||||||
private final Currency currency;
|
private final String currencyCode;
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Date creationDate;
|
private final Date creationDate;
|
||||||
|
|
||||||
|
@ -100,7 +99,7 @@ public class Offer implements Serializable {
|
||||||
Coin amount,
|
Coin amount,
|
||||||
Coin minAmount,
|
Coin minAmount,
|
||||||
FiatAccountType fiatAccountType,
|
FiatAccountType fiatAccountType,
|
||||||
Currency currency,
|
String currencyCode,
|
||||||
Country bankAccountCountry,
|
Country bankAccountCountry,
|
||||||
String bankAccountUID,
|
String bankAccountUID,
|
||||||
List<Arbitrator> arbitrators,
|
List<Arbitrator> arbitrators,
|
||||||
|
@ -114,7 +113,7 @@ public class Offer implements Serializable {
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
this.minAmount = minAmount;
|
this.minAmount = minAmount;
|
||||||
this.fiatAccountType = fiatAccountType;
|
this.fiatAccountType = fiatAccountType;
|
||||||
this.currency = currency;
|
this.currencyCode = currencyCode;
|
||||||
this.bankAccountCountry = bankAccountCountry;
|
this.bankAccountCountry = bankAccountCountry;
|
||||||
this.bankAccountUID = bankAccountUID;
|
this.bankAccountUID = bankAccountUID;
|
||||||
this.arbitrators = arbitrators;
|
this.arbitrators = arbitrators;
|
||||||
|
@ -150,7 +149,7 @@ public class Offer implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fiat getPrice() {
|
public Fiat getPrice() {
|
||||||
return Fiat.valueOf(currency.getCurrencyCode(), fiatPrice);
|
return Fiat.valueOf(currencyCode, fiatPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Coin getAmount() {
|
public Coin getAmount() {
|
||||||
|
@ -173,8 +172,8 @@ public class Offer implements Serializable {
|
||||||
return fiatAccountType;
|
return fiatAccountType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Currency getCurrency() {
|
public String getCurrencyCode() {
|
||||||
return currency;
|
return currencyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Country getBankAccountCountry() {
|
public Country getBankAccountCountry() {
|
||||||
|
@ -191,7 +190,7 @@ public class Offer implements Serializable {
|
||||||
|
|
||||||
public Fiat getVolumeByAmount(Coin amount) {
|
public Fiat getVolumeByAmount(Coin amount) {
|
||||||
if (fiatPrice != 0 && amount != null && !amount.isZero())
|
if (fiatPrice != 0 && amount != null && !amount.isZero())
|
||||||
return new ExchangeRate(Fiat.valueOf(currency.getCurrencyCode(), fiatPrice)).coinToFiat(amount);
|
return new ExchangeRate(Fiat.valueOf(currencyCode, fiatPrice)).coinToFiat(amount);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +245,7 @@ public class Offer implements Serializable {
|
||||||
checkNotNull(getBankAccountId(), "BankAccountId is null");
|
checkNotNull(getBankAccountId(), "BankAccountId is null");
|
||||||
checkNotNull(getSecurityDeposit(), "SecurityDeposit is null");
|
checkNotNull(getSecurityDeposit(), "SecurityDeposit is null");
|
||||||
checkNotNull(getCreationDate(), "CreationDate is null");
|
checkNotNull(getCreationDate(), "CreationDate is null");
|
||||||
checkNotNull(getCurrency(), "Currency is null");
|
checkNotNull(getCurrencyCode(), "Currency is null");
|
||||||
checkNotNull(getDirection(), "Direction is null");
|
checkNotNull(getDirection(), "Direction is null");
|
||||||
checkNotNull(getId(), "Id is null");
|
checkNotNull(getId(), "Id is null");
|
||||||
checkNotNull(getP2PSigPubKey(), "p2pSigPubKey is null");
|
checkNotNull(getP2PSigPubKey(), "p2pSigPubKey is null");
|
||||||
|
@ -271,7 +270,7 @@ public class Offer implements Serializable {
|
||||||
"id='" + id + '\'' +
|
"id='" + id + '\'' +
|
||||||
", state=" + state +
|
", state=" + state +
|
||||||
", direction=" + direction +
|
", direction=" + direction +
|
||||||
", currency=" + currency +
|
", currency=" + currencyCode +
|
||||||
", creationDate=" + creationDate +
|
", creationDate=" + creationDate +
|
||||||
", fiatPrice=" + fiatPrice +
|
", fiatPrice=" + fiatPrice +
|
||||||
", amount=" + amount +
|
", amount=" + amount +
|
||||||
|
|
|
@ -138,13 +138,13 @@ public class OfferBook {
|
||||||
log.debug("setBankAccount " + fiatAccount);
|
log.debug("setBankAccount " + fiatAccount);
|
||||||
if (fiatAccount != null) {
|
if (fiatAccount != null) {
|
||||||
country = fiatAccount.getCountry();
|
country = fiatAccount.getCountry();
|
||||||
fiatCode = fiatAccount.getCurrency().getCurrencyCode();
|
fiatCode = fiatAccount.getCurrencyCode();
|
||||||
|
|
||||||
// TODO check why that was used (probably just for update triggering, if so refactor that)
|
// TODO check why that was used (probably just for update triggering, if so refactor that)
|
||||||
//offerBookListItems.stream().forEach(e -> e.setBankAccountCountry(country));
|
//offerBookListItems.stream().forEach(e -> e.setBankAccountCountry(country));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fiatCode = CurrencyUtil.getDefaultCurrency().getCurrencyCode();
|
fiatCode = CurrencyUtil.getDefaultCurrencyAsCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class TomP2POfferBookService extends TomP2PDHTService implements OfferBoo
|
||||||
@Override
|
@Override
|
||||||
public void addOffer(Offer offer, ResultHandler resultHandler, FaultHandler faultHandler) {
|
public void addOffer(Offer offer, ResultHandler resultHandler, FaultHandler faultHandler) {
|
||||||
log.debug("addOffer " + offer);
|
log.debug("addOffer " + offer);
|
||||||
Number160 locationKey = Number160.createHash(offer.getCurrency().getCurrencyCode());
|
Number160 locationKey = Number160.createHash(offer.getCurrencyCode());
|
||||||
try {
|
try {
|
||||||
final Data offerData = new Data(offer);
|
final Data offerData = new Data(offer);
|
||||||
offerData.ttlSeconds(TTL);
|
offerData.ttlSeconds(TTL);
|
||||||
|
@ -91,7 +91,7 @@ public class TomP2POfferBookService extends TomP2PDHTService implements OfferBoo
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
writeInvalidationTimestampToDHT(offer.getCurrency().getCurrencyCode());
|
writeInvalidationTimestampToDHT(offer.getCurrencyCode());
|
||||||
log.trace("Add offer to DHT was successful. Added data: [locationKey: " + locationKey +
|
log.trace("Add offer to DHT was successful. Added data: [locationKey: " + locationKey +
|
||||||
", value: " + offerData + "]");
|
", value: " + offerData + "]");
|
||||||
});
|
});
|
||||||
|
@ -110,7 +110,7 @@ public class TomP2POfferBookService extends TomP2PDHTService implements OfferBoo
|
||||||
|
|
||||||
public void removeOffer(Offer offer, ResultHandler resultHandler, FaultHandler faultHandler) {
|
public void removeOffer(Offer offer, ResultHandler resultHandler, FaultHandler faultHandler) {
|
||||||
log.debug("removeOffer " + offer);
|
log.debug("removeOffer " + offer);
|
||||||
Number160 locationKey = Number160.createHash(offer.getCurrency().getCurrencyCode());
|
Number160 locationKey = Number160.createHash(offer.getCurrencyCode());
|
||||||
try {
|
try {
|
||||||
final Data offerData = new Data(offer);
|
final Data offerData = new Data(offer);
|
||||||
log.trace("Remove offer from DHT requested. Removed data: [locationKey: " + locationKey +
|
log.trace("Remove offer from DHT requested. Removed data: [locationKey: " + locationKey +
|
||||||
|
@ -140,7 +140,7 @@ public class TomP2POfferBookService extends TomP2PDHTService implements OfferBoo
|
||||||
faultHandler.handleFault("Remove offer from DHT failed. Error: " + e.getMessage(), e);
|
faultHandler.handleFault("Remove offer from DHT failed. Error: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
writeInvalidationTimestampToDHT(offer.getCurrency().getCurrencyCode());
|
writeInvalidationTimestampToDHT(offer.getCurrencyCode());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class TradeManager {
|
||||||
amount,
|
amount,
|
||||||
minAmount,
|
minAmount,
|
||||||
currentFiatAccount.getFiatAccountType(),
|
currentFiatAccount.getFiatAccountType(),
|
||||||
currentFiatAccount.getCurrency(),
|
currentFiatAccount.getCurrencyCode(),
|
||||||
currentFiatAccount.getCountry(),
|
currentFiatAccount.getCountry(),
|
||||||
currentFiatAccount.getId(),
|
currentFiatAccount.getId(),
|
||||||
accountSettings.getAcceptedArbitrators(),
|
accountSettings.getAcceptedArbitrators(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue