Implementováno a sjednoceno řazení záznamů podle českých znaků.
Změnit v databázi collation z ut8_czech_ci na latin2_czech_cs!!! Sjednocen vzhled gridů ve všech agendách. closes #83multitenant
parent
0f9d1baf94
commit
1c19625ffb
@ -0,0 +1,25 @@
|
||||
package info.bukova.isspst.sort;
|
||||
|
||||
import org.zkoss.zul.Listheader;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class CzechSortListheader extends Listheader {
|
||||
|
||||
@Override
|
||||
public void setSort(String type) {
|
||||
|
||||
if (type.startsWith("auto"))
|
||||
{
|
||||
// czech(propertyName)
|
||||
String propertyName = type.substring("auto(".length(), type.length() - 1);
|
||||
this.setSortAscending(new CzechStringComparator(propertyName, true));
|
||||
this.setSortDescending(new CzechStringComparator(propertyName, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
// auto(propertyName)
|
||||
super.setSort(type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
package info.bukova.isspst.sort;
|
||||
|
||||
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;
|
||||
|
||||
public class CzechStringComparator implements Comparator<Object> {
|
||||
private String m_rule;
|
||||
private final String m_property;
|
||||
private final boolean m_ascending;
|
||||
private Method m_getter;
|
||||
private Comparator<Object> m_comparator;
|
||||
|
||||
public CzechStringComparator(String property, boolean ascending) {
|
||||
m_rule = "";
|
||||
m_rule += "< A,a < Á,á < Ä,ä ";
|
||||
m_rule += "< B,b ";
|
||||
m_rule += "< C,c < Ć,ć < Č,č ";
|
||||
m_rule += "< D,d < Ď,ď ";
|
||||
m_rule += "< E,e < É,é < Ë,ë ";
|
||||
m_rule += "< F,f ";
|
||||
m_rule += "< G,g ";
|
||||
m_rule += "< H,h ";
|
||||
m_rule += "< CH,Ch,ch ";
|
||||
m_rule += "< I,i < Í,í ";
|
||||
m_rule += "< J,j ";
|
||||
m_rule += "< K,k ";
|
||||
m_rule += "< L,l < Ľ,ľ < Ĺ,ĺ ";
|
||||
m_rule += "< M,m ";
|
||||
m_rule += "< N,n < Ń,ń < Ň,ň ";
|
||||
m_rule += "< O,o < Ó,ó < Ö,ö ";
|
||||
m_rule += "< P,p ";
|
||||
m_rule += "< Q,q ";
|
||||
m_rule += "< R,r < Ŕ,ŕ < Ř,ř ";
|
||||
m_rule += "< S,s < ß < Ś,ś < Š,š ";
|
||||
m_rule += "< T,t < Ť,ť ";
|
||||
m_rule += "< U,u < Ú,ú < Ů,ů < Ü,ü ";
|
||||
m_rule += "< V,v ";
|
||||
m_rule += "< W,w ";
|
||||
m_rule += "< X,x ";
|
||||
m_rule += "< Y,y < Ý,ý ";
|
||||
m_rule += "< Z,z < Ź,ź < Ž,ž ";
|
||||
|
||||
m_property = property;
|
||||
m_ascending = ascending;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Object argL, Object argR) {
|
||||
|
||||
try {
|
||||
return this.internalCompare(argL, argR);
|
||||
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
} 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 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
boolean isNullValL = (valL == null);
|
||||
boolean isNullValR = (valR == null);
|
||||
|
||||
int result = 0;
|
||||
|
||||
if (isNullValL || isNullValR)
|
||||
{
|
||||
if (isNullValL && isNullValR)
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
else if (isNullValL)
|
||||
{
|
||||
result = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = m_comparator.compare(valL, valR);
|
||||
}
|
||||
|
||||
return (m_ascending ? result : -result);
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package info.bukova.isspst.sort;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ReflectionTools {
|
||||
|
||||
private static String capitalizeFirstLetter(String string)
|
||||
{
|
||||
String result = string.substring(0,1).toUpperCase() + string.substring(1, string.length());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getGetterName(String propertyName)
|
||||
{
|
||||
String getterName = "get" + ReflectionTools.capitalizeFirstLetter(propertyName);
|
||||
return getterName;
|
||||
}
|
||||
|
||||
public static String getBoolGetterName(String propertyName)
|
||||
{
|
||||
String getterName = "is" + ReflectionTools.capitalizeFirstLetter(propertyName);
|
||||
return getterName;
|
||||
}
|
||||
|
||||
public static Method getGetterMethod(Object bean, String propertyName)
|
||||
{
|
||||
Class<?> beanClass = bean.getClass();
|
||||
|
||||
try
|
||||
{
|
||||
return beanClass.getMethod(ReflectionTools.getGetterName(propertyName));
|
||||
}
|
||||
catch(Throwable t)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return beanClass.getMethod(ReflectionTools.getBoolGetterName(propertyName));
|
||||
}
|
||||
catch(Throwable t)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Not getter method found for '" + propertyName + "', bean: " + bean);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
jdbc.driverClassName=com.mysql.jdbc.Driver
|
||||
jdbc.dialect=org.hibernate.dialect.MySQLDialect
|
||||
jdbc.databaseurl=jdbc:mysql://127.0.0.1:3306/isspst?characterEncoding=utf8
|
||||
jdbc.databaseurl=jdbc:mysql://127.0.0.1:3306/isspst?characterEncoding=latin2
|
||||
jdbc.username=root
|
||||
jdbc.password=xsacfgd
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<language-addon>
|
||||
<addon-name>CzechSortListheader</addon-name>
|
||||
<language-name>xul/html</language-name>
|
||||
<component>
|
||||
<component-name>listheader</component-name>
|
||||
<extends>listheader</extends>
|
||||
<component-class>info.bukova.isspst.sort.CzechSortListheader</component-class>
|
||||
</component>
|
||||
</language-addon>
|
@ -1,10 +1,10 @@
|
||||
<?page title="toolbar" contentType="text/html;charset=UTF-8"?>
|
||||
<zk>
|
||||
<toolbar>
|
||||
<toolbarbutton image="/img/add.png" tooltiptext="Nový" id="btnNew" onClick="@command('addNew')" disabled="@load(vm.filter)" />
|
||||
<toolbarbutton image="/img/edit.png" tooltiptext="Upravit" id="btnEdit" onClick="@command('edit')" disabled="@load(empty vm.dataBean ? 'true' : 'false')"/>
|
||||
<toolbarbutton image="/img/delete.png" tooltiptext="Smazat" id="btnDelete" onClick="@command('delete')" disabled="@load(empty vm.dataBean ? 'true' : 'false')"/>
|
||||
<toolbarbutton image="/img/funnel.png" tooltiptext="Filtr" id="btnFilter" onClick="@command('filter')" />
|
||||
<toolbarbutton image="/img/print.png" tooltiptext="Filtr" id="btnPrint" onClick="@command('onPrint')" />
|
||||
<toolbarbutton image="/img/add.png" tooltiptext="${labels.ToolbarRecNew}" id="btnNew" onClick="@command('addNew')" disabled="@load(vm.filter)" />
|
||||
<toolbarbutton image="/img/edit.png" tooltiptext="${labels.ToolbarRecEdit}" id="btnEdit" onClick="@command('edit')" disabled="@load(empty vm.dataBean ? 'true' : 'false')"/>
|
||||
<toolbarbutton image="/img/delete.png" tooltiptext="${labels.ToolbarRecDelete}" id="btnDelete" onClick="@command('delete')" disabled="@load(empty vm.dataBean ? 'true' : 'false')"/>
|
||||
<toolbarbutton image="/img/funnel.png" tooltiptext="${labels.ToolbarRecFilter}" id="btnFilter" onClick="@command('filter')" />
|
||||
<toolbarbutton image="/img/print.png" tooltiptext="${labels.ToolbarPrint}" id="btnPrint" onClick="@command('onPrint')" />
|
||||
</toolbar>
|
||||
</zk>
|
Loading…
Reference in New Issue