diff --git a/doc/README.txt b/doc/README.txt index 4baa8cb..2f636af 100644 --- a/doc/README.txt +++ b/doc/README.txt @@ -10,9 +10,289 @@ Down load http://www.ehecht.com/eclipse_ve/ve.html (lin_mac version) Unzip and move the plug ins and features into the plug in and features directory of eclipse. - Swing will run by default. +-- XyReasscan ? + +zie tables statline.cbs.nl voor bs asielverzoeken nl + + ---- Object tree: +3 layers + +- Data Backend + - JPA or Hibernate + - Meta Query + - LDAP + # List via geparametered xql query + # Save + # Merge + # Delete + # Create ? + FilteringDataSource + PagingDataSource + FilteringPagingDataSource + Ordering + Parameter + +- Data Source Controller + - Data Access Controller + # User ACL on data items/columns + # Create new entry hooks + +- Table Controller + - User Settings + + +- Data Frontends + - Extjs + - Swing + - WS + - SWT via SwingWT + - JSF (met utr plugin) + + + +- default view field +- Admin fields and order +- Admin field groups -> 'collapse +- List filters auto by type +- search fields + +verbose_name_plural +The plural name for the object: +verbose_name_plural = "stories" +If this isn’t given, Django will use verbose_name + "s" + + +- plural +- ordering +- order_with_respect_to + +# admin +- date_hierarchy +- fields = ( + (None, { + 'fields': ('url', 'title', 'content', 'sites') + }), + ('Advanced options', { + 'classes': 'collapse', + 'fields' : ('enable_comments', 'registration_required', 'template_name') + 'description' : 'sdf' + }), + ) +- JS +- list_display_links +- list_filter = BooleanField, DateField, DateTimeField or ForeignKey. +- list_per_page +- ordering def +- save_as +- search_fields + +@Entity +@VascAdmin(list=true,edit=true,create=true,delete=false) +public class BlogPost { + + @VascPrimaryKey + @VascName(key="generic.id.name") + @VascDescription(key="generic.id.name") + @VascHelpId(key="generic.id.help") + @VascImage(key="generid.id.image"); + Integer id; + + @Column(columnName="title") + @VascDisplayName + @VascUserRoles(list="(floormanager&sitemanager)|admin" editViewOnly="floormanager" edit="sitemanager|admin") + String title; + + @VascEditorType(type="slugField") + String slug; + + @VascChoices() + @VascDefaultValue(key="") + String tags; + + @VascRegex(regex="<(.*)>" key="generic.regex.html.tagsNotAllowed") + String content; + + @VascEditorType(type="floatField" hints="max_digits=3,decimal_places=2") + @VascFieldOptions + @VascColumnWidth(width=130) + Float price; + + @VascModelReference + @VascDefaultValue + @VascObjectNotNull + BlogStatus blogStatus; + + @VascEditorType(type="dateField" hints="auto_now=true,auto_now_add=true") + @VascDefaultValue(key="new_date") + @VascUserRoles(list="admin") + Date createdDate + + @VascEventChannel(channel="BlogPost.modifiedDate" create=true) + Date modifiedDate + + @VascDateFuture + Date publicedDate +} + + + +$it['ldap']['user']="uid=admin-sudo,ou=services,dc=m4n,dc=nl"; +$it['ldap']['pass']="adminSudo"; +$it['ldap']['baseDN']="ou=sudoers,dc=m4n,dc=nl"; +$it['ldap']['key']="cn"; + +$it['columns'][0]['name']="Edit"; +$it['columns'][0]['columnType']="edit"; +$it['columns'][1]['name']="Delete"; +$it['columns'][1]['columnType']="delete"; +$it['columns'][2]['name']="User"; +$it['columns'][2]['attr']="cn"; +$it['columns'][3]['name']="Description"; +$it['columns'][3]['attr']="description"; +$it['columns'][4]['name']="sudoCommand"; +$it['columns'][4]['attr']="sudocommand"; +$it['columns'][4]['columnType']="list"; +$it['columns'][5]['name']="sudoHost"; +$it['columns'][5]['attr']="sudohost"; +$it['columns'][5]['columnType']="list"; +$it['columns'][6]['name']="sudoUser"; +$it['columns'][6]['attr']="sudouser"; +$it['columns'][6]['columnType']="list"; + +$it['list']['filter']="(&(objectClass=sudoRole))"; +$it['list']['columns']="0,2,6,4,5,1"; +$it['delete']['filter']="cn=%s"; + +$it['edit']['filter']="(cn=%s)"; +$it['edit']['create_dn_key']="cn=%s"; +$it['edit']['columns_edit']="2,3,4,5,6"; +$it['edit']['columns_edit_readonly']="2"; +$it['edit']['columns_create']="2,3,4,5,6"; +$it['edit']['map']['objectclass'][]="sudoRole"; +$it['edit']['map']['objectclass'][]="top"; +$it['edit']['map']['cn']="\$key"; +$it['edit']['map']['description']="\$formData['description']"; + + + vasc + + admin=true + backend=extjs + path=/js/extjs/* + + + vasc + /vasc/* + + + +DefaultVascController r = new D..(); + +r.set + + +EmployeeDataSource dataSource = new EmployeeDataSource(); +dataSource.setJdbcTemplate(new JdbcTemplate(employeeDataSource())); + FilteringPaginator filteringPaginator = new FilteringPaginator(dataSource, EmployeeReportObject.class); + JsfCrudAdapter adapter = new JsfCrudAdapter(filteringPaginator, (CrudController)empCrud().getController()){ + public Serializable getEntity() { + Object object = ((Row)getModel().getRowData()).getObject(); + EmployeeReportObject employeeReportObject = (EmployeeReportObject) object; + Employee employee = new Employee(); + employee.setId(employeeReportObject.getId()); + return employee; + } + }; + + return adapter; + + + +EVt; + + + + + + + + + + + + + + + + + +Table def: + + + + + + +@SuppressWarnings({ "unchecked", "serial" }) +@Bean(scope = DefaultScopes.SESSION) +public JsfCrudAdapter empRecordCrud() { + EmployeeDataSource dataSource = new EmployeeDataSource(); + dataSource.setJdbcTemplate(new JdbcTemplate(employeeDataSource())); + FilteringPaginator filteringPaginator = new FilteringPaginator(dataSource, EmployeeReportObject.class); + JsfCrudAdapter adapter = new JsfCrudAdapter(filteringPaginator, (CrudController)empCrud().getController()){ + public Serializable getEntity() { + Object object = ((Row)getModel().getRowData()).getObject(); + EmployeeReportObject employeeReportObject = (EmployeeReportObject) object; + Employee employee = new Employee(); + employee.setId(employeeReportObject.getId()); + return employee; + } + }; + + return adapter; +} + + + + + + + + + + + + + + + + + + + diff --git a/lib/idcanet-x4o-bin.jar b/lib/idcanet-x4o-bin.jar index 1a5c7aa..bb27fcb 100644 Binary files a/lib/idcanet-x4o-bin.jar and b/lib/idcanet-x4o-bin.jar differ diff --git a/src/META-INF/fieldtype-lang.eld b/src/META-INF/fieldtype-lang.eld new file mode 100644 index 0000000..235da1e --- /dev/null +++ b/src/META-INF/fieldtype-lang.eld @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/META-INF/fieldtype-namespaces.xml b/src/META-INF/fieldtype-namespaces.xml new file mode 100644 index 0000000..e81ccd1 --- /dev/null +++ b/src/META-INF/fieldtype-namespaces.xml @@ -0,0 +1,8 @@ + + + + + Vasc namespace for the fieldtype language + + META-INF/fieldtype-lang.eld + \ No newline at end of file diff --git a/src/META-INF/vasc-fields.xml b/src/META-INF/fieldtypes.xml similarity index 91% rename from src/META-INF/vasc-fields.xml rename to src/META-INF/fieldtypes.xml index adc9931..ae2469a 100644 --- a/src/META-INF/vasc-fields.xml +++ b/src/META-INF/fieldtypes.xml @@ -1,15 +1,17 @@ - + - - - - - - - - + + + + + + + - +--> + - + + + + + + \ No newline at end of file diff --git a/src/com/idcanet/vasc/backends/ldap/LdapVascBackend.java b/src/com/idcanet/vasc/backends/ldap/LdapVascBackend.java index 8370b51..144123f 100644 --- a/src/com/idcanet/vasc/backends/ldap/LdapVascBackend.java +++ b/src/com/idcanet/vasc/backends/ldap/LdapVascBackend.java @@ -115,6 +115,7 @@ public class LdapVascBackend extends AbstractVascBackend { /** * @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object) */ + @SuppressWarnings("unchecked") public Object getValue(VascEntryField field, Object record) throws ElementParameterException,ElementParameterNotFoundException { Map map = (Map)record; return map.get(field.getBackendName()); @@ -123,6 +124,7 @@ public class LdapVascBackend extends AbstractVascBackend { /** * @see com.idcanet.vasc.core.entry.VascEntryFieldValue#setValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object, java.lang.Object) */ + @SuppressWarnings("unchecked") public void setValue(VascEntryField field, Object record,Object value) throws ElementParameterException,ElementParameterNotFoundException { Map map = (Map)record; map.put(field.getBackendName(), value); diff --git a/src/com/idcanet/vasc/backends/ldap/SimpleLdapConnectionProvider.java b/src/com/idcanet/vasc/backends/ldap/SimpleLdapConnectionProvider.java index bade087..b353a88 100644 --- a/src/com/idcanet/vasc/backends/ldap/SimpleLdapConnectionProvider.java +++ b/src/com/idcanet/vasc/backends/ldap/SimpleLdapConnectionProvider.java @@ -26,11 +26,7 @@ package com.idcanet.vasc.backends.ldap; -import java.security.Security; - import com.novell.ldap.LDAPConnection; -import com.novell.ldap.LDAPJSSESecureSocketFactory; -import com.novell.ldap.LDAPSocketFactory; /** * @@ -45,7 +41,6 @@ public class SimpleLdapConnectionProvider implements LdapConnectionProvider { private int ldapVersion = LDAPConnection.LDAP_V3; private String bindUser = null; private String bindPass = null; - /** * @see com.idcanet.vasc.backends.ldap.LdapConnectionProvider#getLdapConnection() @@ -71,7 +66,6 @@ public class SimpleLdapConnectionProvider implements LdapConnectionProvider { } } - /** * @return the ldapHost */ diff --git a/src/com/idcanet/vasc/core/AbstractVascEntryFieldType.java b/src/com/idcanet/vasc/core/AbstractVascEntryFieldType.java new file mode 100644 index 0000000..c36a7a6 --- /dev/null +++ b/src/com/idcanet/vasc/core/AbstractVascEntryFieldType.java @@ -0,0 +1,168 @@ +/* + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.idcanet.vasc.core.ui.VascUIComponent; +import com.idcanet.vasc.validators.VascValidator; + +/** + * + * @author Willem Cazander + * @version 1.0 Aug 2, 2007 + */ +abstract public class AbstractVascEntryFieldType implements VascEntryFieldType { + + private String id = null; + private Class autoFieldClass = null; + private ObjectConverter objectConverter = null; + private VascUIComponent vascUIComponent = null; + private List vascValidators = null; + private Map properties = null; + private String parentEntryFieldTypeName = null; + + public AbstractVascEntryFieldType() { + vascValidators = new ArrayList(4); + properties = new HashMap(); + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#addVascValidator(com.idcanet.vasc.validators.VascValidator) + */ + public void addVascValidator(VascValidator vascValidator) { + vascValidators.add(vascValidator); + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#getAutoFieldClass() + */ + public Class getAutoFieldClass() { + return autoFieldClass; + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#getId() + */ + public String getId() { + return id; + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#getObjectConverter() + */ + public ObjectConverter getObjectConverter() { + return objectConverter; + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#getParentEntryFieldTypeName() + */ + public String getParentEntryFieldTypeName() { + return parentEntryFieldTypeName; + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#getProperty(java.lang.String) + */ + public String getProperty(String name) { + return properties.get(name); + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#getPropertyNames() + */ + public List getPropertyNames() { + return new ArrayList(properties.keySet()); + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#getVascUIComponent() + */ + public VascUIComponent getVascUIComponent() { + return vascUIComponent; + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#getVascValidators() + */ + public List getVascValidators() { + return vascValidators; + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#removeVascValidator(com.idcanet.vasc.validators.VascValidator) + */ + public void removeVascValidator(VascValidator vascValidator) { + vascValidators.remove(vascValidator); + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#setAutoFieldClass(java.lang.Class) + */ + public void setAutoFieldClass(Class autoFieldClass) { + this.autoFieldClass=autoFieldClass; + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#setId(java.lang.String) + */ + public void setId(String id) { + this.id=id; + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#setObjectConverter(com.idcanet.vasc.core.VascEntryFieldType.ObjectConverter) + */ + public void setObjectConverter(ObjectConverter objectConverter) { + this.objectConverter=objectConverter; + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#setParentEntryFieldTypeName(java.lang.String) + */ + public void setParentEntryFieldTypeName(String parentEntryFieldTypeName) { + this.parentEntryFieldTypeName=parentEntryFieldTypeName; + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#setProperty(java.lang.String, java.lang.String) + */ + public void setProperty(String name, String value) { + properties.put(name, value); + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#setVascUIComponent(com.idcanet.vasc.core.ui.VascUIComponent) + */ + public void setVascUIComponent(VascUIComponent vascUIComponent) { + this.vascUIComponent=vascUIComponent; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascController.java b/src/com/idcanet/vasc/core/VascController.java new file mode 100644 index 0000000..f413eeb --- /dev/null +++ b/src/com/idcanet/vasc/core/VascController.java @@ -0,0 +1,54 @@ +/* + * 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; + + +/** + * Resolvs all the resolvers. + * + * @author Willem Cazander + * @version 1.0 Sep 11, 2008 + */ +public interface VascController { + + /** + * @return Returns the VascBackendControllerResolver + */ + public VascBackendControllerResolver getVascBackendControllerResolver(); + + /** + * + * @return Returns the VascEntryControllerResolver + */ + public VascEntryControllerResolver getVascEntryControllerResolver(); + + /** + * + * @return Returns the VascEntryFieldControllerResolver + */ + public VascEntryFieldTypeControllerResolver getVascEntryFieldTypeControllerResolver(); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascEntry.java b/src/com/idcanet/vasc/core/VascEntry.java index 8e3d0b3..dd8372e 100644 --- a/src/com/idcanet/vasc/core/VascEntry.java +++ b/src/com/idcanet/vasc/core/VascEntry.java @@ -31,7 +31,6 @@ import java.util.List; 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.entry.VascEntryResourceResolver; /** * @@ -45,7 +44,7 @@ import com.idcanet.vasc.core.entry.VascEntryResourceResolver; * @author Willem Cazander * @version 1.0 Mar 21, 2007 */ -public interface VascEntry { +public interface VascEntry extends Cloneable { /** * @return the id @@ -130,22 +129,22 @@ public interface VascEntry { /** * @return the primaryKeyField */ - public String getPrimaryKeyField(); + public String getPrimaryKeyFieldId(); /** * @param primaryKeyField the primaryKeyField to set */ - public void setPrimaryKeyField(String primaryKeyField); + public void setPrimaryKeyFieldId(String primaryKeyField); /** * @return the displayNameField */ - public String getDisplayNameField(); + public String getDisplayNameFieldId(); /** * @param displayNameField the displayNameField to set */ - public void setDisplayNameField(String displayNameField); + public void setDisplayNameFieldId(String displayNameField); /** * @return the vascAdmimList @@ -203,85 +202,10 @@ public interface VascEntry { public void removeVascEntryField(VascEntryField vascField); /** - * @return the entryDataList + * @return the vascField */ - public List getEntryDataList(); - - /** - * @param entryDataList the entryDataList to set - */ - public void setEntryDataList(List entryDataList); - - /** - * @return the entryDataObject - */ - public Object getEntryDataObject(); - - /** - * @param entryDataObject the entryDataObject to set - */ - public void setEntryDataObject(Object entryDataObject); - - /** - * @return the vascBackend - */ - public VascBackend getVascBackend(); - - /** - * @param vascBackend the vascBackend to set - */ - public void setVascBackend(VascBackend vascBackend); - - /** - * @return the vascFrontend - */ - public VascFrontend getVascFrontend(); - - /** - * @param vascFrontend the vascFrontend to set - */ - public void setVascFrontend(VascFrontend vascFrontend); - - /** - * @return the vascBackendController - */ - public VascBackendController getVascBackendController(); - - /** - * @param vascBackendController the vascBackendController to set - */ - public void setVascBackendController(VascBackendController vascBackendController); - - /** - * @return the vascEntryController - */ - public VascEntryController getVascEntryController(); - - /** - * @param vascEntryController the vascEntryController to set - */ - public void setVascEntryController(VascEntryController vascEntryController); - - /** - * @return the vascFrontendController - */ - public VascFrontendController getVascFrontendController(); - - /** - * @param vascFrontendController the vascFrontendController to set - */ - public void setVascFrontendController(VascFrontendController vascFrontendController); - - /** - * @return the vascEntryResourceResolver - */ - public VascEntryResourceResolver getVascEntryResourceResolver(); - - /** - * @param vascEntryResourceResolver the vascEntryResourceResolver to set - */ - public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver); - + public VascEntryField getVascEntryFieldById(String id); + /** * @return the rowActions */ @@ -360,4 +284,7 @@ public interface VascEntry { public Object getEntryParameter(String key); public void setEntryParameter(String key,Object value); public List getEntryParameterKeys(); + + public VascFrontendData getVascFrontendData(); + public void setVascFrontendData(VascFrontendData vascFrontendData); } diff --git a/src/com/idcanet/vasc/core/VascEntryController.java b/src/com/idcanet/vasc/core/VascEntryController.java index 1da70b8..4017c12 100644 --- a/src/com/idcanet/vasc/core/VascEntryController.java +++ b/src/com/idcanet/vasc/core/VascEntryController.java @@ -26,6 +26,8 @@ package com.idcanet.vasc.core; +import java.util.List; + /** * @@ -35,4 +37,6 @@ package com.idcanet.vasc.core; public interface VascEntryController { public VascEntry getVascEntry(String name); + + public List getVascEntryNames(); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascEntryFieldType.java b/src/com/idcanet/vasc/core/VascEntryFieldType.java index db33d7d..0c6c609 100644 --- a/src/com/idcanet/vasc/core/VascEntryFieldType.java +++ b/src/com/idcanet/vasc/core/VascEntryFieldType.java @@ -39,8 +39,8 @@ import com.idcanet.vasc.validators.VascValidator; */ public interface VascEntryFieldType { - public String getName(); - public void setName(String name); + public String getId(); + public void setId(String id); public Class getAutoFieldClass(); public void setAutoFieldClass(Class classObject); diff --git a/src/com/idcanet/vasc/core/VascEntryFieldTypeController.java b/src/com/idcanet/vasc/core/VascEntryFieldTypeController.java new file mode 100644 index 0000000..fc91e5b --- /dev/null +++ b/src/com/idcanet/vasc/core/VascEntryFieldTypeController.java @@ -0,0 +1,42 @@ +/* + * 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.List; + + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 4, 2008 + */ +public interface VascEntryFieldTypeController { + + public VascEntryFieldType getVascEntryFieldType(String name); + + public List getVascEntryFieldTypeNames(); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascFrontendControllerResolver.java b/src/com/idcanet/vasc/core/VascEntryFieldTypeControllerResolver.java similarity index 92% rename from src/com/idcanet/vasc/core/VascFrontendControllerResolver.java rename to src/com/idcanet/vasc/core/VascEntryFieldTypeControllerResolver.java index 89bf347..9be26ee 100644 --- a/src/com/idcanet/vasc/core/VascFrontendControllerResolver.java +++ b/src/com/idcanet/vasc/core/VascEntryFieldTypeControllerResolver.java @@ -32,7 +32,7 @@ package com.idcanet.vasc.core; * @author Willem Cazander * @version 1.0 Sep 4, 2008 */ -public interface VascFrontendControllerResolver { +public interface VascEntryFieldTypeControllerResolver { - public VascFrontendController getVascFrontendController(); + public VascEntryFieldTypeController getVascEntryFieldTypeController(); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascFrontendController.java b/src/com/idcanet/vasc/core/VascEntryFinalizer.java similarity index 90% rename from src/com/idcanet/vasc/core/VascFrontendController.java rename to src/com/idcanet/vasc/core/VascEntryFinalizer.java index 3887684..f2e856b 100644 --- a/src/com/idcanet/vasc/core/VascFrontendController.java +++ b/src/com/idcanet/vasc/core/VascEntryFinalizer.java @@ -30,11 +30,9 @@ package com.idcanet.vasc.core; /** * * @author Willem Cazander - * @version 1.0 Sep 4, 2008 + * @version 1.0 Sep 9, 2008 */ -public interface VascFrontendController { +public interface VascEntryFinalizer { - public VascFrontend getVascFrontend(String name); - - public VascFrontendHelper getVascFrontendHelper(); + public void finalizeVascEntry(VascEntry table) throws Exception; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascFrontendData.java b/src/com/idcanet/vasc/core/VascFrontendData.java new file mode 100644 index 0000000..cf633e7 --- /dev/null +++ b/src/com/idcanet/vasc/core/VascFrontendData.java @@ -0,0 +1,100 @@ +/* + * 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.List; + +import com.idcanet.vasc.core.entry.VascEntryResourceResolver; + + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public interface VascFrontendData { + + /** + * @return the vascBackend + */ + public VascBackend getVascBackend(); + + /** + * @param vascBackend the vascBackend to set + */ + public void setVascBackend(VascBackend vascBackend); + + /** + * @return the entryDataList + */ + public List getEntryDataList(); + + /** + * @param entryDataList the entryDataList to set + */ + public void setEntryDataList(List entryDataList); + + /** + * @return the entryDataObject + */ + public Object getEntryDataObject(); + + /** + * @param entryDataObject the entryDataObject to set + */ + public void setEntryDataObject(Object entryDataObject); + + /** + * @return the vascFrontend + */ + public VascFrontend getVascFrontend(); + + /** + * @param vascFrontend the vascFrontend to set + */ + public void setVascFrontend(VascFrontend vascFrontend); + + /** + * @return the VascFrontendHelper + */ + public VascFrontendHelper getVascFrontendHelper(); + + /** + * @param vascFrontendHelper The VascFrontendHelper to set. + */ + public void setVascFrontendHelper(VascFrontendHelper vascFrontendHelper); + + /** + * @return the vascEntryResourceResolver + */ + public VascEntryResourceResolver getVascEntryResourceResolver(); + + /** + * @param vascEntryResourceResolver the vascEntryResourceResolver to set + */ + public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver); +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascFrontendHelper.java b/src/com/idcanet/vasc/core/VascFrontendHelper.java index efff7a6..abcea90 100644 --- a/src/com/idcanet/vasc/core/VascFrontendHelper.java +++ b/src/com/idcanet/vasc/core/VascFrontendHelper.java @@ -36,10 +36,6 @@ import com.idcanet.vasc.core.entry.VascEntryEventListener; */ public interface VascFrontendHelper { - public void finalizeVascEntry(VascEntry table) throws Exception; - - public void finalizeVascEntryFields(VascEntry table) throws Exception; - public Integer getTotalColumnsWidth(VascEntry table); public void refreshData(VascEntry table) throws Exception; diff --git a/src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java b/src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java index b353425..14379c1 100644 --- a/src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java +++ b/src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java @@ -106,16 +106,14 @@ public class SwingVascFrontend implements VascFrontend { public void initEntry(VascEntry entry) throws Exception { - if (entry.getVascFrontend()==null) { - entry.setVascFrontend(this); + if (entry.getVascFrontendData().getVascFrontend()==null) { + entry.getVascFrontendData().setVascFrontend(this); } else { - if (entry.getVascFrontend()!=this) { + if (entry.getVascFrontendData().getVascFrontend()!=this) { throw new IllegalArgumentException("VascEntry has already a differtent VascViewRenderer attected"); } } - entry.getVascFrontendController().getVascFrontendHelper().finalizeVascEntry(entry); - entry.getVascFrontendController().getVascFrontendHelper().finalizeVascEntryFields(entry); - entry.getVascFrontendController().getVascFrontendHelper().refreshData(entry); + entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry); /* entry.putUIComponent(VascTextField.class, SwingTextField.class); entry.putUIComponent(VascList.class, SwingList.class); @@ -129,7 +127,7 @@ public class SwingVascFrontend implements VascFrontend { public ImageIcon getImageIcon(String imageResource) { /// TODO hack beter - String key = entry.getVascEntryResourceResolver().getTextValue(imageResource); + String key = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(imageResource); //logger.fine("KEY======================="+key); if (key.indexOf("META-INF")>0 | key.indexOf("resource")>0) { @@ -149,10 +147,13 @@ public class SwingVascFrontend implements VascFrontend { - rowBean = entry.getVascFrontendController().getVascFrontendHelper().initEditObject(entry, rowBean); + rowBean = entry.getVascFrontendData().getVascFrontendHelper().initEditObject(entry, rowBean); String beanValue = rowBean.toString(); - if (entry.getDisplayNameField()!=null) { - Object vv = entry.getUIIdentifierVascEntryColomn().getVascColumnValue().getValue(entry.getUIIdentifierVascEntryColomn(), rowBean); + if (entry.getDisplayNameFieldId()!=null) { + + VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId()); + + Object vv = v.getVascEntryFieldValue().getValue(v, rowBean); if (vv==null) { beanValue=""; } else { @@ -162,27 +163,28 @@ public class SwingVascFrontend implements VascFrontend { beanValue=beanValue.substring(0, 30); } } - SwingEditDialog dialog = new SwingEditDialog(parent,entry,rowBean,entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.edit.title"),entry.getVascTextValue().getTextValue("vasc.dialog.edit.message",beanValue)); + SwingEditDialog dialog = new SwingEditDialog(parent,entry,rowBean,entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.edit.title"),entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.edit.message",beanValue)); Object result = dialog.openDialog(); logger.finest("OPEN closed : "+result); if(result==null) { return; } - entry.getVascFrontendController().getVascFrontendHelper().mergeObject(entry, result); + entry.getVascFrontendData().getVascFrontendHelper().mergeObject(entry, result); } public void renderDelete(Object rowBean) throws Exception { String beanValue = rowBean.toString(); - if (entry.getUIIdentifierVascEntryColomn()!=null) { - beanValue = ""+entry.getUIIdentifierVascEntryColomn().getVascColumnValue().getValue(entry.getUIIdentifierVascEntryColomn(), rowBean); + if (entry.getDisplayNameFieldId()!=null) { + VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId()); + beanValue = ""+v.getVascEntryFieldValue().getValue(v, rowBean); if (beanValue.length()>30) { beanValue=beanValue.substring(0, 30); } } int response = JOptionPane.showOptionDialog( parent // Center in window. - , entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.delete.message",beanValue) // Message - , entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.delete.title") // Title in titlebar + , entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.delete.message",beanValue) // Message + , entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.delete.title") // Title in titlebar , JOptionPane.YES_NO_OPTION // Option type , JOptionPane.PLAIN_MESSAGE // messageType , null // Icon (none) @@ -190,10 +192,10 @@ public class SwingVascFrontend implements VascFrontend { , null // Default button's label ); if (response==JOptionPane.YES_OPTION) { - entry.getVascBackend().delete(rowBean); - entry.getEntryDataList().remove(rowBean); - entry.setEntryDataObject(null); - entry.getVascFrontendController().getVascFrontendHelper().fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, rowBean); + entry.getVascFrontendData().getVascBackend().delete(rowBean); + entry.getVascFrontendData().getEntryDataList().remove(rowBean); + entry.getVascFrontendData().setEntryDataObject(null); + //entry.getVascFrontendController().getVascFrontendHelper().fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, rowBean); } } @@ -210,7 +212,7 @@ public class SwingVascFrontend implements VascFrontend { this.headerText = headerText; this.bean = bean; - setTitle(entry.getVascEntryResourceResolver().getTextValue(title)); + setTitle(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(title)); setModal(true); JPanel pane = new JPanel(); @@ -250,7 +252,7 @@ public class SwingVascFrontend implements VascFrontend { public void createHeader(JPanel header) { JLabel l = new JLabel(); - l.setText(entry.getVascEntryResourceResolver().getTextValue(headerText)); + l.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(headerText)); l.setFont(new Font(null,Font.BOLD, 14)); //l.setToolTipText(entry.getVascTextValue().getTextValue(headerText)); header.add(l); @@ -260,7 +262,7 @@ public class SwingVascFrontend implements VascFrontend { body.setLayout(new SpringLayout()); int column = 0; for(VascEntryField c:entry.getVascEntryFields()) { - entry.getVascFrontendController().getVascFrontendHelper().initEditObjectColumn(c, bean); + entry.getVascFrontendData().getVascFrontendHelper().initEditObjectColumn(c, bean); if (c.isEdit()==false) { continue; } @@ -269,16 +271,16 @@ public class SwingVascFrontend implements VascFrontend { JLabel l = new JLabel(); l.setHorizontalAlignment(JLabel.TRAILING); - l.setText(entry.getVascEntryResourceResolver().getTextValue(c.getName())); + l.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getName())); if(c.getDescription()!=null) { - l.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(c.getDescription())); + l.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getDescription())); } body.add(l); if (c.isEditReadOnly()==true) { JLabel valueLabel = new JLabel(); valueLabel.setText(""+c.getVascEntryFieldValue().getValue(c, bean)); - c.setColumnEditor(valueLabel); + //c.setColumnEditor(valueLabel); body.add(valueLabel); continue; } @@ -286,7 +288,7 @@ public class SwingVascFrontend implements VascFrontend { if(c.getVascEntryFieldType().getVascUIComponent()==null) { JLabel valueLabel = new JLabel(); valueLabel.setText(""+c.getVascEntryFieldValue().getValue(c, bean)); - c.setColumnEditor(valueLabel); + //c.setColumnEditor(valueLabel); body.add(valueLabel); } else { VascUIComponent comp = c.getVascEntryFieldType().getVascUIComponent(); @@ -294,7 +296,7 @@ public class SwingVascFrontend implements VascFrontend { model.setValue(c.getVascEntryFieldValue().getValue(c, bean)); model.addListener(new VascColumnValueModelListener(c,bean)); comp.createComponent(entry, model, body); - c.setColumnEditor(comp); + //c.setColumnEditor(comp); } } //JComponent, rows, cols, initX, initY ,xPad, yPad @@ -305,11 +307,11 @@ public class SwingVascFrontend implements VascFrontend { JButton saveButton = new JButton(); saveButton.setIcon(getImageIcon("vasc.dialog.save.image")); - saveButton.setText(entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.save.name")); - saveButton.setToolTipText(entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.save.tooltip")); + saveButton.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.save.name")); + saveButton.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.save.tooltip")); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { - if(entry.getVascFrontendController().getVascFrontendHelper().setUIComponentsBeanErrors(entry, bean)) { + if(entry.getVascFrontendData().getVascFrontendHelper().setUIComponentsBeanErrors(entry, bean)) { return; } result = bean; @@ -320,8 +322,8 @@ public class SwingVascFrontend implements VascFrontend { JButton cancelButton = new JButton(); cancelButton.setIcon(getImageIcon("vasc.dialog.cancel.image")); - cancelButton.setText(entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.cancel.name")); - cancelButton.setToolTipText(entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.cancel.tooltip")); + cancelButton.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.cancel.name")); + cancelButton.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.cancel.tooltip")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { result = null; @@ -361,7 +363,7 @@ public class SwingVascFrontend implements VascFrontend { try { exporter.doExport(out, entry); } catch (Exception e) { - entry.getVascFrontendController().getVascFrontendHelper().handleException(e, entry); + entry.getVascFrontendData().getVascFrontendHelper().handleException(e, entry); } finally { if (out!=null) { out.close(); @@ -410,17 +412,17 @@ public class SwingVascFrontend implements VascFrontend { // TODO: hack images working l.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(entry.getHeaderImage())).getScaledInstance(32, 32, Image.SCALE_SMOOTH))); if (entry.getHeaderDescription()!=null) { - l.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription())); + l.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription())); } header.add(l,BorderLayout.WEST); } if(entry.getHeaderName()!=null) { - JLabel l = new JLabel(entry.getVascEntryResourceResolver().getTextValue(entry.getHeaderName())); + JLabel l = new JLabel(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getHeaderName())); l.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); l.setFont(new Font(null,Font.BOLD, 18)); if (entry.getHeaderDescription()!=null) { - l.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription())); + l.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription())); } header.add(l,BorderLayout.CENTER); } @@ -429,8 +431,8 @@ public class SwingVascFrontend implements VascFrontend { //top.setBackground(Color.BLUE); for (GlobalVascAction action:entry.getGlobalActions()) { JButton but = new JButton(); - but.setText(entry.getVascEntryResourceResolver().getTextValue(action.getName())); - but.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(action.getToolTip())); + but.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getName())); + but.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getToolTip())); but.addActionListener(new GlobalActionListener(action)); but.setIcon(getImageIcon(action.getImage())); top.add(but); @@ -481,7 +483,11 @@ public class SwingVascFrontend implements VascFrontend { continue; } TableColumn t = new TableColumn(); - t.setPreferredWidth(c.getSizeList()); + if (c.getSizeList()!=null) { + t.setPreferredWidth(c.getSizeList()); + } else { + t.setPreferredWidth(200); + } t.setHeaderValue(c); t.setHeaderRenderer(renderer); t.setModelIndex(counter); @@ -493,15 +499,15 @@ public class SwingVascFrontend implements VascFrontend { table.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getClickCount() == 2) { - Object o = entry.getEntryDataObject(); + Object o = entry.getVascFrontendData().getEntryDataObject(); if (o==null) { return; } try { // TODO: fix this - entry.getVascFrontend().renderEdit(o); + entry.getVascFrontendData().getVascFrontend().renderEdit(o); } catch (Exception ee) { - entry.getVascFrontendController().getVascFrontendHelper().handleException(ee, entry); + entry.getVascFrontendData().getVascFrontendHelper().handleException(ee, entry); } } } @@ -524,10 +530,10 @@ public class SwingVascFrontend implements VascFrontend { if (rowIndex!=-1) { // temp; gets index by sorter rowIndex = tableSorter.modelIndex(rowIndex); - Object data = entry.getEntryDataList().get(rowIndex); - entry.setEntryDataObject(data); + Object data = entry.getVascFrontendData().getEntryDataList().get(rowIndex); + entry.getVascFrontendData().setEntryDataObject(data); } else { - entry.setEntryDataObject(null); + entry.getVascFrontendData().setEntryDataObject(null); } } } @@ -535,8 +541,8 @@ public class SwingVascFrontend implements VascFrontend { private static final long serialVersionUID = 10L; public Component getentryCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) { VascEntryField c = (VascEntryField)value; - setText(c.getVascEntry().getVascEntryResourceResolver().getTextValue(c.getName())); - setToolTipText(c.getVascEntry().getVascEntryResourceResolver().getTextValue(c.getDescription())); + setText(c.getVascEntry().getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getName())); + setToolTipText(c.getVascEntry().getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getDescription())); if(c.getImage()!=null) { setIcon(getImageIcon(c.getImage())); @@ -563,8 +569,8 @@ public class SwingVascFrontend implements VascFrontend { JPanel panel = new JPanel(); for(RowVascAction action:entry.getRowActions()) { JButton but = new JButton(); - but.setText(entry.getVascEntryResourceResolver().getTextValue(action.getName())); - but.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(action.getToolTip())); + but.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getName())); + but.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getToolTip())); but.setIcon(getImageIcon(action.getImage())); but.addActionListener(new RowActionListener(action)); panel.add(but); @@ -585,9 +591,9 @@ public class SwingVascFrontend implements VascFrontend { public void actionPerformed(ActionEvent event) { logger.fine("Row Action"); try { - action.doRowAction(entry, entry.getEntryDataObject()); + action.doRowAction(entry, entry.getVascFrontendData().getEntryDataObject()); } catch (Exception e) { - entry.getVascFrontendController().getVascFrontendHelper().handleException(e, entry); + entry.getVascFrontendData().getVascFrontendHelper().handleException(e, entry); } } } @@ -605,12 +611,12 @@ public class SwingVascFrontend implements VascFrontend { try { action.doGlobalAction(entry); } catch (Exception e) { - entry.getVascFrontendController().getVascFrontendHelper().handleException(e, entry); + entry.getVascFrontendData().getVascFrontendHelper().handleException(e, entry); } } } - class VascColumnModel extends AbstractTableModel implements VascEventListener { + class VascColumnModel extends AbstractTableModel { //implements VascEventListener { private static final long serialVersionUID = 10L; public void vascEvent(VascEventType e,Object o) { @@ -637,17 +643,17 @@ public class SwingVascFrontend implements VascFrontend { * @see javax.swing.entry.entryModel#getRowCount() */ public int getRowCount() { - if (entry.getEntryDataList()==null) { + if (entry.getVascFrontendData().getEntryDataList()==null) { return 0; } - return entry.getEntryDataList().size(); + return entry.getVascFrontendData().getEntryDataList().size(); } /** * @see javax.swing.entry.entryModel#getValueAt(int, int) */ public Object getValueAt(int rowIndex, int columnIndex) { - Object bean = entry.getEntryDataList().get(rowIndex); + Object bean = entry.getVascFrontendData().getEntryDataList().get(rowIndex); logger.finer("Rending column; "+columnIndex+" bean: "+bean); // TODO: this is slowing.... diff --git a/src/com/idcanet/vasc/frontends/swt/SwtVascFrontend.java b/src/com/idcanet/vasc/frontends/swt/SwtVascFrontend.java index 8f82bcf..d3f0713 100644 --- a/src/com/idcanet/vasc/frontends/swt/SwtVascFrontend.java +++ b/src/com/idcanet/vasc/frontends/swt/SwtVascFrontend.java @@ -65,6 +65,7 @@ import org.eclipse.swt.widgets.ToolItem; import com.idcanet.fff.SwingImageHelper; import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascFrontend; import com.idcanet.vasc.core.actions.GlobalVascAction; import com.idcanet.vasc.core.actions.RowVascAction; diff --git a/src/com/idcanet/vasc/impl/DefaultVascController.java b/src/com/idcanet/vasc/impl/DefaultVascController.java new file mode 100644 index 0000000..92f5508 --- /dev/null +++ b/src/com/idcanet/vasc/impl/DefaultVascController.java @@ -0,0 +1,87 @@ +/* + * 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.impl; + +import com.idcanet.vasc.core.VascBackendControllerResolver; +import com.idcanet.vasc.core.VascController; +import com.idcanet.vasc.core.VascEntryControllerResolver; +import com.idcanet.vasc.core.VascEntryFieldTypeControllerResolver; + +/** + * + * + * @author Willem Cazander + * @version 1.0 Sep 11, 2008 + */ +public class DefaultVascController implements VascController { + + private VascBackendControllerResolver vascBackendControllerResolver = null; + private VascEntryControllerResolver vascEntryControllerResolver = null; + private VascEntryFieldTypeControllerResolver vascEntryFieldTypeControllerResolver = null; + + /** + * @return the vascBackendControllerResolver + */ + public VascBackendControllerResolver getVascBackendControllerResolver() { + return vascBackendControllerResolver; + } + + /** + * @param vascBackendControllerResolver the vascBackendControllerResolver to set + */ + public void setVascBackendControllerResolver(VascBackendControllerResolver vascBackendControllerResolver) { + this.vascBackendControllerResolver = vascBackendControllerResolver; + } + + /** + * @return the vascEntryControllerResolver + */ + public VascEntryControllerResolver getVascEntryControllerResolver() { + return vascEntryControllerResolver; + } + + /** + * @param vascEntryControllerResolver the vascEntryControllerResolver to set + */ + public void setVascEntryControllerResolver(VascEntryControllerResolver vascEntryControllerResolver) { + this.vascEntryControllerResolver = vascEntryControllerResolver; + } + + /** + * @return the vascEntryFieldControllerResolver + */ + public VascEntryFieldTypeControllerResolver getVascEntryFieldTypeControllerResolver() { + return vascEntryFieldTypeControllerResolver; + } + + /** + * @param vascEntryFieldControllerResolver the vascEntryFieldControllerResolver to set + */ + public void setVascEntryFieldTypeControllerResolver(VascEntryFieldTypeControllerResolver vascEntryFieldTypeControllerResolver) { + this.vascEntryFieldTypeControllerResolver = vascEntryFieldTypeControllerResolver; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/DefaultVascEntry.java b/src/com/idcanet/vasc/impl/DefaultVascEntry.java index 472b75e..b014c1b 100644 --- a/src/com/idcanet/vasc/impl/DefaultVascEntry.java +++ b/src/com/idcanet/vasc/impl/DefaultVascEntry.java @@ -31,22 +31,17 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import com.idcanet.vasc.core.VascBackend; -import com.idcanet.vasc.core.VascBackendController; import com.idcanet.vasc.core.VascEntry; -import com.idcanet.vasc.core.VascEntryController; import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.VascEntryFieldSet; -import com.idcanet.vasc.core.VascFrontend; -import com.idcanet.vasc.core.VascFrontendController; +import com.idcanet.vasc.core.VascFrontendData; import com.idcanet.vasc.core.VascLinkEntry; 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.entry.VascEntryResourceResolver; - /** + * VascEntry * * @author Willem Cazander * @version 1.0 Mar 21, 2007 @@ -64,8 +59,8 @@ public class DefaultVascEntry implements VascEntry { private String headerImage = null; private String headerDescription = null; - private String primaryKeyField = null; - private String displayNameField = null; + private String primaryKeyFieldId = null; + private String displayNameFieldId = null; private boolean vascAdmimList = true; private boolean vascAdmimEdit = true; @@ -73,15 +68,6 @@ public class DefaultVascEntry implements VascEntry { private boolean vascAdmimDelete = true; private List vascFields = null; - private List entryDataList = null; - private Object entryDataObject = null; - private VascBackend vascBackend = null; - private VascFrontend vascFrontend = null; - - private VascBackendController vascBackendController = null; - private VascEntryController vascEntryController = null; - private VascFrontendController vascFrontendController = null; - private VascEntryResourceResolver vascEntryResourceResolver = null; private List rowActions = null; private List columnActions = null; @@ -91,10 +77,13 @@ public class DefaultVascEntry implements VascEntry { private List vascLinkEntries = null; private Map entryParameters = null; + private VascFrontendData vascFrontendData = null; + /** + * Te constructor + */ public DefaultVascEntry() { - vascFields = new ArrayList(10); - entryDataList = new ArrayList(0); + vascFields = new ArrayList(10); rowActions = new ArrayList(10); columnActions = new ArrayList(10); @@ -105,7 +94,17 @@ public class DefaultVascEntry implements VascEntry { entryParameters = new HashMap(); } - + /** + * @see java.lang.Object#clone() + */ + @Override + protected Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + + + /** * @return the id */ @@ -219,31 +218,31 @@ public class DefaultVascEntry implements VascEntry { } /** - * @return the primaryKeyField + * @return the primaryKeyFieldId */ - public String getPrimaryKeyField() { - return primaryKeyField; + public String getPrimaryKeyFieldId() { + return primaryKeyFieldId; } /** - * @param primaryKeyField the primaryKeyField to set + * @param primaryKeyFieldId the primaryKeyFieldId to set */ - public void setPrimaryKeyField(String primaryKeyField) { - this.primaryKeyField = primaryKeyField; + public void setPrimaryKeyFieldId(String primaryKeyFieldId) { + this.primaryKeyFieldId = primaryKeyFieldId; } /** - * @return the displayNameField + * @return the displayNameFieldId */ - public String getDisplayNameField() { - return displayNameField; + public String getDisplayNameFieldId() { + return displayNameFieldId; } /** - * @param displayNameField the displayNameField to set + * @param displayNameFieldId the displayNameFieldId to set */ - public void setDisplayNameField(String displayNameField) { - this.displayNameField = displayNameField; + public void setDisplayNameFieldId(String displayNameFieldId) { + this.displayNameFieldId = displayNameFieldId; } /** @@ -324,117 +323,17 @@ public class DefaultVascEntry implements VascEntry { } /** - * @return the entryDataList + * @see com.idcanet.vasc.core.VascEntry#getVascEntryFieldById(java.lang.String) */ - public List getEntryDataList() { - return entryDataList; + public VascEntryField getVascEntryFieldById(String id) { + for (VascEntryField v:vascFields) { + if (v.getId().equals(id)) { + return v; + } + } + throw new IllegalArgumentException("Id not found as field"); } - - /** - * @param entryDataList the entryDataList to set - */ - public void setEntryDataList(List entryDataList) { - this.entryDataList = entryDataList; - } - - /** - * @return the entryDataObject - */ - public Object getEntryDataObject() { - return entryDataObject; - } - - /** - * @param entryDataObject the entryDataObject to set - */ - public void setEntryDataObject(Object entryDataObject) { - this.entryDataObject = entryDataObject; - } - - /** - * @return the vascBackend - */ - public VascBackend getVascBackend() { - return vascBackend; - } - - /** - * @param vascBackend the vascBackend to set - */ - public void setVascBackend(VascBackend vascBackend) { - this.vascBackend = vascBackend; - } - - /** - * @return the vascFrontend - */ - public VascFrontend getVascFrontend() { - return vascFrontend; - } - - /** - * @param vascFrontend the vascFrontend to set - */ - public void setVascFrontend(VascFrontend vascFrontend) { - this.vascFrontend = vascFrontend; - } - - /** - * @return the vascBackendController - */ - public VascBackendController getVascBackendController() { - return vascBackendController; - } - - /** - * @param vascBackendController the vascBackendController to set - */ - public void setVascBackendController(VascBackendController vascBackendController) { - this.vascBackendController = vascBackendController; - } - - /** - * @return the vascEntryController - */ - public VascEntryController getVascEntryController() { - return vascEntryController; - } - - /** - * @param vascEntryController the vascEntryController to set - */ - public void setVascEntryController(VascEntryController vascEntryController) { - this.vascEntryController = vascEntryController; - } - - /** - * @return the vascFrontendController - */ - public VascFrontendController getVascFrontendController() { - return vascFrontendController; - } - - /** - * @param vascFrontendController the vascFrontendController to set - */ - public void setVascFrontendController(VascFrontendController vascFrontendController) { - this.vascFrontendController = vascFrontendController; - } - - /** - * @return the vascEntryResourceResolver - */ - public VascEntryResourceResolver getVascEntryResourceResolver() { - return vascEntryResourceResolver; - } - - /** - * @param vascEntryResourceResolver the vascEntryResourceResolver to set - */ - public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver) { - this.vascEntryResourceResolver = vascEntryResourceResolver; - } - + /** * @return the rowActions */ @@ -540,7 +439,6 @@ public class DefaultVascEntry implements VascEntry { vascLinkEntries.remove(vascLinkEntry); } - /** * @see com.idcanet.vasc.core.VascEntry#getEntryParameter(java.lang.String) */ @@ -548,7 +446,6 @@ public class DefaultVascEntry implements VascEntry { return entryParameters.get(key); } - /** * @see com.idcanet.vasc.core.VascEntry#getEntryParameterKeys() */ @@ -556,13 +453,24 @@ public class DefaultVascEntry implements VascEntry { return new ArrayList(entryParameters.keySet()); } - /** * @see com.idcanet.vasc.core.VascEntry#setEntryParameter(java.lang.String, java.lang.Object) */ public void setEntryParameter(String key, Object value) { entryParameters.put(key, value); } - - + + /** + * @return the vascFrontendData + */ + public VascFrontendData getVascFrontendData() { + return vascFrontendData; + } + + /** + * @param vascFrontendData the vascFrontendData to set + */ + public void setVascFrontendData(VascFrontendData vascFrontendData) { + this.vascFrontendData = vascFrontendData; + } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/DefaultVascFrontendData.java b/src/com/idcanet/vasc/impl/DefaultVascFrontendData.java new file mode 100644 index 0000000..5cef5f5 --- /dev/null +++ b/src/com/idcanet/vasc/impl/DefaultVascFrontendData.java @@ -0,0 +1,156 @@ +/* + * 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.impl; + +import java.util.ArrayList; +import java.util.List; + +import com.idcanet.vasc.core.VascBackend; +import com.idcanet.vasc.core.VascEntryFinalizer; +import com.idcanet.vasc.core.VascFrontend; +import com.idcanet.vasc.core.VascFrontendData; +import com.idcanet.vasc.core.VascFrontendHelper; +import com.idcanet.vasc.core.entry.VascEntryResourceResolver; + + +/** + * + * @author Willem Cazander + * @version 1.0 Mar 21, 2007 + */ +public class DefaultVascFrontendData implements VascFrontendData { + + private VascBackend vascBackend = null; + private List entryDataList = null; + private Object entryDataObject = null; + private VascFrontend vascFrontend = null; + private VascEntryFinalizer vascEntryFinalizer = null; + private VascFrontendHelper vascFrontendHelper = null; + private VascEntryResourceResolver vascEntryResourceResolver = null; + + public DefaultVascFrontendData() { + entryDataList = new ArrayList(0); + } + + /** + * @return the vascBackend + */ + public VascBackend getVascBackend() { + return vascBackend; + } + + /** + * @param vascBackend the vascBackend to set + */ + public void setVascBackend(VascBackend vascBackend) { + this.vascBackend = vascBackend; + } + + /** + * @return the entryDataList + */ + public List getEntryDataList() { + return entryDataList; + } + + /** + * @param entryDataList the entryDataList to set + */ + public void setEntryDataList(List entryDataList) { + this.entryDataList = entryDataList; + } + + /** + * @return the entryDataObject + */ + public Object getEntryDataObject() { + return entryDataObject; + } + + /** + * @param entryDataObject the entryDataObject to set + */ + public void setEntryDataObject(Object entryDataObject) { + this.entryDataObject = entryDataObject; + } + + /** + * @return the vascFrontend + */ + public VascFrontend getVascFrontend() { + return vascFrontend; + } + + /** + * @param vascFrontend the vascFrontend to set + */ + public void setVascFrontend(VascFrontend vascFrontend) { + this.vascFrontend = vascFrontend; + } + + /** + * @see com.idcanet.vasc.core.VascBackendData#getVascEntryFinalizer() + */ + public VascEntryFinalizer getVascEntryFinalizer() { + return vascEntryFinalizer; + } + + /** + * @see com.idcanet.vasc.core.VascBackendData#setVascEntryFinalizer(com.idcanet.vasc.core.VascEntryFinalizer) + */ + public void setVascEntryFinalizer(VascEntryFinalizer vascEntryFinalizer) { + this.vascEntryFinalizer=vascEntryFinalizer; + } + + /** + * @return the vascFrontendHelper + */ + public VascFrontendHelper getVascFrontendHelper() { + return vascFrontendHelper; + } + + /** + * @param vascFrontendHelper the vascFrontendHelper to set + */ + public void setVascFrontendHelper(VascFrontendHelper vascFrontendHelper) { + this.vascFrontendHelper = vascFrontendHelper; + } + + /** + * @return the vascEntryResourceResolver + */ + public VascEntryResourceResolver getVascEntryResourceResolver() { + return vascEntryResourceResolver; + } + + /** + * @param vascEntryResourceResolver the vascEntryResourceResolver to set + */ + public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver) { + this.vascEntryResourceResolver = vascEntryResourceResolver; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/DefaultVascTableController.java b/src/com/idcanet/vasc/impl/DefaultVascFrontendHelper.java similarity index 60% rename from src/com/idcanet/vasc/impl/DefaultVascTableController.java rename to src/com/idcanet/vasc/impl/DefaultVascFrontendHelper.java index f72ed71..26ffe2b 100644 --- a/src/com/idcanet/vasc/impl/DefaultVascTableController.java +++ b/src/com/idcanet/vasc/impl/DefaultVascFrontendHelper.java @@ -36,37 +36,204 @@ import org.hibernate.validator.ClassValidator; import org.hibernate.validator.InvalidValue; import com.idcanet.vasc.annotations.VascAnnotationParser; -import com.idcanet.vasc.core.VascEventListener; -import com.idcanet.vasc.core.VascExceptionListener; -import com.idcanet.vasc.core.VascTable; -import com.idcanet.vasc.core.VascTableController; -import com.idcanet.vasc.core.column.VascAnnotationTableColumn; -import com.idcanet.vasc.core.column.VascTableColumn; -import com.idcanet.vasc.core.ui.VascDate; -import com.idcanet.vasc.core.ui.VascTextField; -import com.idcanet.vasc.core.ui.VascToggle; -import com.idcanet.vasc.impl.column.BeanPropertyVascColumnValue; +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryField; +import com.idcanet.vasc.core.VascFrontendHelper; +import com.idcanet.vasc.core.entry.VascEntryEventListener; +import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType; + /** * * @author Willem Cazander * @version 1.0 Apr 28, 2007 */ -public class DefaultVascTableController implements VascTableController { +public class DefaultVascFrontendHelper implements VascFrontendHelper { private Logger logger = null; - private List eventListeners = null; - private List exceptionListeners = null; + //private List eventListeners = null; + //private List exceptionListeners = null; - public DefaultVascTableController() { - logger = Logger.getLogger(DefaultVascTableController.class.getName()); - eventListeners = new ArrayList(2); - exceptionListeners = new ArrayList(2); + public DefaultVascFrontendHelper() { + logger = Logger.getLogger(DefaultVascFrontendHelper.class.getName()); + //eventListeners = new ArrayList(2); + //exceptionListeners = new ArrayList(2); } - + /** - * @see com.idcanet.vasc.core.VascTableController#finalizeVascColumns(com.idcanet.vasc.core.VascTable) + * @see com.idcanet.vasc.core.VascFrontendHelper#addEventListener(com.idcanet.vasc.core.entry.VascEntryEventListener) */ + public void addEventListener(VascEntryEventListener e) { + // TODO Auto-generated method stub + } + + /** + * @see com.idcanet.vasc.core.VascFrontendHelper#addExceptionListener(com.idcanet.vasc.core.entry.VascEntryEventListener) + */ + public void addExceptionListener(VascEntryEventListener listener) { + } + + /** + * @see com.idcanet.vasc.core.VascFrontendHelper#fireVascEvent(com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType, java.lang.Object) + */ + public void fireVascEvent(VascEventType type, Object data) { + + } + + /** + * @see com.idcanet.vasc.core.VascFrontendHelper#getTotalColumnsWidth(com.idcanet.vasc.core.VascEntry) + */ + public Integer getTotalColumnsWidth(VascEntry entry) { + int result = 0; + for(VascEntryField c:entry.getVascEntryFields()) { + if(c.getSizeList()==null) { + Logger.getLogger(VascEntry.class.getName()).finer("Column no size: "+c.getName()); + } else { + result+=c.getSizeList(); + } + } + return result; + } + + /** + * @see com.idcanet.vasc.core.VascFrontendHelper#handleException(java.lang.Exception, com.idcanet.vasc.core.VascEntry) + */ + public void handleException(Exception e, VascEntry table) { + + e.printStackTrace(); + + /* + if (exceptionListeners.isEmpty()) { + Logger.getLogger(DefaultVascTableController.class.getName()).log(Level.WARNING,e.getMessage(),e); + return; + } + for(VascExceptionListener ee:exceptionListeners) { + try { + ee.handleException(e, table); + } catch (Exception eee) { + Logger.getLogger(DefaultVascTableController.class.getName()).log(Level.WARNING,"Error in ExceptionListener: "+eee.getMessage(),eee); + } + } + */ + } + + /** + * @see com.idcanet.vasc.core.VascFrontendHelper#initEditObject(com.idcanet.vasc.core.VascEntry, java.lang.Object) + */ + public Object initEditObject(VascEntry entry, Object object) throws Exception { + if (object!=null) { + return object; + } + object = entry.getVascFrontendData().getVascBackend().provideVascEntryRecordCreator(entry).newRecord(entry); + //fireVascEvent(VascEventListener.VascEventType.BEAN_INIT, object); + return object; + } + + /** + * @see com.idcanet.vasc.core.VascFrontendHelper#initEditObjectColumn(com.idcanet.vasc.core.VascEntryField, java.lang.Object) + */ + public void initEditObjectColumn(VascEntryField field, Object bean) throws Exception { + Object value = field.getVascEntryFieldValue().getValue(field, bean); + if(value==null & field.getDefaultValue()!=null) { + try { + logger.finer("Setting default value for: "+field.getName()+" def: "+field.getDefaultValue()); + field.getVascEntryFieldValue().setValue(field, bean, field.getDefaultValue()); + } catch (Exception e) { + logger.log(Level.WARNING,"Error in setting default value: '"+field.getDefaultValue()+"' error: "+e.getMessage(),e); + } + } + } + + /** + * @see com.idcanet.vasc.core.VascFrontendHelper#mergeObject(com.idcanet.vasc.core.VascEntry, java.lang.Object) + */ + public Object mergeObject(VascEntry entry, Object object) { + Object result = null; + try { + object = entry.getVascFrontendData().getVascBackend().merge(object); + //fireVascEvent(VascEventListener.VascEventType.BEAN_MERGE,object); + // todo: make faster + // add to table at position old old object + // then remove old object + // send refresh + + refreshData(entry); + } catch (Exception e) { + handleException(e, entry); + } + return result; + } + + /** + * @see com.idcanet.vasc.core.VascFrontendHelper#refreshData(com.idcanet.vasc.core.VascEntry) + */ + public void refreshData(VascEntry entry) throws Exception { + entry.getVascFrontendData().setEntryDataObject(null); + entry.getVascFrontendData().setEntryDataList(entry.getVascFrontendData().getVascBackend().execute()); + //fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, null); + } + + /** + * @see com.idcanet.vasc.core.VascFrontendHelper#removeEventListener(com.idcanet.vasc.core.entry.VascEntryEventListener) + */ + public void removeEventListener(VascEntryEventListener e) { + // TODO Auto-generated method stub + + } + + /** + * @see com.idcanet.vasc.core.VascFrontendHelper#removeExceptionListener(com.idcanet.vasc.core.entry.VascEntryEventListener) + */ + public void removeExceptionListener(VascEntryEventListener listener) { + // TODO Auto-generated method stub + + } + + /** + * @see com.idcanet.vasc.core.VascFrontendHelper#setUIComponentsBeanErrors(com.idcanet.vasc.core.VascEntry, java.lang.Object) + */ + public boolean setUIComponentsBeanErrors(VascEntry entry, Object bean) { + boolean error = false; + if(bean==null) { + logger.finest("No bean to check."); + return true; // nothing to check + } + + ClassValidator val = new ClassValidator(bean.getClass()); + InvalidValue[] ival = val.getInvalidValues(bean); + logger.fine("Got invaliled value: "+ival.length); + + for(VascEntryField col:entry.getVascEntryFields()) { + /* + if(col.getVascUIComponent()==null) { + continue; // we only DISPLAY user input errors !! + } + if (col instanceof VascAnnotationTableColumn) { + VascAnnotationTableColumn column = (VascAnnotationTableColumn)col; + + InvalidValue iv = findInvalidValueByProperty(ival,column.getBeanProperty()); + if(iv==null) { + column.getVascUIComponent().setErrorText(null); + continue; // no error on this property + } + error = true; + column.getVascUIComponent().setErrorText(iv.getMessage()); + } + */ + } + logger.finest("Checked for errors: "+error); + return error; + } + private InvalidValue findInvalidValueByProperty(InvalidValue[] ival,String property) { + for(InvalidValue iv:ival) { + if(iv.getPropertyName().equals(property)) { + return iv; + } + } + return null; + } + + /* public void finalizeVascColumns(VascTable table) throws Exception { VascAnnotationParser vap = new VascAnnotationParser(); @@ -116,76 +283,7 @@ public class DefaultVascTableController implements VascTableController { } } - /** - * @see com.idcanet.vasc.core.VascTableController#finalizeVascTable(com.idcanet.vasc.core.VascTable) - */ - public void finalizeVascTable(VascTable table) throws Exception { - } - /** - * @see com.idcanet.vasc.core.VascTableController#getTotalColumnsWidth(com.idcanet.vasc.core.VascTable) - */ - public Integer getTotalColumnsWidth(VascTable table) { - int result = 0; - for(VascTableColumn c:table.getTableColumns()) { - if(c.getWidth()==null) { - Logger.getLogger(VascTable.class.getName()).finer("Column no size: "+c.getName()); - } else { - result+=c.getWidth(); - } - } - return result; - } - - - - /** - * @see com.idcanet.vasc.core.VascTableController#initEditObject(com.idcanet.vasc.core.VascTable, java.lang.Object) - */ - public Object initEditObject(VascTable table, Object object) throws Exception { - if (object!=null) { - return object; - } - object = table.getVascRecordCreator().newRecord(table); - fireVascEvent(VascEventListener.VascEventType.BEAN_INIT, object); - return object; - } - - public void initEditObjectColumn(VascTableColumn c,Object bean) throws Exception { - Object value = c.getVascColumnValue().getValue(c, bean); - if(value==null & c.getDefaultValue()!=null) { - try { - logger.finer("Setting default value for: "+c.getName()+" def: "+c.getDefaultValue()); - c.getVascColumnValue().setValue(c, bean, c.getDefaultValue()); - } catch (Exception e) { - logger.log(Level.WARNING,"Error in setting default value: '"+c.getDefaultValue()+"' error: "+e.getMessage(),e); - } - } - } - - /** - * @see com.idcanet.vasc.core.VascTableController#refreshData() - */ - public void refreshData(VascTable table) throws Exception { - table.setSelectedObject(null); - table.setTableData(table.getVascDataSource().execute()); - fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, null); - } - - public void handleException(Exception e,VascTable table) { - if (exceptionListeners.isEmpty()) { - Logger.getLogger(DefaultVascTableController.class.getName()).log(Level.WARNING,e.getMessage(),e); - return; - } - for(VascExceptionListener ee:exceptionListeners) { - try { - ee.handleException(e, table); - } catch (Exception eee) { - Logger.getLogger(DefaultVascTableController.class.getName()).log(Level.WARNING,"Error in ExceptionListener: "+eee.getMessage(),eee); - } - } - } - public void addEventListener(VascEventListener e) { eventListeners.add(e); } @@ -199,46 +297,7 @@ public class DefaultVascTableController implements VascTableController { } } - @SuppressWarnings("unchecked") - public boolean setUIComponentsBeanErrors(VascTable table,Object bean) { - boolean error = false; - if(bean==null) { - logger.finest("No bean to check."); - return true; // nothing to check - } - - ClassValidator val = new ClassValidator(bean.getClass()); - InvalidValue[] ival = val.getInvalidValues(bean); - logger.fine("Got invaliled value: "+ival.length); - for(VascTableColumn col:table.getTableColumns()) { - if(col.getVascUIComponent()==null) { - continue; // we only DISPLAY user input errors !! - } - if (col instanceof VascAnnotationTableColumn) { - VascAnnotationTableColumn column = (VascAnnotationTableColumn)col; - - InvalidValue iv = findInvalidValueByProperty(ival,column.getBeanProperty()); - if(iv==null) { - column.getVascUIComponent().setErrorText(null); - continue; // no error on this property - } - error = true; - column.getVascUIComponent().setErrorText(iv.getMessage()); - } - } - logger.finest("Checked for errors: "+error); - return error; - } - private InvalidValue findInvalidValueByProperty(InvalidValue[] ival,String property) { - for(InvalidValue iv:ival) { - if(iv.getPropertyName().equals(property)) { - return iv; - } - } - return null; - } - public void addExceptionListener(VascExceptionListener listener) { exceptionListeners.add(listener); } @@ -246,21 +305,5 @@ public class DefaultVascTableController implements VascTableController { public void removeExceptionListener(VascExceptionListener listener) { exceptionListeners.remove(listener); } - - public Object mergeObject(VascTable table,Object object) { - Object result = null; - try { - object = table.getVascDataSource().merge(object); - fireVascEvent(VascEventListener.VascEventType.BEAN_MERGE,object); - // todo: make faster - // add to table at position old old object - // then remove old object - // send refresh - - table.getVascTableController().refreshData(table); - } catch (Exception e) { - handleException(e, table); - } - return result; - } + */ } \ 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 613c029..7798e26 100644 --- a/src/com/idcanet/vasc/impl/actions/AddRowAction.java +++ b/src/com/idcanet/vasc/impl/actions/AddRowAction.java @@ -44,6 +44,6 @@ public class AddRowAction extends AbstractVascAction implements RowVascAction { } public void doRowAction(VascEntry enty,Object rowObject) throws Exception { - enty.getVascFrontend().renderEdit(null); + enty.getVascFrontendData().getVascFrontend().renderEdit(null); } } \ 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 14901b5..8ed2cd7 100644 --- a/src/com/idcanet/vasc/impl/actions/CSVExportGlobalAction.java +++ b/src/com/idcanet/vasc/impl/actions/CSVExportGlobalAction.java @@ -49,7 +49,7 @@ public class CSVExportGlobalAction extends AbstractVascAction implements GlobalV } public void doGlobalAction(VascEntry entry) throws Exception { - entry.getVascFrontend().renderExport(this); + entry.getVascFrontendData().getVascFrontend().renderExport(this); } public void doExport(OutputStream out,VascEntry entry) throws Exception { @@ -59,7 +59,7 @@ public class CSVExportGlobalAction extends AbstractVascAction implements GlobalV p.write(c.getName()+"\t"); } p.write("\n"); - for (Object o:entry.getEntryDataList()) { + for (Object o:entry.getVascFrontendData().getEntryDataList()) { for (VascEntryField c:entry.getVascEntryFields()) { p.write(c.getVascEntryFieldValue().getValue(c, o)+"\t"); } diff --git a/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java b/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java index 5734e1d..9518584 100644 --- a/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java +++ b/src/com/idcanet/vasc/impl/actions/DeleteRowAction.java @@ -47,6 +47,6 @@ public class DeleteRowAction extends AbstractVascAction implements RowVascAction if (rowObject==null) { return; } - entry.getVascFrontend().renderDelete(rowObject); + entry.getVascFrontendData().getVascFrontend().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 eafab35..b643870 100644 --- a/src/com/idcanet/vasc/impl/actions/EditRowAction.java +++ b/src/com/idcanet/vasc/impl/actions/EditRowAction.java @@ -48,6 +48,6 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction { if (rowObject==null) { return; } - entry.getVascFrontend().renderEdit(rowObject); + entry.getVascFrontendData().getVascFrontend().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 e7390a9..ba20974 100644 --- a/src/com/idcanet/vasc/impl/actions/RefreshDataGlobalAction.java +++ b/src/com/idcanet/vasc/impl/actions/RefreshDataGlobalAction.java @@ -45,6 +45,6 @@ public class RefreshDataGlobalAction extends AbstractVascAction implements Globa public void doGlobalAction(VascEntry entry) throws Exception { - entry.get.refreshData(table); // this wil also fire the event + entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry); // 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 599c5c7..3ff0bec 100644 --- a/src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java +++ b/src/com/idcanet/vasc/impl/actions/XMLExportGlobalAction.java @@ -49,14 +49,14 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV } public void doGlobalAction(VascEntry entry) throws Exception { - entry.getVascFrontend().renderExport(this); + entry.getVascFrontendData().getVascFrontend().renderExport(this); } public void doExport(OutputStream out,VascEntry entry) throws Exception { PrintWriter p = new PrintWriter(out); p.write("\n"); p.write("\n"); - for (Object o:entry.getEntryDataList()) { + for (Object o:entry.getVascFrontendData().getEntryDataList()) { for (VascEntryField c:entry.getVascEntryFields()) { p.write(""); p.write(""+c.getVascEntryFieldValue().getValue(c, o)); diff --git a/src/com/idcanet/vasc/impl/type/DefaultVascEntryFieldType.java b/src/com/idcanet/vasc/impl/type/DefaultVascEntryFieldType.java new file mode 100644 index 0000000..831d482 --- /dev/null +++ b/src/com/idcanet/vasc/impl/type/DefaultVascEntryFieldType.java @@ -0,0 +1,39 @@ +/* + * 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.impl.type; + + +import com.idcanet.vasc.core.AbstractVascEntryFieldType; + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 8, 2008 + */ +public class DefaultVascEntryFieldType extends AbstractVascEntryFieldType { + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/type/FieldTypeParser.java b/src/com/idcanet/vasc/impl/type/FieldTypeParser.java new file mode 100644 index 0000000..044ee88 --- /dev/null +++ b/src/com/idcanet/vasc/impl/type/FieldTypeParser.java @@ -0,0 +1,72 @@ +/* + * 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.impl.type; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.parsers.ParserConfigurationException; + +import org.xml.sax.SAXException; + +import com.idcanet.vasc.core.VascEntryFieldType; +import com.idcanet.x4o.core.X4OParser; +import com.idcanet.x4o.element.Element; + +/** + * + * + * @author Willem Cazander + * @version 1.0 Sep 11, 2008 + */ +public class FieldTypeParser extends X4OParser { + + static public final String FIELD_TYPE_LANGUAGE = "fieldtype"; + + /** + * + * @param language + * @throws Exception + */ + public FieldTypeParser() throws Exception { + super(FIELD_TYPE_LANGUAGE); + } + + public void parseVascFieldTypes() throws IOException, SecurityException, NullPointerException, ParserConfigurationException, SAXException { + parseResource("META-INF/fieldtypes.xml"); + } + + public List getTypes() { + List result = new ArrayList(4); + for (Element e:getElementContext().getRootElements()) { + VascEntryFieldType a = (VascEntryFieldType)e.getElementObject(); + result.add(a); + } + return result; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascStringLength.java b/src/com/idcanet/vasc/validators/VascStringLength.java index bb2b1e3..6e4ea55 100644 --- a/src/com/idcanet/vasc/validators/VascStringLength.java +++ b/src/com/idcanet/vasc/validators/VascStringLength.java @@ -53,4 +53,17 @@ public @interface VascStringLength { * @return */ int max() default 0; + + static BB bb = new BB() { + public VascValidator getValidator(VascStringLength ano) { + VascStringLengthValidator v = new VascStringLengthValidator(); + v.setMinLenght(ano.min()); + v.setMaxLenght(ano.max()); + return v; + } + }; +} + +interface BB { + public VascValidator getValidator(VascStringLength ano); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/validators/VascStringLengthValidator.java b/src/com/idcanet/vasc/validators/VascStringLengthValidator.java index 3a16c7f..18bca4b 100644 --- a/src/com/idcanet/vasc/validators/VascStringLengthValidator.java +++ b/src/com/idcanet/vasc/validators/VascStringLengthValidator.java @@ -33,11 +33,50 @@ package com.idcanet.vasc.validators; * @version 1.0 Sep 5, 2008 */ public class VascStringLengthValidator implements VascValidator { - + + private Integer minLenght = null; + private Integer maxLenght = null; + /** * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) */ public boolean isObjectValid(Object object) throws VascValidatorException { - return false; + String result = (String)object; + + if (getMinLenght()!=null && result.length()getMaxLenght()) { + return false; + } + return true; + } + + /** + * @return the minLenght + */ + public Integer getMinLenght() { + return minLenght; + } + + /** + * @param minLenght the minLenght to set + */ + public void setMinLenght(Integer minLenght) { + this.minLenght = minLenght; + } + + /** + * @return the maxLenght + */ + public Integer getMaxLenght() { + return maxLenght; + } + + /** + * @param maxLenght the maxLenght to set + */ + public void setMaxLenght(Integer maxLenght) { + this.maxLenght = maxLenght; } } \ No newline at end of file diff --git a/tests/META-INF/logging.properties b/tests/META-INF/logging.properties index 74fa94a..2d94ca8 100644 --- a/tests/META-INF/logging.properties +++ b/tests/META-INF/logging.properties @@ -10,7 +10,7 @@ handlers = java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level = ALL # Set the default logging level for the root logger -.level = ALL +.level = FINE com.idcanet.x4o = ALL diff --git a/tests/com/idcanet/vasc/FieldTypesTest.java b/tests/com/idcanet/vasc/FieldTypesTest.java new file mode 100644 index 0000000..884c8c8 --- /dev/null +++ b/tests/com/idcanet/vasc/FieldTypesTest.java @@ -0,0 +1,64 @@ +/* + * 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; + +import java.io.InputStream; +import java.util.logging.LogManager; + +import com.idcanet.vasc.core.VascEntryFieldType; +import com.idcanet.vasc.impl.type.FieldTypeParser; + +import junit.framework.TestCase; + +/** + * Tests a simple x4o xml language. + * + * @author Willem Cazander + * @version 1.0 Jul 24, 2006 + */ +public class FieldTypesTest extends TestCase { + + public void setUp() throws Exception { + // enable all logs + InputStream loggingProperties = this.getClass().getResourceAsStream("/META-INF/logging.properties"); + LogManager.getLogManager().readConfiguration( loggingProperties ); + loggingProperties.close(); + } + + public void tearDown() throws Exception { + } + + public void testParse() throws Exception { + FieldTypeParser p = new FieldTypeParser(); + p.parseVascFieldTypes(); + + System.out.println("Got types;"); + for (VascEntryFieldType t:p.getTypes()) { + System.out.println("t= "+t.getId()); + } + } +} \ No newline at end of file diff --git a/tests/com/idcanet/vasc/SwingTest.java b/tests/com/idcanet/vasc/SwingTest.java index 95607c3..5df6d2e 100644 --- a/tests/com/idcanet/vasc/SwingTest.java +++ b/tests/com/idcanet/vasc/SwingTest.java @@ -33,6 +33,7 @@ import javax.swing.JFrame; import javax.swing.JPanel; import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.frontends.swing.SwingVascFrontend; import junit.framework.TestCase; @@ -53,16 +54,7 @@ public class SwingTest extends TestCase { public void tearDown() throws Exception { } - - /* - - - default view field - - Admin fields and order - - Admin field groups -> 'collapse - - List filters auto by type - - search fields - - */ + public void testAll() throws Exception { JFrame.setDefaultLookAndFeelDecorated(false); @@ -73,15 +65,15 @@ public class SwingTest extends TestCase { frame.setLocationRelativeTo(null); // get table - VascTable table = TestTable.getVascTable(); + VascEntry entry = TestTable.getVascTable(); // define redering JPanel panel = new JPanel(); - SwingVascViewRenderer render = new SwingVascViewRenderer(panel); + SwingVascFrontend render = new SwingVascFrontend(panel); frame.add(panel); // render - render.initTable(table); + render.initEntry(entry); //table.getTableColumns().get(0).set diff --git a/tests/com/idcanet/vasc/TestModelVascDataSource.java b/tests/com/idcanet/vasc/TestModelVascDataSource.java index f35198e..b241a76 100644 --- a/tests/com/idcanet/vasc/TestModelVascDataSource.java +++ b/tests/com/idcanet/vasc/TestModelVascDataSource.java @@ -37,6 +37,7 @@ import com.idcanet.vasc.core.entry.VascEntryFieldValue; import com.idcanet.vasc.core.entry.VascEntryRecordCreator; import com.idcanet.vasc.core.ui.VascSelectItem; import com.idcanet.vasc.core.ui.VascSelectItemModel; +import com.idcanet.vasc.impl.entry.BeanVascEntryRecordCreator; import com.idcanet.vasc.models.TestModel; /** @@ -103,6 +104,6 @@ public class TestModelVascDataSource extends AbstractVascBackend implements Vasc } public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) { - return null; + return new BeanVascEntryRecordCreator(TestModel.class); } } \ No newline at end of file diff --git a/tests/com/idcanet/vasc/TestTable.java b/tests/com/idcanet/vasc/TestTable.java index 597763f..0c73783 100644 --- a/tests/com/idcanet/vasc/TestTable.java +++ b/tests/com/idcanet/vasc/TestTable.java @@ -28,12 +28,13 @@ package com.idcanet.vasc; import java.util.Date; +import com.idcanet.vasc.core.VascController; import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.ui.VascList; +import com.idcanet.vasc.impl.DefaultVascController; import com.idcanet.vasc.impl.DefaultVascEntry; import com.idcanet.vasc.impl.DefaultVascEntryField; -import com.idcanet.vasc.impl.DefaultVascTableController; import com.idcanet.vasc.impl.actions.AddRowAction; import com.idcanet.vasc.impl.actions.CSVExportGlobalAction; import com.idcanet.vasc.impl.actions.DeleteRowAction; @@ -52,6 +53,17 @@ import com.idcanet.vasc.models.TestModel; */ public class TestTable { + static VascController getDefaultVascController() { + DefaultVascController c = new DefaultVascController(); + + + //entry.setVascEntryResourceResolver(new VascI18nTextValue()); + + return c; + + } + + static public VascEntry getVascTable() throws Exception { // define query @@ -63,6 +75,8 @@ public class TestTable { */ + VascController c = getDefaultVascController(); + TestModelVascDataSource data = new TestModelVascDataSource(); // config table @@ -72,24 +86,16 @@ public class TestTable { entry.setHeaderDescription("Met een hele coole tooltip"); entry.setHeaderImage("/resources/images/gabelfresser.gif"); entry.setHelpId("someKey"); - //entry.setVascTableController(new DefaultVascTableController()); - entry.setVascBackend(data); - - //table.setVascTextValue(new DefaultVascTextValue()); - entry.setVascEntryResourceResolver(new VascI18nTextValue()); - - // entry.setVascEntryRecordCreator(new BeanVascEntryRecordCreator(TestModel.class)); + entry.addRowAction(new AddRowAction()); entry.addRowAction(new EditRowAction()); entry.addRowAction(new DeleteRowAction()); entry.addGlobalAction(new XMLExportGlobalAction()); entry.addGlobalAction(new CSVExportGlobalAction()); - //table.addGlobalActions(new HTMLExportGlobalAction()); entry.addGlobalAction(new RefreshDataGlobalAction()); //table.addUserOptions(userOption); - //table.addColumnActions(new GraphColumnAction()); VascEntryField field = new DefaultVascEntryField(); @@ -98,7 +104,12 @@ public class TestTable { field.setDefaultValue("DEFFFFFF"); field.setHelpId("helpColumnKey"); field.setImage("/META-INF/images/silk/png/tick.png"); - field.setVascEntryFieldType(vascEntryFieldType) + try { + field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldType("TextField")); + } catch (Throwable e) { + e.printStackTrace(); + } + field.setVascEntryFieldValue(new BeanPropertyVascEntryFieldValue("name")); entry.addVascEntryField(field); diff --git a/tests/com/idcanet/vasc/models/TestModel.java b/tests/com/idcanet/vasc/models/TestModel.java index ece5fcb..0671a52 100644 --- a/tests/com/idcanet/vasc/models/TestModel.java +++ b/tests/com/idcanet/vasc/models/TestModel.java @@ -39,10 +39,10 @@ import com.idcanet.vasc.annotations.VascHelpId; import com.idcanet.vasc.annotations.VascImage; import com.idcanet.vasc.annotations.VascModelReference; import com.idcanet.vasc.annotations.VascName; -import com.idcanet.vasc.annotations.VascToolTip; -import com.idcanet.vasc.validator.VascDateFuture; -import com.idcanet.vasc.validator.VascObjectNotNull; -import com.idcanet.vasc.validator.VascStringLength; +import com.idcanet.vasc.annotations.VascDescription; +import com.idcanet.vasc.validators.VascDateFuture; +import com.idcanet.vasc.validators.VascObjectNotNull; +import com.idcanet.vasc.validators.VascStringLength; /** * TestModel @@ -51,7 +51,7 @@ import com.idcanet.vasc.validator.VascStringLength; * @author Willem Cazander * @version 1.0 Mar 28, 2007 */ -@VascToolTip(key="En een tooltip op het model") +@VascDescription(key="En een tooltip op het model") public class TestModel { private String name = null; @@ -82,7 +82,7 @@ public class TestModel { * @return the description */ @VascName(key="omscheiving") - @VascToolTip(key="De omscheiving") + @VascDescription(key="De omscheiving") @VascHelpId(helpId="help.id") @VascDefaultValue(defaultValue="xxxxx") @VascColumnWidth(width=200) diff --git a/tests/resources/vasc/tables.xml b/tests/resources/vasc/tables.xml index 73610a8..e7c9c48 100644 --- a/tests/resources/vasc/tables.xml +++ b/tests/resources/vasc/tables.xml @@ -80,15 +80,28 @@ Master + + + + + + + + + - - - + + + + + + +