mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Use DI for validators, add @Deprecated/TODOs,
This commit is contained in:
parent
964c4ada9e
commit
bd5f8d0020
@ -26,7 +26,11 @@ import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.OverlayController;
|
||||
import io.bitsquare.gui.main.trade.orderbook.OrderBook;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.validation.BankAccountNumberValidator;
|
||||
import io.bitsquare.gui.util.validation.BtcValidator;
|
||||
import io.bitsquare.gui.util.validation.FiatValidator;
|
||||
import io.bitsquare.gui.util.validation.InputValidator;
|
||||
import io.bitsquare.gui.util.validation.PasswordValidator;
|
||||
import io.bitsquare.msg.BootstrappedPeerFactory;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.P2PNode;
|
||||
@ -70,7 +74,12 @@ public class BitSquareModule extends AbstractModule {
|
||||
bind(NavigationController.class).asEagerSingleton();
|
||||
bind(OverlayController.class).asEagerSingleton();
|
||||
bind(BSFormatter.class).asEagerSingleton();
|
||||
|
||||
bind(BankAccountNumberValidator.class).asEagerSingleton();
|
||||
bind(BtcValidator.class).asEagerSingleton();
|
||||
bind(FiatValidator.class).asEagerSingleton();
|
||||
bind(InputValidator.class).asEagerSingleton();
|
||||
bind(PasswordValidator.class).asEagerSingleton();
|
||||
|
||||
|
||||
//bind(String.class).annotatedWith(Names.named("networkType")).toInstance(WalletFacade.MAIN_NET);
|
||||
|
@ -12,10 +12,10 @@ import org.slf4j.LoggerFactory;
|
||||
* active and awake it at reactivation.
|
||||
* * @param <T> The PresentationModel used in that class
|
||||
*/
|
||||
public class CachedCodeBehind<T extends PresentationModel> extends CodeBehind<T> {
|
||||
private static final Logger log = LoggerFactory.getLogger(CachedCodeBehind.class);
|
||||
public class CachedViewCB<T extends PresentationModel> extends ViewCB<T> {
|
||||
private static final Logger log = LoggerFactory.getLogger(CachedViewCB.class);
|
||||
|
||||
public CachedCodeBehind(T presentationModel) {
|
||||
public CachedViewCB(T presentationModel) {
|
||||
super(presentationModel);
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ public class CachedCodeBehind<T extends PresentationModel> extends CodeBehind<T>
|
||||
*/
|
||||
public void activate() {
|
||||
log.trace("Lifecycle: activate " + this.getClass().getSimpleName());
|
||||
if (childController instanceof CachedCodeBehind) ((CachedCodeBehind) childController).activate();
|
||||
if (childController instanceof CachedViewCB) ((CachedViewCB) childController).activate();
|
||||
|
||||
presentationModel.activate();
|
||||
}
|
||||
@ -57,7 +57,7 @@ public class CachedCodeBehind<T extends PresentationModel> extends CodeBehind<T>
|
||||
*/
|
||||
public void deactivate() {
|
||||
log.trace("Lifecycle: deactivate " + this.getClass().getSimpleName());
|
||||
if (childController instanceof CachedCodeBehind) ((CachedCodeBehind) childController).deactivate();
|
||||
if (childController instanceof CachedViewCB) ((CachedViewCB) childController).deactivate();
|
||||
|
||||
presentationModel.deactivate();
|
||||
}
|
@ -16,8 +16,8 @@ import org.slf4j.LoggerFactory;
|
||||
*
|
||||
* @param <T> The PresentationModel used in that class
|
||||
*/
|
||||
public class CodeBehind<T extends PresentationModel> implements Initializable {
|
||||
private static final Logger log = LoggerFactory.getLogger(CodeBehind.class);
|
||||
public class ViewCB<T extends PresentationModel> implements Initializable {
|
||||
private static final Logger log = LoggerFactory.getLogger(ViewCB.class);
|
||||
|
||||
protected T presentationModel;
|
||||
//TODO Initializable has to be changed to CodeBehind<? extends PresentationModel> when all UIs are updated
|
||||
@ -26,11 +26,11 @@ public class CodeBehind<T extends PresentationModel> implements Initializable {
|
||||
protected Initializable parentController;
|
||||
@FXML protected Parent root;
|
||||
|
||||
public CodeBehind(T presentationModel) {
|
||||
public ViewCB(T presentationModel) {
|
||||
this.presentationModel = presentationModel;
|
||||
}
|
||||
|
||||
public CodeBehind() {
|
||||
public ViewCB() {
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +61,7 @@ public class CodeBehind<T extends PresentationModel> implements Initializable {
|
||||
public void terminate() {
|
||||
log.trace("Lifecycle: terminate " + this.getClass().getSimpleName());
|
||||
if (childController != null)
|
||||
((CodeBehind<? extends PresentationModel>) childController).terminate();
|
||||
((ViewCB<? extends PresentationModel>) childController).terminate();
|
||||
|
||||
presentationModel.deactivate();
|
||||
presentationModel.terminate();
|
@ -67,8 +67,8 @@ public abstract class ViewController implements Initializable {
|
||||
if (childController != null) {
|
||||
if (childController instanceof ViewController)
|
||||
((ViewController) childController).terminate();
|
||||
else if (childController instanceof CodeBehind)
|
||||
((CodeBehind) childController).terminate();
|
||||
else if (childController instanceof ViewCB)
|
||||
((ViewCB) childController).terminate();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ import javafx.scene.control.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
// TODO refactor
|
||||
// TODO in new design not used anymore
|
||||
@Deprecated
|
||||
public class ConfidenceDisplay {
|
||||
private static final Logger log = LoggerFactory.getLogger(ConfidenceDisplay.class);
|
||||
|
||||
|
@ -20,6 +20,8 @@ package io.bitsquare.gui.components;
|
||||
|
||||
import javafx.scene.layout.*;
|
||||
|
||||
// TODO remove and use margin or padding instead
|
||||
@Deprecated
|
||||
public class HSpacer extends Pane {
|
||||
public HSpacer() {
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ package io.bitsquare.gui.components;
|
||||
|
||||
import javafx.scene.layout.*;
|
||||
|
||||
// TODO remove and use margin or padding instead
|
||||
@Deprecated
|
||||
public class VSpacer extends Pane {
|
||||
public VSpacer() {
|
||||
}
|
||||
|
@ -19,10 +19,10 @@ package io.bitsquare.gui.main;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.gui.AWTSystemTray;
|
||||
import io.bitsquare.gui.CodeBehind;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.OverlayController;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.components.NetworkSyncPane;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
@ -51,7 +51,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class MainViewCB extends CodeBehind<MainPM> {
|
||||
public class MainViewCB extends ViewCB<MainPM> {
|
||||
private static final Logger log = LoggerFactory.getLogger(MainViewCB.class);
|
||||
|
||||
private NavigationController navigationController;
|
||||
@ -185,8 +185,8 @@ public class MainViewCB extends CodeBehind<MainPM> {
|
||||
contentContainer.getChildren().setAll(view);
|
||||
childController = loader.getController();
|
||||
|
||||
if (childController instanceof CodeBehind)
|
||||
((CodeBehind) childController).setParentController(this);
|
||||
if (childController instanceof ViewCB)
|
||||
((ViewCB) childController).setParentController(this);
|
||||
|
||||
presentationModel.setSelectedNavigationItem(navigationItem);
|
||||
return childController;
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
package io.bitsquare.gui.main.account;
|
||||
|
||||
import io.bitsquare.gui.CachedCodeBehind;
|
||||
import io.bitsquare.gui.CodeBehind;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.main.account.setup.AccountSetupViewCB;
|
||||
import io.bitsquare.util.BSFXMLLoader;
|
||||
|
||||
@ -39,7 +39,7 @@ import javafx.scene.layout.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class AccountViewCB extends CachedCodeBehind<AccountPM> {
|
||||
public class AccountViewCB extends CachedViewCB<AccountPM> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AccountViewCB.class);
|
||||
|
||||
@ -110,7 +110,7 @@ public class AccountViewCB extends CachedCodeBehind<AccountPM> {
|
||||
Pane view = loader.load();
|
||||
tab.setContent(view);
|
||||
Initializable childController = loader.getController();
|
||||
((CodeBehind) childController).setParentController(this);
|
||||
((ViewCB) childController).setParentController(this);
|
||||
|
||||
if (childController instanceof AccountSetupViewCB)
|
||||
((AccountSetupViewCB) childController).setRemoveCallBack(() -> {
|
||||
|
@ -17,9 +17,9 @@
|
||||
|
||||
package io.bitsquare.gui.main.account;
|
||||
|
||||
import io.bitsquare.gui.CodeBehind;
|
||||
import io.bitsquare.gui.PresentationModel;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
|
||||
public interface MultiStepNavigation {
|
||||
void nextStep(CodeBehind<? extends PresentationModel> useSettingsContext);
|
||||
void nextStep(ViewCB<? extends PresentationModel> useSettingsContext);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
|
||||
public class ChangePasswordPM extends PresentationModel<ChangePasswordModel> {
|
||||
private static final Logger log = LoggerFactory.getLogger(ChangePasswordPM.class);
|
||||
|
||||
private final PasswordValidator passwordValidator = new PasswordValidator();
|
||||
private final PasswordValidator passwordValidator;
|
||||
|
||||
private String errorMessage;
|
||||
|
||||
@ -48,8 +48,9 @@ public class ChangePasswordPM extends PresentationModel<ChangePasswordModel> {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private ChangePasswordPM(ChangePasswordModel model) {
|
||||
private ChangePasswordPM(ChangePasswordModel model, PasswordValidator passwordValidator) {
|
||||
super(model);
|
||||
this.passwordValidator = passwordValidator;
|
||||
|
||||
passwordField.addListener((ov) -> saveButtonDisabled.set(!validate()));
|
||||
repeatedPasswordField.addListener((ov) -> saveButtonDisabled.set(!validate()));
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package io.bitsquare.gui.main.account.content.changepassword;
|
||||
|
||||
import io.bitsquare.gui.CachedCodeBehind;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
import io.bitsquare.gui.main.help.Help;
|
||||
@ -36,7 +36,7 @@ import javafx.scene.layout.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ChangePasswordViewCB extends CachedCodeBehind<ChangePasswordPM> implements ContextAware {
|
||||
public class ChangePasswordViewCB extends CachedViewCB<ChangePasswordPM> implements ContextAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ChangePasswordViewCB.class);
|
||||
|
||||
|
@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory;
|
||||
public class FiatAccountPm extends PresentationModel<FiatAccountModel> {
|
||||
private static final Logger log = LoggerFactory.getLogger(FiatAccountPm.class);
|
||||
|
||||
private final BankAccountNumberValidator validator = new BankAccountNumberValidator();
|
||||
private final BankAccountNumberValidator bankAccountNumberValidator;
|
||||
|
||||
public final StringProperty title = new SimpleStringProperty();
|
||||
public final StringProperty holderName = new SimpleStringProperty();
|
||||
@ -67,8 +67,9 @@ public class FiatAccountPm extends PresentationModel<FiatAccountModel> {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private FiatAccountPm(FiatAccountModel model) {
|
||||
private FiatAccountPm(FiatAccountModel model, BankAccountNumberValidator bankAccountNumberValidator) {
|
||||
super(model);
|
||||
this.bankAccountNumberValidator = bankAccountNumberValidator;
|
||||
}
|
||||
|
||||
|
||||
@ -264,8 +265,8 @@ public class FiatAccountPm extends PresentationModel<FiatAccountModel> {
|
||||
return model.getAllCountriesFor(selectedRegion);
|
||||
}
|
||||
|
||||
public BankAccountNumberValidator getValidator() {
|
||||
return validator;
|
||||
public BankAccountNumberValidator getBankAccountNumberValidator() {
|
||||
return bankAccountNumberValidator;
|
||||
}
|
||||
|
||||
|
||||
@ -294,13 +295,13 @@ public class FiatAccountPm extends PresentationModel<FiatAccountModel> {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private InputValidator.ValidationResult validateInput() {
|
||||
InputValidator.ValidationResult result = validator.validate(model.title.get());
|
||||
InputValidator.ValidationResult result = bankAccountNumberValidator.validate(model.title.get());
|
||||
if (result.isValid) {
|
||||
result = validator.validate(model.holderName.get());
|
||||
result = bankAccountNumberValidator.validate(model.holderName.get());
|
||||
if (result.isValid) {
|
||||
result = validator.validate(model.primaryID.get());
|
||||
result = bankAccountNumberValidator.validate(model.primaryID.get());
|
||||
if (result.isValid) {
|
||||
result = validator.validate(model.secondaryID.get());
|
||||
result = bankAccountNumberValidator.validate(model.secondaryID.get());
|
||||
if (result.isValid) {
|
||||
if (model.currency.get() == null)
|
||||
result = new InputValidator.ValidationResult(false,
|
||||
|
@ -19,7 +19,7 @@ package io.bitsquare.gui.main.account.content.fiat;
|
||||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.gui.CachedCodeBehind;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.components.InputTextField;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
@ -52,7 +52,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import static javafx.beans.binding.Bindings.createBooleanBinding;
|
||||
|
||||
public class FiatAccountViewCB extends CachedCodeBehind<FiatAccountPm> implements ContextAware {
|
||||
public class FiatAccountViewCB extends CachedViewCB<FiatAccountPm> implements ContextAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FiatAccountViewCB.class);
|
||||
|
||||
@ -94,10 +94,10 @@ public class FiatAccountViewCB extends CachedCodeBehind<FiatAccountPm> implement
|
||||
regionComboBox.setConverter(presentationModel.getRegionConverter());
|
||||
countryComboBox.setConverter(presentationModel.getCountryConverter());
|
||||
|
||||
titleTextField.setValidator(presentationModel.getValidator());
|
||||
holderNameTextField.setValidator(presentationModel.getValidator());
|
||||
primaryIDTextField.setValidator(presentationModel.getValidator());
|
||||
secondaryIDTextField.setValidator(presentationModel.getValidator());
|
||||
titleTextField.setValidator(presentationModel.getBankAccountNumberValidator());
|
||||
holderNameTextField.setValidator(presentationModel.getBankAccountNumberValidator());
|
||||
primaryIDTextField.setValidator(presentationModel.getBankAccountNumberValidator());
|
||||
secondaryIDTextField.setValidator(presentationModel.getBankAccountNumberValidator());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
|
||||
public class PasswordPM extends PresentationModel<PasswordModel> {
|
||||
private static final Logger log = LoggerFactory.getLogger(PasswordPM.class);
|
||||
|
||||
private final PasswordValidator passwordValidator = new PasswordValidator();
|
||||
private final PasswordValidator passwordValidator;
|
||||
|
||||
private String errorMessage;
|
||||
|
||||
@ -48,8 +48,9 @@ public class PasswordPM extends PresentationModel<PasswordModel> {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private PasswordPM(PasswordModel model) {
|
||||
private PasswordPM(PasswordModel model, PasswordValidator passwordValidator) {
|
||||
super(model);
|
||||
this.passwordValidator = passwordValidator;
|
||||
|
||||
passwordField.addListener((ov) -> saveButtonDisabled.set(!validate()));
|
||||
repeatedPasswordField.addListener((ov) -> saveButtonDisabled.set(!validate()));
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package io.bitsquare.gui.main.account.content.password;
|
||||
|
||||
import io.bitsquare.gui.CachedCodeBehind;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
import io.bitsquare.gui.main.help.Help;
|
||||
@ -36,7 +36,7 @@ import javafx.scene.layout.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PasswordViewCB extends CachedCodeBehind<PasswordPM> implements ContextAware {
|
||||
public class PasswordViewCB extends CachedViewCB<PasswordPM> implements ContextAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PasswordViewCB.class);
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package io.bitsquare.gui.main.account.content.registration;
|
||||
|
||||
import io.bitsquare.gui.CachedCodeBehind;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.OverlayController;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.components.btc.AddressTextField;
|
||||
@ -48,7 +48,7 @@ import org.controlsfx.dialog.Dialog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RegistrationViewCB extends CachedCodeBehind<RegistrationPM> implements ContextAware {
|
||||
public class RegistrationViewCB extends CachedViewCB<RegistrationPM> implements ContextAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RegistrationViewCB.class);
|
||||
|
||||
|
@ -19,7 +19,7 @@ package io.bitsquare.gui.main.account.content.restrictions;
|
||||
|
||||
import io.bitsquare.BitSquare;
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.gui.CachedCodeBehind;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
@ -53,7 +53,7 @@ import javafx.util.StringConverter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RestrictionsViewCB extends CachedCodeBehind<RestrictionsPM> implements ContextAware {
|
||||
public class RestrictionsViewCB extends CachedViewCB<RestrictionsPM> implements ContextAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RestrictionsViewCB.class);
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package io.bitsquare.gui.main.account.content.seedwords;
|
||||
|
||||
import io.bitsquare.gui.CachedCodeBehind;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
import io.bitsquare.gui.main.help.Help;
|
||||
@ -36,7 +36,7 @@ import javafx.scene.layout.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SeedWordsViewCB extends CachedCodeBehind<SeedWordsPM> implements ContextAware {
|
||||
public class SeedWordsViewCB extends CachedViewCB<SeedWordsPM> implements ContextAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SeedWordsViewCB.class);
|
||||
|
||||
|
@ -17,11 +17,11 @@
|
||||
|
||||
package io.bitsquare.gui.main.account.settings;
|
||||
|
||||
import io.bitsquare.gui.CachedCodeBehind;
|
||||
import io.bitsquare.gui.CodeBehind;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.PresentationModel;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
import io.bitsquare.util.BSFXMLLoader;
|
||||
|
||||
@ -46,7 +46,7 @@ import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class AccountSettingsViewCB extends CachedCodeBehind<AccountSettingsPM> {
|
||||
public class AccountSettingsViewCB extends CachedViewCB<AccountSettingsPM> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AccountSettingsViewCB.class);
|
||||
|
||||
@ -160,7 +160,7 @@ public class AccountSettingsViewCB extends CachedCodeBehind<AccountSettingsPM> {
|
||||
final Pane view = loader.load();
|
||||
content.getChildren().setAll(view);
|
||||
childController = loader.getController();
|
||||
((CodeBehind<? extends PresentationModel>) childController).setParentController(this);
|
||||
((ViewCB<? extends PresentationModel>) childController).setParentController(this);
|
||||
((ContextAware) childController).useSettingsContext(true);
|
||||
return childController;
|
||||
} catch (IOException e) {
|
||||
@ -174,7 +174,7 @@ public class AccountSettingsViewCB extends CachedCodeBehind<AccountSettingsPM> {
|
||||
class MenuItem extends ToggleButton {
|
||||
private static final Logger log = LoggerFactory.getLogger(MenuItem.class);
|
||||
|
||||
private CodeBehind<? extends PresentationModel> childController;
|
||||
private ViewCB<? extends PresentationModel> childController;
|
||||
|
||||
private final AccountSettingsViewCB parentCB;
|
||||
private final Parent content;
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
package io.bitsquare.gui.main.account.setup;
|
||||
|
||||
import io.bitsquare.gui.CachedCodeBehind;
|
||||
import io.bitsquare.gui.CodeBehind;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.PresentationModel;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
import io.bitsquare.gui.main.account.content.fiat.FiatAccountViewCB;
|
||||
@ -51,7 +51,7 @@ import javafx.scene.layout.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class AccountSetupViewCB extends CachedCodeBehind<AccountSetupPM> implements MultiStepNavigation {
|
||||
public class AccountSetupViewCB extends CachedViewCB<AccountSetupPM> implements MultiStepNavigation {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AccountSetupViewCB.class);
|
||||
|
||||
@ -122,7 +122,7 @@ public class AccountSetupViewCB extends CachedCodeBehind<AccountSetupPM> impleme
|
||||
// UI handlers
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void nextStep(CodeBehind<? extends PresentationModel> childView) {
|
||||
public void nextStep(ViewCB<? extends PresentationModel> childView) {
|
||||
if (childView instanceof SeedWordsViewCB) {
|
||||
seedWords.onCompleted();
|
||||
childController = password.show();
|
||||
@ -170,7 +170,7 @@ public class AccountSetupViewCB extends CachedCodeBehind<AccountSetupPM> impleme
|
||||
final Pane view = loader.load();
|
||||
content.getChildren().setAll(view);
|
||||
childController = loader.getController();
|
||||
((CodeBehind<? extends PresentationModel>) childController).setParentController(this);
|
||||
((ViewCB<? extends PresentationModel>) childController).setParentController(this);
|
||||
((ContextAware) childController).useSettingsContext(false);
|
||||
return childController;
|
||||
} catch (IOException e) {
|
||||
@ -184,7 +184,7 @@ public class AccountSetupViewCB extends CachedCodeBehind<AccountSetupPM> impleme
|
||||
class WizardItem extends HBox {
|
||||
private static final Logger log = LoggerFactory.getLogger(WizardItem.class);
|
||||
|
||||
private CodeBehind<? extends PresentationModel> childController;
|
||||
private ViewCB<? extends PresentationModel> childController;
|
||||
|
||||
private final ImageView imageView;
|
||||
private final Label titleLabel;
|
||||
@ -232,7 +232,7 @@ class WizardItem extends HBox {
|
||||
getChildren().addAll(imageView, vBox);
|
||||
}
|
||||
|
||||
CodeBehind<? extends PresentationModel> show() {
|
||||
ViewCB<? extends PresentationModel> show() {
|
||||
parentCB.loadView(navigationItem);
|
||||
setId("wizard-item-background-active");
|
||||
imageView.setImage(ImageUtil.getIconImage(ImageUtil.ARROW_BLUE));
|
||||
|
@ -52,8 +52,8 @@ import static javafx.beans.binding.Bindings.createStringBinding;
|
||||
public class CreateOfferPM extends PresentationModel<CreateOfferModel> {
|
||||
private static final Logger log = LoggerFactory.getLogger(CreateOfferPM.class);
|
||||
|
||||
private final BtcValidator btcValidator = new BtcValidator();
|
||||
private final FiatValidator fiatValidator = new FiatValidator();
|
||||
private final BtcValidator btcValidator;
|
||||
private final FiatValidator fiatValidator;
|
||||
|
||||
public final StringProperty amount = new SimpleStringProperty();
|
||||
public final StringProperty minAmount = new SimpleStringProperty();
|
||||
@ -102,8 +102,11 @@ public class CreateOfferPM extends PresentationModel<CreateOfferModel> {
|
||||
|
||||
// non private for testing
|
||||
@Inject
|
||||
CreateOfferPM(CreateOfferModel model) {
|
||||
CreateOfferPM(CreateOfferModel model, FiatValidator fiatValidator, BtcValidator btcValidator) {
|
||||
super(model);
|
||||
|
||||
this.fiatValidator = fiatValidator;
|
||||
this.btcValidator = btcValidator;
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package io.bitsquare.gui.main.trade.createoffer;
|
||||
|
||||
import io.bitsquare.gui.CachedCodeBehind;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.OverlayController;
|
||||
@ -70,7 +70,7 @@ import static javafx.beans.binding.Bindings.createStringBinding;
|
||||
// TODO Implement other positioning method in InoutTextField to display it over the field instead of right side
|
||||
// priceAmountHBox is too large after redesign as to be used as layoutReference.
|
||||
|
||||
public class CreateOfferViewCB extends CachedCodeBehind<CreateOfferPM> {
|
||||
public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
|
||||
private static final Logger log = LoggerFactory.getLogger(CreateOfferViewCB.class);
|
||||
|
||||
private NavigationController navigationController;
|
||||
|
@ -20,10 +20,10 @@ package io.bitsquare.gui.main.trade.orderbook;
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.CachedViewController;
|
||||
import io.bitsquare.gui.CodeBehind;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.OverlayController;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.ViewController;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.main.trade.OrderBookFilter;
|
||||
@ -246,8 +246,8 @@ public class OrderBookController extends CachedViewController {
|
||||
if (parentController instanceof ViewController)
|
||||
nextController = ((ViewController) parentController).loadViewAndGetChildController(NavigationItem
|
||||
.CREATE_OFFER);
|
||||
else if (parentController instanceof CodeBehind)
|
||||
nextController = ((CodeBehind) parentController).loadView(NavigationItem
|
||||
else if (parentController instanceof ViewCB)
|
||||
nextController = ((ViewCB) parentController).loadView(NavigationItem
|
||||
.CREATE_OFFER);
|
||||
}
|
||||
|
||||
@ -327,8 +327,8 @@ public class OrderBookController extends CachedViewController {
|
||||
takeOfferController = (TakeOfferController) ((ViewController) parentController)
|
||||
.loadViewAndGetChildController(NavigationItem
|
||||
.TAKE_OFFER);
|
||||
else if (parentController instanceof CodeBehind)
|
||||
takeOfferController = (TakeOfferController) ((CodeBehind) parentController)
|
||||
else if (parentController instanceof ViewCB)
|
||||
takeOfferController = (TakeOfferController) ((ViewCB) parentController)
|
||||
.loadView(NavigationItem
|
||||
.TAKE_OFFER);
|
||||
}
|
||||
|
@ -50,15 +50,18 @@ public final class FiatValidator extends NumberValidator {
|
||||
|
||||
@Inject
|
||||
public FiatValidator(User user) {
|
||||
if (user.currentBankAccountProperty().get() == null)
|
||||
setFiatCurrencyCode(Currency.getInstance(Locale.getDefault()).getCurrencyCode());
|
||||
else
|
||||
setFiatCurrencyCode(user.currentBankAccountProperty().get().getCurrency().getCurrencyCode());
|
||||
if (user != null) {
|
||||
if (user.currentBankAccountProperty().get() == null)
|
||||
setFiatCurrencyCode(Currency.getInstance(Locale.getDefault()).getCurrencyCode());
|
||||
else
|
||||
setFiatCurrencyCode(user.currentBankAccountProperty().get().getCurrency().getCurrencyCode());
|
||||
|
||||
user.currentBankAccountProperty().addListener((ov, oldValue, newValue) ->
|
||||
setFiatCurrencyCode(newValue.getCurrency().getCurrencyCode()));
|
||||
user.currentBankAccountProperty().addListener((ov, oldValue, newValue) ->
|
||||
setFiatCurrencyCode(newValue.getCurrency().getCurrencyCode()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -94,6 +94,7 @@ public class TradeManager {
|
||||
private final Map<String, Offer> offers;
|
||||
private final Map<String, Trade> trades;
|
||||
|
||||
// TODO There might be multiple pending trades
|
||||
private Trade pendingTrade;
|
||||
|
||||
|
||||
|
@ -55,6 +55,8 @@ public class BSFXMLLoader {
|
||||
this(url, true);
|
||||
}
|
||||
|
||||
// TODO check relationship with CachedViewCB -> derive caching strategy, but there are some special cases where
|
||||
// we need an override, as caching is done manually in the client class
|
||||
public BSFXMLLoader(URL url, boolean useCaching) {
|
||||
this.url = url;
|
||||
|
||||
|
@ -39,6 +39,9 @@ import javafx.animation.AnimationTimer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* General utilities
|
||||
*/
|
||||
public class Utilities {
|
||||
private static final Logger log = LoggerFactory.getLogger(Utilities.class);
|
||||
private static long lastTimeStamp = System.currentTimeMillis();
|
||||
|
@ -24,6 +24,9 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
|
||||
/**
|
||||
* Utility class for validating domain data.
|
||||
*/
|
||||
public class Validator {
|
||||
private static final Logger log = LoggerFactory.getLogger(Validator.class);
|
||||
|
||||
|
@ -8,7 +8,7 @@ import java.nio.file.Paths;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
// TODO update to open source file when its released
|
||||
// TODO update to open source file when its released, check licence issues
|
||||
|
||||
/**
|
||||
* Manages the directory where the app stores all its files.
|
||||
|
@ -22,8 +22,8 @@ import io.bitsquare.gui.main.trade.createoffer.CreateOfferPMTest;
|
||||
import io.bitsquare.gui.util.BSFormatterTest;
|
||||
import io.bitsquare.gui.util.BitSquareConverterTest;
|
||||
import io.bitsquare.gui.util.BitSquareNumberValidatorTest;
|
||||
import io.bitsquare.gui.util.BtcValidatorTest;
|
||||
import io.bitsquare.gui.util.FiatValidatorTest;
|
||||
import io.bitsquare.gui.util.validation.BtcValidatorTest;
|
||||
import io.bitsquare.gui.util.validation.FiatValidatorTest;
|
||||
import io.bitsquare.msg.P2PNodeTest;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -19,6 +19,8 @@ package io.bitsquare.gui.main.trade.createoffer;
|
||||
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.validation.BtcValidator;
|
||||
import io.bitsquare.gui.util.validation.FiatValidator;
|
||||
import io.bitsquare.locale.Country;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
@ -47,7 +49,7 @@ public class CreateOfferPMTest {
|
||||
BSFormatter.setLocale(Locale.US);
|
||||
BSFormatter.setFiatCurrencyCode("USD");
|
||||
|
||||
presenter = new CreateOfferPM(model);
|
||||
presenter = new CreateOfferPM(model, new FiatValidator(null), new BtcValidator());
|
||||
presenter.initialized();
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.util;
|
||||
|
||||
import io.bitsquare.gui.util.validation.BtcValidator;
|
||||
package io.bitsquare.gui.util.validation;
|
||||
|
||||
import com.google.bitcoin.core.Coin;
|
||||
import com.google.bitcoin.core.NetworkParameters;
|
@ -15,10 +15,7 @@
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.util;
|
||||
|
||||
import io.bitsquare.gui.util.validation.FiatValidator;
|
||||
import io.bitsquare.gui.util.validation.NumberValidator;
|
||||
package io.bitsquare.gui.util.validation;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@ -27,7 +24,7 @@ import static org.junit.Assert.*;
|
||||
public class FiatValidatorTest {
|
||||
@Test
|
||||
public void testValidate() {
|
||||
FiatValidator validator = new FiatValidator();
|
||||
FiatValidator validator = new FiatValidator(null);
|
||||
NumberValidator.ValidationResult validationResult;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user