Cleanup account UIs

This commit is contained in:
Manfred Karrer 2014-09-09 10:51:06 +02:00
parent a51aafbdbd
commit 11cff6dcdb
28 changed files with 336 additions and 245 deletions

View file

@ -27,27 +27,46 @@ import org.slf4j.LoggerFactory;
public class AccountModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(AccountModel.class);
private final User user;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private AccountModel(User user) {
this.user = user;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public methods
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialized() {
super.initialized();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
///////////////////////////////////////////////////////////////////////////////////////////
@ -58,14 +77,6 @@ public class AccountModel extends UIModel {
return user.getAccountId() == null;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
}

View file

@ -27,39 +27,42 @@ import org.slf4j.LoggerFactory;
public class AccountSettingsModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(AccountSettingsModel.class);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private AccountSettingsModel() {
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public methods
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialized() {
super.initialized();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
}

View file

@ -27,39 +27,41 @@ import org.slf4j.LoggerFactory;
public class AccountSetupModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(AccountSetupModel.class);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private AccountSetupModel() {
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public methods
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialized() {
super.initialized();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
}

View file

@ -33,7 +33,6 @@ public class ChangePasswordModel extends UIModel {
@Inject
private ChangePasswordModel() {
}

View file

@ -62,6 +62,7 @@ public class FiatAccountModel extends UIModel {
public final ObjectProperty<Country> country = new SimpleObjectProperty<>();
public final ObjectProperty<Currency> currency = new SimpleObjectProperty<>();
public final ObjectProperty<BankAccount> currentBankAccount = new SimpleObjectProperty<>();
public final ObservableList<BankAccountType> allTypes = FXCollections.observableArrayList(BankAccountType
.getAllBankAccountTypes());
public final ObservableList<BankAccount> allBankAccounts = FXCollections.observableArrayList();

View file

@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
public class PasswordModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(PasswordModel.class);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -51,12 +51,15 @@ public class RegistrationModel extends UIModel {
private final WalletFacade walletFacade;
private final User user;
private final Persistence persistence;
public AddressEntry addressEntry;
private String transactionId;
private AddressEntry addressEntry;
public final BooleanProperty isWalletFunded = new SimpleBooleanProperty();
public final BooleanProperty payFeeSuccess = new SimpleBooleanProperty();
private String transactionId;
public final StringProperty payFeeErrorMessage = new SimpleStringProperty();
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@ -80,13 +83,13 @@ public class RegistrationModel extends UIModel {
if (walletFacade != null && walletFacade.getWallet() != null) {
addressEntry = walletFacade.getRegistrationAddressEntry();
walletFacade.addBalanceListener(new BalanceListener(addressEntry.getAddress()) {
walletFacade.addBalanceListener(new BalanceListener(getAddressEntry().getAddress()) {
@Override
public void onBalanceChanged(@NotNull Coin balance) {
updateBalance(balance);
}
});
updateBalance(walletFacade.getBalanceForAddress(addressEntry.getAddress()));
updateBalance(walletFacade.getBalanceForAddress(getAddressEntry().getAddress()));
}
}
@ -122,8 +125,8 @@ public class RegistrationModel extends UIModel {
transactionId = transaction.getHashAsString();
log.info("payRegistrationFee onSuccess tx id:" + transaction.getHashAsString());
if (addressEntry != null)
user.setAccountID(addressEntry.toString());
if (getAddressEntry() != null)
user.setAccountID(getAddressEntry().toString());
persistence.write(user.getClass().getName(), user);
payFeeSuccess.set(true);
@ -160,6 +163,11 @@ public class RegistrationModel extends UIModel {
return transactionId;
}
public AddressEntry getAddressEntry() {
return addressEntry;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
@ -167,4 +175,5 @@ public class RegistrationModel extends UIModel {
private void updateBalance(@NotNull Coin balance) {
isWalletFunded.set(balance.compareTo(getFeeAsCoin()) >= 0);
}
}

View file

@ -56,7 +56,6 @@ public class RestrictionsModel extends UIModel {
public final ObservableList<Locale> languageList = FXCollections.observableArrayList();
public final ObservableList<Country> countryList = FXCollections.observableArrayList();
public final ObservableList<Arbitrator> arbitratorList = FXCollections.observableArrayList();
public final ObservableList<Locale> allLanguages = FXCollections.observableArrayList(LanguageUtil
.getAllLanguageLocales());
public final ObservableList<Region> allRegions = FXCollections.observableArrayList(CountryUtil.getAllRegions());
@ -185,6 +184,7 @@ public class RestrictionsModel extends UIModel {
persistence.write(settings);
}
// TODO Remove mock later
private void addMockArbitrator() {
if (settings.getAcceptedArbitrators().isEmpty() && user.getMessageKeyPair() != null) {
String pubKeyAsHex = Utils.HEX.encode(new ECKey().getPubKey());

View file

@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
public class SeedWordsModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(SeedWordsModel.class);
public List<String> mnemonicCode;
private List<String> mnemonicCode;
///////////////////////////////////////////////////////////////////////////////////////////
@ -43,4 +43,40 @@ public class SeedWordsModel extends UIModel {
mnemonicCode = walletFacade.getWallet().getKeyChainSeed().getMnemonicCode();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialized() {
super.initialized();
}
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getter
///////////////////////////////////////////////////////////////////////////////////////////
public List<String> getMnemonicCode() {
return mnemonicCode;
}
}

View file

@ -74,6 +74,9 @@ public class CreateOfferModel extends UIModel {
private final String offerId;
@Nullable private Direction direction = null;
private AddressEntry addressEntry;
public final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty();
public final StringProperty transactionId = new SimpleStringProperty();
public final StringProperty bankAccountCurrency = new SimpleStringProperty();
@ -101,9 +104,6 @@ public class CreateOfferModel extends UIModel {
public final ObservableList<Locale> acceptedLanguages = FXCollections.observableArrayList();
public final ObservableList<Arbitrator> acceptedArbitrators = FXCollections.observableArrayList();
@Nullable private Direction direction = null;
private AddressEntry addressEntry;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor

View file

@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
public class AccountPM extends PresentationModel<AccountModel> {
private static final Logger log = LoggerFactory.getLogger(AccountPM.class);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@ -39,13 +40,31 @@ public class AccountPM extends PresentationModel<AccountModel> {
///////////////////////////////////////////////////////////////////////////////////////////
// Public methods
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialized() {
super.initialized();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
///////////////////////////////////////////////////////////////////////////////////////////
@ -56,14 +75,4 @@ public class AccountPM extends PresentationModel<AccountModel> {
return model.getNeedRegistration();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
}

View file

@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
public class AccountSettingsPM extends PresentationModel<AccountSettingsModel> {
private static final Logger log = LoggerFactory.getLogger(AccountSettingsPM.class);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@ -39,28 +40,30 @@ public class AccountSettingsPM extends PresentationModel<AccountSettingsModel> {
///////////////////////////////////////////////////////////////////////////////////////////
// Public methods
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialized() {
super.initialized();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
}

View file

@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
public class AccountSetupPM extends PresentationModel<AccountSetupModel> {
private static final Logger log = LoggerFactory.getLogger(AccountSetupPM.class);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@ -39,28 +40,30 @@ public class AccountSetupPM extends PresentationModel<AccountSetupModel> {
///////////////////////////////////////////////////////////////////////////////////////////
// Public methods
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialized() {
super.initialized();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
}

View file

@ -38,10 +38,12 @@ public class ChangePasswordPM extends PresentationModel<ChangePasswordModel> {
private final PasswordValidator passwordValidator = new PasswordValidator();
private String errorMessage;
public final StringProperty passwordField = new SimpleStringProperty();
public final StringProperty repeatedPasswordField = new SimpleStringProperty();
public final BooleanProperty saveButtonDisabled = new SimpleBooleanProperty(true);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@ -87,7 +89,7 @@ public class ChangePasswordPM extends PresentationModel<ChangePasswordModel> {
// Public
///////////////////////////////////////////////////////////////////////////////////////////
public boolean savePassword() {
public boolean requestSavePassword() {
if (validate()) {
model.savePassword(passwordField.get());
return true;

View file

@ -58,7 +58,6 @@ public class FiatAccountPm extends PresentationModel<FiatAccountModel> {
public final StringProperty selectionPrompt = new SimpleStringProperty();
public final BooleanProperty selectionDisable = new SimpleBooleanProperty();
public final BooleanProperty saveButtonDisable = new SimpleBooleanProperty(true);
public final ObjectProperty<BankAccountType> type = new SimpleObjectProperty<>();
public final ObjectProperty<Country> country = new SimpleObjectProperty<>();
public final ObjectProperty<Currency> currency = new SimpleObjectProperty<>();
@ -136,7 +135,7 @@ public class FiatAccountPm extends PresentationModel<FiatAccountModel> {
// Public
///////////////////////////////////////////////////////////////////////////////////////////
public InputValidator.ValidationResult saveBankAccount() {
public InputValidator.ValidationResult requestSaveBankAccount() {
InputValidator.ValidationResult result = validateInput();
if (result.isValid) {
model.saveBankAccount();
@ -258,12 +257,16 @@ public class FiatAccountPm extends PresentationModel<FiatAccountModel> {
return model.allRegions;
}
public BooleanProperty getCountryNotInAcceptedCountriesList() {
return model.countryNotInAcceptedCountriesList;
}
public ObservableList<Country> getAllCountriesFor(Region selectedRegion) {
return model.getAllCountriesFor(selectedRegion);
}
public BooleanProperty getCountryNotInAcceptedCountriesList() {
return model.countryNotInAcceptedCountriesList;
public BankAccountNumberValidator getValidator() {
return validator;
}
@ -322,10 +325,4 @@ public class FiatAccountPm extends PresentationModel<FiatAccountModel> {
return result;
}
public InputValidator getValidator() {
return validator;
}
}

View file

@ -38,10 +38,12 @@ public class PasswordPM extends PresentationModel<PasswordModel> {
private final PasswordValidator passwordValidator = new PasswordValidator();
private String errorMessage;
public final StringProperty passwordField = new SimpleStringProperty();
public final StringProperty repeatedPasswordField = new SimpleStringProperty();
public final BooleanProperty saveButtonDisabled = new SimpleBooleanProperty(true);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@ -87,7 +89,7 @@ public class PasswordPM extends PresentationModel<PasswordModel> {
// Public
///////////////////////////////////////////////////////////////////////////////////////////
public boolean savePassword() {
public boolean requestSavePassword() {
if (validate()) {
model.savePassword(passwordField.get());
return true;

View file

@ -42,12 +42,13 @@ import static io.bitsquare.gui.util.BSFormatter.formatCoinWithCode;
public class RegistrationPM extends PresentationModel<RegistrationModel> {
private static final Logger log = LoggerFactory.getLogger(RegistrationPM.class);
// Those are needed for the addressTextField
public final ObjectProperty<Address> address = new SimpleObjectProperty<>();
public final BooleanProperty isPayButtonDisabled = new SimpleBooleanProperty(true);
public final StringProperty requestPlaceOfferErrorMessage = new SimpleStringProperty();
public final BooleanProperty showTransactionPublishedScreen = new SimpleBooleanProperty();
// That is needed for the addressTextField
public final ObjectProperty<Address> address = new SimpleObjectProperty<>();
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
@ -67,8 +68,8 @@ public class RegistrationPM extends PresentationModel<RegistrationModel> {
public void initialized() {
super.initialized();
if (model.addressEntry != null) {
address.set(model.addressEntry.getAddress());
if (model.getAddressEntry() != null) {
address.set(model.getAddressEntry().getAddress());
}
model.isWalletFunded.addListener((ov, oldValue, newValue) -> {
@ -103,7 +104,7 @@ public class RegistrationPM extends PresentationModel<RegistrationModel> {
///////////////////////////////////////////////////////////////////////////////////////////
// UI actions (called by CB)
// UI actions
///////////////////////////////////////////////////////////////////////////////////////////
public void payFee() {
@ -117,7 +118,7 @@ public class RegistrationPM extends PresentationModel<RegistrationModel> {
///////////////////////////////////////////////////////////////////////////////////////////
// Getters (called by CB)
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public WalletFacade getWalletFacade() {
@ -129,7 +130,7 @@ public class RegistrationPM extends PresentationModel<RegistrationModel> {
}
public String getAddressAsString() {
return model.addressEntry != null ? model.addressEntry.getAddress().toString() : "";
return model.getAddressEntry() != null ? model.getAddressEntry().getAddress().toString() : "";
}
public String getPaymentLabel() {
@ -144,6 +145,7 @@ public class RegistrationPM extends PresentationModel<RegistrationModel> {
return model.getTransactionId();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -37,8 +37,7 @@ import org.slf4j.LoggerFactory;
public class RestrictionsPM extends PresentationModel<RestrictionsModel> {
private static final Logger log = LoggerFactory.getLogger(RestrictionsPM.class);
public final BooleanProperty doneButtonDisabled = new SimpleBooleanProperty(true);
public final BooleanProperty doneButtonDisable = new SimpleBooleanProperty(true);
///////////////////////////////////////////////////////////////////////////////////////////
@ -66,7 +65,7 @@ public class RestrictionsPM extends PresentationModel<RestrictionsModel> {
public void activate() {
super.activate();
updateDoneButtonDisabled();
updateDoneButtonDisableState();
}
@SuppressWarnings("EmptyMethod")
@ -80,76 +79,80 @@ public class RestrictionsPM extends PresentationModel<RestrictionsModel> {
// Public
///////////////////////////////////////////////////////////////////////////////////////////
public void onAddLanguage(Locale locale) {
public void addLanguage(Locale locale) {
model.addLanguage(locale);
updateDoneButtonDisabled();
}
public ObservableList<Locale> getLanguageList() {
updateDoneButtonDisabled();
return model.languageList;
}
public ObservableList<Locale> getAllLanguages() {
updateDoneButtonDisabled();
return model.allLanguages;
updateDoneButtonDisableState();
}
public void removeLanguage(Locale locale) {
model.removeLanguage(locale);
updateDoneButtonDisabled();
updateDoneButtonDisableState();
}
public void onAddCountry(Country country) {
public void addCountry(Country country) {
model.addCountry(country);
updateDoneButtonDisabled();
updateDoneButtonDisableState();
}
public void removeCountry(Country country) {
model.removeCountry(country);
updateDoneButtonDisableState();
}
public void removeArbitrator(Arbitrator arbitrator) {
model.removeArbitrator(arbitrator);
updateDoneButtonDisableState();
}
public void updateArbitratorList() {
model.updateArbitratorList();
updateDoneButtonDisableState();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public ObservableList<Country> getListWithAllEuroCountries() {
ObservableList<Country> result = model.getListWithAllEuroCountries();
updateDoneButtonDisabled();
return result;
return model.getListWithAllEuroCountries();
}
public ObservableList<Country> getAllCountriesFor(Region selectedRegion) {
return model.getAllCountriesFor(selectedRegion);
}
public ObservableList<Locale> getLanguageList() {
return model.languageList;
}
public ObservableList<Region> getAllRegions() {
return model.allRegions;
}
public ObservableList<Locale> getAllLanguages() {
return model.allLanguages;
}
public ObservableList<Country> getCountryList() {
updateDoneButtonDisabled();
return model.countryList;
}
public void removeCountry(Country country) {
model.removeCountry(country);
updateDoneButtonDisabled();
}
public ObservableList<Arbitrator> getArbitratorList() {
updateDoneButtonDisabled();
return model.arbitratorList;
}
public void removeArbitrator(Arbitrator arbitrator) {
model.removeArbitrator(arbitrator);
updateDoneButtonDisabled();
}
public void updateArbitratorList() {
model.updateArbitratorList();
updateDoneButtonDisabled();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
//TODO Revert size() > -1 to 0(2 later). For mock testing disabled arbitratorList test
public void updateDoneButtonDisabled() {
private void updateDoneButtonDisableState() {
boolean isValid = model.languageList != null && model.languageList.size() > 0 &&
model.countryList != null && model.countryList.size() > 0 &&
model.arbitratorList != null && model.arbitratorList.size() > -1;
doneButtonDisabled.set(!isValid);
doneButtonDisable.set(!isValid);
}
}

View file

@ -49,12 +49,30 @@ public class SeedWordsPM extends PresentationModel<SeedWordsModel> {
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialized() {
super.initialized();
if (model.mnemonicCode != null)
seedWords.set(BSFormatter.mnemonicCodeToString(model.mnemonicCode));
if (model.getMnemonicCode() != null)
seedWords.set(BSFormatter.mnemonicCodeToString(model.getMnemonicCode()));
}
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
}

View file

@ -148,7 +148,7 @@ public class CreateOfferPM extends PresentationModel<CreateOfferModel> {
///////////////////////////////////////////////////////////////////////////////////////////
// Public API methods (called by CB)
// Public API methods
///////////////////////////////////////////////////////////////////////////////////////////
// setOrderBookFilter is a one time call
@ -171,7 +171,7 @@ public class CreateOfferPM extends PresentationModel<CreateOfferModel> {
///////////////////////////////////////////////////////////////////////////////////////////
// UI actions (called by CB)
// UI actions
///////////////////////////////////////////////////////////////////////////////////////////
public void onPlaceOffer() {
@ -185,7 +185,7 @@ public class CreateOfferPM extends PresentationModel<CreateOfferModel> {
///////////////////////////////////////////////////////////////////////////////////////////
// UI events (called by CB)
// UI events
///////////////////////////////////////////////////////////////////////////////////////////
public void onShowPayFundsScreen() {
@ -278,7 +278,7 @@ public class CreateOfferPM extends PresentationModel<CreateOfferModel> {
///////////////////////////////////////////////////////////////////////////////////////////
// Getters (called by CB)
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public WalletFacade getWalletFacade() {

View file

@ -22,6 +22,7 @@ import io.bitsquare.gui.CodeBehind;
import io.bitsquare.gui.MainController;
import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.pm.AccountPM;
import io.bitsquare.gui.view.account.AccountSetupCB;
import io.bitsquare.util.BSFXMLLoader;
import java.io.IOException;
@ -42,6 +43,7 @@ import org.slf4j.LoggerFactory;
public class AccountCB extends CachedCodeBehind<AccountPM> {
private static final Logger log = LoggerFactory.getLogger(AccountCB.class);
public Tab tab;
@ -108,6 +110,13 @@ public class AccountCB extends CachedCodeBehind<AccountPM> {
tab.setContent(view);
Initializable childController = loader.getController();
((CodeBehind) childController).setParentController(this);
if (childController instanceof AccountSetupCB)
((AccountSetupCB) childController).setRemoveCallBack(() -> {
removeSetup();
return null;
});
} catch (IOException e) {
log.error("Loading view failed. FxmlUrl = " + NavigationItem.ACCOUNT_SETUP.getFxmlUrl());
e.getStackTrace();
@ -115,7 +124,12 @@ public class AccountCB extends CachedCodeBehind<AccountPM> {
return childController;
}
public void removeSetup() {
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
private void removeSetup() {
childController = null;
NavigationItem previousItem = MainController.GET_INSTANCE().getPreviousNavigationItem();
@ -125,10 +139,5 @@ public class AccountCB extends CachedCodeBehind<AccountPM> {
MainController.GET_INSTANCE().loadViewAndGetChildController(previousItem);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
}

View file

@ -129,11 +129,10 @@ public class AccountSettingsCB extends CachedCodeBehind<AccountSettingsPM> {
}
class MenuItem extends ToggleButton {
private static final Logger log = LoggerFactory.getLogger(MenuItem.class);
private CodeBehind<? extends PresentationModel> childController;
private final AccountSettingsCB parentCB;
private final Parent content;
private final NavigationItem navigationItem;
@ -144,15 +143,13 @@ class MenuItem extends ToggleButton {
this.content = content;
this.navigationItem = navigationItem;
setToggleGroup(toggleGroup);
setText(title);
setId("account-settings-item-background-active");
setPrefHeight(40);
setPrefWidth(200);
setAlignment(Pos.CENTER_LEFT);
setToggleGroup(toggleGroup);
setText(title);
setId("account-settings-item-background-active");
Label icon = new Label();
icon.setTextFill(Paint.valueOf("#999"));
if (navigationItem.equals(NavigationItem.SEED_WORDS))
@ -162,10 +159,10 @@ class MenuItem extends ToggleButton {
else
AwesomeDude.setIcon(icon, AwesomeIcon.EDIT_SIGN);
setGraphic(icon);
setOnAction((event) -> show());
selectedProperty().addListener((ov, oldValue, newValue) -> {
if (newValue) {
setId("account-settings-item-background-selected");
@ -180,7 +177,7 @@ class MenuItem extends ToggleButton {
disableProperty().addListener((ov, oldValue, newValue) -> {
if (newValue) {
setId("account-settings-item-background-disabled");
//icon.setTextFill(Paint.valueOf("#ccc"));
icon.setTextFill(Paint.valueOf("#ccc"));
}
else {
setId("account-settings-item-background-active");
@ -202,10 +199,5 @@ class MenuItem extends ToggleButton {
e.getStackTrace();
}
}
CodeBehind<? extends PresentationModel> getChildController() {
return childController;
}
}

View file

@ -23,7 +23,6 @@ import io.bitsquare.gui.NavigationItem;
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;
@ -37,9 +36,11 @@ import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.concurrent.Callable;
import javax.inject.Inject;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.scene.*;
import javafx.scene.control.*;
@ -52,9 +53,13 @@ import org.slf4j.LoggerFactory;
public class AccountSetupCB extends CachedCodeBehind<AccountSetupPM> {
private static final Logger log = LoggerFactory.getLogger(AccountSetupCB.class);
public VBox leftVBox;
public AnchorPane content;
private WizardItem seedWords, password, fiatAccount, restrictions, registration;
private Callable<Void> requestCloseCallable;
@FXML private VBox leftVBox;
@FXML private AnchorPane content;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
@ -137,7 +142,13 @@ public class AccountSetupCB extends CachedCodeBehind<AccountSetupPM> {
registration.onCompleted();
childController = null;
((AccountCB) parentController).removeSetup();
if (requestCloseCallable != null) {
try {
requestCloseCallable.call();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
@ -146,21 +157,17 @@ public class AccountSetupCB extends CachedCodeBehind<AccountSetupPM> {
// Public Methods
///////////////////////////////////////////////////////////////////////////////////////////
public void setRemoveCallBack(Callable<Void> requestCloseCallable) {
///////////////////////////////////////////////////////////////////////////////////////////
// UI handlers
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
this.requestCloseCallable = requestCloseCallable;
}
}
class WizardItem extends HBox {
private static final Logger log = LoggerFactory.getLogger(WizardItem.class);
private CodeBehind<? extends PresentationModel> childController;
private final ImageView imageView;
private final Label titleLabel;
private final Label subTitleLabel;
@ -168,15 +175,12 @@ class WizardItem extends HBox {
private final Parent content;
private final NavigationItem navigationItem;
private CodeBehind<? extends PresentationModel> childController;
WizardItem(AccountSetupCB parentCB, Parent content, String title, String subTitle, NavigationItem navigationItem) {
this.parentCB = parentCB;
this.content = content;
this.navigationItem = navigationItem;
setId("wizard-item-background-deactivated");
layout();
setSpacing(5);
setPrefWidth(200);
@ -187,11 +191,6 @@ class WizardItem extends HBox {
imageView.setMouseTransparent(true);
HBox.setMargin(imageView, new Insets(8, 0, 0, 8));
final VBox vBox = new VBox();
vBox.setSpacing(1);
HBox.setMargin(vBox, new Insets(5, 0, 8, 0));
vBox.setMouseTransparent(true);
titleLabel = new Label(title);
titleLabel.setId("wizard-title-deactivated");
titleLabel.setLayoutX(7);
@ -205,11 +204,16 @@ class WizardItem extends HBox {
subTitleLabel.setWrapText(true);
subTitleLabel.setMouseTransparent(true);
final VBox vBox = new VBox();
vBox.setSpacing(1);
HBox.setMargin(vBox, new Insets(5, 0, 8, 0));
vBox.setMouseTransparent(true);
vBox.getChildren().addAll(titleLabel, subTitleLabel);
getChildren().addAll(imageView, vBox);
}
public CodeBehind<? extends PresentationModel> show() {
CodeBehind<? extends PresentationModel> show() {
loadView(navigationItem);
setId("wizard-item-background-active");
imageView.setImage(ImageUtil.getIconImage(ImageUtil.ARROW_BLUE));
@ -218,29 +222,13 @@ class WizardItem extends HBox {
return childController;
}
public void onCompleted() {
void onCompleted() {
setId("wizard-item-background-completed");
imageView.setImage(ImageUtil.getIconImage(ImageUtil.TICK));
titleLabel.setId("wizard-title-completed");
subTitleLabel.setId("wizard-sub-title-completed");
}
public CodeBehind<? extends PresentationModel> getChildController() {
return childController;
}
public ImageView getImageView() {
return imageView;
}
public Label getTitleLabel() {
return titleLabel;
}
public Label getSubTitleLabel() {
return subTitleLabel;
}
private void loadView(NavigationItem navigationItem) {
final BSFXMLLoader loader = new BSFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()));
try {

View file

@ -105,7 +105,7 @@ public class ChangePasswordCB extends CachedCodeBehind<ChangePasswordPM> impleme
@FXML
private void onSaved() {
boolean result = presentationModel.savePassword();
boolean result = presentationModel.requestSavePassword();
if (result) {
if (parentController instanceof AccountSetupCB)
((AccountSetupCB) parentController).onCompleted(this);

View file

@ -166,7 +166,7 @@ public class FiatAccountCB extends CachedCodeBehind<FiatAccountPm> implements Ad
@FXML
private void onSave() {
InputValidator.ValidationResult result = presentationModel.saveBankAccount();
InputValidator.ValidationResult result = presentationModel.requestSaveBankAccount();
if (result.isValid) {
selectionComboBox.getSelectionModel().select(null);
Popups.openInfo("You can add more accounts or continue to the next step.",

View file

@ -105,7 +105,7 @@ public class PasswordCB extends CachedCodeBehind<PasswordPM> implements Adjustab
@FXML
private void onSaved() {
boolean result = presentationModel.savePassword();
boolean result = presentationModel.requestSavePassword();
if (result) {
if (parentController instanceof AccountSetupCB)
((AccountSetupCB) parentController).onCompleted(this);

View file

@ -86,7 +86,7 @@ public class RestrictionsCB extends CachedCodeBehind<RestrictionsPM> implements
initCountry();
initArbitrators();
completedButton.disableProperty().bind(presentationModel.doneButtonDisabled);
completedButton.disableProperty().bind(presentationModel.doneButtonDisable);
}
@Override
@ -128,7 +128,7 @@ public class RestrictionsCB extends CachedCodeBehind<RestrictionsPM> implements
@FXML
private void onAddLanguage() {
presentationModel.onAddLanguage(languageComboBox.getSelectionModel().getSelectedItem());
presentationModel.addLanguage(languageComboBox.getSelectionModel().getSelectedItem());
languageComboBox.getSelectionModel().clearSelection();
}
@ -143,7 +143,7 @@ public class RestrictionsCB extends CachedCodeBehind<RestrictionsPM> implements
@FXML
private void onAddCountry() {
presentationModel.onAddCountry(countryComboBox.getSelectionModel().getSelectedItem());
presentationModel.addCountry(countryComboBox.getSelectionModel().getSelectedItem());
countryComboBox.getSelectionModel().clearSelection();
}

View file

@ -75,6 +75,7 @@ public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> {
private boolean detailsVisible;
private boolean advancedScreenInited;
private Callable<Void> onCloseCallable;
private ImageView expand;
private ImageView collapse;
@ -97,7 +98,6 @@ public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> {
acceptedLanguagesTextField;
@FXML private AddressTextField addressTextField;
@FXML private BalanceTextField balanceTextField;
private Callable<Void> onCloseCallBack;
///////////////////////////////////////////////////////////////////////////////////////////
@ -140,13 +140,14 @@ public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> {
// Inform parent that we gor removed.
// Needed to reset disable state of createOfferButton in OrderBookController
if (onCloseCallBack != null)
if (onCloseCallable != null) {
try {
onCloseCallBack.call();
onCloseCallable.call();
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
}
}
@ -522,7 +523,7 @@ public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> {
}
public void setOnClose(Callable<Void> onCloseCallBack) {
this.onCloseCallBack = onCloseCallBack;
this.onCloseCallable = onCloseCallBack;
}
}