Move Create offer to new package structure

This commit is contained in:
Manfred Karrer 2014-09-09 09:59:16 +02:00
parent 08dba76d9e
commit cd606d4b96
19 changed files with 157 additions and 145 deletions

View file

@ -36,7 +36,7 @@ public enum NavigationItem {
ORDER_BOOK("/io/bitsquare/gui/trade/orderbook/OrderBookView.fxml"), ORDER_BOOK("/io/bitsquare/gui/trade/orderbook/OrderBookView.fxml"),
BUY("/io/bitsquare/gui/trade/BuyView.fxml", ImageUtil.NAV_BUY, ImageUtil.NAV_BUY_ACTIVE), 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), 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"), TAKE_OFFER("/io/bitsquare/gui/trade/takeoffer/TakeOfferView.fxml"),
// orders // orders

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>. * along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/ */
package io.bitsquare.gui.trade.createoffer; package io.bitsquare.gui.model.trade;
import io.bitsquare.arbitrator.Arbitrator; import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.bank.BankAccount; 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). * 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. * 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 static final Logger log = LoggerFactory.getLogger(CreateOfferModel.class);
private final TradeManager tradeManager; private final TradeManager tradeManager;
@ -75,42 +75,43 @@ class CreateOfferModel extends UIModel {
private final String offerId; private final String offerId;
@Nullable private Direction direction = null; @Nullable private Direction direction = null;
AddressEntry addressEntry; public AddressEntry addressEntry;
final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty(); public final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty();
final StringProperty transactionId = new SimpleStringProperty(); public final StringProperty transactionId = new SimpleStringProperty();
final StringProperty bankAccountCurrency = new SimpleStringProperty(); public final StringProperty bankAccountCurrency = new SimpleStringProperty();
final StringProperty bankAccountCounty = new SimpleStringProperty(); public final StringProperty bankAccountCounty = new SimpleStringProperty();
final StringProperty bankAccountType = new SimpleStringProperty(); public final StringProperty bankAccountType = new SimpleStringProperty();
final StringProperty fiatCode = new SimpleStringProperty(); public final StringProperty fiatCode = new SimpleStringProperty();
final StringProperty btcCode = new SimpleStringProperty(); public final StringProperty btcCode = new SimpleStringProperty();
final LongProperty collateralAsLong = new SimpleLongProperty(); public final LongProperty collateralAsLong = new SimpleLongProperty();
final BooleanProperty requestPlaceOfferSuccess = new SimpleBooleanProperty(); public final BooleanProperty requestPlaceOfferSuccess = new SimpleBooleanProperty();
final BooleanProperty isWalletFunded = new SimpleBooleanProperty(); public final BooleanProperty isWalletFunded = new SimpleBooleanProperty();
final BooleanProperty useMBTC = new SimpleBooleanProperty(); public final BooleanProperty useMBTC = new SimpleBooleanProperty();
final ObjectProperty<Coin> amountAsCoin = new SimpleObjectProperty<>(); public final ObjectProperty<Coin> amountAsCoin = new SimpleObjectProperty<>();
final ObjectProperty<Coin> minAmountAsCoin = new SimpleObjectProperty<>(); public final ObjectProperty<Coin> minAmountAsCoin = new SimpleObjectProperty<>();
final ObjectProperty<Fiat> priceAsFiat = new SimpleObjectProperty<>(); public final ObjectProperty<Fiat> priceAsFiat = new SimpleObjectProperty<>();
final ObjectProperty<Fiat> volumeAsFiat = new SimpleObjectProperty<>(); public final ObjectProperty<Fiat> volumeAsFiat = new SimpleObjectProperty<>();
final ObjectProperty<Coin> totalToPayAsCoin = new SimpleObjectProperty<>(); public final ObjectProperty<Coin> totalToPayAsCoin = new SimpleObjectProperty<>();
final ObjectProperty<Coin> collateralAsCoin = new SimpleObjectProperty<>(); public final ObjectProperty<Coin> collateralAsCoin = new SimpleObjectProperty<>();
final ObjectProperty<Coin> offerFeeAsCoin = new SimpleObjectProperty<>(); public final ObjectProperty<Coin> offerFeeAsCoin = new SimpleObjectProperty<>();
final ObjectProperty<Coin> networkFeeAsCoin = new SimpleObjectProperty<>(); public final ObjectProperty<Coin> networkFeeAsCoin = new SimpleObjectProperty<>();
final ObservableList<Country> acceptedCountries = FXCollections.observableArrayList(); public final ObservableList<Country> acceptedCountries = FXCollections.observableArrayList();
final ObservableList<Locale> acceptedLanguages = FXCollections.observableArrayList(); public final ObservableList<Locale> acceptedLanguages = FXCollections.observableArrayList();
final ObservableList<Arbitrator> acceptedArbitrators = FXCollections.observableArrayList(); public final ObservableList<Arbitrator> acceptedArbitrators = FXCollections.observableArrayList();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// non private for testing
@Inject @Inject
CreateOfferModel(TradeManager tradeManager, WalletFacade walletFacade, Settings settings, User user) { public CreateOfferModel(TradeManager tradeManager, WalletFacade walletFacade, Settings settings, User user) {
this.tradeManager = tradeManager; this.tradeManager = tradeManager;
this.walletFacade = walletFacade; this.walletFacade = walletFacade;
this.settings = settings; 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 // data validation is done in the trade domain
tradeManager.requestPlaceOffer(offerId, tradeManager.requestPlaceOffer(offerId,
direction, direction,
@ -204,7 +205,7 @@ class CreateOfferModel extends UIModel {
); );
} }
void calculateVolume() { public void calculateVolume() {
try { try {
if (priceAsFiat.get() != null && amountAsCoin.get() != null && !amountAsCoin.get().isZero() && !priceAsFiat if (priceAsFiat.get() != null && amountAsCoin.get() != null && !amountAsCoin.get().isZero() && !priceAsFiat
.get().isZero()) { .get().isZero()) {
@ -216,7 +217,7 @@ class CreateOfferModel extends UIModel {
} }
} }
void calculateAmount() { public void calculateAmount() {
try { try {
if (volumeAsFiat.get() != null && priceAsFiat.get() != null && !volumeAsFiat.get().isZero() && !priceAsFiat if (volumeAsFiat.get() != null && priceAsFiat.get() != null && !volumeAsFiat.get().isZero() && !priceAsFiat
.get().isZero()) { .get().isZero()) {
@ -233,7 +234,7 @@ class CreateOfferModel extends UIModel {
} }
} }
void calculateTotalToPay() { public void calculateTotalToPay() {
calculateCollateral(); calculateCollateral();
try { try {
if (collateralAsCoin.get() != null) { if (collateralAsCoin.get() != null) {
@ -245,7 +246,7 @@ class CreateOfferModel extends UIModel {
} }
} }
void calculateCollateral() { public void calculateCollateral() {
try { try {
if (amountAsCoin.get() != null) if (amountAsCoin.get() != null)
@ -256,43 +257,44 @@ class CreateOfferModel extends UIModel {
} }
} }
public boolean isMinAmountLessOrEqualAmount() {
///////////////////////////////////////////////////////////////////////////////////////////
// Validation
///////////////////////////////////////////////////////////////////////////////////////////
boolean isMinAmountLessOrEqualAmount() {
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (minAmountAsCoin.get() != null && amountAsCoin.get() != null) if (minAmountAsCoin.get() != null && amountAsCoin.get() != null)
return !minAmountAsCoin.get().isGreaterThan(amountAsCoin.get()); return !minAmountAsCoin.get().isGreaterThan(amountAsCoin.get());
return true; return true;
} }
private void updateBalance(@NotNull Coin balance) {
isWalletFunded.set(totalToPayAsCoin.get() != null && balance.compareTo(totalToPayAsCoin.get()) >= 0);
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Setter/Getter // Setter/Getter
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Nullable @Nullable
Direction getDirection() { public Direction getDirection() {
return direction; return direction;
} }
void setDirection(Direction direction) { public void setDirection(Direction direction) {
// direction can not be changed once it is initially set // direction can not be changed once it is initially set
checkArgument(this.direction == null); checkArgument(this.direction == null);
this.direction = direction; this.direction = direction;
} }
WalletFacade getWalletFacade() { public WalletFacade getWalletFacade() {
return walletFacade; return walletFacade;
} }
String getOfferId() { public String getOfferId() {
return offerId; return offerId;
} }
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
private void updateBalance(@NotNull Coin balance) {
isWalletFunded.set(totalToPayAsCoin.get() != null && balance.compareTo(totalToPayAsCoin.get()) >= 0);
}
} }

View file

@ -15,10 +15,11 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>. * along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/ */
package io.bitsquare.gui.trade.createoffer; package io.bitsquare.gui.pm.trade;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletFacade;
import io.bitsquare.gui.PresentationModel; import io.bitsquare.gui.PresentationModel;
import io.bitsquare.gui.model.trade.CreateOfferModel;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.gui.util.validation.BtcValidator; import io.bitsquare.gui.util.validation.BtcValidator;
import io.bitsquare.gui.util.validation.FiatValidator; import io.bitsquare.gui.util.validation.FiatValidator;
@ -49,61 +50,63 @@ import org.slf4j.LoggerFactory;
import static io.bitsquare.gui.util.BSFormatter.*; import static io.bitsquare.gui.util.BSFormatter.*;
import static javafx.beans.binding.Bindings.createStringBinding; import static javafx.beans.binding.Bindings.createStringBinding;
class CreateOfferPM extends PresentationModel<CreateOfferModel> { public class CreateOfferPM extends PresentationModel<CreateOfferModel> {
private static final Logger log = LoggerFactory.getLogger(CreateOfferPM.class); private static final Logger log = LoggerFactory.getLogger(CreateOfferPM.class);
private final BtcValidator btcValidator = new BtcValidator(); private final BtcValidator btcValidator = new BtcValidator();
private final FiatValidator fiatValidator = new FiatValidator(); private final FiatValidator fiatValidator = new FiatValidator();
final StringProperty amount = new SimpleStringProperty(); public final StringProperty amount = new SimpleStringProperty();
final StringProperty minAmount = new SimpleStringProperty(); public final StringProperty minAmount = new SimpleStringProperty();
final StringProperty price = new SimpleStringProperty(); public final StringProperty price = new SimpleStringProperty();
final StringProperty volume = new SimpleStringProperty(); public final StringProperty volume = new SimpleStringProperty();
final StringProperty collateral = new SimpleStringProperty(); public final StringProperty collateral = new SimpleStringProperty();
final StringProperty totalToPay = new SimpleStringProperty(); public final StringProperty totalToPay = new SimpleStringProperty();
final StringProperty directionLabel = new SimpleStringProperty(); public final StringProperty directionLabel = new SimpleStringProperty();
final StringProperty collateralLabel = new SimpleStringProperty(); public final StringProperty collateralLabel = new SimpleStringProperty();
final StringProperty offerFee = new SimpleStringProperty(); public final StringProperty offerFee = new SimpleStringProperty();
final StringProperty networkFee = new SimpleStringProperty(); public final StringProperty networkFee = new SimpleStringProperty();
final StringProperty bankAccountType = new SimpleStringProperty(); public final StringProperty bankAccountType = new SimpleStringProperty();
final StringProperty bankAccountCurrency = new SimpleStringProperty(); public final StringProperty bankAccountCurrency = new SimpleStringProperty();
final StringProperty bankAccountCounty = new SimpleStringProperty(); public final StringProperty bankAccountCounty = new SimpleStringProperty();
final StringProperty acceptedCountries = new SimpleStringProperty(); public final StringProperty acceptedCountries = new SimpleStringProperty();
final StringProperty acceptedLanguages = new SimpleStringProperty(); public final StringProperty acceptedLanguages = new SimpleStringProperty();
final StringProperty acceptedArbitrators = new SimpleStringProperty(); public final StringProperty acceptedArbitrators = new SimpleStringProperty();
final StringProperty addressAsString = new SimpleStringProperty(); public final StringProperty addressAsString = new SimpleStringProperty();
final StringProperty paymentLabel = new SimpleStringProperty(); public final StringProperty paymentLabel = new SimpleStringProperty();
final StringProperty transactionId = new SimpleStringProperty(); public final StringProperty transactionId = new SimpleStringProperty();
final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty(); public final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty();
final StringProperty btcCode = new SimpleStringProperty(); public final StringProperty btcCode = new SimpleStringProperty();
final StringProperty fiatCode = new SimpleStringProperty(); public final StringProperty fiatCode = new SimpleStringProperty();
final BooleanProperty isPlaceOfferButtonVisible = new SimpleBooleanProperty(false); public final BooleanProperty isPlaceOfferButtonVisible = new SimpleBooleanProperty(false);
final BooleanProperty isPlaceOfferButtonDisabled = new SimpleBooleanProperty(true); public final BooleanProperty isPlaceOfferButtonDisabled = new SimpleBooleanProperty(true);
final BooleanProperty showWarningAdjustedVolume = new SimpleBooleanProperty(); public final BooleanProperty showWarningAdjustedVolume = new SimpleBooleanProperty();
final BooleanProperty showWarningInvalidFiatDecimalPlaces = new SimpleBooleanProperty(); public final BooleanProperty showWarningInvalidFiatDecimalPlaces = new SimpleBooleanProperty();
final BooleanProperty showWarningInvalidBtcDecimalPlaces = new SimpleBooleanProperty(); public final BooleanProperty showWarningInvalidBtcDecimalPlaces = new SimpleBooleanProperty();
final BooleanProperty showTransactionPublishedScreen = new SimpleBooleanProperty(); public final BooleanProperty showTransactionPublishedScreen = new SimpleBooleanProperty();
final ObjectProperty<InputValidator.ValidationResult> amountValidationResult = new SimpleObjectProperty<>(); public final ObjectProperty<InputValidator.ValidationResult> amountValidationResult = new SimpleObjectProperty<>();
final ObjectProperty<InputValidator.ValidationResult> minAmountValidationResult = new SimpleObjectProperty<>(); public final ObjectProperty<InputValidator.ValidationResult> minAmountValidationResult = new
final ObjectProperty<InputValidator.ValidationResult> priceValidationResult = new SimpleObjectProperty<>(); SimpleObjectProperty<>();
final ObjectProperty<InputValidator.ValidationResult> volumeValidationResult = new SimpleObjectProperty<>(); public final ObjectProperty<InputValidator.ValidationResult> priceValidationResult = new SimpleObjectProperty<>();
public final ObjectProperty<InputValidator.ValidationResult> volumeValidationResult = new SimpleObjectProperty<>();
// Those are needed for the addressTextField // Those are needed for the addressTextField
final ObjectProperty<Coin> totalToPayAsCoin = new SimpleObjectProperty<>(); public final ObjectProperty<Coin> totalToPayAsCoin = new SimpleObjectProperty<>();
final ObjectProperty<Address> address = new SimpleObjectProperty<>(); public final ObjectProperty<Address> address = new SimpleObjectProperty<>();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// non private for testing
@Inject @Inject
CreateOfferPM(CreateOfferModel model) { CreateOfferPM(CreateOfferModel model) {
super(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<CreateOfferModel> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// setOrderBookFilter is a one time call // setOrderBookFilter is a one time call
void setOrderBookFilter(@NotNull OrderBookFilter orderBookFilter) { public void setOrderBookFilter(@NotNull OrderBookFilter orderBookFilter) {
model.setDirection(orderBookFilter.getDirection()); model.setDirection(orderBookFilter.getDirection());
directionLabel.set(model.getDirection() == Direction.BUY ? BSResources.get("shared.buy") : BSResources.get directionLabel.set(model.getDirection() == Direction.BUY ? BSResources.get("shared.buy") : BSResources.get
("shared.sell")); ("shared.sell"));
@ -173,7 +176,7 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
// UI actions (called by CB) // UI actions (called by CB)
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
void onPlaceOffer() { public void onPlaceOffer() {
model.requestPlaceOfferErrorMessage.set(null); model.requestPlaceOfferErrorMessage.set(null);
model.requestPlaceOfferSuccess.set(false); model.requestPlaceOfferSuccess.set(false);
@ -192,7 +195,7 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
} }
// On focus out we do validation and apply the data to the model // 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) { if (oldValue && !newValue) {
InputValidator.ValidationResult result = isBtcInputValid(amount.get()); InputValidator.ValidationResult result = isBtcInputValid(amount.get());
amountValidationResult.set(result); amountValidationResult.set(result);
@ -219,7 +222,7 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
} }
} }
void onFocusOutMinAmountTextField(Boolean oldValue, Boolean newValue, String userInput) { public void onFocusOutMinAmountTextField(Boolean oldValue, Boolean newValue, String userInput) {
if (oldValue && !newValue) { if (oldValue && !newValue) {
InputValidator.ValidationResult result = isBtcInputValid(minAmount.get()); InputValidator.ValidationResult result = isBtcInputValid(minAmount.get());
minAmountValidationResult.set(result); minAmountValidationResult.set(result);
@ -241,7 +244,7 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
} }
} }
void onFocusOutPriceTextField(Boolean oldValue, Boolean newValue, String userInput) { public void onFocusOutPriceTextField(Boolean oldValue, Boolean newValue, String userInput) {
if (oldValue && !newValue) { if (oldValue && !newValue) {
InputValidator.ValidationResult result = isFiatInputValid(price.get()); InputValidator.ValidationResult result = isFiatInputValid(price.get());
boolean isValid = result.isValid; boolean isValid = result.isValid;
@ -256,7 +259,7 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
} }
} }
void onFocusOutVolumeTextField(Boolean oldValue, Boolean newValue, String userInput) { public void onFocusOutVolumeTextField(Boolean oldValue, Boolean newValue, String userInput) {
if (oldValue && !newValue) { if (oldValue && !newValue) {
InputValidator.ValidationResult result = isBtcInputValid(volume.get()); InputValidator.ValidationResult result = isBtcInputValid(volume.get());
volumeValidationResult.set(result); volumeValidationResult.set(result);
@ -280,7 +283,7 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
// Getters (called by CB) // Getters (called by CB)
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
WalletFacade getWalletFacade() { public WalletFacade getWalletFacade() {
return model.getWalletFacade(); return model.getWalletFacade();
} }

View file

@ -20,9 +20,9 @@ package io.bitsquare.gui.trade;
import io.bitsquare.gui.CachedViewController; import io.bitsquare.gui.CachedViewController;
import io.bitsquare.gui.NavigationItem; import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.components.InputTextField; 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.orderbook.OrderBookController;
import io.bitsquare.gui.trade.takeoffer.TakeOfferController; import io.bitsquare.gui.trade.takeoffer.TakeOfferController;
import io.bitsquare.gui.view.trade.CreateOfferCB;
import io.bitsquare.trade.Direction; import io.bitsquare.trade.Direction;
import io.bitsquare.util.BSFXMLLoader; import io.bitsquare.util.BSFXMLLoader;

View file

@ -25,10 +25,10 @@ import io.bitsquare.gui.MainController;
import io.bitsquare.gui.NavigationItem; import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.ViewController; import io.bitsquare.gui.ViewController;
import io.bitsquare.gui.components.Popups; import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.trade.createoffer.CreateOfferCB;
import io.bitsquare.gui.trade.takeoffer.TakeOfferController; import io.bitsquare.gui.trade.takeoffer.TakeOfferController;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.gui.view.trade.CreateOfferCB;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import io.bitsquare.locale.CurrencyUtil; import io.bitsquare.locale.CurrencyUtil;

View file

@ -22,6 +22,7 @@ import io.bitsquare.gui.CodeBehind;
import io.bitsquare.gui.NavigationItem; import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.PresentationModel; import io.bitsquare.gui.PresentationModel;
import io.bitsquare.gui.pm.account.AccountSettingsPM; import io.bitsquare.gui.pm.account.AccountSettingsPM;
import io.bitsquare.gui.view.account.content.AdjustableAccountContent;
import io.bitsquare.util.BSFXMLLoader; import io.bitsquare.util.BSFXMLLoader;
import java.io.IOException; import java.io.IOException;
@ -195,6 +196,7 @@ class MenuItem extends ToggleButton {
((AnchorPane) content).getChildren().setAll(view); ((AnchorPane) content).getChildren().setAll(view);
childController = loader.getController(); childController = loader.getController();
childController.setParentController(parentCB); childController.setParentController(parentCB);
((AdjustableAccountContent) childController).isSettingsMode(true);
} catch (IOException e) { } catch (IOException e) {
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl()); log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
e.getStackTrace(); e.getStackTrace();

View file

@ -24,6 +24,7 @@ import io.bitsquare.gui.PresentationModel;
import io.bitsquare.gui.pm.account.AccountSetupPM; import io.bitsquare.gui.pm.account.AccountSetupPM;
import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.gui.view.AccountCB; 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.FiatAccountCB;
import io.bitsquare.gui.view.account.content.PasswordCB; import io.bitsquare.gui.view.account.content.PasswordCB;
import io.bitsquare.gui.view.account.content.RegistrationCB; import io.bitsquare.gui.view.account.content.RegistrationCB;
@ -247,6 +248,7 @@ class WizardItem extends HBox {
((AnchorPane) content).getChildren().setAll(view); ((AnchorPane) content).getChildren().setAll(view);
childController = loader.getController(); childController = loader.getController();
childController.setParentController(parentCB); childController.setParentController(parentCB);
((AdjustableAccountContent) childController).isSettingsMode(false);
} catch (IOException e) { } catch (IOException e) {
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl()); log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
e.getStackTrace(); e.getStackTrace();

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.view.account.content;
public interface AdjustableAccountContent {
void isSettingsMode(boolean isSettingsMode);
}

View file

@ -21,7 +21,6 @@ import io.bitsquare.gui.CachedCodeBehind;
import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.ChangePasswordPM; import io.bitsquare.gui.pm.account.content.ChangePasswordPM;
import io.bitsquare.gui.view.account.AccountSettingsCB;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.account.AccountSetupCB;
import java.net.URL; import java.net.URL;
@ -31,14 +30,13 @@ import java.util.ResourceBundle;
import javax.inject.Inject; import javax.inject.Inject;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ChangePasswordCB extends CachedCodeBehind<ChangePasswordPM> { public class ChangePasswordCB extends CachedCodeBehind<ChangePasswordPM> implements AdjustableAccountContent {
private static final Logger log = LoggerFactory.getLogger(ChangePasswordCB.class); private static final Logger log = LoggerFactory.getLogger(ChangePasswordCB.class);
@ -91,17 +89,16 @@ public class ChangePasswordCB extends CachedCodeBehind<ChangePasswordPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Override from CodeBehind // Override
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void setParentController(Initializable parentController) { public void isSettingsMode(boolean isSettingsMode) {
super.setParentController(parentController); if (isSettingsMode)
if (parentController instanceof AccountSettingsCB) {
buttonsHBox.getChildren().remove(skipButton); buttonsHBox.getChildren().remove(skipButton);
}
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// UI handlers // UI handlers
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -26,7 +26,6 @@ import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.FiatAccountPm; import io.bitsquare.gui.pm.account.content.FiatAccountPm;
import io.bitsquare.gui.util.validation.InputValidator; import io.bitsquare.gui.util.validation.InputValidator;
import io.bitsquare.gui.view.account.AccountSettingsCB;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.account.AccountSetupCB;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import io.bitsquare.locale.Region; import io.bitsquare.locale.Region;
@ -42,7 +41,6 @@ import javax.inject.Inject;
import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.*; import javafx.scene.layout.*;
@ -54,7 +52,7 @@ import org.slf4j.LoggerFactory;
import static javafx.beans.binding.Bindings.createBooleanBinding; import static javafx.beans.binding.Bindings.createBooleanBinding;
public class FiatAccountCB extends CachedCodeBehind<FiatAccountPm> { public class FiatAccountCB extends CachedCodeBehind<FiatAccountPm> implements AdjustableAccountContent {
private static final Logger log = LoggerFactory.getLogger(FiatAccountCB.class); private static final Logger log = LoggerFactory.getLogger(FiatAccountCB.class);
@ -124,15 +122,13 @@ public class FiatAccountCB extends CachedCodeBehind<FiatAccountPm> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Override from CodeBehind // Override
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void setParentController(Initializable parentController) { public void isSettingsMode(boolean isSettingsMode) {
super.setParentController(parentController); if (isSettingsMode)
if (parentController instanceof AccountSettingsCB) {
buttonsHBox.getChildren().remove(completedButton); buttonsHBox.getChildren().remove(completedButton);
}
} }

View file

@ -21,7 +21,6 @@ import io.bitsquare.gui.CachedCodeBehind;
import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.PasswordPM; import io.bitsquare.gui.pm.account.content.PasswordPM;
import io.bitsquare.gui.view.account.AccountSettingsCB;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.account.AccountSetupCB;
import java.net.URL; import java.net.URL;
@ -31,14 +30,13 @@ import java.util.ResourceBundle;
import javax.inject.Inject; import javax.inject.Inject;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class PasswordCB extends CachedCodeBehind<PasswordPM> { public class PasswordCB extends CachedCodeBehind<PasswordPM> implements AdjustableAccountContent {
private static final Logger log = LoggerFactory.getLogger(PasswordCB.class); private static final Logger log = LoggerFactory.getLogger(PasswordCB.class);
@ -91,15 +89,13 @@ public class PasswordCB extends CachedCodeBehind<PasswordPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Override from CodeBehind // Override
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void setParentController(Initializable parentController) { public void isSettingsMode(boolean isSettingsMode) {
super.setParentController(parentController); if (isSettingsMode)
if (parentController instanceof AccountSettingsCB) {
buttonsHBox.getChildren().remove(skipButton); buttonsHBox.getChildren().remove(skipButton);
}
} }

View file

@ -25,7 +25,6 @@ import io.bitsquare.gui.components.btc.BalanceTextField;
import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.RegistrationPM; 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.gui.view.account.AccountSetupCB;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
@ -39,7 +38,6 @@ import javax.inject.Inject;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.input.*; import javafx.scene.input.*;
@ -50,7 +48,7 @@ import org.controlsfx.dialog.Dialog;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class RegistrationCB extends CachedCodeBehind<RegistrationPM> { public class RegistrationCB extends CachedCodeBehind<RegistrationPM> implements AdjustableAccountContent {
private static final Logger log = LoggerFactory.getLogger(RegistrationCB.class); private static final Logger log = LoggerFactory.getLogger(RegistrationCB.class);
@ -153,18 +151,17 @@ public class RegistrationCB extends CachedCodeBehind<RegistrationPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Override from CodeBehind // Override
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void setParentController(Initializable parentController) { public void isSettingsMode(boolean isSettingsMode) {
super.setParentController(parentController); if (isSettingsMode) {
if (parentController instanceof AccountSettingsCB) { // TODO
//TODO
// ((GridPane) root).getChildren().remove(completedButton);
} }
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// UI handlers // UI handlers
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -25,7 +25,6 @@ import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.RestrictionsPM; import io.bitsquare.gui.pm.account.content.RestrictionsPM;
import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.gui.view.account.AccountSettingsCB;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.account.AccountSetupCB;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import io.bitsquare.locale.Region; import io.bitsquare.locale.Region;
@ -54,7 +53,7 @@ import javafx.util.StringConverter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class RestrictionsCB extends CachedCodeBehind<RestrictionsPM> { public class RestrictionsCB extends CachedCodeBehind<RestrictionsPM> implements AdjustableAccountContent {
private static final Logger log = LoggerFactory.getLogger(RestrictionsCB.class); private static final Logger log = LoggerFactory.getLogger(RestrictionsCB.class);
@ -113,15 +112,13 @@ public class RestrictionsCB extends CachedCodeBehind<RestrictionsPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Override from CodeBehind // Override
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void setParentController(Initializable parentController) { public void isSettingsMode(boolean isSettingsMode) {
super.setParentController(parentController); if (isSettingsMode)
if (parentController instanceof AccountSettingsCB) {
((GridPane) root).getChildren().remove(completedButton); ((GridPane) root).getChildren().remove(completedButton);
}
} }

View file

@ -21,7 +21,6 @@ import io.bitsquare.gui.CachedCodeBehind;
import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.SeedWordsPM; import io.bitsquare.gui.pm.account.content.SeedWordsPM;
import io.bitsquare.gui.view.account.AccountSettingsCB;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.account.AccountSetupCB;
import java.net.URL; import java.net.URL;
@ -31,14 +30,13 @@ import java.util.ResourceBundle;
import javax.inject.Inject; import javax.inject.Inject;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class SeedWordsCB extends CachedCodeBehind<SeedWordsPM> { public class SeedWordsCB extends CachedCodeBehind<SeedWordsPM> implements AdjustableAccountContent {
private static final Logger log = LoggerFactory.getLogger(SeedWordsCB.class); private static final Logger log = LoggerFactory.getLogger(SeedWordsCB.class);
@ -87,15 +85,13 @@ public class SeedWordsCB extends CachedCodeBehind<SeedWordsPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Override from CodeBehind // Override
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void setParentController(Initializable parentController) { public void isSettingsMode(boolean isSettingsMode) {
super.setParentController(parentController); if (isSettingsMode)
if (parentController instanceof AccountSettingsCB) {
((GridPane) root).getChildren().remove(completedButton); ((GridPane) root).getChildren().remove(completedButton);
}
} }

View file

@ -15,7 +15,7 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>. * along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/ */
package io.bitsquare.gui.trade.createoffer; package io.bitsquare.gui.view.trade;
import io.bitsquare.gui.CachedCodeBehind; import io.bitsquare.gui.CachedCodeBehind;
import io.bitsquare.gui.MainController; 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.components.btc.BalanceTextField;
import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.trade.CreateOfferPM;
import io.bitsquare.gui.trade.TradeController; import io.bitsquare.gui.trade.TradeController;
import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;

View file

@ -26,7 +26,7 @@
<?import javafx.scene.image.*?> <?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.*?>
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.trade.createoffer.CreateOfferCB" <AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.view.trade.CreateOfferCB"
AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0"
AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">

View file

@ -18,7 +18,7 @@
package io.bitsquare; package io.bitsquare;
import io.bitsquare.btc.RestrictionsTest; 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.BSFormatterTest;
import io.bitsquare.gui.util.BitSquareConverterTest; import io.bitsquare.gui.util.BitSquareConverterTest;
import io.bitsquare.gui.util.BitSquareNumberValidatorTest; import io.bitsquare.gui.util.BitSquareNumberValidatorTest;

View file

@ -15,9 +15,10 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>. * along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/ */
package io.bitsquare.gui.trade.createoffer; package io.bitsquare.gui.pm.trade;
import io.bitsquare.bank.BankAccountType; import io.bitsquare.bank.BankAccountType;
import io.bitsquare.gui.model.trade.CreateOfferModel;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;

View file

@ -68,7 +68,7 @@ public class CreateOfferUITestRunner extends Application {
log.debug("re load"); log.debug("re load");
pane.getChildren().removeAll(); pane.getChildren().removeAll();
BSFXMLLoader loader = new BSFXMLLoader( BSFXMLLoader loader = new BSFXMLLoader(
getUrl("/io/bitsquare/gui/trade/createoffer/CreateOfferView.fxml"), false); getUrl("/io/bitsquare/gui/view/trade/CreateOfferView.fxml"), false);
try { try {
view = loader.load(); view = loader.load();
pane.getChildren().setAll(view); pane.getChildren().setAll(view);