From 21b4fc7019c9a0776967168814e2a3cba707650b Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Sat, 22 Nov 2014 14:41:46 +0100 Subject: [PATCH] Introduce Model and accept it as generic param to ViewCB --- .../java/io/bitsquare/gui/CachedViewCB.java | 21 ++- .../java/io/bitsquare/gui/Controller.java | 2 +- src/main/java/io/bitsquare/gui/DataModel.java | 2 +- .../java/io/bitsquare/gui/FxmlController.java | 2 +- src/main/java/io/bitsquare/gui/Model.java | 1 - src/main/java/io/bitsquare/gui/ViewCB.java | 14 +- src/main/java/io/bitsquare/gui/ViewModel.java | 2 +- src/main/java/io/bitsquare/gui/XModel.java | 22 +++ .../java/io/bitsquare/gui/main/MainModel.java | 4 +- .../ArbitratorRegistrationViewCB.java | 1 + .../changepassword/ChangePasswordViewCB.java | 6 +- .../content/fiat/FiatAccountViewCB.java | 78 +++++------ .../account/content/irc/IrcAccountViewCB.java | 30 ++-- .../content/password/PasswordViewCB.java | 6 +- .../registration/RegistrationViewCB.java | 5 +- .../restrictions/RestrictionsViewCB.java | 34 ++--- .../content/seedwords/SeedWordsViewCB.java | 6 +- .../account/setup/AccountSetupViewCB.java | 2 + .../portfolio/closed/ClosedTradesViewCB.java | 20 +-- .../main/portfolio/offer/OffersViewCB.java | 22 +-- .../pending/PendingTradesViewCB.java | 116 ++++++++-------- .../application/PreferencesViewCB.java | 14 +- .../trade/createoffer/CreateOfferViewCB.java | 130 +++++++++--------- .../main/trade/offerbook/OfferBookViewCB.java | 68 ++++----- .../main/trade/takeoffer/TakeOfferViewCB.java | 94 ++++++------- 25 files changed, 364 insertions(+), 338 deletions(-) create mode 100644 src/main/java/io/bitsquare/gui/XModel.java diff --git a/src/main/java/io/bitsquare/gui/CachedViewCB.java b/src/main/java/io/bitsquare/gui/CachedViewCB.java index 7438c3dc7e..7cf515af7f 100644 --- a/src/main/java/io/bitsquare/gui/CachedViewCB.java +++ b/src/main/java/io/bitsquare/gui/CachedViewCB.java @@ -27,15 +27,12 @@ import org.slf4j.LoggerFactory; /** * If caching is used for loader we use the CachedViewController for turning the controller into sleep mode if not * active and awake it at reactivation. - * * @param The PresentationModel used in that class */ -public class CachedViewCB extends ViewCB { +public class CachedViewCB extends ViewCB { private static final Logger log = LoggerFactory.getLogger(CachedViewCB.class); - protected final T presentationModel; - - public CachedViewCB(T presentationModel) { - this.presentationModel = presentationModel; + public CachedViewCB(M model) { + super(model); } public CachedViewCB() { @@ -74,8 +71,8 @@ public class CachedViewCB extends ViewCB { public void activate() { log.trace("Lifecycle: activate " + this.getClass().getSimpleName()); - if (presentationModel != null) - presentationModel.activate(); + if (model != null) + model.activate(); } /** @@ -84,8 +81,8 @@ public class CachedViewCB extends ViewCB { public void deactivate() { log.trace("Lifecycle: deactivate " + this.getClass().getSimpleName()); - if (presentationModel != null) - presentationModel.deactivate(); + if (model != null) + model.deactivate(); } /** @@ -96,8 +93,8 @@ public class CachedViewCB extends ViewCB { log.trace("Lifecycle: terminate " + this.getClass().getSimpleName()); super.terminate(); - if (presentationModel != null) - presentationModel.deactivate(); + if (model != null) + model.deactivate(); } } diff --git a/src/main/java/io/bitsquare/gui/Controller.java b/src/main/java/io/bitsquare/gui/Controller.java index 028a83c144..1d236c1324 100644 --- a/src/main/java/io/bitsquare/gui/Controller.java +++ b/src/main/java/io/bitsquare/gui/Controller.java @@ -25,7 +25,7 @@ import javafx.fxml.Initializable; import static com.google.common.base.Preconditions.checkNotNull; -public abstract class Controller implements Initializable { +public abstract class Controller implements Initializable { public static final String TITLE_KEY = "view.title"; diff --git a/src/main/java/io/bitsquare/gui/DataModel.java b/src/main/java/io/bitsquare/gui/DataModel.java index 5125a0de35..86eb5f3ba4 100644 --- a/src/main/java/io/bitsquare/gui/DataModel.java +++ b/src/main/java/io/bitsquare/gui/DataModel.java @@ -17,5 +17,5 @@ package io.bitsquare.gui; -public interface DataModel { +public interface DataModel extends Model { } diff --git a/src/main/java/io/bitsquare/gui/FxmlController.java b/src/main/java/io/bitsquare/gui/FxmlController.java index 0da5966484..a5b0e8edb9 100644 --- a/src/main/java/io/bitsquare/gui/FxmlController.java +++ b/src/main/java/io/bitsquare/gui/FxmlController.java @@ -24,7 +24,7 @@ import java.util.ResourceBundle; import javafx.fxml.FXML; import javafx.scene.*; -public abstract class FxmlController extends Controller { +public abstract class FxmlController extends Controller { protected @FXML R root; diff --git a/src/main/java/io/bitsquare/gui/Model.java b/src/main/java/io/bitsquare/gui/Model.java index 2300711dfd..dd9f24447b 100644 --- a/src/main/java/io/bitsquare/gui/Model.java +++ b/src/main/java/io/bitsquare/gui/Model.java @@ -18,5 +18,4 @@ package io.bitsquare.gui; public interface Model { - void initialize(); } diff --git a/src/main/java/io/bitsquare/gui/ViewCB.java b/src/main/java/io/bitsquare/gui/ViewCB.java index 6a085f50ae..698cc881ef 100644 --- a/src/main/java/io/bitsquare/gui/ViewCB.java +++ b/src/main/java/io/bitsquare/gui/ViewCB.java @@ -31,7 +31,8 @@ import org.slf4j.LoggerFactory; /** * Non caching version for code behind classes using the PM pattern */ -public class ViewCB implements Initializable { +public class ViewCB implements Initializable { + private static final Logger log = LoggerFactory.getLogger(ViewCB.class); public static final String TITLE_KEY = "view.title"; @@ -39,8 +40,18 @@ public class ViewCB implements Initializable { protected Initializable childController; protected Initializable parent; + protected final M model; + @FXML protected Parent root; + public ViewCB(M model) { + this.model = model; + } + + public ViewCB() { + this(null); + } + /** * Get called form GUI framework when the UI is ready. * @@ -87,4 +98,5 @@ public class ViewCB implements Initializable { "= " + navigationItem); return null; } + } diff --git a/src/main/java/io/bitsquare/gui/ViewModel.java b/src/main/java/io/bitsquare/gui/ViewModel.java index 4f47ed5ec2..9739d090c9 100644 --- a/src/main/java/io/bitsquare/gui/ViewModel.java +++ b/src/main/java/io/bitsquare/gui/ViewModel.java @@ -17,5 +17,5 @@ package io.bitsquare.gui; -public interface ViewModel { +public interface ViewModel extends Model { } diff --git a/src/main/java/io/bitsquare/gui/XModel.java b/src/main/java/io/bitsquare/gui/XModel.java new file mode 100644 index 0000000000..237dc6c78d --- /dev/null +++ b/src/main/java/io/bitsquare/gui/XModel.java @@ -0,0 +1,22 @@ +/* + * 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; + +public interface XModel { + void initialize(); +} diff --git a/src/main/java/io/bitsquare/gui/main/MainModel.java b/src/main/java/io/bitsquare/gui/main/MainModel.java index 5036b49df2..4aae90b1d0 100644 --- a/src/main/java/io/bitsquare/gui/main/MainModel.java +++ b/src/main/java/io/bitsquare/gui/main/MainModel.java @@ -20,7 +20,7 @@ package io.bitsquare.gui.main; import io.bitsquare.bank.BankAccount; import io.bitsquare.btc.BitcoinNetwork; import io.bitsquare.btc.WalletService; -import io.bitsquare.gui.Model; +import io.bitsquare.gui.XModel; import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.msg.MessageService; import io.bitsquare.network.BootstrapState; @@ -51,7 +51,7 @@ import org.slf4j.LoggerFactory; import rx.Observable; -class MainModel implements Model { +class MainModel implements XModel { private static final Logger log = LoggerFactory.getLogger(MainModel.class); final DoubleProperty networkSyncProgress = new SimpleDoubleProperty(-1); diff --git a/src/main/java/io/bitsquare/gui/main/account/arbitrator/registration/ArbitratorRegistrationViewCB.java b/src/main/java/io/bitsquare/gui/main/account/arbitrator/registration/ArbitratorRegistrationViewCB.java index 70aa6943dc..cab1461cf3 100644 --- a/src/main/java/io/bitsquare/gui/main/account/arbitrator/registration/ArbitratorRegistrationViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/account/arbitrator/registration/ArbitratorRegistrationViewCB.java @@ -102,6 +102,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB { @Inject private ArbitratorRegistrationViewCB(Persistence persistence, WalletService walletService, MessageService messageService, User user, BSFormatter formatter) { + super(); this.persistence = persistence; this.walletService = walletService; this.messageService = messageService; diff --git a/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordViewCB.java b/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordViewCB.java index 6847d3cf9d..895dea97a1 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/account/content/changepassword/ChangePasswordViewCB.java @@ -36,12 +36,10 @@ import javafx.scene.layout.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ChangePasswordViewCB extends ViewCB implements ContextAware { +public class ChangePasswordViewCB extends ViewCB implements ContextAware { private static final Logger log = LoggerFactory.getLogger(ChangePasswordViewCB.class); - private final ChangePasswordPM model; - @FXML HBox buttonsHBox; @FXML Button saveButton, skipButton; @FXML PasswordField oldPasswordField, passwordField, repeatedPasswordField; @@ -53,7 +51,7 @@ public class ChangePasswordViewCB extends ViewCB implements ContextAware { @Inject private ChangePasswordViewCB(ChangePasswordPM model) { - this.model = model; + super(model); } diff --git a/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountViewCB.java b/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountViewCB.java index a04890c307..c9b08bf94e 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountViewCB.java @@ -76,8 +76,8 @@ public class FiatAccountViewCB extends CachedViewCB implements Co /////////////////////////////////////////////////////////////////////////////////////////// @Inject - FiatAccountViewCB(FiatAccountPM presentationModel, OverlayManager overlayManager) { - super(presentationModel); + FiatAccountViewCB(FiatAccountPM model, OverlayManager overlayManager) { + super(model); this.overlayManager = overlayManager; } @@ -89,19 +89,19 @@ public class FiatAccountViewCB extends CachedViewCB implements Co @Override public void initialize(URL url, ResourceBundle 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()); + typesComboBox.setItems(model.getAllTypes()); + typesComboBox.setConverter(model.getTypesConverter()); + selectionComboBox.setConverter(model.getSelectionConverter()); + currencyComboBox.setItems(model.getAllCurrencies()); + currencyComboBox.setConverter(model.getCurrencyConverter()); + regionComboBox.setItems(model.getAllRegions()); + regionComboBox.setConverter(model.getRegionConverter()); + countryComboBox.setConverter(model.getCountryConverter()); - nameOfBankTextField.setValidator(presentationModel.getBankAccountNumberValidator()); - holderNameTextField.setValidator(presentationModel.getBankAccountNumberValidator()); - primaryIDTextField.setValidator(presentationModel.getBankAccountNumberValidator()); - secondaryIDTextField.setValidator(presentationModel.getBankAccountNumberValidator()); + nameOfBankTextField.setValidator(model.getBankAccountNumberValidator()); + holderNameTextField.setValidator(model.getBankAccountNumberValidator()); + primaryIDTextField.setValidator(model.getBankAccountNumberValidator()); + secondaryIDTextField.setValidator(model.getBankAccountNumberValidator()); super.initialize(url, rb); } @@ -113,7 +113,7 @@ public class FiatAccountViewCB extends CachedViewCB implements Co setupListeners(); setupBindings(); - selectionComboBox.setItems(presentationModel.getAllBankAccounts()); + selectionComboBox.setItems(model.getAllBankAccounts()); } @SuppressWarnings("EmptyMethod") @@ -147,17 +147,17 @@ public class FiatAccountViewCB extends CachedViewCB implements Co @FXML void onSelectAccount() { if (selectionComboBox.getSelectionModel().getSelectedItem() != null) - presentationModel.selectBankAccount(selectionComboBox.getSelectionModel().getSelectedItem()); + model.selectBankAccount(selectionComboBox.getSelectionModel().getSelectedItem()); } @FXML void onSelectType() { - presentationModel.setType(typesComboBox.getSelectionModel().getSelectedItem()); + model.setType(typesComboBox.getSelectionModel().getSelectedItem()); } @FXML void onSelectCurrency() { - presentationModel.setCurrency(currencyComboBox.getSelectionModel().getSelectedItem()); + model.setCurrency(currencyComboBox.getSelectionModel().getSelectedItem()); } @FXML @@ -165,19 +165,19 @@ public class FiatAccountViewCB extends CachedViewCB implements Co countryComboBox.setVisible(true); Region region = regionComboBox.getSelectionModel().getSelectedItem(); if (region != null) - countryComboBox.setItems(presentationModel.getAllCountriesFor(region)); + countryComboBox.setItems(model.getAllCountriesFor(region)); } @FXML void onSelectCountry() { Country country = countryComboBox.getSelectionModel().getSelectedItem(); if (country != null) - presentationModel.setCountry(country); + model.setCountry(country); } @FXML void onSave() { - InputValidator.ValidationResult result = presentationModel.requestSaveBankAccount(); + InputValidator.ValidationResult result = model.requestSaveBankAccount(); if (result.isValid) { selectionComboBox.getSelectionModel().select(null); Popups.openInfoPopup("Your payments account has been saved.", @@ -193,7 +193,7 @@ public class FiatAccountViewCB extends CachedViewCB implements Co @FXML void onRemoveAccount() { - presentationModel.removeBankAccount(); + model.removeBankAccount(); selectionComboBox.getSelectionModel().select(null); } @@ -213,21 +213,21 @@ public class FiatAccountViewCB extends CachedViewCB implements Co /////////////////////////////////////////////////////////////////////////////////////////// private void setupListeners() { - presentationModel.type.addListener((ov, oldValue, newValue) -> { + model.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) -> { + model.currency.addListener((ov, oldValue, newValue) -> { if (newValue != null) currencyComboBox.getSelectionModel().select(currencyComboBox.getItems().indexOf(newValue)); else currencyComboBox.getSelectionModel().clearSelection(); }); - presentationModel.country.addListener((ov, oldValue, newValue) -> { + model.country.addListener((ov, oldValue, newValue) -> { if (newValue != null) { int regionIndex = regionComboBox.getItems().indexOf(newValue.getRegion()); if (regionIndex >= 0 && regionIndex < regionComboBox.getItems().size()) @@ -243,7 +243,7 @@ public class FiatAccountViewCB extends CachedViewCB implements Co } }); - presentationModel.getCountryNotInAcceptedCountriesList().addListener((ov, oldValue, newValue) -> { + model.getCountryNotInAcceptedCountriesList().addListener((ov, oldValue, newValue) -> { if (newValue) { overlayManager.blurContent(); List actions = new ArrayList<>(); @@ -271,28 +271,28 @@ public class FiatAccountViewCB extends CachedViewCB implements Co actions); if (Popups.isYes(response)) - presentationModel.addCountryToAcceptedCountriesList(); + model.addCountryToAcceptedCountriesList(); } }); - presentationModel.getAllBankAccounts().addListener((ListChangeListener) change -> - completedButton.setDisable(presentationModel.getAllBankAccounts().isEmpty())); - completedButton.setDisable(presentationModel.getAllBankAccounts().isEmpty()); + model.getAllBankAccounts().addListener((ListChangeListener) change -> + completedButton.setDisable(model.getAllBankAccounts().isEmpty())); + completedButton.setDisable(model.getAllBankAccounts().isEmpty()); } private void setupBindings() { // input - nameOfBankTextField.textProperty().bindBidirectional(presentationModel.title); - holderNameTextField.textProperty().bindBidirectional(presentationModel.holderName); - primaryIDTextField.textProperty().bindBidirectional(presentationModel.primaryID); - secondaryIDTextField.textProperty().bindBidirectional(presentationModel.secondaryID); + nameOfBankTextField.textProperty().bindBidirectional(model.title); + holderNameTextField.textProperty().bindBidirectional(model.holderName); + primaryIDTextField.textProperty().bindBidirectional(model.primaryID); + secondaryIDTextField.textProperty().bindBidirectional(model.secondaryID); - primaryIDTextField.promptTextProperty().bind(presentationModel.primaryIDPrompt); - secondaryIDTextField.promptTextProperty().bind(presentationModel.secondaryIDPrompt); - selectionComboBox.promptTextProperty().bind(presentationModel.selectionPrompt); - selectionComboBox.disableProperty().bind(presentationModel.selectionDisable); + primaryIDTextField.promptTextProperty().bind(model.primaryIDPrompt); + secondaryIDTextField.promptTextProperty().bind(model.secondaryIDPrompt); + selectionComboBox.promptTextProperty().bind(model.selectionPrompt); + selectionComboBox.disableProperty().bind(model.selectionDisable); - saveButton.disableProperty().bind(presentationModel.saveButtonDisable); + saveButton.disableProperty().bind(model.saveButtonDisable); removeBankAccountButton.disableProperty().bind(createBooleanBinding(() -> (selectionComboBox.getSelectionModel().selectedIndexProperty().get() == -1), diff --git a/src/main/java/io/bitsquare/gui/main/account/content/irc/IrcAccountViewCB.java b/src/main/java/io/bitsquare/gui/main/account/content/irc/IrcAccountViewCB.java index d352b09ed0..fcd466eeb1 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/irc/IrcAccountViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/account/content/irc/IrcAccountViewCB.java @@ -63,8 +63,8 @@ public class IrcAccountViewCB extends CachedViewCB implements Cont /////////////////////////////////////////////////////////////////////////////////////////// @Inject - IrcAccountViewCB(IrcAccountPM presentationModel) { - super(presentationModel); + IrcAccountViewCB(IrcAccountPM model) { + super(model); } @@ -74,10 +74,10 @@ public class IrcAccountViewCB extends CachedViewCB implements Cont @Override public void initialize(URL url, ResourceBundle rb) { - ircNickNameTextField.setValidator(presentationModel.getNickNameValidator()); + ircNickNameTextField.setValidator(model.getNickNameValidator()); - typesComboBox.setItems(presentationModel.getAllTypes()); - typesComboBox.setConverter(presentationModel.getTypesConverter()); + typesComboBox.setItems(model.getAllTypes()); + typesComboBox.setConverter(model.getTypesConverter()); // we use a custom cell for deactivating non IRC items, later we use the standard cell and the StringConverter typesComboBox.setCellFactory(new Callback, ListCell>() { @Override @@ -88,7 +88,7 @@ public class IrcAccountViewCB extends CachedViewCB implements Cont protected void updateItem(BankAccountType item, boolean empty) { super.updateItem(item, empty); - setText(presentationModel.getBankAccountType(item)); + setText(model.getBankAccountType(item)); if (item == null || empty) { setGraphic(null); @@ -103,8 +103,8 @@ public class IrcAccountViewCB extends CachedViewCB implements Cont }); typesComboBox.getSelectionModel().select(0); - currencyComboBox.setItems(presentationModel.getAllCurrencies()); - currencyComboBox.setConverter(presentationModel.getCurrencyConverter()); + currencyComboBox.setItems(model.getAllCurrencies()); + currencyComboBox.setConverter(model.getCurrencyConverter()); // we use a custom cell for deactivating non EUR items, later we use the standard cell and the StringConverter currencyComboBox.setCellFactory(new Callback, ListCell>() { @Override @@ -182,17 +182,17 @@ public class IrcAccountViewCB extends CachedViewCB implements Cont @FXML void onSelectType() { - presentationModel.setType(typesComboBox.getSelectionModel().getSelectedItem()); + model.setType(typesComboBox.getSelectionModel().getSelectedItem()); } @FXML void onSelectCurrency() { - presentationModel.setCurrency(currencyComboBox.getSelectionModel().getSelectedItem()); + model.setCurrency(currencyComboBox.getSelectionModel().getSelectedItem()); } @FXML void onSave() { - InputValidator.ValidationResult result = presentationModel.requestSaveBankAccount(); + InputValidator.ValidationResult result = model.requestSaveBankAccount(); if (result.isValid && parent instanceof MultiStepNavigation) ((MultiStepNavigation) parent).nextStep(this); } @@ -217,14 +217,14 @@ public class IrcAccountViewCB extends CachedViewCB implements Cont /////////////////////////////////////////////////////////////////////////////////////////// private void setupListeners() { - presentationModel.type.addListener((ov, oldValue, newValue) -> { + model.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) -> { + model.currency.addListener((ov, oldValue, newValue) -> { if (newValue != null) currencyComboBox.getSelectionModel().select(currencyComboBox.getItems().indexOf(newValue)); else @@ -234,8 +234,8 @@ public class IrcAccountViewCB extends CachedViewCB implements Cont private void setupBindings() { // input - ircNickNameTextField.textProperty().bindBidirectional(presentationModel.ircNickName); - saveButton.disableProperty().bind(presentationModel.saveButtonDisable); + ircNickNameTextField.textProperty().bindBidirectional(model.ircNickName); + saveButton.disableProperty().bind(model.saveButtonDisable); } diff --git a/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordViewCB.java b/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordViewCB.java index 8c45cdef6d..ab1e16efca 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordViewCB.java @@ -36,12 +36,10 @@ import javafx.scene.layout.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PasswordViewCB extends ViewCB implements ContextAware { +public class PasswordViewCB extends ViewCB implements ContextAware { private static final Logger log = LoggerFactory.getLogger(PasswordViewCB.class); - private final PasswordPM model; - @FXML HBox buttonsHBox; @FXML Button saveButton, skipButton; @FXML PasswordField oldPasswordField, passwordField, repeatedPasswordField; @@ -53,7 +51,7 @@ public class PasswordViewCB extends ViewCB implements ContextAware { @Inject private PasswordViewCB(PasswordPM model) { - this.model = model; + super(model); } diff --git a/src/main/java/io/bitsquare/gui/main/account/content/registration/RegistrationViewCB.java b/src/main/java/io/bitsquare/gui/main/account/content/registration/RegistrationViewCB.java index 8a26bda39c..2e60bfb45f 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/registration/RegistrationViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/account/content/registration/RegistrationViewCB.java @@ -48,12 +48,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class RegistrationViewCB extends ViewCB implements ContextAware { +public class RegistrationViewCB extends ViewCB implements ContextAware { private static final Logger log = LoggerFactory.getLogger(RegistrationViewCB.class); private final OverlayManager overlayManager; - private final RegistrationPM model; @FXML TextField feeTextField; @FXML AddressTextField addressTextField; @@ -69,7 +68,7 @@ public class RegistrationViewCB extends ViewCB implements ContextAware { @Inject private RegistrationViewCB(RegistrationPM model, OverlayManager overlayManager) { - this.model = model; + super(model); this.overlayManager = overlayManager; } diff --git a/src/main/java/io/bitsquare/gui/main/account/content/restrictions/RestrictionsViewCB.java b/src/main/java/io/bitsquare/gui/main/account/content/restrictions/RestrictionsViewCB.java index 7df548f030..b96151a3f8 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/restrictions/RestrictionsViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/account/content/restrictions/RestrictionsViewCB.java @@ -71,8 +71,8 @@ public class RestrictionsViewCB extends CachedViewCB implements /////////////////////////////////////////////////////////////////////////////////////////// @Inject - private RestrictionsViewCB(RestrictionsPM presentationModel, ViewLoader viewLoader, Stage primaryStage) { - super(presentationModel); + private RestrictionsViewCB(RestrictionsPM model, ViewLoader viewLoader, Stage primaryStage) { + super(model); this.viewLoader = viewLoader; this.primaryStage = primaryStage; } @@ -90,16 +90,16 @@ public class RestrictionsViewCB extends CachedViewCB implements initCountry(); initArbitrators(); - completedButton.disableProperty().bind(presentationModel.doneButtonDisable); + completedButton.disableProperty().bind(model.doneButtonDisable); } @Override public void activate() { super.activate(); - languagesListView.setItems(presentationModel.getLanguageList()); - countriesListView.setItems(presentationModel.getCountryList()); - arbitratorsListView.setItems(presentationModel.getArbitratorList()); + languagesListView.setItems(model.getLanguageList()); + countriesListView.setItems(model.getCountryList()); + arbitratorsListView.setItems(model.getArbitratorList()); } @SuppressWarnings("EmptyMethod") @@ -132,7 +132,7 @@ public class RestrictionsViewCB extends CachedViewCB implements @FXML private void onAddLanguage() { - presentationModel.addLanguage(languageComboBox.getSelectionModel().getSelectedItem()); + model.addLanguage(languageComboBox.getSelectionModel().getSelectedItem()); languageComboBox.getSelectionModel().clearSelection(); } @@ -140,20 +140,20 @@ public class RestrictionsViewCB extends CachedViewCB implements private void onSelectRegion() { countryComboBox.setVisible(true); Region region = regionComboBox.getSelectionModel().getSelectedItem(); - countryComboBox.setItems(presentationModel.getAllCountriesFor(region)); + countryComboBox.setItems(model.getAllCountriesFor(region)); addAllEuroCountriesButton.setVisible(region.getCode().equals("EU")); } @FXML private void onAddCountry() { - presentationModel.addCountry(countryComboBox.getSelectionModel().getSelectedItem()); + model.addCountry(countryComboBox.getSelectionModel().getSelectedItem()); countryComboBox.getSelectionModel().clearSelection(); } @FXML private void onAddAllEuroCountries() { - countriesListView.setItems(presentationModel.getListWithAllEuroCountries()); + countriesListView.setItems(model.getListWithAllEuroCountries()); } @FXML @@ -219,8 +219,8 @@ public class RestrictionsViewCB extends CachedViewCB implements /////////////////////////////////////////////////////////////////////////////////////////// void updateArbitratorList() { - presentationModel.updateArbitratorList(); - arbitratorsListView.setItems(presentationModel.getArbitratorList()); + model.updateArbitratorList(); + arbitratorsListView.setItems(model.getArbitratorList()); } private void initLanguage() { @@ -255,7 +255,7 @@ public class RestrictionsViewCB extends CachedViewCB implements } }); - languageComboBox.setItems(presentationModel.getAllLanguages()); + languageComboBox.setItems(model.getAllLanguages()); languageComboBox.setConverter(new StringConverter() { @Override public String toString(Locale locale) { @@ -270,7 +270,7 @@ public class RestrictionsViewCB extends CachedViewCB implements } private void initCountry() { - regionComboBox.setItems(presentationModel.getAllRegions()); + regionComboBox.setItems(model.getAllRegions()); regionComboBox.setConverter(new StringConverter() { @Override public String toString(io.bitsquare.locale.Region region) { @@ -361,15 +361,15 @@ public class RestrictionsViewCB extends CachedViewCB implements } private void removeLanguage(Locale locale) { - presentationModel.removeLanguage(locale); + model.removeLanguage(locale); } private void removeCountry(Country country) { - presentationModel.removeCountry(country); + model.removeCountry(country); } private void removeArbitrator(Arbitrator arbitrator) { - presentationModel.removeArbitrator(arbitrator); + model.removeArbitrator(arbitrator); } diff --git a/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsViewCB.java b/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsViewCB.java index c03383506f..8f2d7d966d 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsViewCB.java @@ -36,15 +36,13 @@ import javafx.scene.layout.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SeedWordsViewCB extends ViewCB implements ContextAware { +public class SeedWordsViewCB extends ViewCB implements ContextAware { private static final Logger log = LoggerFactory.getLogger(SeedWordsViewCB.class); @FXML Button completedButton; @FXML TextArea seedWordsTextArea; - private final SeedWordsPM model; - /////////////////////////////////////////////////////////////////////////////////////////// // Constructor @@ -52,7 +50,7 @@ public class SeedWordsViewCB extends ViewCB implements ContextAware { @Inject private SeedWordsViewCB(SeedWordsPM model) { - this.model = model; + super(model); } diff --git a/src/main/java/io/bitsquare/gui/main/account/setup/AccountSetupViewCB.java b/src/main/java/io/bitsquare/gui/main/account/setup/AccountSetupViewCB.java index 5e4fffb676..373c52d63b 100644 --- a/src/main/java/io/bitsquare/gui/main/account/setup/AccountSetupViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/account/setup/AccountSetupViewCB.java @@ -17,6 +17,7 @@ package io.bitsquare.gui.main.account.setup; +import io.bitsquare.gui.Model; import io.bitsquare.gui.Navigation; import io.bitsquare.gui.ViewCB; import io.bitsquare.gui.ViewLoader; @@ -67,6 +68,7 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation { @Inject private AccountSetupViewCB(ViewLoader viewLoader, Navigation navigation) { + super(); this.viewLoader = viewLoader; this.navigation = navigation; } diff --git a/src/main/java/io/bitsquare/gui/main/portfolio/closed/ClosedTradesViewCB.java b/src/main/java/io/bitsquare/gui/main/portfolio/closed/ClosedTradesViewCB.java index 1ba56b06c5..85f1a3b114 100644 --- a/src/main/java/io/bitsquare/gui/main/portfolio/closed/ClosedTradesViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/portfolio/closed/ClosedTradesViewCB.java @@ -47,8 +47,8 @@ public class ClosedTradesViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// @Inject - private ClosedTradesViewCB(ClosedTradesPM presentationModel) { - super(presentationModel); + private ClosedTradesViewCB(ClosedTradesPM model) { + super(model); } @@ -75,7 +75,7 @@ public class ClosedTradesViewCB extends CachedViewCB { public void activate() { super.activate(); - table.setItems(presentationModel.getList()); + table.setItems(model.getList()); } @SuppressWarnings("EmptyMethod") @@ -124,9 +124,9 @@ public class ClosedTradesViewCB extends CachedViewCB { super.updateItem(item, empty); if (item != null && !empty) { - hyperlink = new Hyperlink(presentationModel.getTradeId(item)); + hyperlink = new Hyperlink(model.getTradeId(item)); hyperlink.setId("id-link"); - Tooltip.install(hyperlink, new Tooltip(presentationModel.getTradeId(item))); + Tooltip.install(hyperlink, new Tooltip(model.getTradeId(item))); hyperlink.setOnAction(event -> openOfferDetails(item)); setGraphic(hyperlink); } @@ -153,7 +153,7 @@ public class ClosedTradesViewCB extends CachedViewCB { public void updateItem(final ClosedTradesListItem item, boolean empty) { super.updateItem(item, empty); if (item != null) - setText(presentationModel.getDate(item)); + setText(model.getDate(item)); else setText(""); } @@ -175,7 +175,7 @@ public class ClosedTradesViewCB extends CachedViewCB { @Override public void updateItem(final ClosedTradesListItem item, boolean empty) { super.updateItem(item, empty); - setText(presentationModel.getAmount(item)); + setText(model.getAmount(item)); } }; } @@ -194,7 +194,7 @@ public class ClosedTradesViewCB extends CachedViewCB { @Override public void updateItem(final ClosedTradesListItem item, boolean empty) { super.updateItem(item, empty); - setText(presentationModel.getPrice(item)); + setText(model.getPrice(item)); } }; } @@ -214,7 +214,7 @@ public class ClosedTradesViewCB extends CachedViewCB { public void updateItem(final ClosedTradesListItem item, boolean empty) { super.updateItem(item, empty); if (item != null) - setText(presentationModel.getVolume(item)); + setText(model.getVolume(item)); else setText(""); } @@ -235,7 +235,7 @@ public class ClosedTradesViewCB extends CachedViewCB { @Override public void updateItem(final ClosedTradesListItem item, boolean empty) { super.updateItem(item, empty); - setText(presentationModel.getDirectionLabel(item)); + setText(model.getDirectionLabel(item)); } }; } diff --git a/src/main/java/io/bitsquare/gui/main/portfolio/offer/OffersViewCB.java b/src/main/java/io/bitsquare/gui/main/portfolio/offer/OffersViewCB.java index 5cb0bf3844..32b54bbf0f 100644 --- a/src/main/java/io/bitsquare/gui/main/portfolio/offer/OffersViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/portfolio/offer/OffersViewCB.java @@ -49,8 +49,8 @@ public class OffersViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// @Inject - private OffersViewCB(OffersPM presentationModel) { - super(presentationModel); + private OffersViewCB(OffersPM model) { + super(model); } @@ -78,7 +78,7 @@ public class OffersViewCB extends CachedViewCB { public void activate() { super.activate(); - table.setItems(presentationModel.getList()); + table.setItems(model.getList()); } @SuppressWarnings("EmptyMethod") @@ -99,7 +99,7 @@ public class OffersViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// private void removeOffer(OfferListItem item) { - presentationModel.removeOffer(item); + model.removeOffer(item); } private void openOfferDetails(OfferListItem item) { @@ -133,9 +133,9 @@ public class OffersViewCB extends CachedViewCB { super.updateItem(item, empty); if (item != null && !empty) { - hyperlink = new Hyperlink(presentationModel.getTradeId(item)); + hyperlink = new Hyperlink(model.getTradeId(item)); hyperlink.setId("id-link"); - Tooltip.install(hyperlink, new Tooltip(presentationModel.getTradeId(item))); + Tooltip.install(hyperlink, new Tooltip(model.getTradeId(item))); hyperlink.setOnAction(event -> openOfferDetails(item)); setGraphic(hyperlink); } @@ -162,7 +162,7 @@ public class OffersViewCB extends CachedViewCB { public void updateItem(final OfferListItem item, boolean empty) { super.updateItem(item, empty); if (item != null) - setText(presentationModel.getDate(item)); + setText(model.getDate(item)); else setText(""); } @@ -184,7 +184,7 @@ public class OffersViewCB extends CachedViewCB { @Override public void updateItem(final OfferListItem item, boolean empty) { super.updateItem(item, empty); - setText(presentationModel.getAmount(item)); + setText(model.getAmount(item)); } }; } @@ -203,7 +203,7 @@ public class OffersViewCB extends CachedViewCB { @Override public void updateItem(final OfferListItem item, boolean empty) { super.updateItem(item, empty); - setText(presentationModel.getPrice(item)); + setText(model.getPrice(item)); } }; } @@ -223,7 +223,7 @@ public class OffersViewCB extends CachedViewCB { public void updateItem(final OfferListItem item, boolean empty) { super.updateItem(item, empty); if (item != null) - setText(presentationModel.getVolume(item)); + setText(model.getVolume(item)); else setText(""); } @@ -244,7 +244,7 @@ public class OffersViewCB extends CachedViewCB { @Override public void updateItem(final OfferListItem item, boolean empty) { super.updateItem(item, empty); - setText(presentationModel.getDirectionLabel(item)); + setText(model.getDirectionLabel(item)); } }; } diff --git a/src/main/java/io/bitsquare/gui/main/portfolio/pending/PendingTradesViewCB.java b/src/main/java/io/bitsquare/gui/main/portfolio/pending/PendingTradesViewCB.java index 762277b89b..a63e160f12 100644 --- a/src/main/java/io/bitsquare/gui/main/portfolio/pending/PendingTradesViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/portfolio/pending/PendingTradesViewCB.java @@ -99,8 +99,8 @@ public class PendingTradesViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// @Inject - PendingTradesViewCB(PendingTradesPM presentationModel, Navigation navigation) { - super(presentationModel); + PendingTradesViewCB(PendingTradesPM model, Navigation navigation) { + super(model); this.navigation = navigation; } @@ -123,11 +123,11 @@ public class PendingTradesViewCB extends CachedViewCB { table.setPlaceholder(new Label("No pending trades available")); txIdChangeListener = (ov, oldValue, newValue) -> - txIdTextField.setup(presentationModel.getWalletService(), newValue); + txIdTextField.setup(model.getWalletService(), newValue); selectedItemChangeListener = (obsValue, oldValue, newValue) -> { if (oldValue != null && newValue != null) { - presentationModel.selectTrade(newValue); + model.selectTrade(newValue); updateScreen(); } }; @@ -143,8 +143,8 @@ public class PendingTradesViewCB extends CachedViewCB { takerStateChangeListener = (ov, oldValue, newValue) -> applyTakerState(newValue); faultChangeListener = (ov, oldValue, newValue) -> onFault(newValue); - withdrawAddressTextField.setValidator(presentationModel.getBtcAddressValidator()); - withdrawButton.disableProperty().bind(presentationModel.withdrawalButtonDisable); + withdrawAddressTextField.setValidator(model.getBtcAddressValidator()); + withdrawButton.disableProperty().bind(model.withdrawalButtonDisable); super.initialize(url, rb); } @@ -152,14 +152,14 @@ public class PendingTradesViewCB extends CachedViewCB { public void activate() { super.activate(); - table.setItems(presentationModel.getList()); + table.setItems(model.getList()); - presentationModel.getList().addListener(listChangeListener); - presentationModel.txId.addListener(txIdChangeListener); - presentationModel.fault.addListener(faultChangeListener); + model.getList().addListener(listChangeListener); + model.txId.addListener(txIdChangeListener); + model.fault.addListener(faultChangeListener); - txIdTextField.setup(presentationModel.getWalletService(), presentationModel.txId.get()); - table.getSelectionModel().select(presentationModel.getSelectedItem()); + txIdTextField.setup(model.getWalletService(), model.txId.get()); + table.getSelectionModel().select(model.getSelectedItem()); table.getSelectionModel().selectedItemProperty().addListener(selectedItemChangeListener); // TODO Set focus to row does not work yet... @@ -168,7 +168,7 @@ public class PendingTradesViewCB extends CachedViewCB { withdrawAddressTextField.focusedProperty().addListener((ov, oldValue, newValue) -> { if (oldValue && !newValue) - presentationModel.withdrawAddressFocusOut(withdrawAddressTextField.getText()); + model.withdrawAddressFocusOut(withdrawAddressTextField.getText()); }); updateScreen(); } @@ -178,12 +178,12 @@ public class PendingTradesViewCB extends CachedViewCB { super.deactivate(); table.getSelectionModel().selectedItemProperty().removeListener(selectedItemChangeListener); - presentationModel.getList().removeListener(listChangeListener); - presentationModel.txId.removeListener(txIdChangeListener); - presentationModel.fault.removeListener(faultChangeListener); + model.getList().removeListener(listChangeListener); + model.txId.removeListener(txIdChangeListener); + model.fault.removeListener(faultChangeListener); - presentationModel.state.removeListener(offererStateChangeListener); - presentationModel.state.removeListener(takerStateChangeListener); + model.state.removeListener(offererStateChangeListener); + model.state.removeListener(takerStateChangeListener); } @@ -193,18 +193,18 @@ public class PendingTradesViewCB extends CachedViewCB { @FXML void onPaymentStarted() { - presentationModel.fiatPaymentStarted(); + model.fiatPaymentStarted(); } @FXML void onConfirmPaymentReceipt() { - presentationModel.fiatPaymentReceived(); + model.fiatPaymentReceived(); } @FXML public void onWithdraw() { setSummaryControlsVisible(false); - presentationModel.withdraw(withdrawAddressTextField.getText()); + model.withdraw(withdrawAddressTextField.getText()); Platform.runLater(() -> navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.PORTFOLIO, Navigation.Item.CLOSED_TRADES)); @@ -212,7 +212,7 @@ public class PendingTradesViewCB extends CachedViewCB { @FXML void onOpenHelp() { - Help.openWindow(presentationModel.isOfferer() ? HelpId.PENDING_TRADE_OFFERER : HelpId.PENDING_TRADE_TAKER); + Help.openWindow(model.isOfferer() ? HelpId.PENDING_TRADE_OFFERER : HelpId.PENDING_TRADE_TAKER); } @FXML @@ -240,7 +240,7 @@ public class PendingTradesViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// private void updateScreen() { - boolean dataAvailable = !presentationModel.getList().isEmpty(); + boolean dataAvailable = !model.getList().isEmpty(); titledGroupBg.setVisible(dataAvailable); processBar.setVisible(dataAvailable); statusLabel.setVisible(dataAvailable); @@ -258,7 +258,7 @@ public class PendingTradesViewCB extends CachedViewCB { infoDisplay.setManaged(dataAvailable); if (dataAvailable) { - if (presentationModel.isOfferer()) + if (model.isOfferer()) setupScreenForOfferer(); else setupScreenForTaker(); @@ -275,8 +275,8 @@ public class PendingTradesViewCB extends CachedViewCB { processBar.setProcessStepItems(items); } - presentationModel.state.addListener(offererStateChangeListener); - applyOffererState(presentationModel.state.get()); + model.state.addListener(offererStateChangeListener); + applyOffererState(model.state.get()); } private void setupScreenForTaker() { @@ -290,8 +290,8 @@ public class PendingTradesViewCB extends CachedViewCB { processBar.setProcessStepItems(items); } - presentationModel.state.addListener(takerStateChangeListener); - applyTakerState(presentationModel.state.get()); + model.state.addListener(takerStateChangeListener); + applyTakerState(model.state.get()); } private void applyOffererState(PendingTradesPM.State state) { @@ -321,26 +321,26 @@ public class PendingTradesViewCB extends CachedViewCB { infoDisplay.setText("You are now safe to start the payment. You can wait for up to 6 block chain " + "confirmations if you want more security."); - paymentMethodTextField.setText(presentationModel.getPaymentMethod()); - fiatAmountTextField.setText(presentationModel.getFiatAmount()); - holderNameTextField.setText(presentationModel.getHolderName()); - primaryIdTextField.setText(presentationModel.getPrimaryId()); - secondaryIdTextField.setText(presentationModel.getSecondaryId()); + paymentMethodTextField.setText(model.getPaymentMethod()); + fiatAmountTextField.setText(model.getFiatAmount()); + holderNameTextField.setText(model.getHolderName()); + primaryIdTextField.setText(model.getPrimaryId()); + secondaryIdTextField.setText(model.getSecondaryId()); paymentsInfoDisplay.setText(BSResources.get("Copy and paste the payment account data to your " + "internet banking web page and transfer the {0} amount to the other traders " + "payment account. When the transfer is completed inform the other trader by " + "clicking the button below.", - presentationModel.getCurrencyCode())); + model.getCurrencyCode())); break; case OFFERER_BUYER_WAIT_CONFIRM_PAYMENT_RECEIVED: processBar.setSelectedIndex(2); statusTextField.setText(BSResources.get("Waiting for the Bitcoin sellers confirmation " + "that the {0} payment has arrived.", - presentationModel.getCurrencyCode())); + model.getCurrencyCode())); infoDisplay.setText(BSResources.get("When the confirmation that the {0} payment arrived at the " + "Bitcoin sellers payment account, the payout transaction will be published.", - presentationModel.getCurrencyCode())); + model.getCurrencyCode())); break; case OFFERER_BUYER_COMPLETED: processBar.setSelectedIndex(3); @@ -354,14 +354,14 @@ public class PendingTradesViewCB extends CachedViewCB { btcTradeAmountLabel.setText("You have bought:"); fiatTradeAmountLabel.setText("You have paid:"); - btcTradeAmountTextField.setText(presentationModel.getTradeVolume()); - fiatTradeAmountTextField.setText(presentationModel.getFiatVolume()); - feesTextField.setText(presentationModel.getTotalFees()); - securityDepositTextField.setText(presentationModel.getSecurityDeposit()); + btcTradeAmountTextField.setText(model.getTradeVolume()); + fiatTradeAmountTextField.setText(model.getFiatVolume()); + feesTextField.setText(model.getTotalFees()); + securityDepositTextField.setText(model.getSecurityDeposit()); summaryInfoDisplay.setText("Your security deposit has been refunded to you. " + "You can review the details to that trade any time in the closed trades screen."); - withdrawAmountTextField.setText(presentationModel.getAmountToWithdraw()); + withdrawAmountTextField.setText(model.getAmountToWithdraw()); break; } } @@ -388,7 +388,7 @@ public class PendingTradesViewCB extends CachedViewCB { "That is needed to assure that the deposit input funding has not been " + "double-spent. " + "For higher trade volumes it is recommended to wait up to 6 confirmations.", - presentationModel.getCurrencyCode())); + model.getCurrencyCode())); break; case TAKER_SELLER_WAIT_PAYMENT_STARTED: processBar.setSelectedIndex(1); @@ -396,10 +396,10 @@ public class PendingTradesViewCB extends CachedViewCB { statusTextField.setText(BSResources.get("Deposit transaction has at least one block chain " + "confirmation. " + "Waiting that other trader starts the {0} payment.", - presentationModel.getCurrencyCode())); + model.getCurrencyCode())); infoDisplay.setText(BSResources.get("You will get informed when the other trader has indicated " + "the {0} payment has been started.", - presentationModel.getCurrencyCode())); + model.getCurrencyCode())); break; case TAKER_SELLER_CONFIRM_RECEIVE_PAYMENT: processBar.setSelectedIndex(2); @@ -409,11 +409,11 @@ public class PendingTradesViewCB extends CachedViewCB { statusTextField.setText(BSResources.get("The Bitcoin buyer has started the {0} payment." + "Check your payments account and confirm when you have received the payment.", - presentationModel.getCurrencyCode())); + model.getCurrencyCode())); infoDisplay.setText(BSResources.get("It is important that you confirm when you have received the " + "{0} payment as this will publish the payout transaction where you get returned " + "your security deposit and the Bitcoin buyer receive the Bitcoin amount you sold.", - presentationModel.getCurrencyCode())); + model.getCurrencyCode())); break; case TAKER_SELLER_COMPLETED: @@ -429,14 +429,14 @@ public class PendingTradesViewCB extends CachedViewCB { btcTradeAmountLabel.setText("You have sold:"); fiatTradeAmountLabel.setText("You have received:"); - btcTradeAmountTextField.setText(presentationModel.getTradeVolume()); - fiatTradeAmountTextField.setText(presentationModel.getFiatVolume()); - feesTextField.setText(presentationModel.getTotalFees()); - securityDepositTextField.setText(presentationModel.getSecurityDeposit()); + btcTradeAmountTextField.setText(model.getTradeVolume()); + fiatTradeAmountTextField.setText(model.getFiatVolume()); + feesTextField.setText(model.getTotalFees()); + securityDepositTextField.setText(model.getSecurityDeposit()); summaryInfoDisplay.setText("Your security deposit has been refunded to you. " + "You can review the details to that trade any time in the closed trades screen."); - withdrawAmountTextField.setText(presentationModel.getAmountToWithdraw()); + withdrawAmountTextField.setText(model.getAmountToWithdraw()); break; } } @@ -552,9 +552,9 @@ public class PendingTradesViewCB extends CachedViewCB { super.updateItem(id, empty); if (id != null && !empty) { - hyperlink = new Hyperlink(presentationModel.formatTradeId(id)); + hyperlink = new Hyperlink(model.formatTradeId(id)); hyperlink.setId("id-link"); - Tooltip.install(hyperlink, new Tooltip(presentationModel.formatTradeId(id))); + Tooltip.install(hyperlink, new Tooltip(model.formatTradeId(id))); hyperlink.setOnAction(event -> openOfferDetails(id)); setGraphic(hyperlink); } @@ -574,7 +574,7 @@ public class PendingTradesViewCB extends CachedViewCB { new StringConverter() { @Override public String toString(Date value) { - return presentationModel.formatDate(value); + return model.formatDate(value); } @Override @@ -589,7 +589,7 @@ public class PendingTradesViewCB extends CachedViewCB { new StringConverter() { @Override public String toString(Coin value) { - return presentationModel.formatTradeAmount(value); + return model.formatTradeAmount(value); } @Override @@ -604,7 +604,7 @@ public class PendingTradesViewCB extends CachedViewCB { new StringConverter() { @Override public String toString(Fiat value) { - return presentationModel.formatPrice(value); + return model.formatPrice(value); } @Override @@ -620,7 +620,7 @@ public class PendingTradesViewCB extends CachedViewCB { new StringConverter() { @Override public String toString(Fiat value) { - return presentationModel.formatTradeVolume(value); + return model.formatTradeVolume(value); } @Override @@ -643,7 +643,7 @@ public class PendingTradesViewCB extends CachedViewCB { public void updateItem(final PendingTradesListItem item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) - setText(presentationModel.evaluateDirection(item)); + setText(model.evaluateDirection(item)); else setText(null); } diff --git a/src/main/java/io/bitsquare/gui/main/settings/application/PreferencesViewCB.java b/src/main/java/io/bitsquare/gui/main/settings/application/PreferencesViewCB.java index 489615f4ef..7aa0b3108c 100644 --- a/src/main/java/io/bitsquare/gui/main/settings/application/PreferencesViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/settings/application/PreferencesViewCB.java @@ -47,8 +47,8 @@ public class PreferencesViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// @Inject - private PreferencesViewCB(PreferencesPM presentationModel) { - super(presentationModel); + private PreferencesViewCB(PreferencesPM model) { + super(model); } @@ -65,11 +65,11 @@ public class PreferencesViewCB extends CachedViewCB { public void activate() { super.activate(); - btcDenominationComboBox.setItems(presentationModel.getBtcDenominationItems()); - btcDenominationComboBox.getSelectionModel().select(presentationModel.btcDenomination().get()); + btcDenominationComboBox.setItems(model.getBtcDenominationItems()); + btcDenominationComboBox.getSelectionModel().select(model.btcDenomination().get()); - useAnimationsCheckBox.selectedProperty().bindBidirectional(presentationModel.useAnimations()); - useEffectsCheckBox.selectedProperty().bindBidirectional(presentationModel.useEffects()); + useAnimationsCheckBox.selectedProperty().bindBidirectional(model.useAnimations()); + useEffectsCheckBox.selectedProperty().bindBidirectional(model.useEffects()); } @@ -94,6 +94,6 @@ public class PreferencesViewCB extends CachedViewCB { @FXML void onSelectBtcDenomination() { - presentationModel.btcDenomination().set(btcDenominationComboBox.getSelectionModel().getSelectedItem()); + model.btcDenomination().set(btcDenominationComboBox.getSelectionModel().getSelectedItem()); } } diff --git a/src/main/java/io/bitsquare/gui/main/trade/createoffer/CreateOfferViewCB.java b/src/main/java/io/bitsquare/gui/main/trade/createoffer/CreateOfferViewCB.java index f89a5cdea0..144793e60b 100644 --- a/src/main/java/io/bitsquare/gui/main/trade/createoffer/CreateOfferViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/trade/createoffer/CreateOfferViewCB.java @@ -117,9 +117,9 @@ public class CreateOfferViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// @Inject - private CreateOfferViewCB(CreateOfferPM presentationModel, Navigation navigation, + private CreateOfferViewCB(CreateOfferPM model, Navigation navigation, OverlayManager overlayManager) { - super(presentationModel); + super(model); this.navigation = navigation; this.overlayManager = overlayManager; } @@ -135,9 +135,9 @@ public class CreateOfferViewCB extends CachedViewCB { setupListeners(); setupBindings(); - balanceTextField.setup(presentationModel.getWalletService(), presentationModel.address.get(), - presentationModel.getFormatter()); - volumeTextField.setPromptText(BSResources.get("createOffer.volume.prompt", presentationModel.fiatCode.get())); + balanceTextField.setup(model.getWalletService(), model.address.get(), + model.getFormatter()); + volumeTextField.setPromptText(BSResources.get("createOffer.volume.prompt", model.fiatCode.get())); } @SuppressWarnings("EmptyMethod") @@ -168,7 +168,7 @@ public class CreateOfferViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// public void initWithData(Direction direction, Coin amount, Fiat price) { - presentationModel.initWithData(direction, amount, price); + model.initWithData(direction, amount, price); if (direction == Direction.BUY) imageView.setId("image-buy-large"); @@ -179,7 +179,7 @@ public class CreateOfferViewCB extends CachedViewCB { public void configCloseHandlers(CloseListener closeListener, BooleanProperty tabIsClosable) { this.closeListener = closeListener; this.tabIsClosable = tabIsClosable; - tabIsClosable.bind(presentationModel.tabIsClosable); + tabIsClosable.bind(model.tabIsClosable); } @@ -189,12 +189,12 @@ public class CreateOfferViewCB extends CachedViewCB { @FXML void onPlaceOffer() { - presentationModel.placeOffer(); + model.placeOffer(); } @FXML void onShowPayFundsScreen() { - if (presentationModel.displaySecurityDepositInfo()) { + if (model.displaySecurityDepositInfo()) { overlayManager.blurContent(); List actions = new ArrayList<>(); actions.add(new AbstractAction(BSResources.get("shared.close")) { @@ -211,7 +211,7 @@ public class CreateOfferViewCB extends CachedViewCB { "\nIt will be refunded to you after the trade has successfully completed.", actions); - presentationModel.securityDepositInfoDisplayed(); + model.securityDepositInfoDisplayed(); } @@ -241,7 +241,7 @@ public class CreateOfferViewCB extends CachedViewCB { setupTotalToPayInfoIconLabel(); - presentationModel.onShowPayFundsScreen(); + model.onShowPayFundsScreen(); } @FXML @@ -303,60 +303,60 @@ public class CreateOfferViewCB extends CachedViewCB { // focus out amountTextField.focusedProperty().addListener((o, oldValue, newValue) -> { - presentationModel.onFocusOutAmountTextField(oldValue, newValue, amountTextField.getText()); - amountTextField.setText(presentationModel.amount.get()); + model.onFocusOutAmountTextField(oldValue, newValue, amountTextField.getText()); + amountTextField.setText(model.amount.get()); }); minAmountTextField.focusedProperty().addListener((o, oldValue, newValue) -> { - presentationModel.onFocusOutMinAmountTextField(oldValue, newValue, minAmountTextField.getText()); - minAmountTextField.setText(presentationModel.minAmount.get()); + model.onFocusOutMinAmountTextField(oldValue, newValue, minAmountTextField.getText()); + minAmountTextField.setText(model.minAmount.get()); }); priceTextField.focusedProperty().addListener((o, oldValue, newValue) -> { - presentationModel.onFocusOutPriceTextField(oldValue, newValue, priceTextField.getText()); - priceTextField.setText(presentationModel.price.get()); + model.onFocusOutPriceTextField(oldValue, newValue, priceTextField.getText()); + priceTextField.setText(model.price.get()); }); volumeTextField.focusedProperty().addListener((o, oldValue, newValue) -> { - presentationModel.onFocusOutVolumeTextField(oldValue, newValue, volumeTextField.getText()); - volumeTextField.setText(presentationModel.volume.get()); + model.onFocusOutVolumeTextField(oldValue, newValue, volumeTextField.getText()); + volumeTextField.setText(model.volume.get()); }); // warnings - presentationModel.showWarningInvalidBtcDecimalPlaces.addListener((o, oldValue, newValue) -> { + model.showWarningInvalidBtcDecimalPlaces.addListener((o, oldValue, newValue) -> { if (newValue) { Popups.openWarningPopup(BSResources.get("shared.warning"), BSResources.get("createOffer.amountPriceBox.warning.invalidBtcDecimalPlaces")); - presentationModel.showWarningInvalidBtcDecimalPlaces.set(false); + model.showWarningInvalidBtcDecimalPlaces.set(false); } }); - presentationModel.showWarningInvalidFiatDecimalPlaces.addListener((o, oldValue, newValue) -> { + model.showWarningInvalidFiatDecimalPlaces.addListener((o, oldValue, newValue) -> { if (newValue) { Popups.openWarningPopup(BSResources.get("shared.warning"), BSResources.get("createOffer.amountPriceBox.warning.invalidFiatDecimalPlaces")); - presentationModel.showWarningInvalidFiatDecimalPlaces.set(false); + model.showWarningInvalidFiatDecimalPlaces.set(false); } }); - presentationModel.showWarningAdjustedVolume.addListener((o, oldValue, newValue) -> { + model.showWarningAdjustedVolume.addListener((o, oldValue, newValue) -> { if (newValue) { Popups.openWarningPopup(BSResources.get("shared.warning"), BSResources.get("createOffer.amountPriceBox.warning.adjustedVolume")); - presentationModel.showWarningAdjustedVolume.set(false); - volumeTextField.setText(presentationModel.volume.get()); + model.showWarningAdjustedVolume.set(false); + volumeTextField.setText(model.volume.get()); } }); - presentationModel.requestPlaceOfferErrorMessage.addListener((o, oldValue, newValue) -> { + model.requestPlaceOfferErrorMessage.addListener((o, oldValue, newValue) -> { if (newValue != null) { Popups.openErrorPopup(BSResources.get("shared.error"), BSResources.get("createOffer.amountPriceBox.error.message", - presentationModel.requestPlaceOfferErrorMessage.get())); + model.requestPlaceOfferErrorMessage.get())); } }); - presentationModel.showTransactionPublishedScreen.addListener((o, oldValue, newValue) -> { + model.showTransactionPublishedScreen.addListener((o, oldValue, newValue) -> { if (newValue) { overlayManager.blurContent(); @@ -367,7 +367,7 @@ public class CreateOfferViewCB extends CachedViewCB { @Override public void handle(ActionEvent actionEvent) { getProperties().put("type", "COPY"); - Utilities.copyToClipboard(presentationModel.transactionId.get()); + Utilities.copyToClipboard(model.transactionId.get()); } });*/ actions.add(new AbstractAction(BSResources.get("shared.close")) { @@ -392,54 +392,54 @@ public class CreateOfferViewCB extends CachedViewCB { } private void setupBindings() { - amountBtcLabel.textProperty().bind(presentationModel.btcCode); - priceFiatLabel.textProperty().bind(presentationModel.fiatCode); - volumeFiatLabel.textProperty().bind(presentationModel.fiatCode); - minAmountBtcLabel.textProperty().bind(presentationModel.btcCode); + amountBtcLabel.textProperty().bind(model.btcCode); + priceFiatLabel.textProperty().bind(model.fiatCode); + volumeFiatLabel.textProperty().bind(model.fiatCode); + minAmountBtcLabel.textProperty().bind(model.btcCode); priceDescriptionLabel.textProperty().bind(createStringBinding(() -> BSResources.get("createOffer.amountPriceBox.priceDescription", - presentationModel.fiatCode.get()), - presentationModel.fiatCode)); + model.fiatCode.get()), + model.fiatCode)); volumeDescriptionLabel.textProperty().bind(createStringBinding(() -> BSResources.get("createOffer.amountPriceBox.volumeDescription", - presentationModel.fiatCode.get()), - presentationModel.fiatCode)); + model.fiatCode.get()), + model.fiatCode)); - buyLabel.textProperty().bind(presentationModel.directionLabel); + buyLabel.textProperty().bind(model.directionLabel); - amountTextField.textProperty().bindBidirectional(presentationModel.amount); - minAmountTextField.textProperty().bindBidirectional(presentationModel.minAmount); - priceTextField.textProperty().bindBidirectional(presentationModel.price); - volumeTextField.textProperty().bindBidirectional(presentationModel.volume); + amountTextField.textProperty().bindBidirectional(model.amount); + minAmountTextField.textProperty().bindBidirectional(model.minAmount); + priceTextField.textProperty().bindBidirectional(model.price); + volumeTextField.textProperty().bindBidirectional(model.volume); - totalToPayTextField.textProperty().bind(presentationModel.totalToPay); + totalToPayTextField.textProperty().bind(model.totalToPay); - addressTextField.amountAsCoinProperty().bind(presentationModel.totalToPayAsCoin); - addressTextField.paymentLabelProperty().bind(presentationModel.paymentLabel); - addressTextField.addressProperty().bind(presentationModel.addressAsString); + addressTextField.amountAsCoinProperty().bind(model.totalToPayAsCoin); + addressTextField.paymentLabelProperty().bind(model.paymentLabel); + addressTextField.addressProperty().bind(model.addressAsString); - bankAccountTypeTextField.textProperty().bind(presentationModel.bankAccountType); - bankAccountCurrencyTextField.textProperty().bind(presentationModel.bankAccountCurrency); - bankAccountCountyTextField.textProperty().bind(presentationModel.bankAccountCounty); + bankAccountTypeTextField.textProperty().bind(model.bankAccountType); + bankAccountCurrencyTextField.textProperty().bind(model.bankAccountCurrency); + bankAccountCountyTextField.textProperty().bind(model.bankAccountCounty); - acceptedCountriesTextField.textProperty().bind(presentationModel.acceptedCountries); - acceptedLanguagesTextField.textProperty().bind(presentationModel.acceptedLanguages); - acceptedArbitratorsTextField.textProperty().bind(presentationModel.acceptedArbitrators); + acceptedCountriesTextField.textProperty().bind(model.acceptedCountries); + acceptedLanguagesTextField.textProperty().bind(model.acceptedLanguages); + acceptedArbitratorsTextField.textProperty().bind(model.acceptedArbitrators); // Validation - amountTextField.validationResultProperty().bind(presentationModel.amountValidationResult); - minAmountTextField.validationResultProperty().bind(presentationModel.minAmountValidationResult); - priceTextField.validationResultProperty().bind(presentationModel.priceValidationResult); - volumeTextField.validationResultProperty().bind(presentationModel.volumeValidationResult); + amountTextField.validationResultProperty().bind(model.amountValidationResult); + minAmountTextField.validationResultProperty().bind(model.minAmountValidationResult); + priceTextField.validationResultProperty().bind(model.priceValidationResult); + volumeTextField.validationResultProperty().bind(model.volumeValidationResult); // buttons - placeOfferButton.visibleProperty().bind(presentationModel.isPlaceOfferButtonVisible); - placeOfferButton.disableProperty().bind(presentationModel.isPlaceOfferButtonDisabled); + placeOfferButton.visibleProperty().bind(model.isPlaceOfferButtonVisible); + placeOfferButton.disableProperty().bind(model.isPlaceOfferButtonDisabled); - placeOfferSpinnerInfoLabel.visibleProperty().bind(presentationModel.isPlaceOfferSpinnerVisible); + placeOfferSpinnerInfoLabel.visibleProperty().bind(model.isPlaceOfferSpinnerVisible); - presentationModel.isPlaceOfferSpinnerVisible.addListener((ov, oldValue, newValue) -> { + model.isPlaceOfferSpinnerVisible.addListener((ov, oldValue, newValue) -> { placeOfferSpinner.setProgress(newValue ? -1 : 0); placeOfferSpinner.setVisible(newValue); }); @@ -535,18 +535,18 @@ public class CreateOfferViewCB extends CachedViewCB { addPayInfoEntry(infoGridPane, 0, BSResources.get("createOffer.fundsBox.securityDeposit"), - presentationModel.securityDeposit.get()); + model.securityDeposit.get()); addPayInfoEntry(infoGridPane, 1, BSResources.get("createOffer.fundsBox.offerFee"), - presentationModel.offerFee.get()); + model.offerFee.get()); addPayInfoEntry(infoGridPane, 2, BSResources.get("createOffer.fundsBox.networkFee"), - presentationModel.networkFee.get()); + model.networkFee.get()); Separator separator = new Separator(); separator.setOrientation(Orientation.HORIZONTAL); separator.setStyle("-fx-background: #666;"); GridPane.setConstraints(separator, 1, 3); infoGridPane.getChildren().add(separator); addPayInfoEntry(infoGridPane, 4, BSResources.get("createOffer.fundsBox.total"), - presentationModel.totalToPay.get()); + model.totalToPay.get()); totalToPayInfoPopover = new PopOver(infoGridPane); if (totalToPayInfoIconLabel.getScene() != null) { totalToPayInfoPopover.setDetachable(false); diff --git a/src/main/java/io/bitsquare/gui/main/trade/offerbook/OfferBookViewCB.java b/src/main/java/io/bitsquare/gui/main/trade/offerbook/OfferBookViewCB.java index a761de2ada..05d29403b7 100644 --- a/src/main/java/io/bitsquare/gui/main/trade/offerbook/OfferBookViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/trade/offerbook/OfferBookViewCB.java @@ -90,12 +90,12 @@ public class OfferBookViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// @Inject - OfferBookViewCB(OfferBookPM presentationModel, + OfferBookViewCB(OfferBookPM model, Navigation navigation, OverlayManager overlayManager, OptionalBtcValidator optionalBtcValidator, OptionalFiatValidator optionalFiatValidator) { - super(presentationModel); + super(model); this.navigation = navigation; this.overlayManager = overlayManager; @@ -150,10 +150,10 @@ public class OfferBookViewCB extends CachedViewCB { setupBindings(); // setOfferBookInfo has been called before - SortedList offerList = presentationModel.getOfferList(); + SortedList offerList = model.getOfferList(); table.setItems(offerList); offerList.comparatorProperty().bind(table.comparatorProperty()); - priceColumn.setSortType((presentationModel.getDirection() == Direction.BUY) ? + priceColumn.setSortType((model.getDirection() == Direction.BUY) ? TableColumn.SortType.ASCENDING : TableColumn.SortType.DESCENDING); table.sort(); } @@ -188,7 +188,7 @@ public class OfferBookViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// public void setDirection(Direction direction) { - presentationModel.setDirection(direction); + model.setDirection(direction); } @@ -198,10 +198,10 @@ public class OfferBookViewCB extends CachedViewCB { @FXML void createOffer() { - if (presentationModel.isRegistered()) { + if (model.isRegistered()) { createOfferButton.setDisable(true); - ((TradeNavigator) parent).createOffer(presentationModel.getAmountAsCoin(), - presentationModel.getPriceAsCoin()); + ((TradeNavigator) parent).createOffer(model.getAmountAsCoin(), + model.getPriceAsCoin()); } else { openSetupScreen(); @@ -264,10 +264,10 @@ public class OfferBookViewCB extends CachedViewCB { private void takeOffer(Offer offer) { - if (presentationModel.isRegistered()) { + if (model.isRegistered()) { if (offer.getDirection() == Direction.BUY) { - ((TradeNavigator) parent).takeOffer(presentationModel.getAmountAsCoin(), - presentationModel.getPriceAsCoin(), offer); + ((TradeNavigator) parent).takeOffer(model.getAmountAsCoin(), + model.getPriceAsCoin(), offer); } else { Popups.openInfoPopup("Not implemented yet", @@ -352,23 +352,23 @@ public class OfferBookViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// private void setupBindings() { - amountTextField.textProperty().bindBidirectional(presentationModel.amount); - priceTextField.textProperty().bindBidirectional(presentationModel.price); - volumeTextField.textProperty().bindBidirectional(presentationModel.volume); - amountBtcLabel.textProperty().bind(presentationModel.btcCode); - priceFiatLabel.textProperty().bind(presentationModel.fiatCode); - volumeFiatLabel.textProperty().bind(presentationModel.fiatCode); - priceDescriptionLabel.textProperty().bind(presentationModel.fiatCode); - volumeDescriptionLabel.textProperty().bind(presentationModel.fiatCode);//Price per Bitcoin in EUR + amountTextField.textProperty().bindBidirectional(model.amount); + priceTextField.textProperty().bindBidirectional(model.price); + volumeTextField.textProperty().bindBidirectional(model.volume); + amountBtcLabel.textProperty().bind(model.btcCode); + priceFiatLabel.textProperty().bind(model.fiatCode); + volumeFiatLabel.textProperty().bind(model.fiatCode); + priceDescriptionLabel.textProperty().bind(model.fiatCode); + volumeDescriptionLabel.textProperty().bind(model.fiatCode);//Price per Bitcoin in EUR priceDescriptionLabel.textProperty().bind(createStringBinding(() -> - BSResources.get("Filter by price in {0}", presentationModel.fiatCode.get()), - presentationModel.fiatCode)); + BSResources.get("Filter by price in {0}", model.fiatCode.get()), + model.fiatCode)); volumeDescriptionLabel.textProperty().bind(createStringBinding(() -> - BSResources.get("Filter by amount in {0}", presentationModel.fiatCode.get()), - presentationModel.fiatCode)); + BSResources.get("Filter by amount in {0}", model.fiatCode.get()), + model.fiatCode)); volumeTextField.promptTextProperty().bind(createStringBinding(() -> - BSResources.get("Amount in {0}", presentationModel.fiatCode.get()), - presentationModel.fiatCode)); + BSResources.get("Amount in {0}", model.fiatCode.get()), + model.fiatCode)); } private void removeBindings() { @@ -419,7 +419,7 @@ public class OfferBookViewCB extends CachedViewCB { @Override public void updateItem(final OfferBookListItem item, boolean empty) { super.updateItem(item, empty); - setText(presentationModel.getAmount(item)); + setText(model.getAmount(item)); } }; } @@ -438,7 +438,7 @@ public class OfferBookViewCB extends CachedViewCB { @Override public void updateItem(final OfferBookListItem item, boolean empty) { super.updateItem(item, empty); - setText(presentationModel.getPrice(item)); + setText(model.getPrice(item)); } }; } @@ -457,7 +457,7 @@ public class OfferBookViewCB extends CachedViewCB { @Override public void updateItem(final OfferBookListItem item, boolean empty) { super.updateItem(item, empty); - setText(presentationModel.getVolume(item)); + setText(model.getVolume(item)); } }; } @@ -483,7 +483,7 @@ public class OfferBookViewCB extends CachedViewCB { } private void verifyIfTradable(final OfferBookListItem item) { - boolean isMatchingRestrictions = presentationModel.isTradable(item + boolean isMatchingRestrictions = model.isTradable(item .getOffer()); button.setDisable(!isMatchingRestrictions); @@ -504,7 +504,7 @@ public class OfferBookViewCB extends CachedViewCB { if (tableRow != null) { getTableRow().setTooltip(new Tooltip("Click for more information.")); getTableRow().setOnMouseClicked((e) -> openRestrictionsWarning - (presentationModel.restrictionsInfo.get())); + (model.restrictionsInfo.get())); } } } @@ -517,10 +517,10 @@ public class OfferBookViewCB extends CachedViewCB { String title; Offer offer = item.getOffer(); - if (presentationModel.isMyOffer(offer)) { + if (model.isMyOffer(offer)) { iconView.setId("image-remove"); title = "Remove"; - button.setOnAction(event -> presentationModel.removeOffer(item + button.setOnAction(event -> model.removeOffer(item .getOffer())); } else { @@ -528,7 +528,7 @@ public class OfferBookViewCB extends CachedViewCB { iconView.setId("image-buy"); else iconView.setId("image-sell"); - title = presentationModel.getDirectionLabel(offer); + title = model.getDirectionLabel(offer); button.setOnAction(event -> takeOffer(item.getOffer())); } @@ -595,7 +595,7 @@ public class OfferBookViewCB extends CachedViewCB { @Override public void updateItem(final OfferBookListItem offerBookListItem, boolean empty) { super.updateItem(offerBookListItem, empty); - setText(presentationModel.getBankAccountType(offerBookListItem)); + setText(model.getBankAccountType(offerBookListItem)); } }; } diff --git a/src/main/java/io/bitsquare/gui/main/trade/takeoffer/TakeOfferViewCB.java b/src/main/java/io/bitsquare/gui/main/trade/takeoffer/TakeOfferViewCB.java index a9491cfa94..1bbb44e762 100644 --- a/src/main/java/io/bitsquare/gui/main/trade/takeoffer/TakeOfferViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/trade/takeoffer/TakeOfferViewCB.java @@ -112,9 +112,9 @@ public class TakeOfferViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// @Inject - private TakeOfferViewCB(TakeOfferPM presentationModel, Navigation navigation, + private TakeOfferViewCB(TakeOfferPM model, Navigation navigation, OverlayManager overlayManager) { - super(presentationModel); + super(model); this.navigation = navigation; this.overlayManager = overlayManager; @@ -158,7 +158,7 @@ public class TakeOfferViewCB extends CachedViewCB { /////////////////////////////////////////////////////////////////////////////////////////// public void initWithData(Direction direction, Coin amount, Offer offer) { - presentationModel.initWithData(direction, amount, offer); + model.initWithData(direction, amount, offer); if (direction == Direction.BUY) imageView.setId("image-buy-large"); @@ -166,31 +166,31 @@ public class TakeOfferViewCB extends CachedViewCB { imageView.setId("image-sell-large"); priceDescriptionLabel.setText(BSResources.get("takeOffer.amountPriceBox.priceDescription", - presentationModel.getFiatCode())); + model.getFiatCode())); volumeDescriptionLabel.setText(BSResources.get("takeOffer.amountPriceBox.volumeDescription", - presentationModel.getFiatCode())); + model.getFiatCode())); - balanceTextField.setup(presentationModel.getWalletService(), presentationModel.address.get(), - presentationModel.getFormatter()); + balanceTextField.setup(model.getWalletService(), model.address.get(), + model.getFormatter()); - buyLabel.setText(presentationModel.getDirectionLabel()); - amountRangeTextField.setText(presentationModel.getAmountRange()); - priceTextField.setText(presentationModel.getPrice()); - addressTextField.setPaymentLabel(presentationModel.getPaymentLabel()); - addressTextField.setAddress(presentationModel.getAddressAsString()); - bankAccountTypeTextField.setText(presentationModel.getBankAccountType()); - bankAccountTypeTextField.setText(presentationModel.getBankAccountType()); - bankAccountCurrencyTextField.setText(presentationModel.getBankAccountCurrency()); - bankAccountCountyTextField.setText(presentationModel.getBankAccountCounty()); - acceptedCountriesTextField.setText(presentationModel.getAcceptedCountries()); - acceptedLanguagesTextField.setText(presentationModel.getAcceptedLanguages()); - acceptedArbitratorsTextField.setText(presentationModel.getAcceptedArbitrators()); + buyLabel.setText(model.getDirectionLabel()); + amountRangeTextField.setText(model.getAmountRange()); + priceTextField.setText(model.getPrice()); + addressTextField.setPaymentLabel(model.getPaymentLabel()); + addressTextField.setAddress(model.getAddressAsString()); + bankAccountTypeTextField.setText(model.getBankAccountType()); + bankAccountTypeTextField.setText(model.getBankAccountType()); + bankAccountCurrencyTextField.setText(model.getBankAccountCurrency()); + bankAccountCountyTextField.setText(model.getBankAccountCounty()); + acceptedCountriesTextField.setText(model.getAcceptedCountries()); + acceptedLanguagesTextField.setText(model.getAcceptedLanguages()); + acceptedArbitratorsTextField.setText(model.getAcceptedArbitrators()); } public void setCloseListener(CloseListener closeListener, BooleanProperty tabIsClosable) { this.closeListener = closeListener; this.tabIsClosable = tabIsClosable; - tabIsClosable.bind(presentationModel.tabIsClosable); + tabIsClosable.bind(model.tabIsClosable); } @@ -200,13 +200,13 @@ public class TakeOfferViewCB extends CachedViewCB { @FXML void onTakeOffer() { - presentationModel.takeOffer(); + model.takeOffer(); } @FXML void onShowPayFundsScreen() { - if (presentationModel.displaySecurityDepositInfo()) { + if (model.displaySecurityDepositInfo()) { overlayManager.blurContent(); List actions = new ArrayList<>(); actions.add(new AbstractAction(BSResources.get("shared.close")) { @@ -223,7 +223,7 @@ public class TakeOfferViewCB extends CachedViewCB { "\nIt will be refunded to you after the trade has successfully completed.", actions); - presentationModel.securityDepositInfoDisplayed(); + model.securityDepositInfoDisplayed(); } priceAmountPane.setInactive(); @@ -252,7 +252,7 @@ public class TakeOfferViewCB extends CachedViewCB { setupTotalToPayInfoIconLabel(); - presentationModel.onShowPayFundsScreen(); + model.onShowPayFundsScreen(); } @FXML @@ -305,28 +305,28 @@ public class TakeOfferViewCB extends CachedViewCB { // focus out amountTextField.focusedProperty().addListener((o, oldValue, newValue) -> { - presentationModel.onFocusOutAmountTextField(oldValue, newValue, amountTextField.getText()); - amountTextField.setText(presentationModel.amount.get()); + model.onFocusOutAmountTextField(oldValue, newValue, amountTextField.getText()); + amountTextField.setText(model.amount.get()); }); // warnings - presentationModel.showWarningInvalidBtcDecimalPlaces.addListener((o, oldValue, newValue) -> { + model.showWarningInvalidBtcDecimalPlaces.addListener((o, oldValue, newValue) -> { if (newValue) { Popups.openWarningPopup(BSResources.get("shared.warning"), BSResources.get("takeOffer.amountPriceBox.warning.invalidBtcDecimalPlaces")); - presentationModel.showWarningInvalidBtcDecimalPlaces.set(false); + model.showWarningInvalidBtcDecimalPlaces.set(false); } }); - presentationModel.requestTakeOfferErrorMessage.addListener((o, oldValue, newValue) -> { + model.requestTakeOfferErrorMessage.addListener((o, oldValue, newValue) -> { if (newValue != null) { Popups.openErrorPopup(BSResources.get("shared.error"), BSResources.get("takeOffer.amountPriceBox.error.message", - presentationModel.requestTakeOfferErrorMessage.get())); + model.requestTakeOfferErrorMessage.get())); } }); - presentationModel.showTransactionPublishedScreen.addListener((o, oldValue, newValue) -> { + model.showTransactionPublishedScreen.addListener((o, oldValue, newValue) -> { if (newValue) { overlayManager.blurContent(); @@ -337,7 +337,7 @@ public class TakeOfferViewCB extends CachedViewCB { @Override public void handle(ActionEvent actionEvent) { getProperties().put("type", "COPY"); - Utilities.copyToClipboard(presentationModel.transactionId.get()); + Utilities.copyToClipboard(model.transactionId.get()); } });*/ actions.add(new AbstractAction(BSResources.get("shared.close")) { @@ -364,22 +364,22 @@ public class TakeOfferViewCB extends CachedViewCB { } private void setupBindings() { - amountBtcLabel.textProperty().bind(presentationModel.btcCode); - amountTextField.textProperty().bindBidirectional(presentationModel.amount); - volumeTextField.textProperty().bindBidirectional(presentationModel.volume); - totalToPayTextField.textProperty().bind(presentationModel.totalToPay); - addressTextField.amountAsCoinProperty().bind(presentationModel.totalToPayAsCoin); + amountBtcLabel.textProperty().bind(model.btcCode); + amountTextField.textProperty().bindBidirectional(model.amount); + volumeTextField.textProperty().bindBidirectional(model.volume); + totalToPayTextField.textProperty().bind(model.totalToPay); + addressTextField.amountAsCoinProperty().bind(model.totalToPayAsCoin); // Validation - amountTextField.validationResultProperty().bind(presentationModel.amountValidationResult); + amountTextField.validationResultProperty().bind(model.amountValidationResult); // buttons - takeOfferButton.visibleProperty().bind(presentationModel.isTakeOfferButtonVisible); - takeOfferButton.disableProperty().bind(presentationModel.isTakeOfferButtonDisabled); + takeOfferButton.visibleProperty().bind(model.isTakeOfferButtonVisible); + takeOfferButton.disableProperty().bind(model.isTakeOfferButtonDisabled); - takeOfferSpinnerInfoLabel.visibleProperty().bind(presentationModel.isTakeOfferSpinnerVisible); + takeOfferSpinnerInfoLabel.visibleProperty().bind(model.isTakeOfferSpinnerVisible); - presentationModel.isTakeOfferSpinnerVisible.addListener((ov, oldValue, newValue) -> { + model.isTakeOfferSpinnerVisible.addListener((ov, oldValue, newValue) -> { takeOfferSpinner.setProgress(newValue ? -1 : 0); takeOfferSpinner.setVisible(newValue); }); @@ -452,21 +452,21 @@ public class TakeOfferViewCB extends CachedViewCB { addPayInfoEntry(infoGridPane, 0, BSResources.get("takeOffer.fundsBox.amount"), - presentationModel.getAmount()); + model.getAmount()); addPayInfoEntry(infoGridPane, 1, BSResources.get("takeOffer.fundsBox.securityDeposit"), - presentationModel.securityDeposit.get()); + model.securityDeposit.get()); addPayInfoEntry(infoGridPane, 2, BSResources.get("takeOffer.fundsBox.offerFee"), - presentationModel.getOfferFee()); + model.getOfferFee()); addPayInfoEntry(infoGridPane, 3, BSResources.get("takeOffer.fundsBox.networkFee"), - presentationModel.getNetworkFee()); + model.getNetworkFee()); Separator separator = new Separator(); separator.setOrientation(Orientation.HORIZONTAL); separator.setStyle("-fx-background: #666;"); GridPane.setConstraints(separator, 1, 4); infoGridPane.getChildren().add(separator); addPayInfoEntry(infoGridPane, 5, BSResources.get("takeOffer.fundsBox.total"), - presentationModel.totalToPay.get()); + model.totalToPay.get()); totalToPayInfoPopover = new PopOver(infoGridPane); if (totalToPayInfoIconLabel.getScene() != null) { totalToPayInfoPopover.setDetachable(false);