Remove generic model parameter from ViewCB

Push the presentation model field down into CachedViewCB--that is the
only place it is actually used from.
This commit is contained in:
Chris Beams 2014-11-22 11:52:20 +01:00
parent feb891b0dc
commit 100ee01fda
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
5 changed files with 12 additions and 21 deletions

View file

@ -29,15 +29,17 @@ import org.slf4j.LoggerFactory;
* active and awake it at reactivation. * active and awake it at reactivation.
* * @param <T> The PresentationModel used in that class * * @param <T> The PresentationModel used in that class
*/ */
public class CachedViewCB<T extends PresentationModel> extends ViewCB<T> { public class CachedViewCB<T extends PresentationModel> extends ViewCB {
private static final Logger log = LoggerFactory.getLogger(CachedViewCB.class); private static final Logger log = LoggerFactory.getLogger(CachedViewCB.class);
protected final T presentationModel;
public CachedViewCB(T presentationModel) { public CachedViewCB(T presentationModel) {
super(presentationModel); this.presentationModel = presentationModel;
} }
public CachedViewCB() { public CachedViewCB() {
super(); this(null);
} }
/** /**

View file

@ -30,27 +30,17 @@ import org.slf4j.LoggerFactory;
/** /**
* Non caching version for code behind classes using the PM pattern * Non caching version for code behind classes using the PM pattern
*
* @param <T> The PresentationModel used in that class
*/ */
public class ViewCB<T extends PresentationModel> implements Initializable { public class ViewCB implements Initializable {
private static final Logger log = LoggerFactory.getLogger(ViewCB.class); private static final Logger log = LoggerFactory.getLogger(ViewCB.class);
public static final String TITLE_KEY = "view.title"; public static final String TITLE_KEY = "view.title";
protected T presentationModel;
protected Initializable childController; protected Initializable childController;
protected Initializable parent; protected Initializable parent;
@FXML protected Parent root; @FXML protected Parent root;
protected ViewCB(T presentationModel) {
this.presentationModel = presentationModel;
}
protected ViewCB() {
}
/** /**
* Get called form GUI framework when the UI is ready. * Get called form GUI framework when the UI is ready.
* *

View file

@ -17,9 +17,8 @@
package io.bitsquare.gui.main.account; package io.bitsquare.gui.main.account;
import io.bitsquare.gui.PresentationModel;
import io.bitsquare.gui.ViewCB; import io.bitsquare.gui.ViewCB;
public interface MultiStepNavigation { public interface MultiStepNavigation {
void nextStep(ViewCB<? extends PresentationModel> useSettingsContext); void nextStep(ViewCB useSettingsContext);
} }

View file

@ -151,7 +151,7 @@ public class AccountSettingsViewCB extends CachedViewCB {
ViewLoader.Item loaded = viewLoader.load(navigationItem.getFxmlUrl()); ViewLoader.Item loaded = viewLoader.load(navigationItem.getFxmlUrl());
content.getChildren().setAll(loaded.view); content.getChildren().setAll(loaded.view);
childController = loaded.controller; childController = loaded.controller;
((ViewCB<? extends PresentationModel>) childController).setParent(this); ((ViewCB) childController).setParent(this);
((ContextAware) childController).useSettingsContext(true); ((ContextAware) childController).useSettingsContext(true);
return childController; return childController;
} }

View file

@ -154,7 +154,7 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void nextStep(ViewCB<? extends PresentationModel> childView) { public void nextStep(ViewCB childView) {
if (childView instanceof SeedWordsViewCB) { if (childView instanceof SeedWordsViewCB) {
seedWords.onCompleted(); seedWords.onCompleted();
childController = password.show(); childController = password.show();
@ -192,7 +192,7 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
ViewLoader.Item loaded = viewLoader.load(navigationItem.getFxmlUrl()); ViewLoader.Item loaded = viewLoader.load(navigationItem.getFxmlUrl());
content.getChildren().setAll(loaded.view); content.getChildren().setAll(loaded.view);
childController = loaded.controller; childController = loaded.controller;
((ViewCB<? extends PresentationModel>) childController).setParent(this); ((ViewCB) childController).setParent(this);
((ContextAware) childController).useSettingsContext(false); ((ContextAware) childController).useSettingsContext(false);
return childController; return childController;
} }
@ -201,7 +201,7 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
class WizardItem extends HBox { class WizardItem extends HBox {
private static final Logger log = LoggerFactory.getLogger(WizardItem.class); private static final Logger log = LoggerFactory.getLogger(WizardItem.class);
private ViewCB<? extends PresentationModel> childController; private ViewCB childController;
private final ImageView imageView; private final ImageView imageView;
private final Label titleLabel; private final Label titleLabel;
@ -248,7 +248,7 @@ class WizardItem extends HBox {
getChildren().addAll(imageView, vBox); getChildren().addAll(imageView, vBox);
} }
ViewCB<? extends PresentationModel> show() { ViewCB show() {
host.loadView(navigationItem); host.loadView(navigationItem);
/* navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT, Navigation /* navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT, Navigation
.Item.ACCOUNT_SETUP, .Item.ACCOUNT_SETUP,