From a157c099976655a93daebc81d7a2ae6fbf85f86f Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Sat, 22 Nov 2014 15:04:50 +0100 Subject: [PATCH] Allow ViewCB's generic M parameter to be of any type ... and begin implementing CachedViewCB#EMPTY_MODEL support --- .../java/io/bitsquare/gui/CachedViewCB.java | 19 ++++++++++++++++--- src/main/java/io/bitsquare/gui/ViewCB.java | 2 +- .../bitsquare/gui/main/funds/FundsViewCB.java | 1 - 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/bitsquare/gui/CachedViewCB.java b/src/main/java/io/bitsquare/gui/CachedViewCB.java index 7cf515af7f..43e40c7aa5 100644 --- a/src/main/java/io/bitsquare/gui/CachedViewCB.java +++ b/src/main/java/io/bitsquare/gui/CachedViewCB.java @@ -24,21 +24,34 @@ import java.util.ResourceBundle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static com.google.common.base.Preconditions.checkNotNull; + /** * If caching is used for loader we use the CachedViewController for turning the controller into sleep mode if not * active and awake it at reactivation. */ -public class CachedViewCB extends ViewCB { +public class CachedViewCB extends ViewCB { private static final Logger log = LoggerFactory.getLogger(CachedViewCB.class); + protected static final Activatable EMPTY_MODEL = new Activatable() { + @Override + public void activate() { + } + + @Override + public void deactivate() { + } + }; + public CachedViewCB(M model) { - super(model); + super(checkNotNull(model, "Model must not be null")); } public CachedViewCB() { - this(null); + this((M) EMPTY_MODEL); } + /** * Get called form GUI framework when the UI is ready. * In caching controllers the initialize is only used for static UI setup. diff --git a/src/main/java/io/bitsquare/gui/ViewCB.java b/src/main/java/io/bitsquare/gui/ViewCB.java index 698cc881ef..7634f4bce9 100644 --- a/src/main/java/io/bitsquare/gui/ViewCB.java +++ b/src/main/java/io/bitsquare/gui/ViewCB.java @@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory; /** * Non caching version for code behind classes using the PM pattern */ -public class ViewCB implements Initializable { +public class ViewCB implements Initializable { private static final Logger log = LoggerFactory.getLogger(ViewCB.class); diff --git a/src/main/java/io/bitsquare/gui/main/funds/FundsViewCB.java b/src/main/java/io/bitsquare/gui/main/funds/FundsViewCB.java index 3a2261e824..3d7610c4e7 100644 --- a/src/main/java/io/bitsquare/gui/main/funds/FundsViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/funds/FundsViewCB.java @@ -51,7 +51,6 @@ public class FundsViewCB extends CachedViewCB { @Inject FundsViewCB(ViewLoader viewLoader, Navigation navigation) { - super(); this.viewLoader = viewLoader; this.navigation = navigation; }