From 0ea29ce50e1a074378c1c28c25806202efcaaf47 Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Fri, 30 May 2014 19:52:29 +0200 Subject: [PATCH] =?UTF-8?q?Texttov=C3=A9=20sloupce=20volaj=C3=AD=20t=C5=99?= =?UTF-8?q?=C3=ADd=C4=9Bn=C3=AD=20s=20kl=C3=AD=C4=8Dov=C3=BDm=20slovem=20"?= =?UTF-8?q?czech",=20ostatn=C3=AD=20je=20"auto".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #84 --- .../isspst/sort/CzechSortListheader.java | 4 +- .../isspst/sort/CzechStringComparator.java | 40 ++++++++++--------- .../webapp/admin/addressbook/addressbook.zul | 10 ++--- .../webapp/admin/permissions/permissions.zul | 2 +- src/main/webapp/admin/users/users.zul | 8 ++-- src/main/webapp/buildings/building.zul | 6 +-- 6 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/main/java/info/bukova/isspst/sort/CzechSortListheader.java b/src/main/java/info/bukova/isspst/sort/CzechSortListheader.java index bed92a0a..23496978 100644 --- a/src/main/java/info/bukova/isspst/sort/CzechSortListheader.java +++ b/src/main/java/info/bukova/isspst/sort/CzechSortListheader.java @@ -8,10 +8,10 @@ public class CzechSortListheader extends Listheader { @Override public void setSort(String type) { - if (type.startsWith("auto")) + if (type.startsWith("czech")) { // czech(propertyName) - String propertyName = type.substring("auto(".length(), type.length() - 1); + String propertyName = type.substring("czech(".length(), type.length() - 1); this.setSortAscending(new CzechStringComparator(propertyName, true)); this.setSortDescending(new CzechStringComparator(propertyName, false)); } diff --git a/src/main/java/info/bukova/isspst/sort/CzechStringComparator.java b/src/main/java/info/bukova/isspst/sort/CzechStringComparator.java index 99b536f7..58c5d82f 100644 --- a/src/main/java/info/bukova/isspst/sort/CzechStringComparator.java +++ b/src/main/java/info/bukova/isspst/sort/CzechStringComparator.java @@ -7,6 +7,8 @@ import java.text.ParseException; import java.text.RuleBasedCollator; import java.util.Comparator; +import org.zkoss.zk.ui.util.Clients; + public class CzechStringComparator implements Comparator { private String m_rule; private final String m_property; @@ -16,6 +18,7 @@ public class CzechStringComparator implements Comparator { public CzechStringComparator(String property, boolean ascending) { m_rule = ""; + m_rule += "< 0 < 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 "; m_rule += "< A,a < Á,á < Ä,ä "; m_rule += "< B,b "; m_rule += "< C,c < Ć,ć < Č,č "; @@ -50,7 +53,6 @@ public class CzechStringComparator implements Comparator { @Override public int compare(Object argL, Object argR) { - try { return this.internalCompare(argL, argR); @@ -87,29 +89,31 @@ public class CzechStringComparator implements Comparator { Object valR = m_getter.invoke(argR); boolean isNullValL = (valL == null); boolean isNullValR = (valR == null); - + int result = 0; - - if (isNullValL || isNullValR) - { - if (isNullValL && isNullValR) - { + + if (isNullValL || isNullValR) { + if (isNullValL && isNullValR) { result = 0; - } - else if (isNullValL) - { + } else if (isNullValL) { result = -1; - } - else - { + } else { result = 1; } + } else { + + if (valL instanceof String) { + result = m_comparator.compare(valL, valR); + } else { + String className = valL.getClass().getName(); + Clients.alert( + "Nepodporovaný datový typ '" + + className + + "' pro třídění 'sort=czech(...)'. Použít 'sort=auto(...)'", + "Franta", Clients.NOTIFICATION_TYPE_WARNING); + } } - else - { - result = m_comparator.compare(valL, valR); - } - + return (m_ascending ? result : -result); } } diff --git a/src/main/webapp/admin/addressbook/addressbook.zul b/src/main/webapp/admin/addressbook/addressbook.zul index af006151..112721b8 100644 --- a/src/main/webapp/admin/addressbook/addressbook.zul +++ b/src/main/webapp/admin/addressbook/addressbook.zul @@ -8,12 +8,12 @@ - + - - - - + + + + diff --git a/src/main/webapp/admin/permissions/permissions.zul b/src/main/webapp/admin/permissions/permissions.zul index 744114ba..c3a1ca7b 100644 --- a/src/main/webapp/admin/permissions/permissions.zul +++ b/src/main/webapp/admin/permissions/permissions.zul @@ -11,7 +11,7 @@ - +