From b79284009db13ab4071102af7b15c650a404228b Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Fri, 22 Jul 2016 23:15:34 +0200 Subject: [PATCH] SMall cleanup --- src/zutil/ui/Configurator.java | 16 +++++++++++++--- src/zutil/ui/Navigation.java | 26 ++++++++++++++++---------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/zutil/ui/Configurator.java b/src/zutil/ui/Configurator.java index a9befe8..3d650d6 100755 --- a/src/zutil/ui/Configurator.java +++ b/src/zutil/ui/Configurator.java @@ -51,7 +51,7 @@ public class Configurator { */ @Retention(RetentionPolicy.RUNTIME) // Make this annotation accessible at runtime via reflection. @Target({ElementType.FIELD}) // This annotation can only be applied to class fields. - public static @interface Configurable{ + public @interface Configurable{ /** Nice name of this parameter **/ String value(); /** Defines the order the parameters, in ascending order **/ @@ -59,7 +59,7 @@ public class Configurator { } - public static enum ConfigType{ + public enum ConfigType{ STRING, INT, BOOLEAN } @@ -71,11 +71,13 @@ public class Configurator { private PreConfigurationActionListener preListener; private PostConfigurationActionListener postListener; + public Configurator(T obj){ this.obj = obj; this.params = getConfiguration(obj.getClass(), obj); } + public T getObject(){ return obj; } @@ -111,6 +113,8 @@ public class Configurator { /** * Uses a Map to assign all parameters of the Object + * + * @return a reference to itself so that metodcalls can be chained. */ public Configurator setValues(Map parameters){ for(ConfigurationParam param : this.params){ @@ -123,6 +127,8 @@ public class Configurator { /** * Uses a Map to assign all parameters of the Object. * NOTE: the DataNode must be of type Map + * + * @return a reference to itself so that metodcalls can be chained. */ public Configurator setValues(DataNode node){ if(!node.isMap()) @@ -165,8 +171,10 @@ public class Configurator { * been configured if it implements the PreConfigurationActionListener interface. * The postConfigurationAction() method will be called after the target object is * configured if it implements the PostConfigurationActionListener interface. + * + * @return a reference to itself so that metodcalls can be chained. */ - public void applyConfiguration(){ + public Configurator applyConfiguration(){ if(preListener != null) preListener.preConfigurationAction(this, obj); if(obj instanceof PreConfigurationActionListener) @@ -195,6 +203,8 @@ public class Configurator { ((PostConfigurationActionListener) obj).postConfigurationAction(this, obj); if(postListener != null) postListener.postConfigurationAction(this, obj); + + return this; } diff --git a/src/zutil/ui/Navigation.java b/src/zutil/ui/Navigation.java index 7c95dc9..8703221 100755 --- a/src/zutil/ui/Navigation.java +++ b/src/zutil/ui/Navigation.java @@ -153,6 +153,21 @@ public class Navigation implements Iterable{ (o != null && this.id == (((Navigation)o).id)); } + + + + public static Navigation createRootNav(){ + return new Navigation(null, null); + } + public static Navigation getRootNav(Map request) { + List breadcrumb = getBreadcrumb(getParameterizedNavigation(request)); + if (!breadcrumb.isEmpty()) + return breadcrumb.get(0); + return null; + } + + + /** * Will create a clone of the navigation tree with some request instance specific information */ @@ -176,6 +191,7 @@ public class Navigation implements Iterable{ } + public NavInstance createPagedNavInstance(HttpHeader header){ Navigation nav = getPagedNavigation(header); if (nav != null) @@ -197,16 +213,6 @@ public class Navigation implements Iterable{ } - - public static Navigation createRootNav(){ - return new Navigation(null, null); - } - public static Navigation getRootNav(Map request) { - List breadcrumb = getBreadcrumb(getParameterizedNavigation(request)); - if (!breadcrumb.isEmpty()) - return breadcrumb.get(0); - return null; - } /**