From 4e5ae2bbfa6f459ba9518c3b34e12864807e2335 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Fri, 30 May 2014 12:23:20 +0200 Subject: [PATCH] =?UTF-8?q?Na=C4=8D=C3=ADt=C3=A1n=C3=AD=20n=C3=A1zv=C5=AF?= =?UTF-8?q?=20pro=20sestavy=20z=20properties=20souboru.=20Properties=20sou?= =?UTF-8?q?bory=20byly=20p=C5=99esunuty=20do=20WEB-INF/locales,=20p=C5=99e?= =?UTF-8?q?sunuty=20lang=20addony=20do=20WEB-INF/lang-addons.=20closes=20#?= =?UTF-8?q?79?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/info/bukova/isspst/StringUtils.java | 2 +- .../isspst/reporting/DynamicGenerator.java | 4 +- .../bukova/isspst/ui/LocaleConverter.java | 21 ++++++++++ .../info/bukova/isspst/ui/ReportDialogVM.java | 10 ++++- .../ckez-bind-lang-addon.xml | 0 .../{ => lang-addons}/mapa-lang-addon.xml | 0 .../webapp/WEB-INF/locales/columns.properties | 38 +++++++++++++++++++ .../WEB-INF/{ => locales}/zk-label.properties | 1 + src/main/webapp/WEB-INF/zk.xml | 9 ++++- src/main/webapp/app/reportDialog.zul | 2 +- 10 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 src/main/java/info/bukova/isspst/ui/LocaleConverter.java rename src/main/webapp/WEB-INF/{ => lang-addons}/ckez-bind-lang-addon.xml (100%) rename src/main/webapp/WEB-INF/{ => lang-addons}/mapa-lang-addon.xml (100%) create mode 100644 src/main/webapp/WEB-INF/locales/columns.properties rename src/main/webapp/WEB-INF/{ => locales}/zk-label.properties (98%) diff --git a/src/main/java/info/bukova/isspst/StringUtils.java b/src/main/java/info/bukova/isspst/StringUtils.java index cf352fc3..d3b8bcf2 100644 --- a/src/main/java/info/bukova/isspst/StringUtils.java +++ b/src/main/java/info/bukova/isspst/StringUtils.java @@ -28,7 +28,7 @@ public class StringUtils { } public static String localize(String key) { - return Labels.getLabel(key); + return Labels.getLabel(key) == null ? key : Labels.getLabel(key); } private static String getLocalized(String str) { diff --git a/src/main/java/info/bukova/isspst/reporting/DynamicGenerator.java b/src/main/java/info/bukova/isspst/reporting/DynamicGenerator.java index ee1bdaa0..79c5acc4 100644 --- a/src/main/java/info/bukova/isspst/reporting/DynamicGenerator.java +++ b/src/main/java/info/bukova/isspst/reporting/DynamicGenerator.java @@ -1,5 +1,7 @@ package info.bukova.isspst.reporting; +import info.bukova.isspst.StringUtils; + import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.List; @@ -49,7 +51,7 @@ public class DynamicGenerator implements Generator { Class clazz = colClass(col); if (clazz != null) { try { - rb.addColumn(col, col, clazz, 30, false); + rb.addColumn(StringUtils.localize(col), col, clazz, 30, false); } catch (ColumnBuilderException e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/src/main/java/info/bukova/isspst/ui/LocaleConverter.java b/src/main/java/info/bukova/isspst/ui/LocaleConverter.java new file mode 100644 index 00000000..e6efbcfb --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/LocaleConverter.java @@ -0,0 +1,21 @@ +package info.bukova.isspst.ui; + +import info.bukova.isspst.StringUtils; + +import org.zkoss.bind.BindContext; +import org.zkoss.bind.Converter; +import org.zkoss.zk.ui.Component; + +public class LocaleConverter implements Converter { + + @Override + public String coerceToBean(String str, Component component, BindContext ctx) { + return str; + } + + @Override + public String coerceToUi(String str, Component component, BindContext ctx) { + return StringUtils.localize(str); + } + +} diff --git a/src/main/java/info/bukova/isspst/ui/ReportDialogVM.java b/src/main/java/info/bukova/isspst/ui/ReportDialogVM.java index 4072aa8f..66bec2f7 100644 --- a/src/main/java/info/bukova/isspst/ui/ReportDialogVM.java +++ b/src/main/java/info/bukova/isspst/ui/ReportDialogVM.java @@ -27,18 +27,24 @@ public class ReportDialogVM { private List data; @WireVariable private ReportDefinition reportDefinition; + private LocaleConverter locConverter; @Init public void init(@ExecutionArgParam("reports") List reports, @ExecutionArgParam("data") List data) { this.reports = reports; this.data = data; + locConverter = new LocaleConverter(); if (data != null && data.size() > 0 && data.get(0).getClass() != reportDefinition.gatDataClass()) { reportDefinition.clear(); } } + public LocaleConverter getLocConverter() { + return locConverter; + } + public List getReports() { return this.reports; } @@ -64,7 +70,9 @@ public class ReportDialogVM { PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors(); List properties = new ArrayList(); for (PropertyDescriptor pd : pds) { - properties.add(pd.getName()); + if (!(pd.getName().equals("password") || pd.getName().equals("class") || pd.getName().equals("id") || pd.getName().equals("valid"))) { + properties.add(pd.getName()); + } } ListChecks columns = new ListChecks(reportDefinition.getFieldsToPrint(), properties); diff --git a/src/main/webapp/WEB-INF/ckez-bind-lang-addon.xml b/src/main/webapp/WEB-INF/lang-addons/ckez-bind-lang-addon.xml similarity index 100% rename from src/main/webapp/WEB-INF/ckez-bind-lang-addon.xml rename to src/main/webapp/WEB-INF/lang-addons/ckez-bind-lang-addon.xml diff --git a/src/main/webapp/WEB-INF/mapa-lang-addon.xml b/src/main/webapp/WEB-INF/lang-addons/mapa-lang-addon.xml similarity index 100% rename from src/main/webapp/WEB-INF/mapa-lang-addon.xml rename to src/main/webapp/WEB-INF/lang-addons/mapa-lang-addon.xml diff --git a/src/main/webapp/WEB-INF/locales/columns.properties b/src/main/webapp/WEB-INF/locales/columns.properties new file mode 100644 index 00000000..31df501b --- /dev/null +++ b/src/main/webapp/WEB-INF/locales/columns.properties @@ -0,0 +1,38 @@ +#Obecné +created=Vytvořeno +ownedBy=Vytvořil +modified=Změněno +modifiedBy=Změnil + +#Adresa +city=Město +company=Firma +contactName=Kontaktní osoba +department=Oddělení +description=Poznámka +dic=DIČ +email=E-mail +houseNumber=Číslo domu +ic=IČ +phone=Telefon +state=Stát +street=Ulice +web=Webová adresa +zipCode=PSČ + +#Budova +code=Kód +name=Název + +#Uživatel +accountNonExpired=Platný +accountNonLocked=Odemknutý +authorities=Role +credentialsNonExpired=Heslo je platné +enabled=Povolený +firstName=Jméno +fullName=Plné jméno +lastName=Příjmení +notify=Posílat oznámení +personalNumber=Osobní číslo +username=Uživatelské jméno \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties similarity index 98% rename from src/main/webapp/WEB-INF/zk-label.properties rename to src/main/webapp/WEB-INF/locales/zk-label.properties index 19c972fd..51e3507f 100644 --- a/src/main/webapp/WEB-INF/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -77,6 +77,7 @@ ReportSend=Odeslat ReportPrint=Tisk ReportReports=Sestavy ReportTitle=Nadpis sestavy: +ReportOptions=Volby sestavy Error=Chyba ErrorRights=K vykobání této operace nemáte dostatečná oprávnění diff --git a/src/main/webapp/WEB-INF/zk.xml b/src/main/webapp/WEB-INF/zk.xml index 57f1355d..009fe9fc 100644 --- a/src/main/webapp/WEB-INF/zk.xml +++ b/src/main/webapp/WEB-INF/zk.xml @@ -17,10 +17,15 @@ org.zkoss.web.classWebResource.cache false + + + /WEB-INF/locales/zk-label.properties + /WEB-INF/locales/columns.properties + - /WEB-INF/mapa-lang-addon.xml - /WEB-INF/ckez-bind-lang-addon.xml + /WEB-INF/lang-addons/mapa-lang-addon.xml + /WEB-INF/lang-addons/ckez-bind-lang-addon.xml /WEB-INF/lang-addons/CzechSortListheader.xml diff --git a/src/main/webapp/app/reportDialog.zul b/src/main/webapp/app/reportDialog.zul index 1b58a9b4..b71ab691 100644 --- a/src/main/webapp/app/reportDialog.zul +++ b/src/main/webapp/app/reportDialog.zul @@ -19,7 +19,7 @@