diff --git a/doc/README.txt b/doc/README.txt index 2f636af..5198daa 100644 --- a/doc/README.txt +++ b/doc/README.txt @@ -65,6 +65,24 @@ The plural name for the object: verbose_name_plural = "stories" If this isn’t given, Django will use verbose_name + "s" +List of Magic Field Names + + * created_at + * created_on + * updated_at + * updated_on + * lock_version + * type + * id + * #{table_name}_count + * position + * parent_id + * lft + * rgt + * quote_value (is used for quoting) + * template + + - plural - ordering diff --git a/src/META-INF/fieldtypes.xml b/src/META-INF/fieldtypes.xml index ae2469a..f2dd20f 100644 --- a/src/META-INF/fieldtypes.xml +++ b/src/META-INF/fieldtypes.xml @@ -5,21 +5,19 @@ > - + + - + + + + + - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/META-INF/vasc-namespaces.xml b/src/META-INF/vasc-namespaces.xml new file mode 100644 index 0000000..ac27382 --- /dev/null +++ b/src/META-INF/vasc-namespaces.xml @@ -0,0 +1,8 @@ + + + + + Vasc namespace for the fieldtype language + + META-INF/vasc-lang.eld + \ 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 144123f..9f66d42 100644 --- a/src/com/idcanet/vasc/backends/ldap/LdapVascBackend.java +++ b/src/com/idcanet/vasc/backends/ldap/LdapVascBackend.java @@ -33,10 +33,9 @@ import java.util.Map; import com.idcanet.vasc.core.AbstractVascBackend; import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascEntryField; +import com.idcanet.vasc.core.VascException; import com.idcanet.vasc.core.entry.VascEntryFieldValue; import com.idcanet.vasc.core.entry.VascEntryRecordCreator; -import com.idcanet.x4o.element.ElementParameterException; -import com.idcanet.x4o.element.ElementParameterNotFoundException; /** * @@ -116,7 +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 { + public Object getValue(VascEntryField field, Object record) throws VascException { Map map = (Map)record; return map.get(field.getBackendName()); } @@ -125,7 +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 { + public void setValue(VascEntryField field, Object record,Object value) throws VascException { Map map = (Map)record; map.put(field.getBackendName(), value); } diff --git a/src/com/idcanet/vasc/core/AbstractVascBackend.java b/src/com/idcanet/vasc/core/AbstractVascBackend.java index 9af7a21..e1e84df 100644 --- a/src/com/idcanet/vasc/core/AbstractVascBackend.java +++ b/src/com/idcanet/vasc/core/AbstractVascBackend.java @@ -37,7 +37,7 @@ import java.util.Set; */ abstract public class AbstractVascBackend implements VascBackend { - private String name = null; + private String id = null; protected Map parameters = null; private int pageIndex = 0; private int pageSize = 100; @@ -62,20 +62,20 @@ abstract public class AbstractVascBackend implements VascBackend { } /** - * @see com.idcanet.vasc.core.VascBackend#getName() + * @see com.idcanet.vasc.core.VascBackend#getId() */ - public String getName() { - return name; + public String getId() { + return id; } /** - * @see com.idcanet.vasc.core.VascBackend#setName(java.lang.String) + * @see com.idcanet.vasc.core.VascBackend#setId(java.lang.String) */ - public void setName(String name) { - if (name==null) { - throw new IllegalArgumentException("name may not be null"); + public void setId(String id) { + if (id==null) { + throw new IllegalArgumentException("id may not be null"); } - this.name=name; + this.id=id; } diff --git a/src/com/idcanet/vasc/core/AbstractVascEntryFieldType.java b/src/com/idcanet/vasc/core/AbstractVascEntryFieldType.java index c36a7a6..7ca3811 100644 --- a/src/com/idcanet/vasc/core/AbstractVascEntryFieldType.java +++ b/src/com/idcanet/vasc/core/AbstractVascEntryFieldType.java @@ -42,53 +42,32 @@ import com.idcanet.vasc.validators.VascValidator; abstract public class AbstractVascEntryFieldType implements VascEntryFieldType { private String id = null; - private Class autoFieldClass = null; - private ObjectConverter objectConverter = null; - private VascUIComponent vascUIComponent = null; + private List> autoDetectionClasses = null; private List vascValidators = null; private Map properties = null; - private String parentEntryFieldTypeName = null; + + private String uiComponentId = null; + private String inputMask = 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() + * @see com.idcanet.vasc.core.VascEntryFieldType#setId(java.lang.String) */ - public ObjectConverter getObjectConverter() { - return objectConverter; + public void setId(String id) { + this.id=id; } - - /** - * @see com.idcanet.vasc.core.VascEntryFieldType#getParentEntryFieldTypeName() - */ - public String getParentEntryFieldTypeName() { - return parentEntryFieldTypeName; - } - + /** * @see com.idcanet.vasc.core.VascEntryFieldType#getProperty(java.lang.String) */ @@ -96,6 +75,13 @@ abstract public class AbstractVascEntryFieldType implements VascEntryFieldType { return properties.get(name); } + /** + * @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#getPropertyNames() */ @@ -103,13 +89,6 @@ abstract public class AbstractVascEntryFieldType implements VascEntryFieldType { return new ArrayList(properties.keySet()); } - /** - * @see com.idcanet.vasc.core.VascEntryFieldType#getVascUIComponent() - */ - public VascUIComponent getVascUIComponent() { - return vascUIComponent; - } - /** * @see com.idcanet.vasc.core.VascEntryFieldType#getVascValidators() */ @@ -117,6 +96,13 @@ abstract public class AbstractVascEntryFieldType implements VascEntryFieldType { return vascValidators; } + /** + * @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#removeVascValidator(com.idcanet.vasc.validators.VascValidator) */ @@ -125,44 +111,94 @@ abstract public class AbstractVascEntryFieldType implements VascEntryFieldType { } /** - * @see com.idcanet.vasc.core.VascEntryFieldType#setAutoFieldClass(java.lang.Class) + * @see com.idcanet.vasc.core.VascEntryFieldType#addAutoDetectionClass(java.lang.Class) */ - public void setAutoFieldClass(Class autoFieldClass) { - this.autoFieldClass=autoFieldClass; + public void addAutoDetectionClass(Class classObject) { + autoDetectionClasses.add(classObject); } /** - * @see com.idcanet.vasc.core.VascEntryFieldType#setId(java.lang.String) + * @see com.idcanet.vasc.core.VascEntryFieldType#getAutoDetectionClasses() */ - public void setId(String id) { - this.id=id; + public List> getAutoDetectionClasses() { + return autoDetectionClasses; } /** - * @see com.idcanet.vasc.core.VascEntryFieldType#setObjectConverter(com.idcanet.vasc.core.VascEntryFieldType.ObjectConverter) + * @see com.idcanet.vasc.core.VascEntryFieldType#getInputMask() */ - public void setObjectConverter(ObjectConverter objectConverter) { - this.objectConverter=objectConverter; + public String getInputMask() { + return inputMask; } /** - * @see com.idcanet.vasc.core.VascEntryFieldType#setParentEntryFieldTypeName(java.lang.String) + * @see com.idcanet.vasc.core.VascEntryFieldType#setInputMask(java.lang.String) */ - public void setParentEntryFieldTypeName(String parentEntryFieldTypeName) { - this.parentEntryFieldTypeName=parentEntryFieldTypeName; + public void setInputMask(String inputMask) { + this.inputMask=inputMask; } /** - * @see com.idcanet.vasc.core.VascEntryFieldType#setProperty(java.lang.String, java.lang.String) + * @see com.idcanet.vasc.core.VascEntryFieldType#getUIComponentId() */ - public void setProperty(String name, String value) { - properties.put(name, value); + public String getUIComponentId() { + return uiComponentId; } /** - * @see com.idcanet.vasc.core.VascEntryFieldType#setVascUIComponent(com.idcanet.vasc.core.ui.VascUIComponent) + * @see com.idcanet.vasc.core.VascEntryFieldType#setUIComponentId(java.lang.String) */ - public void setVascUIComponent(VascUIComponent vascUIComponent) { - this.vascUIComponent=vascUIComponent; + public void setUIComponentId(String uiComponentId) { + this.uiComponentId=uiComponentId; } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#getUIComponentCount() + */ + public int getUIComponentCount() { + return 1; + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#provideEditorUIComponent(int) + */ + public VascUIComponent provideEditorUIComponent(int index,VascEntryField entryField) throws VascException { + if (index!=0) { + return null; + } + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = entryField.getClass().getClassLoader(); // fallback + } + String compId = getUIComponentId(); + if (compId==null) { + compId = VascUIComponent.VASC_TEXT; // ??? mmmm + } + String componentClass = entryField.getVascEntry().getVascFrontendData().getVascUIComponent(compId); + try { + return (VascUIComponent)cl.loadClass(componentClass).newInstance(); + } catch (Exception e) { + throw new VascException(); + } + } + + /** + * @see com.idcanet.vasc.core.VascEntryFieldType#provideLabelUIComponent(int) + */ + public VascUIComponent provideLabelUIComponent(int index,VascEntryField entryField) throws VascException { + if (index!=0) { + return null; + } + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = entryField.getClass().getClassLoader(); // fallback + } + String componentClass = entryField.getVascEntry().getVascFrontendData().getVascUIComponent(VascUIComponent.VASC_LABEL); + try { + return (VascUIComponent)cl.loadClass(componentClass).newInstance(); + } catch (Exception e) { + throw new VascException(); + } + } + } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/AbstractVascFrontend.java b/src/com/idcanet/vasc/core/AbstractVascFrontend.java index 9c51365..625e54f 100644 --- a/src/com/idcanet/vasc/core/AbstractVascFrontend.java +++ b/src/com/idcanet/vasc/core/AbstractVascFrontend.java @@ -33,7 +33,7 @@ package com.idcanet.vasc.core; */ abstract public class AbstractVascFrontend implements VascFrontend { - private String name = null; + private String id = null; protected VascEntry entry = null; protected String i18n(String key,Object...params) { @@ -44,6 +44,8 @@ abstract public class AbstractVascFrontend implements VascFrontend { return entry; } + abstract protected void addUiComponents(); + /** * @see com.idcanet.vasc.core.VascFrontend#initEntry(com.idcanet.vasc.core.VascEntry) */ @@ -56,19 +58,20 @@ abstract public class AbstractVascFrontend implements VascFrontend { } } this.entry=entry; + addUiComponents(); } /** - * @see com.idcanet.vasc.core.VascFrontend#getName() + * @see com.idcanet.vasc.core.VascFrontend#getId() */ - public String getName() { - return name; + public String getId() { + return id; } /** - * @see com.idcanet.vasc.core.VascFrontend#setName(java.lang.String) + * @see com.idcanet.vasc.core.VascFrontend#setId(java.lang.String) */ - public void setName(String name) { - this.name=name; + public void setId(String id) { + this.id=id; } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascBackend.java b/src/com/idcanet/vasc/core/VascBackend.java index fcae0f4..abbad39 100644 --- a/src/com/idcanet/vasc/core/VascBackend.java +++ b/src/com/idcanet/vasc/core/VascBackend.java @@ -39,8 +39,8 @@ import com.idcanet.vasc.core.entry.VascEntryRecordCreator; */ public interface VascBackend { - public String getName(); - public void setName(String name); + public String getId(); + public void setId(String id); public void setDataParameter(String key,Object data); public Object getDataParameter(String key); diff --git a/src/com/idcanet/vasc/core/VascBackendController.java b/src/com/idcanet/vasc/core/VascBackendController.java index 851516d..6a05d43 100644 --- a/src/com/idcanet/vasc/core/VascBackendController.java +++ b/src/com/idcanet/vasc/core/VascBackendController.java @@ -34,5 +34,5 @@ package com.idcanet.vasc.core; */ public interface VascBackendController { - public VascBackend getVascBackend(String name); + public VascBackend getVascBackendById(String id); } \ 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 dd8372e..17c0cdd 100644 --- a/src/com/idcanet/vasc/core/VascEntry.java +++ b/src/com/idcanet/vasc/core/VascEntry.java @@ -287,4 +287,7 @@ public interface VascEntry extends Cloneable { public VascFrontendData getVascFrontendData(); public void setVascFrontendData(VascFrontendData vascFrontendData); + + public String getBackendId(); + public void setBackendId(String backendId); } diff --git a/src/com/idcanet/vasc/core/VascEntryController.java b/src/com/idcanet/vasc/core/VascEntryController.java index 4017c12..16bd5fe 100644 --- a/src/com/idcanet/vasc/core/VascEntryController.java +++ b/src/com/idcanet/vasc/core/VascEntryController.java @@ -36,7 +36,9 @@ import java.util.List; */ public interface VascEntryController { - public VascEntry getVascEntry(String name); + public VascEntry getVascEntryById(String id); - public List getVascEntryNames(); + public List getVascEntryIds(); + + public List getVascEntryAdminIds(); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascEntryField.java b/src/com/idcanet/vasc/core/VascEntryField.java index fb9f843..e243a68 100644 --- a/src/com/idcanet/vasc/core/VascEntryField.java +++ b/src/com/idcanet/vasc/core/VascEntryField.java @@ -42,8 +42,14 @@ import com.idcanet.vasc.validators.VascValidator; */ public interface VascEntryField { + /** + * @return the VascEntry + */ public VascEntry getVascEntry(); + /** + * @param entry the VascEntry to set + */ public void setVascEntry(VascEntry entry); /** diff --git a/src/com/idcanet/vasc/core/VascEntryFieldType.java b/src/com/idcanet/vasc/core/VascEntryFieldType.java index 0c6c609..26524a0 100644 --- a/src/com/idcanet/vasc/core/VascEntryFieldType.java +++ b/src/com/idcanet/vasc/core/VascEntryFieldType.java @@ -42,8 +42,14 @@ public interface VascEntryFieldType { public String getId(); public void setId(String id); - public Class getAutoFieldClass(); - public void setAutoFieldClass(Class classObject); + public String getUIComponentId(); + public void setUIComponentId(String uiComponentId); + + public String getInputMask(); + public void setInputMask(String inputMask); + + public List> getAutoDetectionClasses(); + public void addAutoDetectionClass(Class classObject); public void addVascValidator(VascValidator vascValidator); public void removeVascValidator(VascValidator vascValidator); @@ -52,17 +58,8 @@ public interface VascEntryFieldType { public void setProperty(String name,String value); public String getProperty(String name); public List getPropertyNames(); - - public String getParentEntryFieldTypeName(); - public void setParentEntryFieldTypeName(String name); - - public ObjectConverter getObjectConverter(); - public void setObjectConverter(ObjectConverter converter); - - public VascUIComponent getVascUIComponent(); - public void setVascUIComponent(VascUIComponent vascUIComponent); - - interface ObjectConverter { - } + public int getUIComponentCount(); + public VascUIComponent provideLabelUIComponent(int index,VascEntryField entryField) throws VascException; + public VascUIComponent provideEditorUIComponent(int index,VascEntryField entryField) throws VascException; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascEntryFieldTypeController.java b/src/com/idcanet/vasc/core/VascEntryFieldTypeController.java index fc91e5b..115067a 100644 --- a/src/com/idcanet/vasc/core/VascEntryFieldTypeController.java +++ b/src/com/idcanet/vasc/core/VascEntryFieldTypeController.java @@ -36,7 +36,7 @@ import java.util.List; */ public interface VascEntryFieldTypeController { - public VascEntryFieldType getVascEntryFieldType(String name); + public VascEntryFieldType getVascEntryFieldTypeById(String id); - public List getVascEntryFieldTypeNames(); + public List getVascEntryFieldTypeIds(); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascEntryFinalizer.java b/src/com/idcanet/vasc/core/VascEntryFinalizer.java index 8f831a2..af2f5c5 100644 --- a/src/com/idcanet/vasc/core/VascEntryFinalizer.java +++ b/src/com/idcanet/vasc/core/VascEntryFinalizer.java @@ -34,5 +34,5 @@ package com.idcanet.vasc.core; */ public interface VascEntryFinalizer { - public VascEntry finalizeVascEntry(VascEntry entry) throws Exception; + public VascEntry finalizeVascEntry(VascEntry entry,VascController vascController) throws VascException; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascException.java b/src/com/idcanet/vasc/core/VascException.java new file mode 100644 index 0000000..b8e614d --- /dev/null +++ b/src/com/idcanet/vasc/core/VascException.java @@ -0,0 +1,46 @@ +/* + * 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; + + + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 18, 2008 + */ +@SuppressWarnings("serial") +public class VascException extends Exception { + + + public VascException() { + } + + public VascException(Exception e) { + super(e); + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/VascFrontend.java b/src/com/idcanet/vasc/core/VascFrontend.java index 801c5da..6b3a782 100644 --- a/src/com/idcanet/vasc/core/VascFrontend.java +++ b/src/com/idcanet/vasc/core/VascFrontend.java @@ -36,9 +36,9 @@ import com.idcanet.vasc.core.entry.VascEntryExporter; */ public interface VascFrontend { - public void setName(String name); + public void setId(String name); - public String getName(); + public String getId(); public void initEntry(VascEntry entry) throws Exception; diff --git a/src/com/idcanet/vasc/core/VascFrontendData.java b/src/com/idcanet/vasc/core/VascFrontendData.java index cf633e7..52b6ee6 100644 --- a/src/com/idcanet/vasc/core/VascFrontendData.java +++ b/src/com/idcanet/vasc/core/VascFrontendData.java @@ -97,4 +97,9 @@ public interface VascFrontendData { * @param vascEntryResourceResolver the vascEntryResourceResolver to set */ public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver); + + + public void putVascUIComponent(String rendererId,String uiComponentClass); + + public String getVascUIComponent(String rendererId); } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/entry/VascEntryFieldValue.java b/src/com/idcanet/vasc/core/entry/VascEntryFieldValue.java index e2eb493..70388b5 100644 --- a/src/com/idcanet/vasc/core/entry/VascEntryFieldValue.java +++ b/src/com/idcanet/vasc/core/entry/VascEntryFieldValue.java @@ -27,8 +27,7 @@ package com.idcanet.vasc.core.entry; import com.idcanet.vasc.core.VascEntryField; -import com.idcanet.x4o.element.ElementParameterException; -import com.idcanet.x4o.element.ElementParameterNotFoundException; +import com.idcanet.vasc.core.VascException; /** * @@ -37,7 +36,7 @@ import com.idcanet.x4o.element.ElementParameterNotFoundException; */ public interface VascEntryFieldValue { - public Object getValue(VascEntryField field,Object record) throws ElementParameterException,ElementParameterNotFoundException; + public Object getValue(VascEntryField field,Object record) throws VascException; - public void setValue(VascEntryField field,Object record,Object value) throws ElementParameterException,ElementParameterNotFoundException; + public void setValue(VascEntryField field,Object record,Object value) throws VascException; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/ui/AbstractVascUIComponent.java b/src/com/idcanet/vasc/core/ui/AbstractVascUIComponent.java index 0cf6d7d..889b13b 100644 --- a/src/com/idcanet/vasc/core/ui/AbstractVascUIComponent.java +++ b/src/com/idcanet/vasc/core/ui/AbstractVascUIComponent.java @@ -26,8 +26,6 @@ package com.idcanet.vasc.core.ui; -import com.idcanet.vasc.core.VascEntry; - /** * * @author Willem Cazander @@ -36,9 +34,7 @@ import com.idcanet.vasc.core.VascEntry; abstract public class AbstractVascUIComponent implements VascUIComponent { private VascUIComponent wrapper = null; - - abstract public Object createComponent(VascEntry entry,VascValueModel model,Object gui) throws Exception; - + /** * @return the wrapper */ diff --git a/src/com/idcanet/vasc/core/ui/VascColumnValueModelListener.java b/src/com/idcanet/vasc/core/ui/VascColumnValueModelListener.java index c9ae359..67f5e85 100644 --- a/src/com/idcanet/vasc/core/ui/VascColumnValueModelListener.java +++ b/src/com/idcanet/vasc/core/ui/VascColumnValueModelListener.java @@ -27,9 +27,7 @@ package com.idcanet.vasc.core.ui; import com.idcanet.vasc.core.VascEntryField; -import com.idcanet.x4o.element.ElementParameterException; -import com.idcanet.x4o.element.ElementParameterNotFoundException; - +import com.idcanet.vasc.core.VascException; /** * @@ -38,50 +36,46 @@ import com.idcanet.x4o.element.ElementParameterNotFoundException; */ public class VascColumnValueModelListener implements VascValueModelListener { - private VascEntryField vascTableColumn = null; + private VascEntryField vascEntryField = null; private Object bean = null; public VascColumnValueModelListener() { } - public VascColumnValueModelListener(VascEntryField vascTableColumn,Object bean) { - setVascTableColumn(vascTableColumn); + + public VascColumnValueModelListener(VascEntryField vascEntryField,Object bean) { + setVascEntryField(vascEntryField); setBean(bean); } - public void valueUpdate(VascValueModel model) throws ElementParameterException,ElementParameterNotFoundException { - //vascTableColumn.getVascColumnValue().setValue(VascEntryField, bean, model.getValue()); - //TODO + public void valueUpdate(VascValueModel model) throws VascException { + vascEntryField.getVascEntryFieldValue().setValue(vascEntryField, bean, model.getValue()); } - - - + /** - * @return the vascTableColumn + * @return the vascEntryField */ - public VascEntryField getVascTableColumn() { - return vascTableColumn; + public VascEntryField getVascEntryField() { + return vascEntryField; } - - - + /** - * @param vascTableColumn the vascTableColumn to set + * @param vascEntryField the vascEntryField to set */ - public void setVascTableColumn(VascEntryField vascTableColumn) { - this.vascTableColumn = vascTableColumn; + public void setVascEntryField(VascEntryField vascEntryField) { + this.vascEntryField = vascEntryField; } + /** * @return the bean */ public Object getBean() { return bean; } + /** * @param bean the bean to set */ public void setBean(Object bean) { this.bean = bean; } - - } \ No newline at end of file diff --git a/src/com/idcanet/vasc/core/ui/VascList.java b/src/com/idcanet/vasc/core/ui/VascList.java index 1afecff..6e304a2 100644 --- a/src/com/idcanet/vasc/core/ui/VascList.java +++ b/src/com/idcanet/vasc/core/ui/VascList.java @@ -27,6 +27,7 @@ package com.idcanet.vasc.core.ui; import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryField; /** @@ -38,7 +39,7 @@ public class VascList extends VascUIComponentImplLoader { private VascSelectItemModel vascSelectItemModel = null; - public Object createComponent(VascEntry entry,VascValueModel model,Object gui) throws Exception { + public Object createComponent(VascEntry entry,VascEntryField entryField,VascValueModel model,Object gui) throws Exception { return loadAndCreateComponent(this, entry, model, gui); } diff --git a/src/com/idcanet/vasc/core/ui/VascUIComponent.java b/src/com/idcanet/vasc/core/ui/VascUIComponent.java index edf0939..bed5eda 100644 --- a/src/com/idcanet/vasc/core/ui/VascUIComponent.java +++ b/src/com/idcanet/vasc/core/ui/VascUIComponent.java @@ -27,6 +27,7 @@ package com.idcanet.vasc.core.ui; import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryField; /** * @@ -35,10 +36,22 @@ import com.idcanet.vasc.core.VascEntry; */ public interface VascUIComponent { + // required ui components + static public final String VASC_LABEL = "VascLabel"; + static public final String VASC_TEXT = "VascText"; + static public final String VASC_LIST = "VascList"; + + // optional ui Components + static public final String VASC_TEXTAREA = "VascTextArea"; + static public final String VASC_BOOLEAN = "VascBoolean"; + static public final String VASC_DATE = "VascDate"; + + static public final String[] requiredUIComponents = {VASC_LABEL,VASC_TEXT,VASC_LIST}; + public void setWrapper(VascUIComponent wrapper); public VascUIComponent getWrapper(); - public Object createComponent(VascEntry entry,VascValueModel model,Object gui) throws Exception; + public Object createComponent(VascEntry entry,VascEntryField entryField,VascValueModel model,Object gui) throws Exception; public void setErrorText(String text); public String getErrorText(); diff --git a/src/com/idcanet/vasc/core/ui/VascValueModel.java b/src/com/idcanet/vasc/core/ui/VascValueModel.java index 1e31aee..8b077ee 100644 --- a/src/com/idcanet/vasc/core/ui/VascValueModel.java +++ b/src/com/idcanet/vasc/core/ui/VascValueModel.java @@ -29,9 +29,7 @@ package com.idcanet.vasc.core.ui; import java.util.ArrayList; import java.util.List; -import com.idcanet.vasc.core.VascEntry; -import com.idcanet.x4o.element.ElementParameterException; -import com.idcanet.x4o.element.ElementParameterNotFoundException; +import com.idcanet.vasc.core.VascException; /** @@ -43,18 +41,16 @@ public class VascValueModel { private Object value = null; private List listeners = null; - //private VascTable table = null; - public VascValueModel(VascEntry entry) { + public VascValueModel() { listeners = new ArrayList(2); - //this.table=table; } - public Object getValue() { + public Object getValue() throws VascException { return value; } - public void setValue(Object value) throws ElementParameterException,ElementParameterNotFoundException { + public void setValue(Object value) throws VascException { this.value = value; fireListeners(); } @@ -65,7 +61,7 @@ public class VascValueModel { public void removeListener(VascValueModelListener l) { listeners.remove(l); } - private void fireListeners() throws ElementParameterException,ElementParameterNotFoundException { + private void fireListeners() throws VascException { for (VascValueModelListener l:listeners) { l.valueUpdate(this); } diff --git a/src/com/idcanet/vasc/core/ui/VascValueModelListener.java b/src/com/idcanet/vasc/core/ui/VascValueModelListener.java index ac81210..d5ab5ee 100644 --- a/src/com/idcanet/vasc/core/ui/VascValueModelListener.java +++ b/src/com/idcanet/vasc/core/ui/VascValueModelListener.java @@ -28,8 +28,8 @@ package com.idcanet.vasc.core.ui; import java.util.EventListener; -import com.idcanet.x4o.element.ElementParameterException; -import com.idcanet.x4o.element.ElementParameterNotFoundException; +import com.idcanet.vasc.core.VascException; + /** @@ -39,5 +39,5 @@ import com.idcanet.x4o.element.ElementParameterNotFoundException; */ public interface VascValueModelListener extends EventListener { - public void valueUpdate(VascValueModel model) throws ElementParameterException,ElementParameterNotFoundException; + public void valueUpdate(VascValueModel model) throws VascException; } \ No newline at end of file diff --git a/src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java b/src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java index 60f414a..eec3e97 100644 --- a/src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java +++ b/src/com/idcanet/vasc/frontends/swing/SwingVascFrontend.java @@ -70,6 +70,7 @@ import com.idcanet.fff.SwingImageHelper; import com.idcanet.vasc.core.AbstractVascFrontend; import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascEntryField; +import com.idcanet.vasc.core.VascFrontendData; import com.idcanet.vasc.core.actions.GlobalVascAction; import com.idcanet.vasc.core.actions.RowVascAction; import com.idcanet.vasc.core.entry.VascEntryExporter; @@ -77,6 +78,12 @@ import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType; import com.idcanet.vasc.core.ui.VascColumnValueModelListener; import com.idcanet.vasc.core.ui.VascUIComponent; import com.idcanet.vasc.core.ui.VascValueModel; +import com.idcanet.vasc.frontends.swing.ui.SwingBoolean; +import com.idcanet.vasc.frontends.swing.ui.SwingDate; +import com.idcanet.vasc.frontends.swing.ui.SwingLabel; +import com.idcanet.vasc.frontends.swing.ui.SwingList; +import com.idcanet.vasc.frontends.swing.ui.SwingText; +import com.idcanet.vasc.frontends.swing.ui.SwingTextArea; /** * @@ -92,28 +99,23 @@ public class SwingVascFrontend extends AbstractVascFrontend { logger = Logger.getLogger(SwingVascFrontend.class.getName()); this.parent=parent; } - - /* - public void initEntry(VascEntry entry) throws Exception { - if (entry.getVascFrontendData().getVascFrontend()==null) { - entry.getVascFrontendData().setVascFrontend(this); - } else { - if (entry.getVascFrontendData().getVascFrontend()!=this) { - throw new IllegalArgumentException("VascEntry has already a differtent VascViewRenderer attected"); - } - } - entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry); - /* - entry.putUIComponent(VascTextField.class, SwingTextField.class); - entry.putUIComponent(VascList.class, SwingList.class); - entry.putUIComponent(VascToggle.class, SwingToggle.class); - entry.putUIComponent(VascDate.class, SwingDate.class); - entry.putUIComponent(VascColorChooser.class, SwingColorChooser.class); - - this.entry=entry; - } - */ + /** + * Add swing implmented ui components + */ + protected void addUiComponents() { + VascFrontendData vfd = getVascEntry().getVascFrontendData(); + + // required UI components + vfd.putVascUIComponent(VascUIComponent.VASC_LABEL,SwingLabel.class.getName()); + vfd.putVascUIComponent(VascUIComponent.VASC_TEXT, SwingText.class.getName()); + vfd.putVascUIComponent(VascUIComponent.VASC_LIST, SwingList.class.getName()); + + // optional UI components + vfd.putVascUIComponent(VascUIComponent.VASC_BOOLEAN , SwingBoolean.class.getName()); + vfd.putVascUIComponent(VascUIComponent.VASC_DATE , SwingDate.class.getName()); + vfd.putVascUIComponent(VascUIComponent.VASC_TEXTAREA, SwingTextArea.class.getName()); + } public ImageIcon getImageIcon(String imageResource) { /// TODO hack beter @@ -255,16 +257,32 @@ public class SwingVascFrontend extends AbstractVascFrontend { public void createBody(JPanel body) throws Exception { body.setLayout(new SpringLayout()); int column = 0; - for(VascEntryField c:entry.getVascEntryFields()) { + for (VascEntryField c:entry.getVascEntryFields()) { entry.getVascFrontendData().getVascFrontendHelper().initEditObjectColumn(c, bean); if (c.isEdit()==false) { continue; } column++; + for (int i=0;i backends = null; + + public DefaultVascBackendController() { + backends = new HashMap(7); + } + + /** + * @see com.idcanet.vasc.core.VascBackendController#getVascBackendById(java.lang.String) + */ + public VascBackend getVascBackendById(String id) { + return backends.get(id); + } + + public void addVascBackend(VascBackend backend) { + if (backend==null) { + throw new NullPointerException("backend must not be null."); + } + if (backend.getId()==null) { + throw new IllegalArgumentException("The backend must have an id."); + } + backends.put(backend.getId(), backend); + } + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/DefaultVascBackendControllerResolver.java b/src/com/idcanet/vasc/impl/DefaultVascBackendControllerResolver.java new file mode 100644 index 0000000..6d7df39 --- /dev/null +++ b/src/com/idcanet/vasc/impl/DefaultVascBackendControllerResolver.java @@ -0,0 +1,51 @@ +/* + * 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.VascBackendController; +import com.idcanet.vasc.core.VascBackendControllerResolver; + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 18, 2008 + */ +public class DefaultVascBackendControllerResolver implements VascBackendControllerResolver { + + private VascBackendController vascBackendController = null; + + /** + * @see com.idcanet.vasc.core.VascBackendControllerResolver#getVascBackendController() + */ + public VascBackendController getVascBackendController() { + return vascBackendController; + } + + public void setVascBackendController(VascBackendController vascBackendController) { + this.vascBackendController=vascBackendController; + } +} \ 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 b014c1b..a4fe605 100644 --- a/src/com/idcanet/vasc/impl/DefaultVascEntry.java +++ b/src/com/idcanet/vasc/impl/DefaultVascEntry.java @@ -77,6 +77,7 @@ public class DefaultVascEntry implements VascEntry { private List vascLinkEntries = null; private Map entryParameters = null; + private String backendId = null; private VascFrontendData vascFrontendData = null; /** @@ -473,4 +474,18 @@ public class DefaultVascEntry implements VascEntry { public void setVascFrontendData(VascFrontendData vascFrontendData) { this.vascFrontendData = vascFrontendData; } + + /** + * @return the backendId + */ + public String getBackendId() { + return backendId; + } + + /** + * @param backendId the backendId to set + */ + public void setBackendId(String backendId) { + this.backendId = backendId; + } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/DefaultVascEntryController.java b/src/com/idcanet/vasc/impl/DefaultVascEntryController.java new file mode 100644 index 0000000..59b2372 --- /dev/null +++ b/src/com/idcanet/vasc/impl/DefaultVascEntryController.java @@ -0,0 +1,85 @@ +/* + * 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.HashMap; +import java.util.List; +import java.util.Map; + +import com.idcanet.vasc.core.VascController; +import com.idcanet.vasc.core.VascEntry; +import com.idcanet.vasc.core.VascEntryController; +import com.idcanet.vasc.core.VascException; + +/** + * + * + * @author Willem Cazander + * @version 1.0 Sep 18, 2008 + */ +public class DefaultVascEntryController implements VascEntryController { + + private Map entries = null; + + public DefaultVascEntryController() { + entries = new HashMap(); + } + + public void addVascEntry(VascEntry entry,VascController vascController) throws VascException { + DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer(); + entry = f.finalizeVascEntry(entry,vascController); + entries.put(entry.getId(), entry); + } + + /** + * @see com.idcanet.vasc.core.VascEntryController#getVascEntryById(java.lang.String) + */ + public VascEntry getVascEntryById(String id) { + return entries.get(id); + } + + /** + * @see com.idcanet.vasc.core.VascEntryController#getVascEntryIds() + */ + public List getVascEntryIds() { + return new ArrayList(entries.keySet()); + } + + /** + * Retuns only the adminList table entries + */ + public List getVascEntryAdminIds() { + List adminIds = new ArrayList(30); + for (VascEntry e:entries.values()) { + if (Boolean.TRUE.equals(e.isVascAdmimList())) { + adminIds.add(e.getId()); + } + } + return adminIds; + } +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/DefaultVascEntryControllerResolver.java b/src/com/idcanet/vasc/impl/DefaultVascEntryControllerResolver.java new file mode 100644 index 0000000..4da3830 --- /dev/null +++ b/src/com/idcanet/vasc/impl/DefaultVascEntryControllerResolver.java @@ -0,0 +1,52 @@ +/* + * 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.VascEntryController; +import com.idcanet.vasc.core.VascEntryControllerResolver; + +/** + * + * @author Willem Cazander + * @version 1.0 Sep 18, 2008 + */ +public class DefaultVascEntryControllerResolver implements VascEntryControllerResolver { + + private VascEntryController vascEntryController = null; + + /** + * @see com.idcanet.vasc.core.VascEntryControllerResolver#getVascEntryController() + */ + public VascEntryController getVascEntryController() { + return vascEntryController; + } + + public void setVascEntryController(VascEntryController vascEntryController) { + this.vascEntryController=vascEntryController; + } + +} \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/DefaultVascFrontendData.java b/src/com/idcanet/vasc/impl/DefaultVascFrontendData.java index 5cef5f5..2c745fc 100644 --- a/src/com/idcanet/vasc/impl/DefaultVascFrontendData.java +++ b/src/com/idcanet/vasc/impl/DefaultVascFrontendData.java @@ -27,7 +27,9 @@ package com.idcanet.vasc.impl; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.idcanet.vasc.core.VascBackend; import com.idcanet.vasc.core.VascEntryFinalizer; @@ -51,9 +53,11 @@ public class DefaultVascFrontendData implements VascFrontendData { private VascEntryFinalizer vascEntryFinalizer = null; private VascFrontendHelper vascFrontendHelper = null; private VascEntryResourceResolver vascEntryResourceResolver = null; + private Map uiComponents = null; public DefaultVascFrontendData() { entryDataList = new ArrayList(0); + uiComponents = new HashMap(8); } /** @@ -153,4 +157,18 @@ public class DefaultVascFrontendData implements VascFrontendData { public void setVascEntryResourceResolver(VascEntryResourceResolver vascEntryResourceResolver) { this.vascEntryResourceResolver = vascEntryResourceResolver; } + + /** + * @see com.idcanet.vasc.core.VascFrontendData#getVascUIComponent(java.lang.String) + */ + public String getVascUIComponent(String rendererId) { + return uiComponents.get(rendererId); + } + + /** + * @see com.idcanet.vasc.core.VascFrontendData#putVascUIComponent(java.lang.String, java.lang.String) + */ + public void putVascUIComponent(String rendererId, String uiComponentClass) { + uiComponents.put(rendererId, uiComponentClass); + } } \ No newline at end of file diff --git a/src/com/idcanet/vasc/impl/DefaultVascFrontendEntryFinalizer.java b/src/com/idcanet/vasc/impl/DefaultVascFrontendEntryFinalizer.java index 79b4646..7665da2 100644 --- a/src/com/idcanet/vasc/impl/DefaultVascFrontendEntryFinalizer.java +++ b/src/com/idcanet/vasc/impl/DefaultVascFrontendEntryFinalizer.java @@ -26,8 +26,10 @@ package com.idcanet.vasc.impl; +import com.idcanet.vasc.core.VascController; import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascEntryFinalizer; +import com.idcanet.vasc.core.VascException; /** @@ -40,7 +42,7 @@ public class DefaultVascFrontendEntryFinalizer implements VascEntryFinalizer { /** * @see com.idcanet.vasc.core.VascEntryFinalizer#finalizeVascEntry(com.idcanet.vasc.core.VascEntry) */ - public VascEntry finalizeVascEntry(VascEntry entry) throws Exception { + public VascEntry finalizeVascEntry(VascEntry entry,VascController vascController) throws VascException { return entry; } diff --git a/src/com/idcanet/vasc/impl/entry/BeanPropertyVascEntryFieldValue.java b/src/com/idcanet/vasc/impl/entry/BeanPropertyVascEntryFieldValue.java index e717e0b..cdf187a 100644 --- a/src/com/idcanet/vasc/impl/entry/BeanPropertyVascEntryFieldValue.java +++ b/src/com/idcanet/vasc/impl/entry/BeanPropertyVascEntryFieldValue.java @@ -27,9 +27,8 @@ package com.idcanet.vasc.impl.entry; import com.idcanet.vasc.core.VascEntryField; +import com.idcanet.vasc.core.VascException; import com.idcanet.vasc.core.entry.VascEntryFieldValue; -import com.idcanet.x4o.element.ElementParameterException; -import com.idcanet.x4o.element.ElementParameterNotFoundException; import com.idcanet.x4o.impl.DefaultElementParameterHelper; /** @@ -54,27 +53,35 @@ public class BeanPropertyVascEntryFieldValue implements VascEntryFieldValue { /** * @see com.idcanet.vasc.core.column.VascColumnValue#getValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object) */ - public Object getValue(VascEntryField column,Object record) throws ElementParameterException,ElementParameterNotFoundException { + public Object getValue(VascEntryField column,Object record) throws VascException { if(getProperty()==null) { return null; } if(getProperty().equals("")) { return ""; } - return helper.getParameter(record, getProperty()); + try { + return helper.getParameter(record, getProperty()); + } catch (Exception e) { + throw new VascException(e); + } } /** * @see com.idcanet.vasc.core.column.VascColumnValue#setValue(com.idcanet.vasc.core.column.VascTableColumn, java.lang.Object, java.lang.Object) */ - public void setValue(VascEntryField column, Object record,Object value) throws ElementParameterException,ElementParameterNotFoundException { + public void setValue(VascEntryField column, Object record,Object value) throws VascException { if(getProperty()==null) { return; } if(getProperty().equals("")) { return; + } + try { + helper.setParameter(record, getProperty(),value); + } catch (Exception e) { + throw new VascException(e); } - helper.setParameter(record, getProperty(),value); } /** diff --git a/src/com/idcanet/vasc/impl/type/DefaultVascEntryFieldTypeController.java b/src/com/idcanet/vasc/impl/type/DefaultVascEntryFieldTypeController.java index b6dbb3c..0d65e86 100644 --- a/src/com/idcanet/vasc/impl/type/DefaultVascEntryFieldTypeController.java +++ b/src/com/idcanet/vasc/impl/type/DefaultVascEntryFieldTypeController.java @@ -48,9 +48,9 @@ public class DefaultVascEntryFieldTypeController implements VascEntryFieldTypeCo /** - * @see com.idcanet.vasc.core.VascEntryFieldTypeController#getVascEntryFieldType(java.lang.String) + * @see com.idcanet.vasc.core.VascEntryFieldTypeController#getVascEntryFieldTypeById(java.lang.String) */ - public VascEntryFieldType getVascEntryFieldType(String name) { + public VascEntryFieldType getVascEntryFieldTypeById(String name) { for(VascEntryFieldType v:parser.getTypes()) { if (v.getId().equals(name)) { return v; @@ -60,9 +60,9 @@ public class DefaultVascEntryFieldTypeController implements VascEntryFieldTypeCo } /** - * @see com.idcanet.vasc.core.VascEntryFieldTypeController#getVascEntryFieldTypeNames() + * @see com.idcanet.vasc.core.VascEntryFieldTypeController#getVascEntryFieldTypeIds() */ - public List getVascEntryFieldTypeNames() { + public List getVascEntryFieldTypeIds() { List result = new ArrayList(5); for(VascEntryFieldType v:parser.getTypes()) { result.add(v.getId()); diff --git a/tests/com/idcanet/vasc/TestModelVascDataSource.java b/tests/com/idcanet/vasc/TestModelVascDataSource.java index 5b6b485..98b9ee0 100644 --- a/tests/com/idcanet/vasc/TestModelVascDataSource.java +++ b/tests/com/idcanet/vasc/TestModelVascDataSource.java @@ -58,6 +58,8 @@ public class TestModelVascDataSource extends AbstractVascBackend implements Vasc t.setDescription("yoyo test"); t.setName("this Name"); t.setPrice(34.1f); + t.setActive(true); + t.setHexColor("#FF66EE"); testModels.add(t); t = new TestModel(); @@ -65,6 +67,8 @@ public class TestModelVascDataSource extends AbstractVascBackend implements Vasc t.setDescription("Model2 test"); t.setName("BeanSourde"); t.setPrice(19.2f); + t.setActive(false); + t.setTestModel((TestModel)testModels.get(0)); testModels.add(t); } public TestModelVascDataSource(List testModels) { diff --git a/tests/com/idcanet/vasc/TestTable.java b/tests/com/idcanet/vasc/TestTable.java index 2a60bc0..bf79968 100644 --- a/tests/com/idcanet/vasc/TestTable.java +++ b/tests/com/idcanet/vasc/TestTable.java @@ -34,6 +34,10 @@ import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.ui.VascList; import com.idcanet.vasc.impl.DefaultVascBackedEntryFinalizer; +import com.idcanet.vasc.impl.DefaultVascBackendController; +import com.idcanet.vasc.impl.DefaultVascBackendControllerResolver; +import com.idcanet.vasc.impl.DefaultVascEntryController; +import com.idcanet.vasc.impl.DefaultVascEntryControllerResolver; import com.idcanet.vasc.impl.DefaultVascFrontendEntryFinalizer; import com.idcanet.vasc.impl.DefaultVascController; import com.idcanet.vasc.impl.DefaultVascEntry; @@ -63,18 +67,23 @@ public class TestTable { static VascController getDefaultVascController() throws Exception { + // for test + TestModelVascDataSource backend = new TestModelVascDataSource(); + backend.setId("testBackend"); + + // config full controller for local jvm use DefaultVascController c = new DefaultVascController(); + DefaultVascBackendControllerResolver vascBackendControllerResolver = new DefaultVascBackendControllerResolver(); + DefaultVascBackendController vascBackendController = new DefaultVascBackendController(); + vascBackendController.addVascBackend(backend); + vascBackendControllerResolver.setVascBackendController(vascBackendController); + c.setVascBackendControllerResolver(vascBackendControllerResolver); - //DefaultVascBackendControllerResolver vascBackendControllerResolver = new DefaultVascBackendControllerResolver(); - //c.setVascBackendControllerResolver(vascBackendControllerResolver); - - - - //DefaultVascEntryControllerResolver vascEntryControllerResolver = new DefaultVascEntryControllerResolver(); - //c.setVascEntryControllerResolver(vascEntryControllerResolver); - - + DefaultVascEntryControllerResolver vascEntryControllerResolver = new DefaultVascEntryControllerResolver(); + DefaultVascEntryController vascEntryController = new DefaultVascEntryController(); + vascEntryControllerResolver.setVascEntryController(vascEntryController); + c.setVascEntryControllerResolver(vascEntryControllerResolver); DefaultVascEntryFieldTypeControllerResolver vascEntryFieldTypeControllerResolver = new DefaultVascEntryFieldTypeControllerResolver(); DefaultVascEntryFieldTypeController vascEntryFieldTypeController = new DefaultVascEntryFieldTypeController(); @@ -87,34 +96,24 @@ public class TestTable { static public VascEntry getVascTable() throws Exception { - - // define query - /* - XTESParser parser = new XTESParser(); - parser.parseResource("/resources/xtes/tests.xml"); - TemplateStore store = XTESParser.getTemplateStore(parser.getElementContext()); - Query query = store.getQuery("testUsers2"); - */ - VascController c = getDefaultVascController(); - - TestModelVascDataSource data = new TestModelVascDataSource(); - + // config table VascEntry entry = new DefaultVascEntry(); + entry.setId("test1"); + entry.setBackendId("testBackend"); DefaultVascFrontendData vascFrontendData = new DefaultVascFrontendData(); - vascFrontendData.setVascBackend(data); + vascFrontendData.setVascBackend(c.getVascBackendControllerResolver().getVascBackendController().getVascBackendById("testBackend")); - DefaultVascEntryResourceResolver vascEntryResourceResolver = new DefaultVascEntryResourceResolver(); + VascI18nTextValue vascEntryResourceResolver = new VascI18nTextValue();// new DefaultVascEntryResourceResolver(); vascFrontendData.setVascEntryResourceResolver(vascEntryResourceResolver); DefaultVascFrontendHelper vascFrontendHelper = new DefaultVascFrontendHelper(); vascFrontendData.setVascFrontendHelper(vascFrontendHelper); entry.setVascFrontendData(vascFrontendData); - entry.setId("test1"); entry.addRowAction(new AddRowAction()); entry.addRowAction(new EditRowAction()); @@ -129,21 +128,11 @@ public class TestTable { VascEntryField field = new DefaultVascEntryField("name"); field.setImage("/META-INF/images/silk/png/tick.png"); - try { - field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldType("TextField")); - } catch (Throwable e) { - e.printStackTrace(); - } - - field.setVascEntryFieldValue(new BeanPropertyVascEntryFieldValue("name")); entry.addVascEntryField(field); - field = new DefaultVascEntryField("description"); - field.setVascEntryFieldValue(new BeanPropertyVascEntryFieldValue("description")); entry.addVascEntryField(field); - - + field = new DefaultVascEntryField("active"); field.setDefaultValue(true); entry.addVascEntryField(field); @@ -153,8 +142,10 @@ public class TestTable { entry.addVascEntryField(field); field = new DefaultVascEntryField("testModel"); + //field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldTypeById("TextField")); + //field.getVascEntryFieldType() VascList list = new VascList(); - list.setVascSelectItemModel(data); + list.setVascSelectItemModel((TestModelVascDataSource)c.getVascBackendControllerResolver().getVascBackendController().getVascBackendById("testBackend")); //field.setVascUIComponent(list); entry.addVascEntryField(field); @@ -168,11 +159,11 @@ public class TestTable { printEntry(entry); DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer(); - entry = f.finalizeVascEntry(entry); + entry = f.finalizeVascEntry(entry,c); printEntry(entry); DefaultVascFrontendEntryFinalizer f2 = new DefaultVascFrontendEntryFinalizer(); - entry = f2.finalizeVascEntry(entry); + entry = f2.finalizeVascEntry(entry,c); //printEntry(entry); return entry; diff --git a/tests/resources/i18n/vasc.properties b/tests/resources/i18n/vasc.properties index 729ac6a..8e9c78b 100644 --- a/tests/resources/i18n/vasc.properties +++ b/tests/resources/i18n/vasc.properties @@ -2,7 +2,23 @@ test = Dit is een test +vasc.entry.test1.headerName = Test Entry 1 +vasc.entry.test1.headerDescription = De test omschrijving van deze entry +vasc.entry.test1.headerImage = /META-INF/images/silk/png/tick.png +vasc.entry.test1.name.name = Naam +vasc.entry.test1.name.description = De naam van het object +vasc.entry.test1.description.name = Omschrijving +vasc.entry.test1.description.description = De omschrijving van het object +vasc.entry.test1.active.name = Aktief +vasc.entry.test1.active.description = Is deze actief +vasc.entry.test1.active.image = /META-INF/images/silk/png/tick.png +vasc.entry.test1.date.name = Datum +vasc.entry.test1.date.description = De datum om te testen +vasc.entry.test1.testModel.name = Tests Models +vasc.entry.test1.testModel.description = ddddd +vasc.entry.test1.hexColor.name = Kleur +vasc.entry.test1.hexColor.description = De kleur van omo power. vasc.dialog.save.name = Opslaan vasc.dialog.save.tooltip = Het opslaan van de waardes. @@ -12,8 +28,8 @@ vasc.dialog.cancel.name = Annuleren vasc.dialog.cancel.tooltip = Niet opslaan van de waardes. vasc.dialog.cancel.image = /META-INF/images/silk/png/cancel.png - - +vasc.dialog.delete.message = Wilt u deze {0} record verwijderen ? +vasc.dialog.delete.title = Verwijderen vasc.action.add.name = Toevoegen vasc.action.add.tooltip = Voegt een nieuw rij toe. diff --git a/tests/resources/vasc/tables.xml b/tests/resources/vasc/tables.xml index e7c9c48..488cf20 100644 --- a/tests/resources/vasc/tables.xml +++ b/tests/resources/vasc/tables.xml @@ -1,5 +1,5 @@ - - + - - - - @@ -90,7 +85,92 @@ Master - + --> + + + + + + + + + + + + + + + + + + + @@ -123,21 +203,16 @@ Master - - + (&(objectClass=sudoRole)) ${baseDn},cn=%s sudoRole,top - + + - + AND role is in @@ -234,4 +308,5 @@ Master - \ No newline at end of file + --> + \ No newline at end of file