mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-20 13:54:32 +01:00
Rename initialized to initialize, add null checks in base UI classes
This commit is contained in:
parent
46863bb4c2
commit
52b04206e8
28 changed files with 90 additions and 76 deletions
|
@ -30,16 +30,19 @@ public class CachedViewCB<T extends PresentationModel> extends ViewCB<T> {
|
|||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
log.trace("Lifecycle: initialize " + this.getClass().getSimpleName());
|
||||
root.sceneProperty().addListener((ov, oldValue, newValue) -> {
|
||||
// we got removed from the scene
|
||||
// lets terminate
|
||||
log.trace("Lifecycle: sceneProperty changed: " + this.getClass().getSimpleName() + " / oldValue=" +
|
||||
oldValue + " / newValue=" + newValue);
|
||||
if (oldValue == null && newValue != null) activate();
|
||||
else if (oldValue != null && newValue == null) deactivate();
|
||||
});
|
||||
if (root != null) {
|
||||
root.sceneProperty().addListener((ov, oldValue, newValue) -> {
|
||||
// we got removed from the scene
|
||||
// lets terminate
|
||||
log.trace("Lifecycle: sceneProperty changed: " + this.getClass().getSimpleName() + " / oldValue=" +
|
||||
oldValue + " / newValue=" + newValue);
|
||||
if (oldValue == null && newValue != null) activate();
|
||||
else if (oldValue != null && newValue == null) deactivate();
|
||||
});
|
||||
}
|
||||
|
||||
presentationModel.initialized();
|
||||
if (presentationModel != null)
|
||||
presentationModel.initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +52,8 @@ public class CachedViewCB<T extends PresentationModel> extends ViewCB<T> {
|
|||
log.trace("Lifecycle: activate " + this.getClass().getSimpleName());
|
||||
if (childController instanceof CachedViewCB) ((CachedViewCB) childController).activate();
|
||||
|
||||
presentationModel.activate();
|
||||
if (presentationModel != null)
|
||||
presentationModel.activate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +63,8 @@ public class CachedViewCB<T extends PresentationModel> extends ViewCB<T> {
|
|||
log.trace("Lifecycle: deactivate " + this.getClass().getSimpleName());
|
||||
if (childController instanceof CachedViewCB) ((CachedViewCB) childController).deactivate();
|
||||
|
||||
presentationModel.deactivate();
|
||||
if (presentationModel != null)
|
||||
presentationModel.deactivate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +75,8 @@ public class CachedViewCB<T extends PresentationModel> extends ViewCB<T> {
|
|||
log.trace("Lifecycle: terminate " + this.getClass().getSimpleName());
|
||||
super.terminate();
|
||||
|
||||
presentationModel.terminate();
|
||||
if (presentationModel != null)
|
||||
presentationModel.terminate();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,25 +8,31 @@ public class PresentationModel<T extends UIModel> {
|
|||
this.model = model;
|
||||
}
|
||||
|
||||
// TODO Still open question if we enforce a model or not? For small UIs it might be too much overhead.
|
||||
public PresentationModel() {
|
||||
}
|
||||
|
||||
public void initialized() {
|
||||
model.initialized();
|
||||
public void initialize() {
|
||||
if (model != null)
|
||||
model.initialize();
|
||||
|
||||
activate();
|
||||
}
|
||||
|
||||
public void activate() {
|
||||
model.activate();
|
||||
if (model != null)
|
||||
model.activate();
|
||||
}
|
||||
|
||||
public void deactivate() {
|
||||
model.deactivate();
|
||||
if (model != null)
|
||||
model.deactivate();
|
||||
}
|
||||
|
||||
public void terminate() {
|
||||
model.terminate();
|
||||
if (model != null)
|
||||
model.terminate();
|
||||
|
||||
deactivate();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory;
|
|||
public class UIModel<T> {
|
||||
private static final Logger log = LoggerFactory.getLogger(UIModel.class);
|
||||
|
||||
public void initialized() {
|
||||
public void initialize() {
|
||||
activate();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,12 +24,14 @@ public class ViewCB<T extends PresentationModel> implements Initializable {
|
|||
protected Initializable childController;
|
||||
//TODO Initializable has to be changed to CodeBehind<? extends PresentationModel> when all UIs are updated
|
||||
protected Initializable parentController;
|
||||
|
||||
@FXML protected Parent root;
|
||||
|
||||
public ViewCB(T presentationModel) {
|
||||
this.presentationModel = presentationModel;
|
||||
}
|
||||
|
||||
// TODO Still open question if we enforce a presentationModel or not? For small UIs it might be too much overhead.
|
||||
public ViewCB() {
|
||||
}
|
||||
|
||||
|
@ -42,16 +44,17 @@ public class ViewCB<T extends PresentationModel> implements Initializable {
|
|||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
log.trace("Lifecycle: initialize " + this.getClass().getSimpleName());
|
||||
root.sceneProperty().addListener((ov, oldValue, newValue) -> {
|
||||
// we got removed from the scene
|
||||
// lets terminate
|
||||
if (oldValue != null && newValue == null)
|
||||
terminate();
|
||||
if (root != null) {
|
||||
root.sceneProperty().addListener((ov, oldValue, newValue) -> {
|
||||
// we got removed from the scene
|
||||
// lets terminate
|
||||
if (oldValue != null && newValue == null)
|
||||
terminate();
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
presentationModel.initialized();
|
||||
presentationModel.activate();
|
||||
if (presentationModel != null)
|
||||
presentationModel.initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,8 +66,8 @@ public class ViewCB<T extends PresentationModel> implements Initializable {
|
|||
if (childController != null)
|
||||
((ViewCB<? extends PresentationModel>) childController).terminate();
|
||||
|
||||
presentationModel.deactivate();
|
||||
presentationModel.terminate();
|
||||
if (presentationModel != null)
|
||||
presentationModel.terminate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,8 +84,8 @@ public class MainModel extends UIModel {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
|
|
|
@ -64,8 +64,8 @@ public class MainPM extends PresentationModel<MainModel> {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
backendInited.bind(model.backendInited);
|
||||
networkSyncComplete.bind(model.networkSyncComplete);
|
||||
|
|
|
@ -50,7 +50,6 @@ import javafx.scene.layout.*;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class MainViewCB extends ViewCB<MainPM> {
|
||||
private static final Logger log = LoggerFactory.getLogger(MainViewCB.class);
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ public class AccountModel extends UIModel {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,8 +44,8 @@ public class AccountPM extends PresentationModel<AccountModel> {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,8 +42,8 @@ public class ChangePasswordModel extends UIModel {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -63,8 +63,8 @@ public class ChangePasswordPM extends PresentationModel<ChangePasswordModel> {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -89,8 +89,8 @@ public class FiatAccountModel extends UIModel {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -78,8 +78,8 @@ public class FiatAccountPm extends PresentationModel<FiatAccountModel> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
// input
|
||||
title.bindBidirectional(model.title);
|
||||
|
|
|
@ -43,8 +43,8 @@ public class PasswordModel extends UIModel {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -63,8 +63,8 @@ public class PasswordPM extends PresentationModel<PasswordModel> {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -78,8 +78,8 @@ public class RegistrationModel extends UIModel {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if (walletFacade != null && walletFacade.getWallet() != null) {
|
||||
addressEntry = walletFacade.getRegistrationAddressEntry();
|
||||
|
|
|
@ -64,8 +64,8 @@ public class RegistrationPM extends PresentationModel<RegistrationModel> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if (model.getAddressEntry() != null) {
|
||||
address.set(model.getAddressEntry().getAddress());
|
||||
|
|
|
@ -79,8 +79,8 @@ public class RestrictionsModel extends UIModel {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
Settings persistedSettings = (Settings) persistence.read(settings);
|
||||
if (persistedSettings != null) {
|
||||
|
|
|
@ -55,8 +55,8 @@ public class RestrictionsPM extends PresentationModel<RestrictionsModel> {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ public class SeedWordsModel extends UIModel {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -50,8 +50,8 @@ public class SeedWordsPM extends PresentationModel<SeedWordsModel> {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if (model.getMnemonicCode() != null)
|
||||
seedWords.set(BSFormatter.mnemonicCodeToString(model.getMnemonicCode()));
|
||||
|
|
|
@ -43,8 +43,8 @@ public class AccountSettingsModel extends UIModel {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,8 +44,8 @@ public class AccountSettingsPM extends PresentationModel<AccountSettingsModel> {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,8 +43,8 @@ public class AccountSetupModel extends UIModel {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,8 +44,8 @@ public class AccountSetupPM extends PresentationModel<AccountSetupModel> {
|
|||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -126,8 +126,8 @@ public class CreateOfferModel extends UIModel {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
// static data
|
||||
offerFeeAsCoin.set(FeePolicy.CREATE_OFFER_FEE);
|
||||
|
|
|
@ -115,8 +115,8 @@ public class CreateOfferPM extends PresentationModel<CreateOfferModel> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initialized() {
|
||||
super.initialized();
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
// static
|
||||
paymentLabel.set(BSResources.get("createOffer.fundsBox.paymentLabel", model.getOfferId()));
|
||||
|
|
|
@ -50,7 +50,7 @@ public class CreateOfferPMTest {
|
|||
BSFormatter.setFiatCurrencyCode("USD");
|
||||
|
||||
presenter = new CreateOfferPM(model, new FiatValidator(null), new BtcValidator());
|
||||
presenter.initialized();
|
||||
presenter.initialize();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue