From dd0b11a71e4e4cdc5eb1580e472bf7dde9075e74 Mon Sep 17 00:00:00 2001 From: Smithor Date: Fri, 13 Feb 2026 09:52:10 -0700 Subject: [PATCH 1/4] Abstract version of ViewOwner that makes it easier to remember which methods are the essential ones. --- src/snap/view/AbstractViewOwner.java | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/snap/view/AbstractViewOwner.java diff --git a/src/snap/view/AbstractViewOwner.java b/src/snap/view/AbstractViewOwner.java new file mode 100644 index 00000000..6204d182 --- /dev/null +++ b/src/snap/view/AbstractViewOwner.java @@ -0,0 +1,37 @@ +package snap.view; + +public abstract class AbstractViewOwner extends ViewOwner { + + /** + * Creates the top level view for this owner. + *

+ * Implementation note: If you want the vanilla interaction of this class, return super.createUI(); + */ + @Override + abstract protected View createUI(); + + /** + * Initializes the UI panel. + *

+ * Implementation note: If you want the vanilla interaction of this class, return super.initUI(); + */ + @Override + abstract protected void initUI(); + + /** + * Reset UI controls. + *

+ * Implementation note: If you want the vanilla interaction of this class, return super.resetUI(); + */ + @Override + abstract protected void resetUI(); + + /** + * Respond to UI controls. + *

+ * Implementation note: If you want the vanilla interaction of this class, return super.respondUI(ViewEvent); + * @param anEvent Any event that has been caught by this ViewOwner. + */ + @Override + abstract protected void respondUI(ViewEvent anEvent); +} From 128f4b4cd03dfef482f2187c0b4706c5f634afa1 Mon Sep 17 00:00:00 2001 From: Smithor Date: Fri, 13 Feb 2026 11:32:50 -0700 Subject: [PATCH 2/4] Documentation change. --- src/snap/view/AbstractViewOwner.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/snap/view/AbstractViewOwner.java b/src/snap/view/AbstractViewOwner.java index 6204d182..d8a97b00 100644 --- a/src/snap/view/AbstractViewOwner.java +++ b/src/snap/view/AbstractViewOwner.java @@ -4,32 +4,28 @@ public abstract class AbstractViewOwner extends ViewOwner { /** * Creates the top level view for this owner. - *

- * Implementation note: If you want the vanilla interaction of this class, return super.createUI(); + * @apiNote If you want the vanilla interaction of this class, return {@code super.createUI();} */ @Override abstract protected View createUI(); /** * Initializes the UI panel. - *

- * Implementation note: If you want the vanilla interaction of this class, return super.initUI(); + * @apiNote If you want the vanilla interaction of this class, return {@code super.initUI();} */ @Override abstract protected void initUI(); /** * Reset UI controls. - *

- * Implementation note: If you want the vanilla interaction of this class, return super.resetUI(); + * @apiNote If you want the vanilla interaction of this class, return {@code super.resetUI();} */ @Override abstract protected void resetUI(); /** * Respond to UI controls. - *

- * Implementation note: If you want the vanilla interaction of this class, return super.respondUI(ViewEvent); + * @apiNote If you want the vanilla interaction of this class, return {@code super.respondUI(ViewEvent);} * @param anEvent Any event that has been caught by this ViewOwner. */ @Override From d980f586d894c9ef9373c329052767c4dbe1b8d1 Mon Sep 17 00:00:00 2001 From: Smithor Date: Fri, 13 Feb 2026 12:01:29 -0700 Subject: [PATCH 3/4] Provided an actually usable implementation of the idea, complete with default methods that reference the original ViewOwner. --- src/snap/view/AbstractViewOwner.java | 33 ---------------- src/snap/view/CustomViewOwner.java | 58 ++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 33 deletions(-) delete mode 100644 src/snap/view/AbstractViewOwner.java create mode 100644 src/snap/view/CustomViewOwner.java diff --git a/src/snap/view/AbstractViewOwner.java b/src/snap/view/AbstractViewOwner.java deleted file mode 100644 index d8a97b00..00000000 --- a/src/snap/view/AbstractViewOwner.java +++ /dev/null @@ -1,33 +0,0 @@ -package snap.view; - -public abstract class AbstractViewOwner extends ViewOwner { - - /** - * Creates the top level view for this owner. - * @apiNote If you want the vanilla interaction of this class, return {@code super.createUI();} - */ - @Override - abstract protected View createUI(); - - /** - * Initializes the UI panel. - * @apiNote If you want the vanilla interaction of this class, return {@code super.initUI();} - */ - @Override - abstract protected void initUI(); - - /** - * Reset UI controls. - * @apiNote If you want the vanilla interaction of this class, return {@code super.resetUI();} - */ - @Override - abstract protected void resetUI(); - - /** - * Respond to UI controls. - * @apiNote If you want the vanilla interaction of this class, return {@code super.respondUI(ViewEvent);} - * @param anEvent Any event that has been caught by this ViewOwner. - */ - @Override - abstract protected void respondUI(ViewEvent anEvent); -} diff --git a/src/snap/view/CustomViewOwner.java b/src/snap/view/CustomViewOwner.java new file mode 100644 index 00000000..027ba98c --- /dev/null +++ b/src/snap/view/CustomViewOwner.java @@ -0,0 +1,58 @@ +package snap.view; + +/** + * Helper class to create custom ViewOwners with novel interpretations. + */ +public abstract class CustomViewOwner extends ViewOwner { + + /** + * Creates the top level view for this owner. + * @apiNote If you want the vanilla interaction of this class, return {@code default_createUI();} + */ + @Override + abstract protected View createUI(); + + /** + * Initializes the UI panel. + * @apiNote If you want the vanilla interaction of this class, return {@code default_initUI();} + */ + @Override + abstract protected void initUI(); + + /** + * Reset UI controls. + * @apiNote If you want the vanilla interaction of this class, return {@code default_resetUI();} + */ + @Override + abstract protected void resetUI(); + + /** + * Respond to UI controls. + * @apiNote If you want the vanilla interaction of this class, return {@code default_respondUI(ViewEvent);} + * @param anEvent Any event that has been caught by this ViewOwner. + */ + @Override + abstract protected void respondUI(ViewEvent anEvent); + + /** + * Default implementation of {@link ViewOwner#createUI()} + * @return View loaded from snp file of the same name as the class. + */ + final protected View default_createUI() {return super.createUI();} + + /** + * Default implementation of {@link ViewOwner#initUI()} + */ + final protected void default_initUI() {super.initUI();} + + /** + * Default implementation of {@link ViewOwner#resetUI()} + */ + final protected void default_resetUI() {super.resetUI();} + + /** + * Default implementation of {@link ViewOwner#respondUI(ViewEvent)} + * @param anEvent An event which has been captured by the view. + */ + final protected void default_respondUI(ViewEvent anEvent) {super.respondUI(anEvent);} +} From 821dc8538f9e0758d60ce498fb534fec19833b34 Mon Sep 17 00:00:00 2001 From: Smithor Date: Fri, 13 Feb 2026 12:46:33 -0700 Subject: [PATCH 4/4] @apiNote is not supported by Gradle Javadoc plugin. --- src/snap/view/CustomViewOwner.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/snap/view/CustomViewOwner.java b/src/snap/view/CustomViewOwner.java index 027ba98c..fdcc7967 100644 --- a/src/snap/view/CustomViewOwner.java +++ b/src/snap/view/CustomViewOwner.java @@ -7,28 +7,32 @@ public abstract class CustomViewOwner extends ViewOwner { /** * Creates the top level view for this owner. - * @apiNote If you want the vanilla interaction of this class, return {@code default_createUI();} + *

+ * API Note: If you want the vanilla interaction of this class, return {@code default_createUI();} */ @Override abstract protected View createUI(); /** * Initializes the UI panel. - * @apiNote If you want the vanilla interaction of this class, return {@code default_initUI();} + *

+ * API Note: If you want the vanilla interaction of this class, return {@code default_initUI();} */ @Override abstract protected void initUI(); /** * Reset UI controls. - * @apiNote If you want the vanilla interaction of this class, return {@code default_resetUI();} + *

+ * API Note: If you want the vanilla interaction of this class, return {@code default_resetUI();} */ @Override abstract protected void resetUI(); /** * Respond to UI controls. - * @apiNote If you want the vanilla interaction of this class, return {@code default_respondUI(ViewEvent);} + *

+ * API Note: If you want the vanilla interaction of this class, return {@code default_respondUI(ViewEvent);} * @param anEvent Any event that has been caught by this ViewOwner. */ @Override