From 9732215c59c6e6a8bb2ce980a4b04fac5ac355fd Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 7 Sep 2014 13:04:31 +0200 Subject: [PATCH] Add setup screens. --- .../java/io/bitsquare/gui/MainController.java | 15 +- .../account/fiataccount/FiatAccountCB.java | 176 ++++++++++- .../account/fiataccount/FiatAccountModel.java | 165 +++++++++- .../account/fiataccount/FiatAccountPm.java | 284 +++++++++++++++++- .../account/fiataccount/FiatAccountView.fxml | 138 +++++++-- .../gui/account/password/PasswordView.fxml | 30 +- .../registration/RegistrationView.fxml | 47 +-- .../account/restrictions/RestrictionsCB.java | 41 +-- .../restrictions/RestrictionsModel.java | 6 +- .../account/restrictions/RestrictionsPm.java | 152 ++++++++++ .../restrictions/RestrictionsView.fxml | 90 ++---- .../gui/account/seedwords/SeedWordsView.fxml | 31 +- .../bitsquare/gui/account/setup/SetupCB.java | 6 +- .../gui/account/setup/SetupView.fxml | 2 +- src/main/java/io/bitsquare/gui/bitsquare.css | 8 +- .../bitsquare/gui/components/InfoDisplay.java | 192 ++++++++++++ .../java/io/bitsquare/gui/help/HelpId.java | 3 +- .../gui/trade/createoffer/CreateOfferCB.java | 63 ++-- .../trade/createoffer/CreateOfferView.fxml | 67 ++--- .../java/io/bitsquare/gui/util/ImageUtil.java | 1 + .../io/bitsquare/gui/util/Transitions.java | 16 +- .../util/validation/BankAccountValidator.java | 62 ++++ .../gui/util/validation/InputValidator.java | 9 +- .../java/io/bitsquare/locale/CountryUtil.java | 2 - .../java/io/bitsquare/trade/TradeManager.java | 4 +- src/main/java/io/bitsquare/user/User.java | 11 +- .../resources/i18n/displayStrings.properties | 4 +- .../i18n/displayStrings_de.properties | 4 +- .../i18n/displayStrings_es.properties | 4 +- .../i18n/displayStrings_sv_SE.properties | 4 +- src/main/resources/images/info_44.png | Bin 1617 -> 0 bytes .../FundRegistrationWalletViewUIMock.fxml | 5 +- .../gui/settings/FiatAccountUITestRunner.java | 101 +++++++ .../gui/settings/PasswordUITestRunner.java | 101 +++++++ .../settings/RestrictionsUITestRunner.java | 101 +++++++ .../gui/settings/SeedWordsUITestRunner.java | 101 +++++++ .../uimock/BankAccountSettingsViewUIMock.fxml | 5 +- .../uimock/RestrictionSettingsViewUIMock.fxml | 11 +- .../settings/uimock/SeedWordsViewUIMock.fxml | 5 +- .../uimock/SetPasswordViewUIMock.fxml | 7 +- .../uimock/CreateOfferViewUIMock.fxml | 11 +- 41 files changed, 1732 insertions(+), 353 deletions(-) create mode 100644 src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsPm.java create mode 100644 src/main/java/io/bitsquare/gui/components/InfoDisplay.java create mode 100644 src/main/java/io/bitsquare/gui/util/validation/BankAccountValidator.java delete mode 100644 src/main/resources/images/info_44.png create mode 100644 src/test/java/io/bitsquare/gui/settings/FiatAccountUITestRunner.java create mode 100644 src/test/java/io/bitsquare/gui/settings/PasswordUITestRunner.java create mode 100644 src/test/java/io/bitsquare/gui/settings/RestrictionsUITestRunner.java create mode 100644 src/test/java/io/bitsquare/gui/settings/SeedWordsUITestRunner.java diff --git a/src/main/java/io/bitsquare/gui/MainController.java b/src/main/java/io/bitsquare/gui/MainController.java index 47bfa5e3b2..1b288da65e 100644 --- a/src/main/java/io/bitsquare/gui/MainController.java +++ b/src/main/java/io/bitsquare/gui/MainController.java @@ -169,6 +169,19 @@ public class MainController extends ViewController { } + /////////////////////////////////////////////////////////////////////////////////////////// + // Blur effect + /////////////////////////////////////////////////////////////////////////////////////////// + + public void removeContentScreenBlur() { + Transitions.removeBlur(viewBuilder.baseContentContainer); + } + + public void blurContentScreen() { + Transitions.blur(viewBuilder.baseContentContainer); + } + + /////////////////////////////////////////////////////////////////////////////////////////// // Startup Handlers /////////////////////////////////////////////////////////////////////////////////////////// @@ -213,7 +226,7 @@ public class MainController extends ViewController { private void fadeOutSplash() { Profiler.printMsgWithTime("MainController.fadeOutSplash"); - Transitions.blurOutAndRemove(viewBuilder.splashVBox); + Transitions.blurAndRemove(viewBuilder.splashVBox); Transitions.fadeIn(viewBuilder.menuBar); Transitions.fadeIn(viewBuilder.contentScreen); } diff --git a/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountCB.java b/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountCB.java index a6f87acc16..233cbe5549 100644 --- a/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountCB.java +++ b/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountCB.java @@ -17,16 +17,32 @@ package io.bitsquare.gui.account.fiataccount; +import io.bitsquare.bank.BankAccount; +import io.bitsquare.bank.BankAccountType; import io.bitsquare.gui.CachedCodeBehind; import io.bitsquare.gui.account.setup.SetupCB; +import io.bitsquare.gui.components.Popups; +import io.bitsquare.gui.help.Help; +import io.bitsquare.gui.help.HelpId; +import io.bitsquare.gui.util.validation.InputValidator; +import io.bitsquare.locale.Country; +import io.bitsquare.locale.Region; import java.net.URL; +import java.util.ArrayList; +import java.util.Currency; +import java.util.List; import java.util.ResourceBundle; import javax.inject.Inject; +import javafx.collections.ListChangeListener; import javafx.fxml.FXML; +import javafx.scene.control.*; + +import org.controlsfx.control.action.Action; +import org.controlsfx.dialog.Dialog; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,6 +51,15 @@ public class FiatAccountCB extends CachedCodeBehind { private static final Logger log = LoggerFactory.getLogger(FiatAccountCB.class); + @FXML private ComboBox regionComboBox; + @FXML private ComboBox countryComboBox; + @FXML private TextField titleTextField, holderNameTextField, primaryIDTextField, secondaryIDTextField; + @FXML private Button saveButton, addBankAccountButton, changeBankAccountButton, removeBankAccountButton; + @FXML private ComboBox selectionComboBox; + @FXML private ComboBox typesComboBox; + @FXML private ComboBox currencyComboBox; + + /////////////////////////////////////////////////////////////////////////////////////////// // Constructor /////////////////////////////////////////////////////////////////////////////////////////// @@ -53,11 +78,24 @@ public class FiatAccountCB extends CachedCodeBehind { public void initialize(URL url, ResourceBundle rb) { super.initialize(url, rb); + typesComboBox.setItems(presentationModel.getAllTypes()); + typesComboBox.setConverter(presentationModel.getTypesConverter()); + selectionComboBox.setConverter(presentationModel.getSelectionConverter()); + currencyComboBox.setItems(presentationModel.getAllCurrencies()); + currencyComboBox.setConverter(presentationModel.getCurrencyConverter()); + regionComboBox.setItems(presentationModel.getAllRegions()); + regionComboBox.setConverter(presentationModel.getRegionConverter()); + countryComboBox.setConverter(presentationModel.getCountryConverter()); } @Override public void activate() { super.activate(); + + setupListeners(); + setupBindings(); + + selectionComboBox.setItems(presentationModel.getAllBankAccounts()); } @Override @@ -71,17 +109,62 @@ public class FiatAccountCB extends CachedCodeBehind { } - /////////////////////////////////////////////////////////////////////////////////////////// - // Public Methods - /////////////////////////////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////////////////////////////// // UI handlers /////////////////////////////////////////////////////////////////////////////////////////// + @FXML - private void onDone() { - ((SetupCB) parentController).onCompleted(this); + public void onSelectAccount() { + presentationModel.setCurrentBankAccount(selectionComboBox.getSelectionModel().getSelectedItem()); + } + + @FXML + public void onSelectType() { + presentationModel.setType(typesComboBox.getSelectionModel().getSelectedItem()); + } + + @FXML + public void onSelectCurrency() { + presentationModel.setCurrency(currencyComboBox.getSelectionModel().getSelectedItem()); + } + + @FXML + private void onSelectRegion() { + countryComboBox.setVisible(true); + Region region = regionComboBox.getSelectionModel().getSelectedItem(); + countryComboBox.setItems(presentationModel.getAllCountriesFor(region)); + } + + @FXML + private void onSelectCountry() { + presentationModel.setCountry(countryComboBox.getSelectionModel().getSelectedItem()); + } + + @FXML + private void onSave() { + InputValidator.ValidationResult result = presentationModel.saveBankAccount(); + if (result.isValid) + ((SetupCB) parentController).onCompleted(this); + } + + @FXML + private void onAddAccount() { + log.error("onAddAccount"); + } + + @FXML + private void onRemoveAccount() { + presentationModel.removeBankAccount(); + } + + @FXML + private void onChangeAccount() { + log.error("onChangeAccount"); + } + + @FXML + private void onOpenHelp() { + Help.openWindow(HelpId.SETUP_FIAT_ACCOUNT); } @@ -89,6 +172,85 @@ public class FiatAccountCB extends CachedCodeBehind { // Private methods /////////////////////////////////////////////////////////////////////////////////////////// + private void setupListeners() { + presentationModel.type.addListener((ov, oldValue, newValue) -> { + if (newValue != null) + typesComboBox.getSelectionModel().select(typesComboBox.getItems().indexOf(newValue)); + else + typesComboBox.getSelectionModel().clearSelection(); + }); + presentationModel.currency.addListener((ov, oldValue, newValue) -> { + if (newValue != null) + currencyComboBox.getSelectionModel().select(currencyComboBox.getItems().indexOf(newValue)); + else + currencyComboBox.getSelectionModel().clearSelection(); + }); + + presentationModel.getCurrentBankAccount().addListener((ov, oldValue, newValue) -> { + if (newValue != null) + selectionComboBox.getSelectionModel().select(selectionComboBox.getItems().indexOf(newValue)); + else + selectionComboBox.getSelectionModel().clearSelection(); + }); + + presentationModel.country.addListener((ov, oldValue, newValue) -> { + if (newValue != null) { + regionComboBox.getSelectionModel().select(regionComboBox.getItems().indexOf(newValue.getRegion())); + countryComboBox.getSelectionModel().select(countryComboBox.getItems().indexOf(newValue)); + } + else { + regionComboBox.getSelectionModel().clearSelection(); + countryComboBox.getSelectionModel().clearSelection(); + } + }); + + presentationModel.getAllBankAccounts().addListener((ListChangeListener) change -> { + Object a = presentationModel.getAllBankAccounts(); + Object a2 = change.getList(); + + if (presentationModel.getCurrentBankAccount() != null) + selectionComboBox.getSelectionModel().select(selectionComboBox.getItems() + .indexOf(presentationModel.getCurrentBankAccount())); + else + selectionComboBox.getSelectionModel().clearSelection(); + }); + + presentationModel.countryNotInAcceptedCountriesList.addListener((ov, oldValue, newValue) -> { + if (newValue) { + List actions = new ArrayList<>(); + actions.add(Dialog.Actions.YES); + actions.add(Dialog.Actions.NO); + + Action response = Popups.openConfirmPopup("Warning", + "The country of your bank account is not included in the accepted countries in the general " + + "settings.\n\nDo you want to add it automatically?", + null, + actions); + + if (response == Dialog.Actions.YES) + presentationModel.addCountryToAcceptedCountriesList(); + } + }); + } + + private void setupBindings() { + // input + titleTextField.textProperty().bindBidirectional(presentationModel.title); + holderNameTextField.textProperty().bindBidirectional(presentationModel.holderName); + primaryIDTextField.textProperty().bindBidirectional(presentationModel.primaryID); + secondaryIDTextField.textProperty().bindBidirectional(presentationModel.secondaryID); + + primaryIDTextField.promptTextProperty().bind(presentationModel.primaryIDPrompt); + secondaryIDTextField.promptTextProperty().bind(presentationModel.secondaryIDPrompt); + selectionComboBox.promptTextProperty().bind(presentationModel.selectionPrompt); + selectionComboBox.disableProperty().bind(presentationModel.selectionDisable); + + saveButton.disableProperty().bind(presentationModel.saveButtonDisable); + addBankAccountButton.disableProperty().bind(presentationModel.addBankAccountButtonDisable); + changeBankAccountButton.disableProperty().bind(presentationModel.changeBankAccountButtonDisable); + removeBankAccountButton.disableProperty().bind(presentationModel.removeBankAccountButtonDisable); + + } } diff --git a/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountModel.java b/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountModel.java index 986d8eb8d9..056eedcd5b 100644 --- a/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountModel.java +++ b/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountModel.java @@ -17,49 +17,206 @@ package io.bitsquare.gui.account.fiataccount; +import io.bitsquare.bank.BankAccount; +import io.bitsquare.bank.BankAccountType; import io.bitsquare.gui.UIModel; +import io.bitsquare.locale.Country; +import io.bitsquare.locale.CountryUtil; +import io.bitsquare.locale.CurrencyUtil; +import io.bitsquare.locale.Region; +import io.bitsquare.persistence.Persistence; +import io.bitsquare.settings.Settings; +import io.bitsquare.user.User; import com.google.inject.Inject; +import java.util.Currency; + +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class FiatAccountModel extends UIModel { private static final Logger log = LoggerFactory.getLogger(FiatAccountModel.class); + private User user; + private Settings settings; + private Persistence persistence; + + StringProperty title = new SimpleStringProperty(); + StringProperty holderName = new SimpleStringProperty(); + StringProperty primaryID = new SimpleStringProperty(); + StringProperty secondaryID = new SimpleStringProperty(); + StringProperty primaryIDPrompt = new SimpleStringProperty(); + StringProperty secondaryIDPrompt = new SimpleStringProperty(); + BooleanProperty countryNotInAcceptedCountriesList = new SimpleBooleanProperty(); + ObjectProperty type = new SimpleObjectProperty<>(); + ObjectProperty country = new SimpleObjectProperty<>(); + ObjectProperty currency = new SimpleObjectProperty<>(); + ObjectProperty currentBankAccount = new SimpleObjectProperty<>(); + ObservableList allTypes = FXCollections.observableArrayList(BankAccountType + .getAllBankAccountTypes()); + ObservableList allBankAccounts = FXCollections.observableArrayList(); + ObservableList allCurrencies = FXCollections.observableArrayList(CurrencyUtil.getAllCurrencies()); + ObservableList allRegions = FXCollections.observableArrayList(CountryUtil.getAllRegions()); + + /////////////////////////////////////////////////////////////////////////////////////////// // Constructor /////////////////////////////////////////////////////////////////////////////////////////// @Inject - public FiatAccountModel() { - + public FiatAccountModel(User user, Persistence persistence, Settings settings) { + this.persistence = persistence; + this.user = user; + this.settings = settings; } /////////////////////////////////////////////////////////////////////////////////////////// - // Public methods + // Lifecycle /////////////////////////////////////////////////////////////////////////////////////////// + @Override + public void initialized() { + super.initialized(); + } + + @Override + public void activate() { + super.activate(); + + currentBankAccount.set(user.getCurrentBankAccount()); + allBankAccounts.setAll(user.getBankAccounts()); + } + + @Override + public void deactivate() { + super.deactivate(); + } + + @Override + public void terminate() { + super.terminate(); + } + /////////////////////////////////////////////////////////////////////////////////////////// - // Interface implementation: Initializable + // Package scope /////////////////////////////////////////////////////////////////////////////////////////// + void saveBankAccount() { + BankAccount bankAccount = new BankAccount(type.get(), + currency.get(), + country.get(), + title.get(), + holderName.get(), + primaryID.get(), + secondaryID.get()); + user.addBankAccount(bankAccount); + + saveUser(); + + countryNotInAcceptedCountriesList.set(!settings.getAcceptedCountries().contains(country.get())); + } + + void removeBankAccount() { + user.removeCurrentBankAccount(); + saveUser(); + } + + // We ask the user if he likes to add his own bank account country to the accepted country list if he has not + // already added it before + void addCountryToAcceptedCountriesList() { + settings.addAcceptedCountry(country.get()); + saveSettings(); + } + /////////////////////////////////////////////////////////////////////////////////////////// // Getters /////////////////////////////////////////////////////////////////////////////////////////// + ObservableList getAllCountriesFor(Region selectedRegion) { + return FXCollections.observableArrayList(CountryUtil.getAllCountriesFor(selectedRegion)); + } + /////////////////////////////////////////////////////////////////////////////////////////// // Setters /////////////////////////////////////////////////////////////////////////////////////////// + void setCurrentBankAccount(BankAccount bankAccount) { + currentBankAccount.set(bankAccount); + + user.setCurrentBankAccount(bankAccount); + persistence.write(user); + + if (bankAccount != null) { + title.set(bankAccount.getAccountTitle()); + holderName.set(bankAccount.getAccountHolderName()); + primaryID.set(bankAccount.getAccountPrimaryID()); + secondaryID.set(bankAccount.getAccountSecondaryID()); + primaryIDPrompt.set(bankAccount.getBankAccountType().getPrimaryId()); + secondaryIDPrompt.set(bankAccount.getBankAccountType().getSecondaryId()); + + type.set(bankAccount.getBankAccountType()); + country.set(bankAccount.getCountry()); + currency.set(bankAccount.getCurrency()); + } + else { + title.set(null); + holderName.set(null); + primaryID.set(null); + secondaryID.set(null); + primaryIDPrompt.set(null); + secondaryIDPrompt.set(null); + + type.set(null); + country.set(null); + currency.set(null); + } + } + + void setType(BankAccountType type) { + this.type.set(type); + + if (type != null) { + primaryIDPrompt.set(type.getPrimaryId()); + secondaryIDPrompt.set(type.getSecondaryId()); + } + else { + primaryIDPrompt.set(null); + secondaryIDPrompt.set(null); + } + } + + void setCountry(Country country) { + this.country.set(country); + } + + void setCurrency(Currency currency) { + this.currency.set(currency); + } + /////////////////////////////////////////////////////////////////////////////////////////// // Private methods /////////////////////////////////////////////////////////////////////////////////////////// + private void saveUser() { + persistence.write(user); + } + private void saveSettings() { + persistence.write(settings); + } } diff --git a/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountPm.java b/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountPm.java index 200469fa04..1e44aa4a11 100644 --- a/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountPm.java +++ b/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountPm.java @@ -17,16 +17,56 @@ package io.bitsquare.gui.account.fiataccount; +import io.bitsquare.bank.BankAccount; +import io.bitsquare.bank.BankAccountType; import io.bitsquare.gui.PresentationModel; +import io.bitsquare.gui.util.validation.BankAccountValidator; +import io.bitsquare.gui.util.validation.InputValidator; +import io.bitsquare.locale.BSResources; +import io.bitsquare.locale.Country; +import io.bitsquare.locale.Region; import com.google.inject.Inject; +import java.util.Currency; + +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; +import javafx.collections.ListChangeListener; +import javafx.collections.ObservableList; +import javafx.util.StringConverter; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class FiatAccountPm extends PresentationModel { private static final Logger log = LoggerFactory.getLogger(FiatAccountPm.class); + private BankAccountValidator bankAccountValidator = new BankAccountValidator(); + + StringProperty title = new SimpleStringProperty(); + StringProperty holderName = new SimpleStringProperty(); + StringProperty primaryID = new SimpleStringProperty(); + StringProperty secondaryID = new SimpleStringProperty(); + StringProperty primaryIDPrompt = new SimpleStringProperty(); + StringProperty secondaryIDPrompt = new SimpleStringProperty(); + StringProperty selectionPrompt = new SimpleStringProperty(); + BooleanProperty selectionDisable = new SimpleBooleanProperty(); + BooleanProperty saveButtonDisable = new SimpleBooleanProperty(true); + BooleanProperty addBankAccountButtonDisable = new SimpleBooleanProperty(true); + BooleanProperty changeBankAccountButtonDisable = new SimpleBooleanProperty(true); + BooleanProperty removeBankAccountButtonDisable = new SimpleBooleanProperty(true); + + BooleanProperty countryNotInAcceptedCountriesList = new SimpleBooleanProperty(); + ObjectProperty type = new SimpleObjectProperty<>(); + ObjectProperty country = new SimpleObjectProperty<>(); + ObjectProperty currency = new SimpleObjectProperty<>(); + + /////////////////////////////////////////////////////////////////////////////////////////// // Constructor /////////////////////////////////////////////////////////////////////////////////////////// @@ -38,28 +78,268 @@ public class FiatAccountPm extends PresentationModel { /////////////////////////////////////////////////////////////////////////////////////////// - // Public methods + // Lifecycle /////////////////////////////////////////////////////////////////////////////////////////// + @Override + public void initialized() { + super.initialized(); + + // input + title.bindBidirectional(model.title); + holderName.bindBidirectional(model.holderName); + primaryID.bindBidirectional(model.primaryID); + secondaryID.bindBidirectional(model.secondaryID); + type.bindBidirectional(model.type); + country.bindBidirectional(model.country); + currency.bindBidirectional(model.currency); + + primaryIDPrompt.bind(model.primaryIDPrompt); + secondaryIDPrompt.bind(model.secondaryIDPrompt); + countryNotInAcceptedCountriesList.bind(model.countryNotInAcceptedCountriesList); + + selectionPrompt.set("No bank account available"); + selectionDisable.set(true); + + model.title.addListener((ov, oldValue, newValue) -> { + validateInput(); + /* + InputValidator.ValidationResult result = validateInput(); + if (result.isValid) { + result = bankAccountValidator.validate(newValue); + saveButtonDisable.set(!result.isValid); + }*/ + }); + holderName.addListener((ov, oldValue, newValue) -> validateInput()); + primaryID.addListener((ov, oldValue, newValue) -> validateInput()); + secondaryID.addListener((ov, oldValue, newValue) -> validateInput()); + } + + @Override + public void activate() { + super.activate(); + + + model.allBankAccounts.addListener((ListChangeListener) change -> { + if (model.allBankAccounts.isEmpty()) { + selectionPrompt.set("No bank account available"); + selectionDisable.set(true); + } + else { + selectionPrompt.set("Select bank account"); + selectionDisable.set(false); + } + }); + } + + @Override + public void deactivate() { + super.deactivate(); + } + + @Override + public void terminate() { + super.terminate(); + } + /////////////////////////////////////////////////////////////////////////////////////////// - // Interface implementation: Initializable + // Package scope /////////////////////////////////////////////////////////////////////////////////////////// + InputValidator.ValidationResult saveBankAccount() { + InputValidator.ValidationResult result = validateInput(); + if (result.isValid) { + model.saveBankAccount(); + + addBankAccountButtonDisable.set(false); + changeBankAccountButtonDisable.set(false); + removeBankAccountButtonDisable.set(false); + } + return result; + } + + void removeBankAccount() { + model.removeBankAccount(); + } + + void updateDoneButtonDisabled() { + /* boolean isValid = model.languageList != null && model.languageList.size() > 0 && + model.countryList != null && model.countryList.size() > 0 && + model.arbitratorList != null && model.arbitratorList.size() > -1; + doneButtonDisabled.set(!isValid);*/ + } + + + void addCountryToAcceptedCountriesList() { + model.addCountryToAcceptedCountriesList(); + } + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Converters + /////////////////////////////////////////////////////////////////////////////////////////// + + StringConverter getTypesConverter() { + return new StringConverter() { + @Override + public String toString(BankAccountType TypeInfo) { + return BSResources.get(TypeInfo.toString()); + } + + @Override + public BankAccountType fromString(String s) { + return null; + } + }; + } + + StringConverter getSelectionConverter() { + return new StringConverter() { + @Override + public String toString(BankAccount bankAccount) { + return bankAccount.getAccountTitle(); + } + + @Override + public BankAccount fromString(String s) { + return null; + } + }; + } + + StringConverter getCurrencyConverter() { + return new StringConverter() { + + @Override + public String toString(Currency currency) { + return currency.getCurrencyCode() + " (" + currency.getDisplayName() + ")"; + } + + + @Override + public Currency fromString(String s) { + return null; + } + }; + } + + StringConverter getRegionConverter() { + return new StringConverter() { + @Override + public String toString(io.bitsquare.locale.Region region) { + return region.getName(); + } + + @Override + public io.bitsquare.locale.Region fromString(String s) { + return null; + } + }; + } + + StringConverter getCountryConverter() { + return new StringConverter() { + @Override + public String toString(Country country) { + return country.getName(); + } + + @Override + public Country fromString(String s) { + return null; + } + }; + } + /////////////////////////////////////////////////////////////////////////////////////////// // Getters /////////////////////////////////////////////////////////////////////////////////////////// + ObservableList getAllTypes() { + return model.allTypes; + } + + ObjectProperty getCurrentBankAccount() { + return model.currentBankAccount; + } + + ObservableList getAllBankAccounts() { + return model.allBankAccounts; + } + + ObservableList getAllCurrencies() { + return model.allCurrencies; + } + + ObservableList getAllRegions() { + return model.allRegions; + } + + ObservableList getAllCountriesFor(Region selectedRegion) { + return model.getAllCountriesFor(selectedRegion); + } + /////////////////////////////////////////////////////////////////////////////////////////// // Setters /////////////////////////////////////////////////////////////////////////////////////////// + void setCurrentBankAccount(BankAccount bankAccount) { + model.setCurrentBankAccount(bankAccount); + validateInput(); + } + + void setType(BankAccountType type) { + model.setType(type); + validateInput(); + } + + void setCountry(Country country) { + model.setCountry(country); + validateInput(); + } + + void setCurrency(Currency currency) { + model.setCurrency(currency); + validateInput(); + } /////////////////////////////////////////////////////////////////////////////////////////// // Private methods /////////////////////////////////////////////////////////////////////////////////////////// + private InputValidator.ValidationResult validateInput() { + InputValidator.ValidationResult result = bankAccountValidator.validate(model.title.get()); + if (result.isValid) { + result = bankAccountValidator.validate(model.holderName.get()); + if (result.isValid) { + result = bankAccountValidator.validate(model.primaryID.get()); + if (result.isValid) { + result = bankAccountValidator.validate(model.secondaryID.get()); + if (result.isValid) { + if (model.currency.get() == null) + result = new InputValidator.ValidationResult(false, + "You have not selected a currency"); + if (result.isValid) { + if (model.country.get() == null) + result = new InputValidator.ValidationResult(false, + "You have not selected a country of the payments account"); + if (result.isValid) { + if (model.type.get() == null) + result = new InputValidator.ValidationResult(false, + "You have not selected a payments method"); + } + } + } + } + } + } + + saveButtonDisable.set(!result.isValid); + return result; + } + } diff --git a/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountView.fxml b/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountView.fxml index d3dafb80f1..3b052aeb62 100644 --- a/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountView.fxml +++ b/src/main/java/io/bitsquare/gui/account/fiataccount/FiatAccountView.fxml @@ -18,22 +18,25 @@ --> + - - + + - - - - - - - - - - - - - - + + diff --git a/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsCB.java b/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsCB.java index 9ed605495d..7ebd0df286 100644 --- a/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsCB.java +++ b/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsCB.java @@ -40,7 +40,6 @@ import javax.inject.Inject; import javafx.fxml.FXML; import javafx.fxml.Initializable; -import javafx.geometry.Pos; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.image.*; @@ -221,19 +220,14 @@ public class RestrictionsCB extends CachedCodeBehind { @Override public ListCell call(ListView list) { return new ListCell() { - final HBox hBox = new HBox(); final Label label = new Label(); - final Button removeButton = new Button(); final ImageView icon = ImageUtil.getIconImageView(ImageUtil.REMOVE); + final Button removeButton = new Button("", icon); + final AnchorPane pane = new AnchorPane(label, removeButton); { - label.setPrefWidth(395); - icon.setMouseTransparent(true); - removeButton.setGraphic(icon); removeButton.setId("icon-button"); - hBox.setSpacing(3); - hBox.setAlignment(Pos.CENTER_LEFT); - hBox.getChildren().addAll(label, removeButton); + AnchorPane.setRightAnchor(removeButton, 0d); } @Override @@ -242,7 +236,7 @@ public class RestrictionsCB extends CachedCodeBehind { if (item != null && !empty) { label.setText(item.getDisplayName()); removeButton.setOnAction(actionEvent -> removeLanguage(item)); - setGraphic(hBox); + setGraphic(pane); } else { setGraphic(null); @@ -284,19 +278,14 @@ public class RestrictionsCB extends CachedCodeBehind { @Override public ListCell call(ListView list) { return new ListCell() { - final HBox hBox = new HBox(); final Label label = new Label(); - final Button removeButton = new Button(); final ImageView icon = ImageUtil.getIconImageView(ImageUtil.REMOVE); + final Button removeButton = new Button("", icon); + final AnchorPane pane = new AnchorPane(label, removeButton); { - label.setPrefWidth(395); - icon.setMouseTransparent(true); - removeButton.setGraphic(icon); removeButton.setId("icon-button"); - hBox.setSpacing(3); - hBox.setAlignment(Pos.CENTER_LEFT); - hBox.getChildren().addAll(label, removeButton); + AnchorPane.setRightAnchor(removeButton, 0d); } @Override @@ -305,7 +294,7 @@ public class RestrictionsCB extends CachedCodeBehind { if (item != null && !empty) { label.setText(item.getName()); removeButton.setOnAction(actionEvent -> removeCountry(item)); - setGraphic(hBox); + setGraphic(pane); } else { setGraphic(null); @@ -333,28 +322,24 @@ public class RestrictionsCB extends CachedCodeBehind { @Override public ListCell call(ListView list) { return new ListCell() { - final HBox hBox = new HBox(); final Label label = new Label(); - final Button removeButton = new Button(); final ImageView icon = ImageUtil.getIconImageView(ImageUtil.REMOVE); + final Button removeButton = new Button("", icon); + final AnchorPane pane = new AnchorPane(label, removeButton); { - label.setPrefWidth(395); - icon.setMouseTransparent(true); - removeButton.setGraphic(icon); removeButton.setId("icon-button"); - hBox.setSpacing(3); - hBox.setAlignment(Pos.CENTER_LEFT); - hBox.getChildren().addAll(label, removeButton); + AnchorPane.setRightAnchor(removeButton, 0d); } + @Override public void updateItem(final Arbitrator item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) { label.setText(item.getName()); removeButton.setOnAction(actionEvent -> removeArbitrator(item)); - setGraphic(hBox); + setGraphic(pane); } else { setGraphic(null); diff --git a/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsModel.java b/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsModel.java index 1c8b04a21e..cabb3c8589 100644 --- a/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsModel.java +++ b/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsModel.java @@ -53,9 +53,9 @@ public class RestrictionsModel extends UIModel { private final Persistence persistence; private final MessageFacade messageFacade; - ObservableList languageList; - ObservableList countryList; - ObservableList arbitratorList; + ObservableList languageList = FXCollections.observableArrayList(); + ObservableList countryList = FXCollections.observableArrayList(); + ObservableList arbitratorList = FXCollections.observableArrayList(); ObservableList allLanguages = FXCollections.observableArrayList(LanguageUtil.getAllLanguageLocales()); ObservableList allRegions = FXCollections.observableArrayList(CountryUtil.getAllRegions()); diff --git a/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsPm.java b/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsPm.java new file mode 100644 index 0000000000..669411d9f9 --- /dev/null +++ b/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsPm.java @@ -0,0 +1,152 @@ +/* + * This file is part of Bitsquare. + * + * Bitsquare is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bitsquare is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bitsquare. If not, see . + */ + +package io.bitsquare.gui.account.restrictions; + +import io.bitsquare.arbitrator.Arbitrator; +import io.bitsquare.gui.PresentationModel; +import io.bitsquare.locale.Country; +import io.bitsquare.locale.Region; + +import com.google.inject.Inject; + +import java.util.Locale; + +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.collections.ObservableList; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RestrictionsPM extends PresentationModel { + private static final Logger log = LoggerFactory.getLogger(RestrictionsPM.class); + + + public BooleanProperty doneButtonDisabled = new SimpleBooleanProperty(true); + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Constructor + /////////////////////////////////////////////////////////////////////////////////////////// + + @Inject + public RestrictionsPM(RestrictionsModel model) { + super(model); + } + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Lifecycle + /////////////////////////////////////////////////////////////////////////////////////////// + + @Override + public void initialized() { + super.initialized(); + + } + + @Override + public void activate() { + super.activate(); + + updateDoneButtonDisabled(); + } + + @Override + public void deactivate() { + super.deactivate(); + } + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Package scope + /////////////////////////////////////////////////////////////////////////////////////////// + + void onAddLanguage(Locale locale) { + model.addLanguage(locale); + updateDoneButtonDisabled(); + } + + ObservableList getLanguageList() { + updateDoneButtonDisabled(); + return model.languageList; + } + + ObservableList getAllLanguages() { + updateDoneButtonDisabled(); + return model.allLanguages; + } + + void removeLanguage(Locale locale) { + model.removeLanguage(locale); + updateDoneButtonDisabled(); + } + + void onAddCountry(Country country) { + model.addCountry(country); + updateDoneButtonDisabled(); + } + + ObservableList getListWithAllEuroCountries() { + ObservableList result = model.getListWithAllEuroCountries(); + updateDoneButtonDisabled(); + return result; + } + + ObservableList getAllCountriesFor(Region selectedRegion) { + return model.getAllCountriesFor(selectedRegion); + } + + ObservableList getAllRegions() { + return model.allRegions; + } + + ObservableList getCountryList() { + updateDoneButtonDisabled(); + return model.countryList; + } + + void removeCountry(Country country) { + model.removeCountry(country); + updateDoneButtonDisabled(); + } + + ObservableList getArbitratorList() { + updateDoneButtonDisabled(); + return model.arbitratorList; + } + + void removeArbitrator(Arbitrator arbitrator) { + model.removeArbitrator(arbitrator); + updateDoneButtonDisabled(); + } + + void updateArbitratorList() { + model.updateArbitratorList(); + updateDoneButtonDisabled(); + } + + //TODO Revert -1 to 0(2 later). For mock testing disabled arbitratorList test + void updateDoneButtonDisabled() { + boolean isValid = model.languageList != null && model.languageList.size() > 0 && + model.countryList != null && model.countryList.size() > 0 && + model.arbitratorList != null && model.arbitratorList.size() > -1; + doneButtonDisabled.set(!isValid); + } + +} diff --git a/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsView.fxml b/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsView.fxml index d64e12f7db..ad398a2282 100644 --- a/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsView.fxml +++ b/src/main/java/io/bitsquare/gui/account/restrictions/RestrictionsView.fxml @@ -16,21 +16,20 @@ ~ You should have received a copy of the GNU Affero General Public License ~ along with Bitsquare. If not, see . --> + - - - + @@ -48,28 +47,14 @@ - + - - - - - - - - - - + + + - - + @@ -45,40 +47,25 @@ - - - - - - - - - - - - - + - - + + diff --git a/src/main/java/io/bitsquare/gui/account/setup/SetupCB.java b/src/main/java/io/bitsquare/gui/account/setup/SetupCB.java index 5e56281a61..c4066bef02 100644 --- a/src/main/java/io/bitsquare/gui/account/setup/SetupCB.java +++ b/src/main/java/io/bitsquare/gui/account/setup/SetupCB.java @@ -76,10 +76,10 @@ public class SetupCB extends CachedCodeBehind { password = new WizardItem(this, content, "Setup password", "Protect your wallet with a password", NavigationItem.PASSWORD); restrictions = new WizardItem(this, content, "Setup your preferences", - "You need to setup your preferences used for trade restrictions", + "Define your preferences with whom you want to trade", NavigationItem.RESTRICTIONS); - fiatAccount = new WizardItem(this, content, " Setup Bank account", - "You need to add the bank account details to your trading account", + fiatAccount = new WizardItem(this, content, " Setup Payments account(s)", + "You need to add a payments account to your trading account", NavigationItem.FIAT_ACCOUNT); registration = new WizardItem(this, root, "Register your account", "Pay in the registration fee of 0.0002 BTC and store your account in the BTC block chain", diff --git a/src/main/java/io/bitsquare/gui/account/setup/SetupView.fxml b/src/main/java/io/bitsquare/gui/account/setup/SetupView.fxml index 3f296830ad..c879a5f5cf 100644 --- a/src/main/java/io/bitsquare/gui/account/setup/SetupView.fxml +++ b/src/main/java/io/bitsquare/gui/account/setup/SetupView.fxml @@ -25,7 +25,7 @@ - diff --git a/src/main/java/io/bitsquare/gui/bitsquare.css b/src/main/java/io/bitsquare/gui/bitsquare.css index e02aa59fed..82d4ae7fee 100644 --- a/src/main/java/io/bitsquare/gui/bitsquare.css +++ b/src/main/java/io/bitsquare/gui/bitsquare.css @@ -17,6 +17,10 @@ tab pane upper bg gradient color mid dark grey to bright grey: cfcfcf -> dddddd -fx-background-color: linear-gradient(to bottom, #cfcfcf, #dddddd); } +#info-icon-label { + -fx-font-size:16; + -fx-text-fill: #333000; +} /* Create offer */ #direction-icon-label { @@ -45,10 +49,6 @@ tab pane upper bg gradient color mid dark grey to bright grey: cfcfcf -> dddddd -fx-border-insets: 0 0 0 -2; } -#info-link { - -fx-padding: 0 0 0 -2; -} - #totals-separator { -fx-background: #aaa; } diff --git a/src/main/java/io/bitsquare/gui/components/InfoDisplay.java b/src/main/java/io/bitsquare/gui/components/InfoDisplay.java new file mode 100644 index 0000000000..4a42ae4447 --- /dev/null +++ b/src/main/java/io/bitsquare/gui/components/InfoDisplay.java @@ -0,0 +1,192 @@ +/* + * This file is part of Bitsquare. + * + * Bitsquare is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bitsquare is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bitsquare. If not, see . + */ + +package io.bitsquare.gui.components; + +import io.bitsquare.gui.util.ImageUtil; +import io.bitsquare.locale.BSResources; + +import javafx.application.Platform; +import javafx.beans.property.IntegerProperty; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.geometry.VPos; +import javafx.scene.*; +import javafx.scene.control.*; +import javafx.scene.image.*; +import javafx.scene.layout.*; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Convenience Component for info icon, info text and link display in a GridPane. + * Only the properties needed are supported. + * We need to extend from Parent so we can use it in FXML, but the InfoDisplay is not used as node, + * but add the children nodes to the gridPane. + */ +public class InfoDisplay extends Parent { + private static final Logger log = LoggerFactory.getLogger(InfoDisplay.class); + + private final StringProperty text = new SimpleStringProperty(); + private final IntegerProperty rowIndex = new SimpleIntegerProperty(0); + private final IntegerProperty columnIndex = new SimpleIntegerProperty(0); + private final ObjectProperty> onAction = new SimpleObjectProperty<>(); + + private final ObjectProperty gridPane = new SimpleObjectProperty<>(); + + private final ImageView icon; + private final VBox vBox; + private final Label label; + private final Hyperlink link; + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Constructor + /////////////////////////////////////////////////////////////////////////////////////////// + + public InfoDisplay() { + + icon = ImageUtil.getIconImageView(ImageUtil.INFO); + icon.setPickOnBounds(true); + icon.setPreserveRatio(true); + + + GridPane.setValignment(icon, VPos.TOP); + GridPane.setMargin(icon, new Insets(4, 2, 0, 0)); + GridPane.setRowSpan(icon, 2); + + label = new Label(); + label.textProperty().bindBidirectional(text); + label.setWrapText(true); + + link = new Hyperlink(BSResources.get("shared.readMore")); + link.setPadding(new Insets(0, 0, 0, -2)); + + vBox = new VBox(); + vBox.setSpacing(0); + vBox.getChildren().addAll(label, link); + + visibleProperty().addListener((ov, oldValue, newValue) -> { + icon.setVisible(newValue); + vBox.setVisible(newValue); + }); + + // The text in the label does not get correctly displayed if there is not enough available overall height. + // Did not find a better way yet to solve the issue... + label.heightProperty().addListener((ov, o, n) -> { + vBox.setMinHeight((double) n + 100); + label.setMinHeight((double) n); + Platform.runLater(() -> vBox.setMinHeight(label.getHeight() + 15)); + }); + } + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Setters + /////////////////////////////////////////////////////////////////////////////////////////// + + public void setText(String text) { + this.text.set(text); + + label.setText(text); + } + + public void setGridPane(GridPane gridPane) { + this.gridPane.set(gridPane); + + gridPane.getChildren().addAll(icon, vBox); + + GridPane.setColumnIndex(icon, columnIndex.get()); + GridPane.setColumnIndex(vBox, columnIndex.get() + 1); + + GridPane.setRowIndex(icon, rowIndex.get()); + GridPane.setRowIndex(vBox, rowIndex.get()); + } + + public void setRowIndex(int rowIndex) { + this.rowIndex.set(rowIndex); + + GridPane.setRowIndex(icon, rowIndex); + GridPane.setRowIndex(vBox, rowIndex); + } + + public void setColumnIndex(int columnIndex) { + this.columnIndex.set(columnIndex); + + GridPane.setColumnIndex(icon, columnIndex); + GridPane.setColumnIndex(vBox, columnIndex + 1); + + } + + public final void setOnAction(javafx.event.EventHandler eventHandler) { + onAction.set(eventHandler); + + link.setOnAction(eventHandler); + } + + + /////////////////////////////////////////////////////////////////////////////////////////// + // Getters + /////////////////////////////////////////////////////////////////////////////////////////// + + public String getText() { + return text.get(); + } + + public StringProperty textProperty() { + return text; + } + + public int getColumnIndex() { + return columnIndex.get(); + } + + public IntegerProperty columnIndexProperty() { + return columnIndex; + } + + public int getRowIndex() { + return rowIndex.get(); + } + + public IntegerProperty rowIndexProperty() { + return rowIndex; + } + + public EventHandler getOnAction() { + return onAction.get(); + } + + public ObjectProperty> onActionProperty() { + return onAction; + } + + public GridPane getGridPane() { + return gridPane.get(); + } + + public ObjectProperty gridPaneProperty() { + return gridPane; + } +} diff --git a/src/main/java/io/bitsquare/gui/help/HelpId.java b/src/main/java/io/bitsquare/gui/help/HelpId.java index 6660d12df6..433eb6b0d1 100644 --- a/src/main/java/io/bitsquare/gui/help/HelpId.java +++ b/src/main/java/io/bitsquare/gui/help/HelpId.java @@ -26,6 +26,7 @@ public enum HelpId { SETUP_RESTRICTION_LANGUAGES, SETUP_RESTRICTION_COUNTRIES, SETUP_RESTRICTION_ARBITRATORS, - SETUP_REGISTRATION + SETUP_REGISTRATION, + SETUP_FIAT_ACCOUNT } diff --git a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferCB.java b/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferCB.java index 65cc5d3920..e9c7b4a1d2 100644 --- a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferCB.java +++ b/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferCB.java @@ -20,6 +20,7 @@ package io.bitsquare.gui.trade.createoffer; import io.bitsquare.gui.CachedCodeBehind; import io.bitsquare.gui.MainController; import io.bitsquare.gui.NavigationItem; +import io.bitsquare.gui.components.InfoDisplay; import io.bitsquare.gui.components.InputTextField; import io.bitsquare.gui.components.Popups; import io.bitsquare.gui.components.btc.AddressTextField; @@ -50,7 +51,6 @@ import javafx.scene.control.*; import javafx.scene.image.*; import javafx.scene.input.*; import javafx.scene.layout.*; -import javafx.scene.text.*; import javafx.stage.Window; import de.jensd.fx.fontawesome.AwesomeDude; @@ -79,9 +79,8 @@ public class CreateOfferCB extends CachedCodeBehind { private ImageView collapse; private PopOver totalToPayInfoPopover; + @FXML private InfoDisplay advancedInfoDisplay, fundsBoxInfoDisplay; @FXML private ScrollPane scrollPane; - @FXML private ImageView payFundsInfoIcon, showDetailsInfoIcon; - @FXML private TextFlow payFundsInfoTextFlow, showDetailsInfoLabel; @FXML private Pane priceAmountPane, payFundsPane, showDetailsPane; @FXML private Label buyLabel, priceAmountTitleLabel, addressLabel, balanceLabel, payFundsTitleLabel, totalToPayLabel, totalToPayInfoIconLabel, @@ -175,8 +174,7 @@ public class CreateOfferCB extends CachedCodeBehind { addressTextField.setVisible(true); balanceLabel.setVisible(true); balanceTextField.setVisible(true); - payFundsInfoIcon.setVisible(true); - payFundsInfoTextFlow.setVisible(true); + fundsBoxInfoDisplay.setVisible(true); showAdvancedSettingsButton.setVisible(true); if (expand == null) { @@ -297,7 +295,9 @@ public class CreateOfferCB extends CachedCodeBehind { }); presentationModel.showTransactionPublishedScreen.addListener((o, oldValue, newValue) -> { - if (newValue != null) { + if (newValue) { + MainController.GET_INSTANCE().blurContentScreen(); + // Dialogs are a bit limited. There is no callback for the InformationDialog button click, so we added // our own actions. List actions = new ArrayList<>(); @@ -319,6 +319,7 @@ public class CreateOfferCB extends CachedCodeBehind { e.printStackTrace(); } Dialog.Actions.CLOSE.handle(actionEvent); + MainController.GET_INSTANCE().removeContentScreenBlur(); } }); @@ -390,34 +391,25 @@ public class CreateOfferCB extends CachedCodeBehind { toggleDetailsScreen(true); } - private void initEditIcons() { - advancedScreenInited = true; - acceptedCountriesLabelIcon.setId("clickable-icon"); - AwesomeDude.setIcon(acceptedCountriesLabelIcon, AwesomeIcon.EDIT_SIGN); - Tooltip.install(acceptedCountriesLabelIcon, new Tooltip(BSResources.get("shared.openSettings"))); - acceptedCountriesLabelIcon.setOnMouseClicked(e -> openSettings()); - - acceptedLanguagesLabelIcon.setId("clickable-icon"); - AwesomeDude.setIcon(acceptedLanguagesLabelIcon, AwesomeIcon.EDIT_SIGN); - Tooltip.install(acceptedLanguagesLabelIcon, new Tooltip(BSResources.get("shared.openSettings"))); - acceptedLanguagesLabelIcon.setOnMouseClicked(e -> openSettings()); - - acceptedArbitratorsLabelIcon.setId("clickable-icon"); - AwesomeDude.setIcon(acceptedArbitratorsLabelIcon, AwesomeIcon.EDIT_SIGN); - Tooltip.install(acceptedArbitratorsLabelIcon, new Tooltip(BSResources.get("shared.openSettings"))); - acceptedArbitratorsLabelIcon.setOnMouseClicked(e -> openSettings()); - } - private void hideDetailsScreen() { payFundsPane.setId("form-group-background-active"); payFundsTitleLabel.setId("form-group-title-active"); scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); scrollPane.layout(); - toggleDetailsScreen(false); } private void toggleDetailsScreen(boolean visible) { + scrollPane.setOnScroll(scrollEvent -> { + if (!visible) + scrollEvent.consume(); + }); + + // deactivate mouse wheel scrolling if hidden + scrollPane.setVmax(visible ? scrollPane.getHeight() : 0); + scrollPane.setVvalue(visible ? scrollPane.getHeight() : 0); + + showDetailsPane.setVisible(visible); showDetailsTitleLabel.setVisible(visible); @@ -438,8 +430,25 @@ public class CreateOfferCB extends CachedCodeBehind { bankAccountCountyLabel.setVisible(visible); bankAccountCountyTextField.setVisible(visible); - showDetailsInfoIcon.setVisible(visible); - showDetailsInfoLabel.setVisible(visible); + advancedInfoDisplay.setVisible(visible); + } + + private void initEditIcons() { + advancedScreenInited = true; + acceptedCountriesLabelIcon.setId("clickable-icon"); + AwesomeDude.setIcon(acceptedCountriesLabelIcon, AwesomeIcon.EDIT_SIGN); + Tooltip.install(acceptedCountriesLabelIcon, new Tooltip(BSResources.get("shared.openSettings"))); + acceptedCountriesLabelIcon.setOnMouseClicked(e -> openSettings()); + + acceptedLanguagesLabelIcon.setId("clickable-icon"); + AwesomeDude.setIcon(acceptedLanguagesLabelIcon, AwesomeIcon.EDIT_SIGN); + Tooltip.install(acceptedLanguagesLabelIcon, new Tooltip(BSResources.get("shared.openSettings"))); + acceptedLanguagesLabelIcon.setOnMouseClicked(e -> openSettings()); + + acceptedArbitratorsLabelIcon.setId("clickable-icon"); + AwesomeDude.setIcon(acceptedArbitratorsLabelIcon, AwesomeIcon.EDIT_SIGN); + Tooltip.install(acceptedArbitratorsLabelIcon, new Tooltip(BSResources.get("shared.openSettings"))); + acceptedArbitratorsLabelIcon.setOnMouseClicked(e -> openSettings()); } private void setupTotalToPayInfoIconLabel() { 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 ae2d568a88..d9bfd77078 100644 --- a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml +++ b/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml @@ -19,6 +19,7 @@ + @@ -34,7 +35,7 @@ AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" AnchorPane.bottomAnchor="0.0"> - + @@ -154,18 +155,8 @@ - - - - - - - - - + - - + diff --git a/src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordViewUIMock.fxml b/src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordViewUIMock.fxml index ab6de1c5d4..3fadfb2fde 100644 --- a/src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordViewUIMock.fxml +++ b/src/test/java/io/bitsquare/gui/settings/uimock/SetPasswordViewUIMock.fxml @@ -26,7 +26,7 @@ AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.bitsquare.gui.settings.uimock.SetPasswordControllerUIMock"> - + @@ -70,10 +70,11 @@ - - + diff --git a/src/test/java/io/bitsquare/gui/trade/createoffer/uimock/CreateOfferViewUIMock.fxml b/src/test/java/io/bitsquare/gui/trade/createoffer/uimock/CreateOfferViewUIMock.fxml index 7102071c48..96aab5572e 100644 --- a/src/test/java/io/bitsquare/gui/trade/createoffer/uimock/CreateOfferViewUIMock.fxml +++ b/src/test/java/io/bitsquare/gui/trade/createoffer/uimock/CreateOfferViewUIMock.fxml @@ -156,11 +156,12 @@ - + url="@../../../../../../../../main/resources/images/info.png"/> @@ -233,7 +234,8 @@ - @@ -320,7 +322,8 @@ text="Spain" visible="true" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="21"/> -