From 0d5312462c858bab52c5dd665a0d5f4483e38c37 Mon Sep 17 00:00:00 2001 From: willemc Date: Fri, 3 Aug 2007 04:09:01 +0200 Subject: [PATCH] [svn r262] made i18n work, added some images, made preperments for the user options --- .../annotations/VascAnnotationParser.java | 21 +++- .../idcanet/vasc/annotations/VascImage.java | 51 ++++++++ .../vasc/core/AbstractVascDataSource.java | 57 +++++++++ src/com/idcanet/vasc/core/VascDataSource.java | 9 +- src/com/idcanet/vasc/core/VascTable.java | 76 +++++------- src/com/idcanet/vasc/core/VascTextValue.java | 4 +- .../idcanet/vasc/core/VascViewRenderer.java | 10 +- .../vasc/impl/DefaultVascTableController.java | 6 +- .../vasc/impl/DefaultVascTextValue.java | 6 +- .../vasc/impl/actions/AddRowAction.java | 8 +- .../impl/actions/CSVExportGlobalAction.java | 10 +- .../vasc/impl/actions/DeleteRowAction.java | 8 +- .../vasc/impl/actions/EditRowAction.java | 8 +- .../impl/actions/RefreshDataGlobalAction.java | 8 +- .../impl/actions/XMLExportGlobalAction.java | 8 +- .../serv5/Serv5HibernateVascDataSource.java | 24 +++- .../impl/swing/SwingVascViewRenderer.java | 113 ++++++++++++------ .../vasc/impl/swt/SwtVascViewRenderer.java | 58 +++++---- tests/com/idcanet/vasc/SWTTest.java | 3 +- tests/com/idcanet/vasc/SwingTest.java | 9 +- .../idcanet/vasc/TestModelVascDataSource.java | 10 +- tests/com/idcanet/vasc/TestTable.java | 15 ++- tests/com/idcanet/vasc/VascI18nTextValue.java | 66 ++++++++++ tests/com/idcanet/vasc/models/TestModel.java | 2 + tests/resources/i18n/vasc.properties | 41 +++++++ tests/resources/images/gabelfresser.gif | Bin 0 -> 7043 bytes tests/{META-INF => resources}/xtes/tests.xml | 0 27 files changed, 468 insertions(+), 163 deletions(-) create mode 100644 src/com/idcanet/vasc/annotations/VascImage.java create mode 100644 src/com/idcanet/vasc/core/AbstractVascDataSource.java create mode 100644 tests/com/idcanet/vasc/VascI18nTextValue.java create mode 100644 tests/resources/i18n/vasc.properties create mode 100644 tests/resources/images/gabelfresser.gif rename tests/{META-INF => resources}/xtes/tests.xml (100%) diff --git a/src/com/idcanet/vasc/annotations/VascAnnotationParser.java b/src/com/idcanet/vasc/annotations/VascAnnotationParser.java index 103c1af..4f96618 100644 --- a/src/com/idcanet/vasc/annotations/VascAnnotationParser.java +++ b/src/com/idcanet/vasc/annotations/VascAnnotationParser.java @@ -114,6 +114,14 @@ public class VascAnnotationParser { return getValue(beanClass,VascDefaultValue.class,null); } + public String getVascImage(Class beanClass,String property) { + return (String)getValue(beanClass,VascImage.class,property); + } + + public String getVascImage(Class beanClass) { + return (String)getValue(beanClass,VascImage.class,null); + } + /** * No oop code here...refactor at some point in time * @@ -129,7 +137,11 @@ public class VascAnnotationParser { Object result = null; if(property==null) { - result = doAnnotation(beanClass.getAnnotation(annotationType)); + Annotation anno = beanClass.getAnnotation(annotationType); + if (anno==null) { + return null; // no annotion avaible + } + result = doAnnotation(anno); if(result!=null) { return result; } @@ -219,6 +231,13 @@ public class VascAnnotationParser { VascColumnWidth c = (VascColumnWidth)b; return c.width(); } + if (a.equals(VascImage.class)) { + VascImage c = (VascImage)b; + if("".equals(c.image()) | "null".equals(c.image())) { + return null; + } + return c.image(); + } return null; } diff --git a/src/com/idcanet/vasc/annotations/VascImage.java b/src/com/idcanet/vasc/annotations/VascImage.java new file mode 100644 index 0000000..8369e05 --- /dev/null +++ b/src/com/idcanet/vasc/annotations/VascImage.java @@ -0,0 +1,51 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions + * and the following disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Sets the VascImage property + * + * @author Willem Cazander + * @version 1.0 May 27, 2006 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD,ElementType.TYPE}) +public @interface VascImage { + + /** + * The resource or key of the Image, default to "null" + * @see com.idcanet.i18n.I18nAnnotationParser#getI18nLabelKey(Class, String) + * @return The key of the ToolTip + */ + String image() default "null"; +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/AbstractVascDataSource.java b/src/com/idcanet/vasc/core/AbstractVascDataSource.java new file mode 100644 index 0000000..5bfb22b --- /dev/null +++ b/src/com/idcanet/vasc/core/AbstractVascDataSource.java @@ -0,0 +1,57 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions + * and the following disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * + * @author Willem Cazander + * @version 1.0 Aug 2, 2007 + */ +abstract public class AbstractVascDataSource implements VascDataSource { + + Map parameters = null; + + public AbstractVascDataSource() { + parameters = new HashMap(10); + } + + public void setDataParameter(String key,Object data) { + parameters.put(key,data); + } + + public Object getDataParameter(String key) { + return parameters.get(key); + } + + public Set getDataParameterKeys() { + return parameters.keySet(); + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascDataSource.java b/src/com/idcanet/vasc/core/VascDataSource.java index a6e3080..780118b 100644 --- a/src/com/idcanet/vasc/core/VascDataSource.java +++ b/src/com/idcanet/vasc/core/VascDataSource.java @@ -27,8 +27,7 @@ package com.idcanet.vasc.core; import java.util.List; - -import com.idcanet.xtes.xpql.query.Query; +import java.util.Set; /** @@ -38,7 +37,11 @@ import com.idcanet.xtes.xpql.query.Query; */ public interface VascDataSource { - public List executeQuery(Query query) throws Exception; + public void setDataParameter(String key,Object data); + public Object getDataParameter(String key); + public Set getDataParameterKeys(); + + public List execute() throws Exception; public void persist(Object object) throws Exception; diff --git a/src/com/idcanet/vasc/core/VascTable.java b/src/com/idcanet/vasc/core/VascTable.java index 46f8858..1191844 100644 --- a/src/com/idcanet/vasc/core/VascTable.java +++ b/src/com/idcanet/vasc/core/VascTable.java @@ -33,7 +33,6 @@ import com.idcanet.vasc.core.actions.ColumnVascAction; import com.idcanet.vasc.core.actions.GlobalVascAction; import com.idcanet.vasc.core.actions.RowVascAction; import com.idcanet.vasc.core.column.VascTableColumn; -import com.idcanet.xtes.xpql.query.Query; /** * @@ -44,14 +43,13 @@ public class VascTable { private String name = null; private String headerName = null; - private String description = null; - private String toolTip = null; + private String headerImage = null; + private String headerToolTip = null; private List tableColumns = null; private List rowActions = null; private List columnActions = null; private List globalActions = null; private VascDataSource vascDataSource = null; - private Query query = null; private List tableData = null; private Object selectedObject = null; private VascRecordCreator vascRecordCreator = null; @@ -84,19 +82,6 @@ public class VascTable { columnActions.add(columnAction); } - /** - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } /** * @return the globalActions @@ -140,20 +125,6 @@ public class VascTable { this.name = name; } - /** - * @return the query - */ - public Query getQuery() { - return query; - } - - /** - * @param query the query to set - */ - public void setQuery(Query query) { - this.query = query; - } - /** * @return the rowActions */ @@ -216,19 +187,6 @@ public class VascTable { this.tableData = tableData; } - /** - * @return the toolTip - */ - public String getToolTip() { - return toolTip; - } - - /** - * @param toolTip the toolTip to set - */ - public void setToolTip(String toolTip) { - this.toolTip = toolTip; - } /** * @return the userOptions @@ -327,6 +285,32 @@ public class VascTable { public void setVascTableController(VascTableController vascTableController) { this.vascTableController = vascTableController; } - - + + /** + * @return the headerImage + */ + public String getHeaderImage() { + return headerImage; + } + + /** + * @param headerImage the headerImage to set + */ + public void setHeaderImage(String headerImage) { + this.headerImage = headerImage; + } + + /** + * @return the headerToolTip + */ + public String getHeaderToolTip() { + return headerToolTip; + } + + /** + * @param headerToolTip the headerToolTip to set + */ + public void setHeaderToolTip(String headerToolTip) { + this.headerToolTip = headerToolTip; + } } diff --git a/src/com/idcanet/vasc/core/VascTextValue.java b/src/com/idcanet/vasc/core/VascTextValue.java index 6b8c3b9..1ce655f 100644 --- a/src/com/idcanet/vasc/core/VascTextValue.java +++ b/src/com/idcanet/vasc/core/VascTextValue.java @@ -33,7 +33,7 @@ package com.idcanet.vasc.core; * @version 1.0 Mar 21, 2007 */ public interface VascTextValue { - - public String getTextValue(String text); + + public String getTextValue(String key,Object...params); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascViewRenderer.java b/src/com/idcanet/vasc/core/VascViewRenderer.java index aaf8f4b..c1799d8 100644 --- a/src/com/idcanet/vasc/core/VascViewRenderer.java +++ b/src/com/idcanet/vasc/core/VascViewRenderer.java @@ -36,13 +36,15 @@ import com.idcanet.vasc.core.column.VascTableColumn; */ public interface VascViewRenderer { - public void renderView(VascTable table) throws Exception; + public void initTable(VascTable table) throws Exception; + + public void renderView() throws Exception; - public void renderEdit(VascTable table,Object rowBean) throws Exception; + public void renderEdit(Object rowBean) throws Exception; - public void renderDelete(VascTable table,Object rowBean) throws Exception; + public void renderDelete(Object rowBean) throws Exception; - public void renderExport(VascTable table,VascDataExporter exporter) throws Exception; + public void renderExport(VascDataExporter exporter) throws Exception; public Object defaultColumnEditor(VascTableColumn column,Object bean,Object gui) throws Exception; diff --git a/src/com/idcanet/vasc/impl/DefaultVascTableController.java b/src/com/idcanet/vasc/impl/DefaultVascTableController.java index c07d777..c48f99c 100644 --- a/src/com/idcanet/vasc/impl/DefaultVascTableController.java +++ b/src/com/idcanet/vasc/impl/DefaultVascTableController.java @@ -86,6 +86,9 @@ public class DefaultVascTableController implements VascTableController { if (c.getVascColumnValue()==null) { c.setVascColumnValue(new BeanPropertyVascColumnValue(column.getBeanProperty())); } + if (c.getImage()==null) { + c.setImage(vap.getVascImage(table.getVascRecordCreator().getObjectClass(),column.getBeanProperty())); + } } if (c.getVascColumnEditor()==null) { c.setVascColumnEditor(new DefaultVascColumnEditor()); @@ -146,7 +149,8 @@ public class DefaultVascTableController implements VascTableController { * @see com.idcanet.vasc.core.VascTableController#refreshData() */ public void refreshData(VascTable table) throws Exception { - table.setTableData(table.getVascDataSource().executeQuery(table.getQuery())); + table.setTableData(table.getVascDataSource().execute()); + fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, null); } public void handleException(Exception e,VascTable table) { diff --git a/src/com/idcanet/vasc/impl/DefaultVascTextValue.java b/src/com/idcanet/vasc/impl/DefaultVascTextValue.java index 7920d11..1d31606 100644 --- a/src/com/idcanet/vasc/impl/DefaultVascTextValue.java +++ b/src/com/idcanet/vasc/impl/DefaultVascTextValue.java @@ -35,7 +35,11 @@ import com.idcanet.vasc.core.VascTextValue; */ public class DefaultVascTextValue implements VascTextValue { - public String getTextValue(String text) { + public String getKeyMapping(String key) { + return key; + } + + public String getTextValue(String text,Object...params) { return text; } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/actions/AddRowAction.java b/src/com/idcanet/vasc/impl/actions/AddRowAction.java index cb73692..4b9b4be 100644 --- a/src/com/idcanet/vasc/impl/actions/AddRowAction.java +++ b/src/com/idcanet/vasc/impl/actions/AddRowAction.java @@ -38,12 +38,12 @@ import com.idcanet.vasc.core.actions.RowVascAction; public class AddRowAction extends AbstractVascAction implements RowVascAction { public AddRowAction() { - setName("generic.crud.add"); - setToolTip("generic.toolTip"); - setImage("/META-INF/images/silk/png/table_add.png"); + setName("vasc.action.add.name"); + setToolTip("vasc.action.add.tooltip"); + setImage("vasc.action.add.image"); } public void doRowAction(VascTable table,Object rowObject) throws Exception { - table.getVascViewRenderer().renderEdit(table,table.getVascRecordCreator().newRecord(table)); + table.getVascViewRenderer().renderEdit(table.getVascRecordCreator().newRecord(table)); } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/actions/CSVExportGlobalAction.java b/src/com/idcanet/vasc/impl/actions/CSVExportGlobalAction.java index 888455b..4cee71d 100644 --- a/src/com/idcanet/vasc/impl/actions/CSVExportGlobalAction.java +++ b/src/com/idcanet/vasc/impl/actions/CSVExportGlobalAction.java @@ -43,18 +43,18 @@ import com.idcanet.vasc.core.column.VascTableColumn; public class CSVExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascDataExporter { public CSVExportGlobalAction() { - setName("generic.crud.export.csv.name"); - setToolTip("generic.crud.export.csv.tooltip"); - setImage("/META-INF/images/silk/png/page_white_excel.png"); + setName("vasc.action.csv.name"); + setToolTip("vasc.action.csv.tooltip"); + setImage("vasc.action.csv.image"); } public void doGlobalAction(VascTable table) throws Exception { - table.getVascViewRenderer().renderExport(table,this); + table.getVascViewRenderer().renderExport(this); } public void doExport(OutputStream out,VascTable table) throws Exception { PrintWriter p = new PrintWriter(out); - p.write("# csv file\n"); + p.write("# csv\n"); for (VascTableColumn c:table.getTableColumns()) { p.write(c.getName()+"\t"); } diff --git a/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java b/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java index c0824b0..d1d665f 100644 --- a/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java +++ b/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java @@ -38,15 +38,15 @@ import com.idcanet.vasc.core.actions.RowVascAction; public class DeleteRowAction extends AbstractVascAction implements RowVascAction { public DeleteRowAction() { - setName("generic.crud.delete.name"); - setToolTip("generic.crud.delete.tooltip"); - setImage("/META-INF/images/silk/png/table_delete.png"); + setName("vasc.action.del.name"); + setToolTip("vasc.action.del.tooltip"); + setImage("vasc.action.del.image"); } public void doRowAction(VascTable table,Object rowObject) throws Exception { if (rowObject==null) { return; } - table.getVascViewRenderer().renderDelete(table,rowObject); + table.getVascViewRenderer().renderDelete(rowObject); } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/actions/EditRowAction.java b/src/com/idcanet/vasc/impl/actions/EditRowAction.java index 6e45213..70f70dc 100644 --- a/src/com/idcanet/vasc/impl/actions/EditRowAction.java +++ b/src/com/idcanet/vasc/impl/actions/EditRowAction.java @@ -38,9 +38,9 @@ import com.idcanet.vasc.core.actions.RowVascAction; public class EditRowAction extends AbstractVascAction implements RowVascAction { public EditRowAction() { - setName("generic.crud.edit"); - setToolTip("generic.crud.edit.toolTip"); - setImage("/META-INF/images/silk/png/table_edit.png"); + setName("vasc.action.edit.name"); + setToolTip("vasc.action.edit.tooltip"); + setImage("vasc.action.edit.image"); } @@ -48,6 +48,6 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction { if (rowObject==null) { return; } - table.getVascViewRenderer().renderEdit(table,rowObject); + table.getVascViewRenderer().renderEdit(rowObject); } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/actions/RefreshDataGlobalAction.java b/src/com/idcanet/vasc/impl/actions/RefreshDataGlobalAction.java index 5fec03a..2d1542f 100644 --- a/src/com/idcanet/vasc/impl/actions/RefreshDataGlobalAction.java +++ b/src/com/idcanet/vasc/impl/actions/RefreshDataGlobalAction.java @@ -38,13 +38,13 @@ import com.idcanet.vasc.core.actions.GlobalVascAction; public class RefreshDataGlobalAction extends AbstractVascAction implements GlobalVascAction { public RefreshDataGlobalAction() { - setName("generic.refresh"); - setToolTip("generic.crud.refresh.tooltip"); - setImage("/META-INF/images/silk/png/table_refresh.png"); + setName("vasc.action.refresh.name"); + setToolTip("vasc.action.refresh.tooltip"); + setImage("vasc.action.refresh.image"); } public void doGlobalAction(VascTable table) throws Exception { - table.getVascTableController().refreshData(table); + table.getVascTableController().refreshData(table); // this wil also fire the event } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java b/src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java index 778318b..73a9853 100644 --- a/src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java +++ b/src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java @@ -43,13 +43,13 @@ import com.idcanet.vasc.core.column.VascTableColumn; public class XMLExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascDataExporter { public XMLExportGlobalAction() { - setName("generic.crud.export.xml.name"); - setToolTip("generic.crud.export.xml.tooltip"); - setImage("/META-INF/images/silk/png/page_white_excel.png"); + setName("vasc.action.xml.name"); + setToolTip("vasc.action.xml.tooltip"); + setImage("vasc.action.xml.image"); } public void doGlobalAction(VascTable table) throws Exception { - table.getVascViewRenderer().renderExport(table,this); + table.getVascViewRenderer().renderExport(this); } public void doExport(OutputStream out,VascTable table) throws Exception { diff --git a/src/com/idcanet/vasc/impl/serv5/Serv5HibernateVascDataSource.java b/src/com/idcanet/vasc/impl/serv5/Serv5HibernateVascDataSource.java index dd38714..dd69a30 100644 --- a/src/com/idcanet/vasc/impl/serv5/Serv5HibernateVascDataSource.java +++ b/src/com/idcanet/vasc/impl/serv5/Serv5HibernateVascDataSource.java @@ -32,6 +32,7 @@ import java.util.logging.Level; import org.hibernate.Query; import com.idcanet.serv5.services.hibernate3.Hibernate3Factory; +import com.idcanet.vasc.core.AbstractVascDataSource; import com.idcanet.vasc.core.VascDataSource; import com.idcanet.xtes.xpql.query.QueryParameterValue; @@ -40,18 +41,21 @@ import com.idcanet.xtes.xpql.query.QueryParameterValue; * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public class Serv5HibernateVascDataSource implements VascDataSource { +public class Serv5HibernateVascDataSource extends AbstractVascDataSource { private String session = null; + private com.idcanet.xtes.xpql.query.Query query = null; + public Serv5HibernateVascDataSource() { } - public Serv5HibernateVascDataSource(String session) { + public Serv5HibernateVascDataSource(String session,com.idcanet.xtes.xpql.query.Query query) { setSession(session); + setQuery(query); } - public List executeQuery(com.idcanet.xtes.xpql.query.Query query) throws Exception { + public List execute() throws Exception { try { Query q = Hibernate3Factory.getSession(getSession()).createQuery(query.toPreparedSQL(query)); @@ -101,6 +105,7 @@ public class Serv5HibernateVascDataSource implements VascDataSource { public String getSession() { return session; } + /** * @param session the session to set */ @@ -108,6 +113,17 @@ public class Serv5HibernateVascDataSource implements VascDataSource { this.session = session; } + /** + * @return the query + */ + public com.idcanet.xtes.xpql.query.Query getQuery() { + return query; + } - + /** + * @param query the query to set + */ + public void setQuery(com.idcanet.xtes.xpql.query.Query query) { + this.query = query; + } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java b/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java index 0ec6236..96b68d5 100644 --- a/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java +++ b/src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java @@ -31,6 +31,8 @@ import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Font; +import java.awt.Image; +import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.FileOutputStream; @@ -38,6 +40,7 @@ import java.io.OutputStream; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JComponent; @@ -89,6 +92,21 @@ public class SwingVascViewRenderer implements VascViewRenderer { this.parent=parent; } + + public void initTable(VascTable table) throws Exception { + if (table.getVascViewRenderer()==null) { + table.setVascViewRenderer(this); + } else { + if (table.getVascViewRenderer()!=this) { + throw new IllegalArgumentException("VascTable has already a differtent VascViewRenderer attected"); + } + } + table.getVascTableController().finalizeVascColumns(table); + table.getVascTableController().finalizeVascTable(table); + table.getVascTableController().refreshData(table); + this.table=table; + } + /** * @see com.idcanet.vasc.core.VascViewRenderer#defaultColumnEditor(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object, java.lang.Object) */ @@ -101,7 +119,10 @@ public class SwingVascViewRenderer implements VascViewRenderer { } public ImageIcon getImageIcon(String imageResource) { - return SwingImageHelper.getImageIcon(imageResource); + /// TODO hack beter + String key = table.getVascTextValue().getTextValue(imageResource); + + return SwingImageHelper.getImageIcon(key); } class TextListener implements DocumentListener { @@ -114,21 +135,21 @@ public class SwingVascViewRenderer implements VascViewRenderer { this.bean=bean; } - /* (non-Javadoc) + /** * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent) */ public void changedUpdate(DocumentEvent e) { update(e); } - /* (non-Javadoc) + /** * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent) */ public void insertUpdate(DocumentEvent e) { update(e); } - /* (non-Javadoc) + /** * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent) */ public void removeUpdate(DocumentEvent e) { @@ -161,26 +182,24 @@ public class SwingVascViewRenderer implements VascViewRenderer { /** * @see com.idcanet.vasc.core.VascViewRenderer#renderEdit(com.idcanet.vasc.core.VascTable, java.lang.Object) */ - public void renderEdit(VascTable table, Object rowBean) throws Exception { + public void renderEdit(Object rowBean) throws Exception { logger.info("Rending Edit View"); table.getVascTableController().initEditObject(table, rowBean); SwingEditDialog dialog = new SwingEditDialog(parent,table,rowBean,"Vasc Edit","Edit"); Object result = dialog.openDialog(); - System.out.println("---------------- OPEN closed : "+result); + logger.finest("OPEN closed : "+result); if(result==null) { return; } try { result = table.getVascDataSource().merge(rowBean); - table.getVascTableController().fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, result); } finally { - //TODO: or merge into table == faster table.getVascTableController().refreshData(table); } } - public void renderDelete(VascTable table,Object rowBean) throws Exception { + public void renderDelete(Object rowBean) throws Exception { int response = JOptionPane.showOptionDialog( parent // Center in window. , "Delete "+rowBean // Message @@ -212,7 +231,7 @@ public class SwingVascViewRenderer implements VascViewRenderer { this.bean = bean; - setTitle(title); + setTitle(table.getVascTextValue().getTextValue(title)); setModal(true); JPanel pane = new JPanel(); @@ -252,8 +271,9 @@ public class SwingVascViewRenderer implements VascViewRenderer { public void createHeader(JPanel header) { JLabel l = new JLabel(); - l.setText(headerText); + l.setText(table.getVascTextValue().getTextValue(headerText)); l.setFont(new Font(null,Font.BOLD, 14)); + //l.setToolTipText(table.getVascTextValue().getTextValue(headerText)); header.add(l); } @@ -291,8 +311,9 @@ public class SwingVascViewRenderer implements VascViewRenderer { public void createFooter(JPanel footer) { JButton saveButton = new JButton(); - saveButton.setIcon(getImageIcon("/META-INF/images/silk/png/tick.png")); - saveButton.setText("generic.save"); + saveButton.setIcon(getImageIcon("vasc.dialog.save.image")); + saveButton.setText(table.getVascTextValue().getTextValue("vasc.dialog.save.name")); + saveButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.save.tooltip")); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { //if(hasRecordError()) { @@ -305,8 +326,9 @@ public class SwingVascViewRenderer implements VascViewRenderer { footer.add(saveButton); JButton cancelButton = new JButton(); - cancelButton.setIcon(getImageIcon("/META-INF/images/silk/png/cancel.png")); - cancelButton.setText("generic.cancel"); + cancelButton.setIcon(getImageIcon("vasc.dialog.cancel.image")); + cancelButton.setText(table.getVascTextValue().getTextValue("vasc.dialog.cancel.name")); + cancelButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.cancel.tooltip")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { result = null; @@ -323,7 +345,7 @@ public class SwingVascViewRenderer implements VascViewRenderer { /** * @see com.idcanet.vasc.core.VascViewRenderer#renderExport(com.idcanet.vasc.core.VascTable, com.idcanet.vasc.core.VascDataExporter) */ - public void renderExport(VascTable table, VascDataExporter exporter) throws Exception { + public void renderExport(VascDataExporter exporter) throws Exception { String fileName = null; JFileChooser c = new JFileChooser(); @@ -359,20 +381,8 @@ public class SwingVascViewRenderer implements VascViewRenderer { /** * @see com.idcanet.vasc.core.VascViewRenderer#renderView(com.idcanet.vasc.core.VascTable) */ - public void renderView(VascTable table) throws Exception { - - if (table.getVascViewRenderer()==null) { - table.setVascViewRenderer(this); - } else { - if (table.getVascViewRenderer()!=this) { - throw new IllegalArgumentException("VascTable has already a differtent VascViewRenderer attected"); - } - } - table.getVascTableController().finalizeVascColumns(table); - table.getVascTableController().finalizeVascTable(table); - table.getVascTableController().refreshData(table); - this.table=table; - + public void renderView() throws Exception { + JPanel topPanel = new JPanel(); topPanel.setLayout(new BorderLayout()); //topPanel.setBackground(Color.PINK); @@ -397,27 +407,52 @@ public class SwingVascViewRenderer implements VascViewRenderer { } private void renderHeader(JComponent parent2) { + + JPanel header = new JPanel(); + header.setLayout(new BorderLayout()); + header.setBackground(Color.WHITE); + header.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + if(table.getHeaderImage()!=null) { + JLabel l = new JLabel(); + + // TODO: hack images working + l.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(table.getHeaderImage())).getScaledInstance(32, 32, Image.SCALE_SMOOTH))); + l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip())); + header.add(l,BorderLayout.WEST); + } if(table.getHeaderName()!=null) { JLabel l = new JLabel(table.getVascTextValue().getTextValue(table.getHeaderName())); - l.setFont(new Font(null,Font.BOLD, 14)); - parent2.add(l); + l.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + l.setFont(new Font(null,Font.BOLD, 18)); + l.setToolTipText(table.getVascTextValue().getTextValue(table.getHeaderToolTip())); + header.add(l,BorderLayout.CENTER); } - + JPanel top = new JPanel(); + //top.setBackground(Color.BLUE); for (GlobalVascAction action:table.getGlobalActions()) { JButton but = new JButton(); but.setText(table.getVascTextValue().getTextValue(action.getName())); but.setToolTipText(table.getVascTextValue().getTextValue(action.getToolTip())); but.addActionListener(new GlobalActionListener(action)); but.setIcon(getImageIcon(action.getImage())); - parent2.add(but); + top.add(but); } // create options + JPanel optionPanel = new JPanel(); + //top.setBackground(Color.GREEN); for(VascUserOption option:table.getUserOptions()) { - + Object obj = option.createUserOptionRenderer(table); } + + //top.add(header,BorderLayout.NORTH); + parent2.setLayout(new BorderLayout()); + parent2.add(header,BorderLayout.NORTH); + parent2.add(optionPanel,BorderLayout.CENTER); + parent2.add(top,BorderLayout.EAST); } private void renderBody(JComponent parent2) { @@ -487,6 +522,7 @@ public class SwingVascViewRenderer implements VascViewRenderer { setFont(header.getFont()); } } + //setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); setBorder(UIManager.getBorder("TableHeader.cellBorder")); return this; } @@ -495,14 +531,17 @@ public class SwingVascViewRenderer implements VascViewRenderer { private void renderFooter(JComponent parent2) { logger.finest("Creating footer"); + JPanel panel = new JPanel(); for(RowVascAction action:table.getRowActions()) { JButton but = new JButton(); but.setText(table.getVascTextValue().getTextValue(action.getName())); but.setToolTipText(table.getVascTextValue().getTextValue(action.getToolTip())); but.setIcon(getImageIcon(action.getImage())); but.addActionListener(new RowActionListener(action)); - parent2.add(but); + panel.add(but); } + parent2.setLayout(new BorderLayout()); + parent2.add(panel,BorderLayout.WEST); } @@ -572,7 +611,7 @@ public class SwingVascViewRenderer implements VascViewRenderer { */ public Object getValueAt(int rowIndex, int columnIndex) { Object bean = table.getTableData().get(rowIndex); - System.out.println("Rending column; "+columnIndex+" bean: "+bean); + logger.finer("Rending column; "+columnIndex+" bean: "+bean); VascTableColumn vtc = table.getTableColumns().get(columnIndex); if (vtc.getColumnRenderer()!=null) { //do iets diff --git a/src/com/idcanet/vasc/impl/swt/SwtVascViewRenderer.java b/src/com/idcanet/vasc/impl/swt/SwtVascViewRenderer.java index 81fa326..3a500ac 100644 --- a/src/com/idcanet/vasc/impl/swt/SwtVascViewRenderer.java +++ b/src/com/idcanet/vasc/impl/swt/SwtVascViewRenderer.java @@ -90,6 +90,20 @@ public class SwtVascViewRenderer implements VascViewRenderer { this.parent=parent; } + public void initTable(VascTable table) throws Exception { + if (table.getVascViewRenderer()==null) { + table.setVascViewRenderer(this); + } else { + if (table.getVascViewRenderer()!=this) { + throw new IllegalArgumentException("VascTable has already a differtent VascViewRenderer attected"); + } + } + table.getVascTableController().finalizeVascColumns(table); + table.getVascTableController().finalizeVascTable(table); + table.getVascTableController().refreshData(table); + this.table=table; + } + private static final String[] FILTER_NAMES = { "All Files (*.*)", "Comma Separated Values Files (*.csv)", @@ -98,7 +112,7 @@ public class SwtVascViewRenderer implements VascViewRenderer { /** These filter extensions are used to filter which files are displayed. */ private static final String[] FILTER_EXTS = { "*.*","*.csv","*.xls" }; - public void renderExport(VascTable table,VascDataExporter exporter) throws Exception { + public void renderExport(VascDataExporter exporter) throws Exception { FileDialog dlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE); dlg.setFilterNames(FILTER_NAMES); dlg.setFilterExtensions(FILTER_EXTS); @@ -121,7 +135,7 @@ public class SwtVascViewRenderer implements VascViewRenderer { } } - public void renderEdit(VascTable table,Object object) throws Exception { + public void renderEdit(Object object) throws Exception { logger.info("Rending Edit View"); table.getVascTableController().initEditObject(table, object); @@ -142,6 +156,9 @@ public class SwtVascViewRenderer implements VascViewRenderer { public ImageDescriptor getImageDescriptor(String path) { try { + path = table.getVascTextValue().getTextValue(path); + + logger.info("Loading image: "+path); //System.out.println("==== 1"); ImageDescriptor result = ImageDescriptor.createFromFile(path.getClass(), path); @@ -172,7 +189,7 @@ public class SwtVascViewRenderer implements VascViewRenderer { } } - public void renderDelete(VascTable table,Object rowBean) throws Exception { + public void renderDelete(Object rowBean) throws Exception { } @@ -282,8 +299,9 @@ public class SwtVascViewRenderer implements VascViewRenderer { new Label(body, SWT.WRAP); Button saveButton = new Button(body, SWT.NONE); - saveButton.setImage(getImageDescriptor("/META-INF/images/silk/png/tick.png").createImage()); - saveButton.setText("generic.save"); + saveButton.setImage(getImageDescriptor("vasc.dialog.save.image").createImage()); + saveButton.setText(table.getVascTextValue().getTextValue("vasc.dialog.save.name")); + saveButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.save.tooltip")); saveButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { //if(hasRecordError()) { @@ -294,8 +312,9 @@ public class SwtVascViewRenderer implements VascViewRenderer { } }); Button cancelButton = new Button(body, SWT.NONE); - cancelButton.setImage(getImageDescriptor("/META-INF/images/silk/png/cancel.png").createImage()); - cancelButton.setText("generic.cancel"); + cancelButton.setImage(getImageDescriptor("vasc.dialog.cancel.image").createImage()); + cancelButton.setText(table.getVascTextValue().getTextValue("vasc.dialog.cancel.name")); + cancelButton.setToolTipText(table.getVascTextValue().getTextValue("vasc.dialog.cancel.tooltip")); cancelButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { result = null; @@ -345,21 +364,7 @@ public class SwtVascViewRenderer implements VascViewRenderer { } - public void renderView(VascTable table) throws Exception { - - if (table.getVascViewRenderer()==null) { - table.setVascViewRenderer(this); - } else { - if (table.getVascViewRenderer()!=this) { - throw new IllegalArgumentException("VascTable has already a differtent VascViewRenderer attected"); - } - } - - table.getVascTableController().finalizeVascColumns(table); - table.getVascTableController().finalizeVascTable(table); - table.getVascTableController().refreshData(table); - - this.table=table; + public void renderView() throws Exception { GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; @@ -424,8 +429,8 @@ public class SwtVascViewRenderer implements VascViewRenderer { ToolBar toolBar = new ToolBar(headerBar, SWT.NONE); for (GlobalVascAction action:table.getGlobalActions()) { ToolItem item = new ToolItem(toolBar, SWT.PUSH); - item.setText(action.getName()); - item.setToolTipText(action.getToolTip()); + item.setText(table.getVascTextValue().getTextValue(action.getName())); + item.setToolTipText(table.getVascTextValue().getTextValue(action.getToolTip())); if (action.getImage()!=null) { item.setImage(getImageDescriptor(action.getImage()).createImage()); } @@ -438,6 +443,7 @@ public class SwtVascViewRenderer implements VascViewRenderer { if(table.getHeaderName()!=null) { Font headerFont = new Font(header.getDisplay(), "verdana", 16, SWT.BOLD); Label l = new Label(headerName, SWT.CENTER); + l.setImage(getImageDescriptor(table.getHeaderImage()).createImage()); l.setFont(headerFont); l.setText(table.getVascTextValue().getTextValue(table.getHeaderName())); l.setBackground(c); @@ -596,8 +602,8 @@ public class SwtVascViewRenderer implements VascViewRenderer { logger.finest("Creating footer"); for(RowVascAction action:table.getRowActions()) { Button actionButton = new Button(footer, SWT.NONE); - actionButton.setText(action.getName()); - actionButton.setToolTipText(action.getToolTip()); + actionButton.setText(table.getVascTextValue().getTextValue(action.getName())); + actionButton.setToolTipText(table.getVascTextValue().getTextValue(action.getToolTip())); if (action.getImage()!=null) { actionButton.setImage(getImageDescriptor(action.getImage()).createImage()); } diff --git a/tests/com/idcanet/vasc/SWTTest.java b/tests/com/idcanet/vasc/SWTTest.java index 426df33..633a540 100644 --- a/tests/com/idcanet/vasc/SWTTest.java +++ b/tests/com/idcanet/vasc/SWTTest.java @@ -65,7 +65,8 @@ public class SWTTest extends TestCase { // define redering and render SwtVascViewRenderer render = new SwtVascViewRenderer(shell); - render.renderView(TestTable.getVascTable()); + render.initTable(TestTable.getVascTable()); + render.renderView(); // view shell.open(); diff --git a/tests/com/idcanet/vasc/SwingTest.java b/tests/com/idcanet/vasc/SwingTest.java index 28b8182..2d985b0 100644 --- a/tests/com/idcanet/vasc/SwingTest.java +++ b/tests/com/idcanet/vasc/SwingTest.java @@ -32,6 +32,7 @@ import java.util.logging.LogManager; import javax.swing.JFrame; import javax.swing.JPanel; +import com.idcanet.vasc.core.VascTable; import com.idcanet.vasc.impl.swing.SwingVascViewRenderer; import junit.framework.TestCase; @@ -63,13 +64,19 @@ public class SwingTest extends TestCase { frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setLocationRelativeTo(null); + // get table + VascTable table = TestTable.getVascTable(); + // define redering JPanel panel = new JPanel(); SwingVascViewRenderer render = new SwingVascViewRenderer(panel); frame.add(panel); // render - render.renderView(TestTable.getVascTable()); + render.initTable(table); + + //render.renderEdit(table.getTableData().get(0)); + render.renderView(); // view frame.pack(); diff --git a/tests/com/idcanet/vasc/TestModelVascDataSource.java b/tests/com/idcanet/vasc/TestModelVascDataSource.java index e2f98ac..caa2c82 100644 --- a/tests/com/idcanet/vasc/TestModelVascDataSource.java +++ b/tests/com/idcanet/vasc/TestModelVascDataSource.java @@ -30,7 +30,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import com.idcanet.vasc.core.VascDataSource; +import com.idcanet.vasc.core.AbstractVascDataSource; import com.idcanet.vasc.models.TestModel; /** @@ -38,7 +38,7 @@ import com.idcanet.vasc.models.TestModel; * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public class TestModelVascDataSource implements VascDataSource { +public class TestModelVascDataSource extends AbstractVascDataSource { private List testModels = null; @@ -63,22 +63,22 @@ public class TestModelVascDataSource implements VascDataSource { this.testModels=testModels; } - public List executeQuery(com.idcanet.xtes.xpql.query.Query query) throws Exception { + public List execute() throws Exception { return testModels; } public void persist(Object object) throws Exception { testModels.add(object); } + public Object merge(Object object) throws Exception { if(testModels.contains(object)==false) { testModels.add(object); } return object; } + public void delete(Object object) throws Exception { testModels.remove(object); } - - } \ No newline at end of file diff --git a/tests/com/idcanet/vasc/TestTable.java b/tests/com/idcanet/vasc/TestTable.java index 5ce3b1d..3e314c0 100644 --- a/tests/com/idcanet/vasc/TestTable.java +++ b/tests/com/idcanet/vasc/TestTable.java @@ -57,22 +57,25 @@ public class TestTable { static public VascTable getVascTable() throws Exception { // define query + /* XTESParser parser = new XTESParser(); - parser.parseResource("/META-INF/xtes/tests.xml"); + parser.parseResource("/resources/xtes/tests.xml"); TemplateStore store = XTESParser.getTemplateStore(parser.getElementContext()); Query query = store.getQuery("testUsers2"); + */ // config table VascTable table = new VascTable(); table.setName("Testje"); - table.setHeaderName("TableHeader"); - table.setToolTip("tooltip text"); - table.setDescription("en de omscheiving"); + table.setHeaderName("Test Table enzo"); + table.setHeaderToolTip("Met een hele coole tooltip"); + table.setHeaderImage("/resources/images/gabelfresser.gif"); table.setHelpId("someKey"); table.setVascTableController(new DefaultVascTableController()); table.setVascDataSource(new TestModelVascDataSource()); - table.setVascTextValue(new DefaultVascTextValue()); - table.setQuery(query); + + //table.setVascTextValue(new DefaultVascTextValue()); + table.setVascTextValue(new VascI18nTextValue()); table.setVascRecordCreator(new BeanVascRecordCreator(TestModel.class)); table.addRowActions(new AddRowAction()); table.addRowActions(new EditRowAction()); diff --git a/tests/com/idcanet/vasc/VascI18nTextValue.java b/tests/com/idcanet/vasc/VascI18nTextValue.java new file mode 100644 index 0000000..5567731 --- /dev/null +++ b/tests/com/idcanet/vasc/VascI18nTextValue.java @@ -0,0 +1,66 @@ +/* + * Copyright 2004-2007 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions + * and the following disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.vasc; + +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import java.util.logging.Logger; + +import com.idcanet.vasc.core.VascTextValue; + +/** + * + * @author Willem Cazander + * @version 1.0 Aug 2, 2007 + */ +public class VascI18nTextValue implements VascTextValue { + + + private String getKeyMapping(String key) { + return key; + } + + public String getTextValue(String key,Object...params) { + return i18n(getKeyMapping(key),params); + } + + static private String i18n(String key,Object...params) { + if (key==null) { throw new NullPointerException("key may not be null"); } + try { + String text = ResourceBundle.getBundle("resources.i18n.vasc").getString(key); + if (params != null) { + MessageFormat mf = new MessageFormat(text); + text = mf.format(params, new StringBuffer(), null).toString(); + } + return text; + } catch(MissingResourceException e){ + Logger.getAnonymousLogger().finer("Missing i18n or non i18n key: "+key); + return key; + } + } +} \ No newline at end of file diff --git a/tests/com/idcanet/vasc/models/TestModel.java b/tests/com/idcanet/vasc/models/TestModel.java index 1f37fc0..a321f90 100644 --- a/tests/com/idcanet/vasc/models/TestModel.java +++ b/tests/com/idcanet/vasc/models/TestModel.java @@ -35,6 +35,7 @@ import org.hibernate.validator.Max; import com.idcanet.vasc.annotations.VascColumnWidth; import com.idcanet.vasc.annotations.VascDefaultValue; import com.idcanet.vasc.annotations.VascHelpId; +import com.idcanet.vasc.annotations.VascImage; import com.idcanet.vasc.annotations.VascName; import com.idcanet.vasc.annotations.VascToolTip; @@ -74,6 +75,7 @@ public class TestModel { @VascHelpId(helpId="help.id") @VascDefaultValue(defaultValue="xxxxx") @VascColumnWidth(width=200) + @VascImage(image="/resources/images/gabelfresser.gif") @NotNull @Max(value=10) public String getDescription() { diff --git a/tests/resources/i18n/vasc.properties b/tests/resources/i18n/vasc.properties new file mode 100644 index 0000000..729ac6a --- /dev/null +++ b/tests/resources/i18n/vasc.properties @@ -0,0 +1,41 @@ + +test = Dit is een test + + + + +vasc.dialog.save.name = Opslaan +vasc.dialog.save.tooltip = Het opslaan van de waardes. +vasc.dialog.save.image = /META-INF/images/silk/png/tick.png + +vasc.dialog.cancel.name = Annuleren +vasc.dialog.cancel.tooltip = Niet opslaan van de waardes. +vasc.dialog.cancel.image = /META-INF/images/silk/png/cancel.png + + + + +vasc.action.add.name = Toevoegen +vasc.action.add.tooltip = Voegt een nieuw rij toe. +vasc.action.add.image = /META-INF/images/silk/png/table_add.png + +vasc.action.edit.name = Aanpassen +vasc.action.edit.tooltip = Pas een waarde aan van de geselecteerde rij in de table. +vasc.action.edit.image = /META-INF/images/silk/png/table_edit.png + +vasc.action.del.name = Verwijderen +vasc.action.del.tooltip = Verwijdert de geselecteerde rij uit de table. +vasc.action.del.image = /META-INF/images/silk/png/table_delete.png + +vasc.action.csv.name = CSV +vasc.action.csv.tooltip = Exporteren naar Excel. +vasc.action.csv.image = /META-INF/images/silk/png/page_white_excel.png + +vasc.action.xml.name = XML +vasc.action.xml.tooltip = Exporteren naar Xml. +vasc.action.xml.image = /META-INF/images/silk/png/page_white_excel.png + +vasc.action.refresh.name = Vernieuwen +vasc.action.refresh.tooltip = Ververst de waardes in de table. +vasc.action.refresh.image = /META-INF/images/silk/png/table_refresh.png + diff --git a/tests/resources/images/gabelfresser.gif b/tests/resources/images/gabelfresser.gif new file mode 100644 index 0000000000000000000000000000000000000000..912d2587cfd67bd4effee955d1dd96605d75b02b GIT binary patch literal 7043 zcmW-ldpuK*lwIb1R~f$)X;^llS}9} zQPjK3Dha8kR4QrR>E`$O{+|E6{(e1PkJsbz^jhy}?-0oa>VP)~fIt6Z7D^-g0P|}NiejVLmq5pLnOfysM zEyA?`W+C$A|Ac4{CrC>Td@n{3WspYDd~qBtodye?l@7|R%9k@c3a)CwTFkxu{ACh# z)>)^kRa-zZZiOutAE9c|X3f|&^%(OWruL5+r~)+kHib%6xA^w$yADDA>kN4A{P}lx zQQF$t0zs>SfTvX~LR1I5@t(gIvEpyeP(vDa)#G{Lx#g6!$aU2*m)INr@QjvgNG%RE|&;w z&@fn0G3$k7cJ`T_As9@!>mq*iv9EH_1hxb1GF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