branch feature/15 created (now 700b8ba)
This is an automated email from the git hooks/post-receive script. New change to branch feature/15 in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git at 700b8ba Les référentiels ne sont pas trié (Closes #15) This branch includes the following new commits: new 700b8ba Les référentiels ne sont pas trié (Closes #15) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 700b8bab55cd44162924641a76d66ea014f7d913 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Dec 21 10:01:53 2016 +0100 Les référentiels ne sont pas trié (Closes #15) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/15 in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 700b8bab55cd44162924641a76d66ea014f7d913 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Dec 21 10:01:53 2016 +0100 Les référentiels ne sont pas trié (Closes #15) --- .../swing/decoration/ObserveI18nDecoratorHelper.java | 6 +++++- .../swing/ui/admin/validate/ValidateUIHandler.java | 4 ++-- .../referential/ReferentialsNavigationTreeNode.java | 3 ++- .../main/java/fr/ird/observe/util/ObserveUtil.java | 20 +++++++------------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/application-swing-decoration/src/main/java/fr/ird/observe/application/swing/decoration/ObserveI18nDecoratorHelper.java b/application-swing-decoration/src/main/java/fr/ird/observe/application/swing/decoration/ObserveI18nDecoratorHelper.java index 64f3a90..9928c84 100644 --- a/application-swing-decoration/src/main/java/fr/ird/observe/application/swing/decoration/ObserveI18nDecoratorHelper.java +++ b/application-swing-decoration/src/main/java/fr/ird/observe/application/swing/decoration/ObserveI18nDecoratorHelper.java @@ -46,10 +46,14 @@ public class ObserveI18nDecoratorHelper { private static final String OBSERVE_COMMON_PREFIX = "observe.common."; private static final String OBSERVE_TYPE_PREFIX = "observe.type."; - public static List<Class> sortTypes(Collection<Class> types) { + public static <C extends Class<?>> List<C> sortTypes(Collection<C> types) { return ObserveUtil.sortTypes(types, klass -> t(ObserveI18nDecoratorHelper.getTypeI18nKey(klass))); } + public static <C extends Class<?>> List<C> sortPluralTypes(Collection<C> types) { + return ObserveUtil.sortTypes(types, klass -> t(ObserveI18nDecoratorHelper.getTypePluralI18nKey(klass))); + } + public static String getPropertyName(Class key) { String name = key.getSimpleName(); name = StringUtils.removeEnd(name, "Dto"); diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/admin/validate/ValidateUIHandler.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/admin/validate/ValidateUIHandler.java index 457a308..8e13d1e 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/admin/validate/ValidateUIHandler.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/admin/validate/ValidateUIHandler.java @@ -215,7 +215,7 @@ public class ValidateUIHandler extends AdminTabUIHandler<ValidateUI> implements Set<Class<? extends IdDto>> messageTypes = tabUI.getStepModel().getMessageTypes(); - List<Class> classes = ObserveI18nDecoratorHelper.sortTypes((Set) messageTypes); + List<Class<? extends IdDto>> classes = ObserveI18nDecoratorHelper.sortTypes(messageTypes); for (Class e : classes) { @@ -280,7 +280,7 @@ public class ValidateUIHandler extends AdminTabUIHandler<ValidateUI> implements return; } - AbstractReference ref = (AbstractReference) o; + AbstractReference<?> ref = (AbstractReference) o; if (log.isDebugEnabled()) { log.debug(ref); diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/tree/navigation/nodes/referential/ReferentialsNavigationTreeNode.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/tree/navigation/nodes/referential/ReferentialsNavigationTreeNode.java index 8fbc2da..dc7e33a 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/tree/navigation/nodes/referential/ReferentialsNavigationTreeNode.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/tree/navigation/nodes/referential/ReferentialsNavigationTreeNode.java @@ -23,6 +23,7 @@ package fr.ird.observe.application.swing.ui.tree.navigation.nodes.referential; */ import com.google.common.collect.ImmutableSet; +import fr.ird.observe.application.swing.decoration.ObserveI18nDecoratorHelper; import fr.ird.observe.application.swing.ui.content.ref.ReferenceHomeUI; import fr.ird.observe.application.swing.ui.tree.navigation.nodes.StringNavigationTreeNodeSupport; import fr.ird.observe.services.dto.referential.ReferentialDto; @@ -39,7 +40,7 @@ public class ReferentialsNavigationTreeNode extends StringNavigationTreeNodeSupp public static ReferentialsNavigationTreeNode of(String name, ImmutableSet<Class<? extends ReferentialDto>> types) { ReferentialsNavigationTreeNode result = new ReferentialsNavigationTreeNode(t(name)); - for (Class<? extends ReferentialDto> aClass : types) { + for (Class<? extends ReferentialDto> aClass : ObserveI18nDecoratorHelper.sortPluralTypes(types)) { ReferentialNavigationTreeNode child = new ReferentialNavigationTreeNode<>(aClass); result.add(child); } diff --git a/services-dto/src/main/java/fr/ird/observe/util/ObserveUtil.java b/services-dto/src/main/java/fr/ird/observe/util/ObserveUtil.java index f9a47ae..ce41394 100644 --- a/services-dto/src/main/java/fr/ird/observe/util/ObserveUtil.java +++ b/services-dto/src/main/java/fr/ird/observe/util/ObserveUtil.java @@ -26,7 +26,6 @@ import org.nuiton.config.ApplicationConfig; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -56,15 +55,15 @@ public class ObserveUtil { return targetProperties; } - public static List<Class> sortTypes(Collection<Class> types, Function<Class, String> function) { + public static <C extends Class<?>> List<C> sortTypes(Collection<C> types, Function<Class, String> function) { - List<Class> list = new ArrayList<>(types); - new ClassComparator(function).sort(list); + List<C> list = new ArrayList<>(types); + new ClassComparator<C>(function).sort(list); return list; } - private static class ClassComparator implements Comparator<Class> { + private static class ClassComparator<C extends Class<?>> implements Comparator<C> { private final Map<Class, String> cache; private final Function<Class, String> function; @@ -82,16 +81,11 @@ public class ObserveUtil { } String getValue(Class klass) { - String result = cache.get(klass); - if (result == null) { - result = function.apply(klass); - cache.put(klass, result); - } - return result; + return cache.computeIfAbsent(klass, k -> function.apply(klass)); } - public void sort(List<Class> list) { - Collections.sort(list, this); + public void sort(List<C> list) { + list.sort(this); cache.clear(); } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm