From 8e33bb8ef701d3049c0710062f693a143c62651a Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Tue, 20 Jan 2015 09:01:24 +0100 Subject: [PATCH] =?UTF-8?q?Agenda=20"Fakturace=20po=C5=BEadavk=C5=AF"=20ny?= =?UTF-8?q?n=C3=AD=20podporuje=20=C5=99azen=C3=AD.=20Po=20otev=C5=99en?= =?UTF-8?q?=C3=AD=20agendy=20je=20nastaveno=20=C5=99azen=C3=AD=20podle=20s?= =?UTF-8?q?loupce=20=C4=8D=C3=ADsla=20po=C5=BEadavku.=20U=20textov=C3=BDch?= =?UTF-8?q?=20sloupc=C5=AF=20se=20data=20=C5=99ad=C3=AD=20podle=20CZ=20pra?= =?UTF-8?q?videl.=20P=C5=99id=C3=A1na=20mo=C5=BEnost=20=C5=99adit=20vno?= =?UTF-8?q?=C5=99en=C3=A9=20property=20podle=20CZ=20pravidel.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #189 --- .../java/info/bukova/isspst/StringUtils.java | 44 +++++++++++++ .../isspst/sort/CzechStringComparator.java | 55 +++++++++++++--- .../orders/material/SelectMaterialItems.java | 6 +- .../main/orders/requirements/SelectItems.java | 7 +- .../orders/services/SelectServicesItems.java | 6 +- .../webapp/main/invoicing/invoicingGrid.zul | 64 +++++++++++-------- 6 files changed, 136 insertions(+), 46 deletions(-) diff --git a/src/main/java/info/bukova/isspst/StringUtils.java b/src/main/java/info/bukova/isspst/StringUtils.java index 07e8cbdf..9185bb93 100644 --- a/src/main/java/info/bukova/isspst/StringUtils.java +++ b/src/main/java/info/bukova/isspst/StringUtils.java @@ -1,5 +1,6 @@ package info.bukova.isspst; +import java.util.ArrayList; import java.util.List; import org.zkoss.util.resource.Labels; @@ -149,4 +150,47 @@ public class StringUtils return result; } + + public static List split(String value, String separator) + { + String tmp = value; + List list = new ArrayList(); + + if (tmp != null) + { + if ((separator == null) || separator.isEmpty() || tmp.isEmpty()) + { + list.add(tmp); + } + else + { + int separatorLength = separator.length(); + + while (!tmp.isEmpty()) + { + String part = ""; + int idx = tmp.indexOf(separator); + + if (idx > -1) + { + part = tmp.substring(0, idx); + list.add(part); + tmp = tmp.substring(idx + separatorLength); + + if (tmp.isEmpty()) + { + list.add(""); + } + } + else + { + list.add(tmp); + tmp = ""; + } + } + } + } + + return list; + } } diff --git a/src/main/java/info/bukova/isspst/sort/CzechStringComparator.java b/src/main/java/info/bukova/isspst/sort/CzechStringComparator.java index 58c5d82f..0e59ad89 100644 --- a/src/main/java/info/bukova/isspst/sort/CzechStringComparator.java +++ b/src/main/java/info/bukova/isspst/sort/CzechStringComparator.java @@ -1,19 +1,21 @@ package info.bukova.isspst.sort; +import info.bukova.isspst.StringUtils; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.text.Collator; import java.text.ParseException; import java.text.RuleBasedCollator; import java.util.Comparator; +import java.util.List; import org.zkoss.zk.ui.util.Clients; public class CzechStringComparator implements Comparator { private String m_rule; - private final String m_property; + private final List m_propertyPath; private final boolean m_ascending; - private Method m_getter; private Comparator m_comparator; public CzechStringComparator(String property, boolean ascending) { @@ -47,7 +49,7 @@ public class CzechStringComparator implements Comparator { m_rule += "< Y,y < Ý,ý "; m_rule += "< Z,z < Ź,ź < Ž,ž "; - m_property = property; + m_propertyPath = StringUtils.split(property, "."); m_ascending = ascending; } @@ -72,21 +74,56 @@ public class CzechStringComparator implements Comparator { return 0; } + private Object getValue(Object caller) + { + Object obj = caller; + + for (String property : m_propertyPath) + { + if (obj == null) + { + return null; + } + + Method method = ReflectionTools.getGetterMethod(obj, property); + + try + { + obj = method.invoke(obj); + } + catch (IllegalAccessException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (IllegalArgumentException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (InvocationTargetException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return obj; + } + private int internalCompare(Object argL, Object argR) throws ParseException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - if (m_getter == null) { - m_getter = ReflectionTools.getGetterMethod(argL, m_property); - } - if (m_comparator == null) { + if (m_comparator == null) + { Collator c = new RuleBasedCollator(m_rule); c.setStrength(Collator.TERTIARY); m_comparator = c; } - Object valL = m_getter.invoke(argL); - Object valR = m_getter.invoke(argR); + Object valL = this.getValue(argL); + Object valR = this.getValue(argR); boolean isNullValL = (valL == null); boolean isNullValR = (valR == null); diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/material/SelectMaterialItems.java b/src/main/java/info/bukova/isspst/ui/main/orders/material/SelectMaterialItems.java index ad618865..42e18abd 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/material/SelectMaterialItems.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/material/SelectMaterialItems.java @@ -29,10 +29,10 @@ public class SelectMaterialItems extends SelectItems private MaterialFilter dataFilterMaterial; - @Init - public void init() + @Init(superclass = true) + public void initSelectMaterialItems() { - super.init(); + // super.init(); this.setFullMaterialList(materialService.getAll()); this.setMaterialList(this.getFullMaterialList()); diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/SelectItems.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/SelectItems.java index ab4a0d25..1087c759 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/SelectItems.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/SelectItems.java @@ -3,13 +3,14 @@ package info.bukova.isspst.ui.main.orders.requirements; import info.bukova.isspst.data.MUnitEmb; import info.bukova.isspst.data.RequirementSubject; import info.bukova.isspst.services.munits.MUnitService; +import info.bukova.isspst.ui.DocumentViewModel; import java.util.List; import org.zkoss.bind.annotation.Init; import org.zkoss.zk.ui.select.annotation.WireVariable; -public class SelectItems +public class SelectItems extends DocumentViewModel { protected RequirementSubject selectedItem; @@ -19,8 +20,8 @@ public class SelectItems protected List munitList; - @Init - public void init() + @Init(superclass = true) + public void initSelectItems() { this.setMunitList(munitService.getEmbAll()); } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/services/SelectServicesItems.java b/src/main/java/info/bukova/isspst/ui/main/orders/services/SelectServicesItems.java index 9cd7939e..f264b8f9 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/services/SelectServicesItems.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/services/SelectServicesItems.java @@ -29,10 +29,10 @@ public class SelectServicesItems extends SelectItems private ServiceItemFilter dataFilterService; - @Init - public void init() + @Init(superclass = true) + public void initSelectServicesItems() { - super.init(); + // super.init(); this.setFullServiceItemList(serviceItemService.getAll()); this.setServiceItemList(this.getFullServiceItemList()); diff --git a/src/main/webapp/main/invoicing/invoicingGrid.zul b/src/main/webapp/main/invoicing/invoicingGrid.zul index 242803ba..c2fdd775 100644 --- a/src/main/webapp/main/invoicing/invoicingGrid.zul +++ b/src/main/webapp/main/invoicing/invoicingGrid.zul @@ -18,35 +18,43 @@ + sort="auto(requirement.reqDate)" + width="150px" /> + sort="czech(requirement.centre.fullName)" + width="180px" /> + sort="czech(requirement.workgroup.fullName)" + width="180px" /> + label="${labels.InvoicingApplicant}" + sort="czech(requirement.ownedBy.fullName)" + width="180px" /> + label="${labels.InvoicingDescription}" + sort="czech(requirement.description)" + width="" /> - + sclass="category-center" + visible="@load(vm.filter)">
@@ -133,34 +141,33 @@ +
+ -