From cd606d4b96d7da5cad5ee1229eeef69ce8effb18 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Tue, 9 Sep 2014 09:59:16 +0200 Subject: [PATCH] Move Create offer to new package structure --- .../java/io/bitsquare/gui/NavigationItem.java | 2 +- .../trade}/CreateOfferModel.java | 92 ++++++++++--------- .../trade}/CreateOfferPM.java | 91 +++++++++--------- .../bitsquare/gui/trade/TradeController.java | 2 +- .../trade/orderbook/OrderBookController.java | 2 +- .../gui/view/account/AccountSettingsCB.java | 2 + .../gui/view/account/AccountSetupCB.java | 2 + .../content/AdjustableAccountContent.java | 22 +++++ .../account/content/ChangePasswordCB.java | 13 +-- .../view/account/content/FiatAccountCB.java | 12 +-- .../gui/view/account/content/PasswordCB.java | 12 +-- .../view/account/content/RegistrationCB.java | 15 ++- .../view/account/content/RestrictionsCB.java | 11 +-- .../gui/view/account/content/SeedWordsCB.java | 12 +-- .../trade}/CreateOfferCB.java | 3 +- .../trade}/CreateOfferView.fxml | 2 +- .../java/io/bitsquare/BitSquareTestSuite.java | 2 +- .../trade}/CreateOfferPMTest.java | 3 +- .../createoffer/CreateOfferUITestRunner.java | 2 +- 19 files changed, 157 insertions(+), 145 deletions(-) rename src/main/java/io/bitsquare/gui/{trade/createoffer => model/trade}/CreateOfferModel.java (78%) rename src/main/java/io/bitsquare/gui/{trade/createoffer => pm/trade}/CreateOfferPM.java (81%) create mode 100644 src/main/java/io/bitsquare/gui/view/account/content/AdjustableAccountContent.java rename src/main/java/io/bitsquare/gui/{trade/createoffer => view/trade}/CreateOfferCB.java (99%) rename src/main/java/io/bitsquare/gui/{trade/createoffer => view/trade}/CreateOfferView.fxml (99%) rename src/test/java/io/bitsquare/gui/{trade/createoffer => pm/trade}/CreateOfferPMTest.java (98%) diff --git a/src/main/java/io/bitsquare/gui/NavigationItem.java b/src/main/java/io/bitsquare/gui/NavigationItem.java index a93580b94b..114e4313bc 100644 --- a/src/main/java/io/bitsquare/gui/NavigationItem.java +++ b/src/main/java/io/bitsquare/gui/NavigationItem.java @@ -36,7 +36,7 @@ public enum NavigationItem { ORDER_BOOK("/io/bitsquare/gui/trade/orderbook/OrderBookView.fxml"), BUY("/io/bitsquare/gui/trade/BuyView.fxml", ImageUtil.NAV_BUY, ImageUtil.NAV_BUY_ACTIVE), SELL("/io/bitsquare/gui/trade/SellView.fxml", ImageUtil.NAV_SELL, ImageUtil.NAV_SELL_ACTIVE), - CREATE_OFFER("/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml"), + CREATE_OFFER("/io/bitsquare/gui/view/trade/CreateOfferView.fxml"), TAKE_OFFER("/io/bitsquare/gui/trade/takeoffer/TakeOfferView.fxml"), // orders diff --git a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferModel.java b/src/main/java/io/bitsquare/gui/model/trade/CreateOfferModel.java similarity index 78% rename from src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferModel.java rename to src/main/java/io/bitsquare/gui/model/trade/CreateOfferModel.java index cb08cd58f3..2dc993e30c 100644 --- a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferModel.java +++ b/src/main/java/io/bitsquare/gui/model/trade/CreateOfferModel.java @@ -15,7 +15,7 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.gui.trade.createoffer; +package io.bitsquare.gui.model.trade; import io.bitsquare.arbitrator.Arbitrator; import io.bitsquare.bank.BankAccount; @@ -64,7 +64,7 @@ import static io.bitsquare.gui.util.BSFormatter.reduceTo4Decimals; * Note that the create offer domain has a deeper scope in the application domain (TradeManager). * That model is just responsible for the domain specific parts displayed needed in that UI element. */ -class CreateOfferModel extends UIModel { +public class CreateOfferModel extends UIModel { private static final Logger log = LoggerFactory.getLogger(CreateOfferModel.class); private final TradeManager tradeManager; @@ -75,42 +75,43 @@ class CreateOfferModel extends UIModel { private final String offerId; @Nullable private Direction direction = null; - AddressEntry addressEntry; + public AddressEntry addressEntry; - final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty(); - final StringProperty transactionId = new SimpleStringProperty(); - final StringProperty bankAccountCurrency = new SimpleStringProperty(); - final StringProperty bankAccountCounty = new SimpleStringProperty(); - final StringProperty bankAccountType = new SimpleStringProperty(); - final StringProperty fiatCode = new SimpleStringProperty(); - final StringProperty btcCode = new SimpleStringProperty(); + public final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty(); + public final StringProperty transactionId = new SimpleStringProperty(); + public final StringProperty bankAccountCurrency = new SimpleStringProperty(); + public final StringProperty bankAccountCounty = new SimpleStringProperty(); + public final StringProperty bankAccountType = new SimpleStringProperty(); + public final StringProperty fiatCode = new SimpleStringProperty(); + public final StringProperty btcCode = new SimpleStringProperty(); - final LongProperty collateralAsLong = new SimpleLongProperty(); + public final LongProperty collateralAsLong = new SimpleLongProperty(); - final BooleanProperty requestPlaceOfferSuccess = new SimpleBooleanProperty(); - final BooleanProperty isWalletFunded = new SimpleBooleanProperty(); - final BooleanProperty useMBTC = new SimpleBooleanProperty(); + public final BooleanProperty requestPlaceOfferSuccess = new SimpleBooleanProperty(); + public final BooleanProperty isWalletFunded = new SimpleBooleanProperty(); + public final BooleanProperty useMBTC = new SimpleBooleanProperty(); - final ObjectProperty amountAsCoin = new SimpleObjectProperty<>(); - final ObjectProperty minAmountAsCoin = new SimpleObjectProperty<>(); - final ObjectProperty priceAsFiat = new SimpleObjectProperty<>(); - final ObjectProperty volumeAsFiat = new SimpleObjectProperty<>(); - final ObjectProperty totalToPayAsCoin = new SimpleObjectProperty<>(); - final ObjectProperty collateralAsCoin = new SimpleObjectProperty<>(); - final ObjectProperty offerFeeAsCoin = new SimpleObjectProperty<>(); - final ObjectProperty networkFeeAsCoin = new SimpleObjectProperty<>(); + public final ObjectProperty amountAsCoin = new SimpleObjectProperty<>(); + public final ObjectProperty minAmountAsCoin = new SimpleObjectProperty<>(); + public final ObjectProperty priceAsFiat = new SimpleObjectProperty<>(); + public final ObjectProperty volumeAsFiat = new SimpleObjectProperty<>(); + public final ObjectProperty totalToPayAsCoin = new SimpleObjectProperty<>(); + public final ObjectProperty collateralAsCoin = new SimpleObjectProperty<>(); + public final ObjectProperty offerFeeAsCoin = new SimpleObjectProperty<>(); + public final ObjectProperty networkFeeAsCoin = new SimpleObjectProperty<>(); - final ObservableList acceptedCountries = FXCollections.observableArrayList(); - final ObservableList acceptedLanguages = FXCollections.observableArrayList(); - final ObservableList acceptedArbitrators = FXCollections.observableArrayList(); + public final ObservableList acceptedCountries = FXCollections.observableArrayList(); + public final ObservableList acceptedLanguages = FXCollections.observableArrayList(); + public final ObservableList acceptedArbitrators = FXCollections.observableArrayList(); /////////////////////////////////////////////////////////////////////////////////////////// // Constructor /////////////////////////////////////////////////////////////////////////////////////////// + // non private for testing @Inject - CreateOfferModel(TradeManager tradeManager, WalletFacade walletFacade, Settings settings, User user) { + public CreateOfferModel(TradeManager tradeManager, WalletFacade walletFacade, Settings settings, User user) { this.tradeManager = tradeManager; this.walletFacade = walletFacade; this.settings = settings; @@ -186,10 +187,10 @@ class CreateOfferModel extends UIModel { /////////////////////////////////////////////////////////////////////////////////////////// - // Methods + // Public /////////////////////////////////////////////////////////////////////////////////////////// - void placeOffer() { + public void placeOffer() { // data validation is done in the trade domain tradeManager.requestPlaceOffer(offerId, direction, @@ -204,7 +205,7 @@ class CreateOfferModel extends UIModel { ); } - void calculateVolume() { + public void calculateVolume() { try { if (priceAsFiat.get() != null && amountAsCoin.get() != null && !amountAsCoin.get().isZero() && !priceAsFiat .get().isZero()) { @@ -216,7 +217,7 @@ class CreateOfferModel extends UIModel { } } - void calculateAmount() { + public void calculateAmount() { try { if (volumeAsFiat.get() != null && priceAsFiat.get() != null && !volumeAsFiat.get().isZero() && !priceAsFiat .get().isZero()) { @@ -233,7 +234,7 @@ class CreateOfferModel extends UIModel { } } - void calculateTotalToPay() { + public void calculateTotalToPay() { calculateCollateral(); try { if (collateralAsCoin.get() != null) { @@ -245,7 +246,7 @@ class CreateOfferModel extends UIModel { } } - void calculateCollateral() { + public void calculateCollateral() { try { if (amountAsCoin.get() != null) @@ -256,43 +257,44 @@ class CreateOfferModel extends UIModel { } } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Validation - /////////////////////////////////////////////////////////////////////////////////////////// - - boolean isMinAmountLessOrEqualAmount() { + public boolean isMinAmountLessOrEqualAmount() { //noinspection SimplifiableIfStatement if (minAmountAsCoin.get() != null && amountAsCoin.get() != null) return !minAmountAsCoin.get().isGreaterThan(amountAsCoin.get()); return true; } - private void updateBalance(@NotNull Coin balance) { - isWalletFunded.set(totalToPayAsCoin.get() != null && balance.compareTo(totalToPayAsCoin.get()) >= 0); - } /////////////////////////////////////////////////////////////////////////////////////////// // Setter/Getter /////////////////////////////////////////////////////////////////////////////////////////// @Nullable - Direction getDirection() { + public Direction getDirection() { return direction; } - void setDirection(Direction direction) { + public void setDirection(Direction direction) { // direction can not be changed once it is initially set checkArgument(this.direction == null); this.direction = direction; } - WalletFacade getWalletFacade() { + public WalletFacade getWalletFacade() { return walletFacade; } - String getOfferId() { + public String getOfferId() { return offerId; } + + /////////////////////////////////////////////////////////////////////////////////////////// + // Private + /////////////////////////////////////////////////////////////////////////////////////////// + + + private void updateBalance(@NotNull Coin balance) { + isWalletFunded.set(totalToPayAsCoin.get() != null && balance.compareTo(totalToPayAsCoin.get()) >= 0); + } } diff --git a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferPM.java b/src/main/java/io/bitsquare/gui/pm/trade/CreateOfferPM.java similarity index 81% rename from src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferPM.java rename to src/main/java/io/bitsquare/gui/pm/trade/CreateOfferPM.java index 754eee8dfe..b6979e9d04 100644 --- a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferPM.java +++ b/src/main/java/io/bitsquare/gui/pm/trade/CreateOfferPM.java @@ -15,10 +15,11 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.gui.trade.createoffer; +package io.bitsquare.gui.pm.trade; import io.bitsquare.btc.WalletFacade; import io.bitsquare.gui.PresentationModel; +import io.bitsquare.gui.model.trade.CreateOfferModel; import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.validation.BtcValidator; import io.bitsquare.gui.util.validation.FiatValidator; @@ -49,61 +50,63 @@ import org.slf4j.LoggerFactory; import static io.bitsquare.gui.util.BSFormatter.*; import static javafx.beans.binding.Bindings.createStringBinding; -class CreateOfferPM extends PresentationModel { +public class CreateOfferPM extends PresentationModel { private static final Logger log = LoggerFactory.getLogger(CreateOfferPM.class); private final BtcValidator btcValidator = new BtcValidator(); private final FiatValidator fiatValidator = new FiatValidator(); - final StringProperty amount = new SimpleStringProperty(); - final StringProperty minAmount = new SimpleStringProperty(); - final StringProperty price = new SimpleStringProperty(); - final StringProperty volume = new SimpleStringProperty(); - final StringProperty collateral = new SimpleStringProperty(); - final StringProperty totalToPay = new SimpleStringProperty(); - final StringProperty directionLabel = new SimpleStringProperty(); - final StringProperty collateralLabel = new SimpleStringProperty(); - final StringProperty offerFee = new SimpleStringProperty(); - final StringProperty networkFee = new SimpleStringProperty(); - final StringProperty bankAccountType = new SimpleStringProperty(); - final StringProperty bankAccountCurrency = new SimpleStringProperty(); - final StringProperty bankAccountCounty = new SimpleStringProperty(); - final StringProperty acceptedCountries = new SimpleStringProperty(); - final StringProperty acceptedLanguages = new SimpleStringProperty(); - final StringProperty acceptedArbitrators = new SimpleStringProperty(); - final StringProperty addressAsString = new SimpleStringProperty(); - final StringProperty paymentLabel = new SimpleStringProperty(); - final StringProperty transactionId = new SimpleStringProperty(); - final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty(); - final StringProperty btcCode = new SimpleStringProperty(); - final StringProperty fiatCode = new SimpleStringProperty(); + public final StringProperty amount = new SimpleStringProperty(); + public final StringProperty minAmount = new SimpleStringProperty(); + public final StringProperty price = new SimpleStringProperty(); + public final StringProperty volume = new SimpleStringProperty(); + public final StringProperty collateral = new SimpleStringProperty(); + public final StringProperty totalToPay = new SimpleStringProperty(); + public final StringProperty directionLabel = new SimpleStringProperty(); + public final StringProperty collateralLabel = new SimpleStringProperty(); + public final StringProperty offerFee = new SimpleStringProperty(); + public final StringProperty networkFee = new SimpleStringProperty(); + public final StringProperty bankAccountType = new SimpleStringProperty(); + public final StringProperty bankAccountCurrency = new SimpleStringProperty(); + public final StringProperty bankAccountCounty = new SimpleStringProperty(); + public final StringProperty acceptedCountries = new SimpleStringProperty(); + public final StringProperty acceptedLanguages = new SimpleStringProperty(); + public final StringProperty acceptedArbitrators = new SimpleStringProperty(); + public final StringProperty addressAsString = new SimpleStringProperty(); + public final StringProperty paymentLabel = new SimpleStringProperty(); + public final StringProperty transactionId = new SimpleStringProperty(); + public final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty(); + public final StringProperty btcCode = new SimpleStringProperty(); + public final StringProperty fiatCode = new SimpleStringProperty(); - final BooleanProperty isPlaceOfferButtonVisible = new SimpleBooleanProperty(false); - final BooleanProperty isPlaceOfferButtonDisabled = new SimpleBooleanProperty(true); - final BooleanProperty showWarningAdjustedVolume = new SimpleBooleanProperty(); - final BooleanProperty showWarningInvalidFiatDecimalPlaces = new SimpleBooleanProperty(); - final BooleanProperty showWarningInvalidBtcDecimalPlaces = new SimpleBooleanProperty(); - final BooleanProperty showTransactionPublishedScreen = new SimpleBooleanProperty(); + public final BooleanProperty isPlaceOfferButtonVisible = new SimpleBooleanProperty(false); + public final BooleanProperty isPlaceOfferButtonDisabled = new SimpleBooleanProperty(true); + public final BooleanProperty showWarningAdjustedVolume = new SimpleBooleanProperty(); + public final BooleanProperty showWarningInvalidFiatDecimalPlaces = new SimpleBooleanProperty(); + public final BooleanProperty showWarningInvalidBtcDecimalPlaces = new SimpleBooleanProperty(); + public final BooleanProperty showTransactionPublishedScreen = new SimpleBooleanProperty(); - final ObjectProperty amountValidationResult = new SimpleObjectProperty<>(); - final ObjectProperty minAmountValidationResult = new SimpleObjectProperty<>(); - final ObjectProperty priceValidationResult = new SimpleObjectProperty<>(); - final ObjectProperty volumeValidationResult = new SimpleObjectProperty<>(); + public final ObjectProperty amountValidationResult = new SimpleObjectProperty<>(); + public final ObjectProperty minAmountValidationResult = new + SimpleObjectProperty<>(); + public final ObjectProperty priceValidationResult = new SimpleObjectProperty<>(); + public final ObjectProperty volumeValidationResult = new SimpleObjectProperty<>(); // Those are needed for the addressTextField - final ObjectProperty totalToPayAsCoin = new SimpleObjectProperty<>(); - final ObjectProperty
address = new SimpleObjectProperty<>(); + public final ObjectProperty totalToPayAsCoin = new SimpleObjectProperty<>(); + public final ObjectProperty
address = new SimpleObjectProperty<>(); /////////////////////////////////////////////////////////////////////////////////////////// // Constructor /////////////////////////////////////////////////////////////////////////////////////////// + // non private for testing @Inject CreateOfferPM(CreateOfferModel model) { super(model); - // Node: Don't do setup in constructor to make object creation faster + // Note: Don't do setup in constructor to make object creation faster } @@ -151,7 +154,7 @@ class CreateOfferPM extends PresentationModel { /////////////////////////////////////////////////////////////////////////////////////////// // setOrderBookFilter is a one time call - void setOrderBookFilter(@NotNull OrderBookFilter orderBookFilter) { + public void setOrderBookFilter(@NotNull OrderBookFilter orderBookFilter) { model.setDirection(orderBookFilter.getDirection()); directionLabel.set(model.getDirection() == Direction.BUY ? BSResources.get("shared.buy") : BSResources.get ("shared.sell")); @@ -173,7 +176,7 @@ class CreateOfferPM extends PresentationModel { // UI actions (called by CB) /////////////////////////////////////////////////////////////////////////////////////////// - void onPlaceOffer() { + public void onPlaceOffer() { model.requestPlaceOfferErrorMessage.set(null); model.requestPlaceOfferSuccess.set(false); @@ -192,7 +195,7 @@ class CreateOfferPM extends PresentationModel { } // On focus out we do validation and apply the data to the model - void onFocusOutAmountTextField(Boolean oldValue, Boolean newValue, String userInput) { + public void onFocusOutAmountTextField(Boolean oldValue, Boolean newValue, String userInput) { if (oldValue && !newValue) { InputValidator.ValidationResult result = isBtcInputValid(amount.get()); amountValidationResult.set(result); @@ -219,7 +222,7 @@ class CreateOfferPM extends PresentationModel { } } - void onFocusOutMinAmountTextField(Boolean oldValue, Boolean newValue, String userInput) { + public void onFocusOutMinAmountTextField(Boolean oldValue, Boolean newValue, String userInput) { if (oldValue && !newValue) { InputValidator.ValidationResult result = isBtcInputValid(minAmount.get()); minAmountValidationResult.set(result); @@ -241,7 +244,7 @@ class CreateOfferPM extends PresentationModel { } } - void onFocusOutPriceTextField(Boolean oldValue, Boolean newValue, String userInput) { + public void onFocusOutPriceTextField(Boolean oldValue, Boolean newValue, String userInput) { if (oldValue && !newValue) { InputValidator.ValidationResult result = isFiatInputValid(price.get()); boolean isValid = result.isValid; @@ -256,7 +259,7 @@ class CreateOfferPM extends PresentationModel { } } - void onFocusOutVolumeTextField(Boolean oldValue, Boolean newValue, String userInput) { + public void onFocusOutVolumeTextField(Boolean oldValue, Boolean newValue, String userInput) { if (oldValue && !newValue) { InputValidator.ValidationResult result = isBtcInputValid(volume.get()); volumeValidationResult.set(result); @@ -280,7 +283,7 @@ class CreateOfferPM extends PresentationModel { // Getters (called by CB) /////////////////////////////////////////////////////////////////////////////////////////// - WalletFacade getWalletFacade() { + public WalletFacade getWalletFacade() { return model.getWalletFacade(); } diff --git a/src/main/java/io/bitsquare/gui/trade/TradeController.java b/src/main/java/io/bitsquare/gui/trade/TradeController.java index a0c880b6ba..bdc93f4d7b 100644 --- a/src/main/java/io/bitsquare/gui/trade/TradeController.java +++ b/src/main/java/io/bitsquare/gui/trade/TradeController.java @@ -20,9 +20,9 @@ package io.bitsquare.gui.trade; import io.bitsquare.gui.CachedViewController; import io.bitsquare.gui.NavigationItem; import io.bitsquare.gui.components.InputTextField; -import io.bitsquare.gui.trade.createoffer.CreateOfferCB; import io.bitsquare.gui.trade.orderbook.OrderBookController; import io.bitsquare.gui.trade.takeoffer.TakeOfferController; +import io.bitsquare.gui.view.trade.CreateOfferCB; import io.bitsquare.trade.Direction; import io.bitsquare.util.BSFXMLLoader; diff --git a/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookController.java b/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookController.java index ad7dbe1f23..195d71aaeb 100644 --- a/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookController.java +++ b/src/main/java/io/bitsquare/gui/trade/orderbook/OrderBookController.java @@ -25,10 +25,10 @@ import io.bitsquare.gui.MainController; import io.bitsquare.gui.NavigationItem; import io.bitsquare.gui.ViewController; import io.bitsquare.gui.components.Popups; -import io.bitsquare.gui.trade.createoffer.CreateOfferCB; import io.bitsquare.gui.trade.takeoffer.TakeOfferController; import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.ImageUtil; +import io.bitsquare.gui.view.trade.CreateOfferCB; import io.bitsquare.locale.BSResources; import io.bitsquare.locale.Country; import io.bitsquare.locale.CurrencyUtil; diff --git a/src/main/java/io/bitsquare/gui/view/account/AccountSettingsCB.java b/src/main/java/io/bitsquare/gui/view/account/AccountSettingsCB.java index ff16dccfc3..0870b7fa71 100644 --- a/src/main/java/io/bitsquare/gui/view/account/AccountSettingsCB.java +++ b/src/main/java/io/bitsquare/gui/view/account/AccountSettingsCB.java @@ -22,6 +22,7 @@ import io.bitsquare.gui.CodeBehind; import io.bitsquare.gui.NavigationItem; import io.bitsquare.gui.PresentationModel; import io.bitsquare.gui.pm.account.AccountSettingsPM; +import io.bitsquare.gui.view.account.content.AdjustableAccountContent; import io.bitsquare.util.BSFXMLLoader; import java.io.IOException; @@ -195,6 +196,7 @@ class MenuItem extends ToggleButton { ((AnchorPane) content).getChildren().setAll(view); childController = loader.getController(); childController.setParentController(parentCB); + ((AdjustableAccountContent) childController).isSettingsMode(true); } catch (IOException e) { log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl()); e.getStackTrace(); diff --git a/src/main/java/io/bitsquare/gui/view/account/AccountSetupCB.java b/src/main/java/io/bitsquare/gui/view/account/AccountSetupCB.java index 534035abb6..2ea302cc99 100644 --- a/src/main/java/io/bitsquare/gui/view/account/AccountSetupCB.java +++ b/src/main/java/io/bitsquare/gui/view/account/AccountSetupCB.java @@ -24,6 +24,7 @@ import io.bitsquare.gui.PresentationModel; import io.bitsquare.gui.pm.account.AccountSetupPM; import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.view.AccountCB; +import io.bitsquare.gui.view.account.content.AdjustableAccountContent; import io.bitsquare.gui.view.account.content.FiatAccountCB; import io.bitsquare.gui.view.account.content.PasswordCB; import io.bitsquare.gui.view.account.content.RegistrationCB; @@ -247,6 +248,7 @@ class WizardItem extends HBox { ((AnchorPane) content).getChildren().setAll(view); childController = loader.getController(); childController.setParentController(parentCB); + ((AdjustableAccountContent) childController).isSettingsMode(false); } catch (IOException e) { log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl()); e.getStackTrace(); diff --git a/src/main/java/io/bitsquare/gui/view/account/content/AdjustableAccountContent.java b/src/main/java/io/bitsquare/gui/view/account/content/AdjustableAccountContent.java new file mode 100644 index 0000000000..135f7a6b76 --- /dev/null +++ b/src/main/java/io/bitsquare/gui/view/account/content/AdjustableAccountContent.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.view.account.content; + +public interface AdjustableAccountContent { + void isSettingsMode(boolean isSettingsMode); +} diff --git a/src/main/java/io/bitsquare/gui/view/account/content/ChangePasswordCB.java b/src/main/java/io/bitsquare/gui/view/account/content/ChangePasswordCB.java index 4eada114e2..99b7ec6f51 100644 --- a/src/main/java/io/bitsquare/gui/view/account/content/ChangePasswordCB.java +++ b/src/main/java/io/bitsquare/gui/view/account/content/ChangePasswordCB.java @@ -21,7 +21,6 @@ import io.bitsquare.gui.CachedCodeBehind; import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.pm.account.content.ChangePasswordPM; -import io.bitsquare.gui.view.account.AccountSettingsCB; import io.bitsquare.gui.view.account.AccountSetupCB; import java.net.URL; @@ -31,14 +30,13 @@ import java.util.ResourceBundle; import javax.inject.Inject; import javafx.fxml.FXML; -import javafx.fxml.Initializable; import javafx.scene.control.*; import javafx.scene.layout.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ChangePasswordCB extends CachedCodeBehind { +public class ChangePasswordCB extends CachedCodeBehind implements AdjustableAccountContent { private static final Logger log = LoggerFactory.getLogger(ChangePasswordCB.class); @@ -91,17 +89,16 @@ public class ChangePasswordCB extends CachedCodeBehind { /////////////////////////////////////////////////////////////////////////////////////////// - // Override from CodeBehind + // Override /////////////////////////////////////////////////////////////////////////////////////////// @Override - public void setParentController(Initializable parentController) { - super.setParentController(parentController); - if (parentController instanceof AccountSettingsCB) { + public void isSettingsMode(boolean isSettingsMode) { + if (isSettingsMode) buttonsHBox.getChildren().remove(skipButton); - } } + /////////////////////////////////////////////////////////////////////////////////////////// // UI handlers /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/main/java/io/bitsquare/gui/view/account/content/FiatAccountCB.java b/src/main/java/io/bitsquare/gui/view/account/content/FiatAccountCB.java index c657bbbeeb..9ac3fcecc5 100644 --- a/src/main/java/io/bitsquare/gui/view/account/content/FiatAccountCB.java +++ b/src/main/java/io/bitsquare/gui/view/account/content/FiatAccountCB.java @@ -26,7 +26,6 @@ import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.pm.account.content.FiatAccountPm; import io.bitsquare.gui.util.validation.InputValidator; -import io.bitsquare.gui.view.account.AccountSettingsCB; import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.locale.Country; import io.bitsquare.locale.Region; @@ -42,7 +41,6 @@ import javax.inject.Inject; import javafx.collections.ListChangeListener; import javafx.fxml.FXML; -import javafx.fxml.Initializable; import javafx.scene.control.*; import javafx.scene.layout.*; @@ -54,7 +52,7 @@ import org.slf4j.LoggerFactory; import static javafx.beans.binding.Bindings.createBooleanBinding; -public class FiatAccountCB extends CachedCodeBehind { +public class FiatAccountCB extends CachedCodeBehind implements AdjustableAccountContent { private static final Logger log = LoggerFactory.getLogger(FiatAccountCB.class); @@ -124,15 +122,13 @@ public class FiatAccountCB extends CachedCodeBehind { /////////////////////////////////////////////////////////////////////////////////////////// - // Override from CodeBehind + // Override /////////////////////////////////////////////////////////////////////////////////////////// @Override - public void setParentController(Initializable parentController) { - super.setParentController(parentController); - if (parentController instanceof AccountSettingsCB) { + public void isSettingsMode(boolean isSettingsMode) { + if (isSettingsMode) buttonsHBox.getChildren().remove(completedButton); - } } diff --git a/src/main/java/io/bitsquare/gui/view/account/content/PasswordCB.java b/src/main/java/io/bitsquare/gui/view/account/content/PasswordCB.java index 82b0181f0f..635cfb5409 100644 --- a/src/main/java/io/bitsquare/gui/view/account/content/PasswordCB.java +++ b/src/main/java/io/bitsquare/gui/view/account/content/PasswordCB.java @@ -21,7 +21,6 @@ import io.bitsquare.gui.CachedCodeBehind; import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.pm.account.content.PasswordPM; -import io.bitsquare.gui.view.account.AccountSettingsCB; import io.bitsquare.gui.view.account.AccountSetupCB; import java.net.URL; @@ -31,14 +30,13 @@ import java.util.ResourceBundle; import javax.inject.Inject; import javafx.fxml.FXML; -import javafx.fxml.Initializable; import javafx.scene.control.*; import javafx.scene.layout.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PasswordCB extends CachedCodeBehind { +public class PasswordCB extends CachedCodeBehind implements AdjustableAccountContent { private static final Logger log = LoggerFactory.getLogger(PasswordCB.class); @@ -91,15 +89,13 @@ public class PasswordCB extends CachedCodeBehind { /////////////////////////////////////////////////////////////////////////////////////////// - // Override from CodeBehind + // Override /////////////////////////////////////////////////////////////////////////////////////////// @Override - public void setParentController(Initializable parentController) { - super.setParentController(parentController); - if (parentController instanceof AccountSettingsCB) { + public void isSettingsMode(boolean isSettingsMode) { + if (isSettingsMode) buttonsHBox.getChildren().remove(skipButton); - } } diff --git a/src/main/java/io/bitsquare/gui/view/account/content/RegistrationCB.java b/src/main/java/io/bitsquare/gui/view/account/content/RegistrationCB.java index f817f41686..ac7558882f 100644 --- a/src/main/java/io/bitsquare/gui/view/account/content/RegistrationCB.java +++ b/src/main/java/io/bitsquare/gui/view/account/content/RegistrationCB.java @@ -25,7 +25,6 @@ import io.bitsquare.gui.components.btc.BalanceTextField; import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.pm.account.content.RegistrationPM; -import io.bitsquare.gui.view.account.AccountSettingsCB; import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.locale.BSResources; @@ -39,7 +38,6 @@ import javax.inject.Inject; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.fxml.Initializable; import javafx.scene.control.*; import javafx.scene.input.*; @@ -50,7 +48,7 @@ import org.controlsfx.dialog.Dialog; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class RegistrationCB extends CachedCodeBehind { +public class RegistrationCB extends CachedCodeBehind implements AdjustableAccountContent { private static final Logger log = LoggerFactory.getLogger(RegistrationCB.class); @@ -153,18 +151,17 @@ public class RegistrationCB extends CachedCodeBehind { /////////////////////////////////////////////////////////////////////////////////////////// - // Override from CodeBehind + // Override /////////////////////////////////////////////////////////////////////////////////////////// @Override - public void setParentController(Initializable parentController) { - super.setParentController(parentController); - if (parentController instanceof AccountSettingsCB) { - //TODO - // ((GridPane) root).getChildren().remove(completedButton); + public void isSettingsMode(boolean isSettingsMode) { + if (isSettingsMode) { + // TODO } } + /////////////////////////////////////////////////////////////////////////////////////////// // UI handlers /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/main/java/io/bitsquare/gui/view/account/content/RestrictionsCB.java b/src/main/java/io/bitsquare/gui/view/account/content/RestrictionsCB.java index 9da23ef713..4415269e1e 100644 --- a/src/main/java/io/bitsquare/gui/view/account/content/RestrictionsCB.java +++ b/src/main/java/io/bitsquare/gui/view/account/content/RestrictionsCB.java @@ -25,7 +25,6 @@ import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.pm.account.content.RestrictionsPM; import io.bitsquare.gui.util.ImageUtil; -import io.bitsquare.gui.view.account.AccountSettingsCB; import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.locale.Country; import io.bitsquare.locale.Region; @@ -54,7 +53,7 @@ import javafx.util.StringConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class RestrictionsCB extends CachedCodeBehind { +public class RestrictionsCB extends CachedCodeBehind implements AdjustableAccountContent { private static final Logger log = LoggerFactory.getLogger(RestrictionsCB.class); @@ -113,15 +112,13 @@ public class RestrictionsCB extends CachedCodeBehind { /////////////////////////////////////////////////////////////////////////////////////////// - // Override from CodeBehind + // Override /////////////////////////////////////////////////////////////////////////////////////////// @Override - public void setParentController(Initializable parentController) { - super.setParentController(parentController); - if (parentController instanceof AccountSettingsCB) { + public void isSettingsMode(boolean isSettingsMode) { + if (isSettingsMode) ((GridPane) root).getChildren().remove(completedButton); - } } diff --git a/src/main/java/io/bitsquare/gui/view/account/content/SeedWordsCB.java b/src/main/java/io/bitsquare/gui/view/account/content/SeedWordsCB.java index 40e842d789..0311640784 100644 --- a/src/main/java/io/bitsquare/gui/view/account/content/SeedWordsCB.java +++ b/src/main/java/io/bitsquare/gui/view/account/content/SeedWordsCB.java @@ -21,7 +21,6 @@ import io.bitsquare.gui.CachedCodeBehind; import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.pm.account.content.SeedWordsPM; -import io.bitsquare.gui.view.account.AccountSettingsCB; import io.bitsquare.gui.view.account.AccountSetupCB; import java.net.URL; @@ -31,14 +30,13 @@ import java.util.ResourceBundle; import javax.inject.Inject; import javafx.fxml.FXML; -import javafx.fxml.Initializable; import javafx.scene.control.*; import javafx.scene.layout.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SeedWordsCB extends CachedCodeBehind { +public class SeedWordsCB extends CachedCodeBehind implements AdjustableAccountContent { private static final Logger log = LoggerFactory.getLogger(SeedWordsCB.class); @@ -87,15 +85,13 @@ public class SeedWordsCB extends CachedCodeBehind { /////////////////////////////////////////////////////////////////////////////////////////// - // Override from CodeBehind + // Override /////////////////////////////////////////////////////////////////////////////////////////// @Override - public void setParentController(Initializable parentController) { - super.setParentController(parentController); - if (parentController instanceof AccountSettingsCB) { + public void isSettingsMode(boolean isSettingsMode) { + if (isSettingsMode) ((GridPane) root).getChildren().remove(completedButton); - } } diff --git a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferCB.java b/src/main/java/io/bitsquare/gui/view/trade/CreateOfferCB.java similarity index 99% rename from src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferCB.java rename to src/main/java/io/bitsquare/gui/view/trade/CreateOfferCB.java index 1e73a928bd..4e023a32ab 100644 --- a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferCB.java +++ b/src/main/java/io/bitsquare/gui/view/trade/CreateOfferCB.java @@ -15,7 +15,7 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.gui.trade.createoffer; +package io.bitsquare.gui.view.trade; import io.bitsquare.gui.CachedCodeBehind; import io.bitsquare.gui.MainController; @@ -27,6 +27,7 @@ import io.bitsquare.gui.components.btc.AddressTextField; import io.bitsquare.gui.components.btc.BalanceTextField; import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.HelpId; +import io.bitsquare.gui.pm.trade.CreateOfferPM; import io.bitsquare.gui.trade.TradeController; import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.locale.BSResources; diff --git a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml b/src/main/java/io/bitsquare/gui/view/trade/CreateOfferView.fxml similarity index 99% rename from src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml rename to src/main/java/io/bitsquare/gui/view/trade/CreateOfferView.fxml index e303b25a36..8b53a9fa36 100644 --- a/src/main/java/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml +++ b/src/main/java/io/bitsquare/gui/view/trade/CreateOfferView.fxml @@ -26,7 +26,7 @@ - diff --git a/src/test/java/io/bitsquare/BitSquareTestSuite.java b/src/test/java/io/bitsquare/BitSquareTestSuite.java index dce66f45f9..93ef8f0f14 100644 --- a/src/test/java/io/bitsquare/BitSquareTestSuite.java +++ b/src/test/java/io/bitsquare/BitSquareTestSuite.java @@ -18,7 +18,7 @@ package io.bitsquare; import io.bitsquare.btc.RestrictionsTest; -import io.bitsquare.gui.trade.createoffer.CreateOfferPMTest; +import io.bitsquare.gui.pm.trade.CreateOfferPMTest; import io.bitsquare.gui.util.BSFormatterTest; import io.bitsquare.gui.util.BitSquareConverterTest; import io.bitsquare.gui.util.BitSquareNumberValidatorTest; diff --git a/src/test/java/io/bitsquare/gui/trade/createoffer/CreateOfferPMTest.java b/src/test/java/io/bitsquare/gui/pm/trade/CreateOfferPMTest.java similarity index 98% rename from src/test/java/io/bitsquare/gui/trade/createoffer/CreateOfferPMTest.java rename to src/test/java/io/bitsquare/gui/pm/trade/CreateOfferPMTest.java index fed5f40b4a..06ab56be4f 100644 --- a/src/test/java/io/bitsquare/gui/trade/createoffer/CreateOfferPMTest.java +++ b/src/test/java/io/bitsquare/gui/pm/trade/CreateOfferPMTest.java @@ -15,9 +15,10 @@ * along with Bitsquare. If not, see . */ -package io.bitsquare.gui.trade.createoffer; +package io.bitsquare.gui.pm.trade; import io.bitsquare.bank.BankAccountType; +import io.bitsquare.gui.model.trade.CreateOfferModel; import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.locale.Country; diff --git a/src/test/java/io/bitsquare/gui/trade/createoffer/CreateOfferUITestRunner.java b/src/test/java/io/bitsquare/gui/trade/createoffer/CreateOfferUITestRunner.java index 7abdc809ef..efce0dc5d8 100644 --- a/src/test/java/io/bitsquare/gui/trade/createoffer/CreateOfferUITestRunner.java +++ b/src/test/java/io/bitsquare/gui/trade/createoffer/CreateOfferUITestRunner.java @@ -68,7 +68,7 @@ public class CreateOfferUITestRunner extends Application { log.debug("re load"); pane.getChildren().removeAll(); BSFXMLLoader loader = new BSFXMLLoader( - getUrl("/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml"), false); + getUrl("/io/bitsquare/gui/view/trade/CreateOfferView.fxml"), false); try { view = loader.load(); pane.getChildren().setAll(view);