2
Fork 0

[svn r342] WIP2

This commit is contained in:
willemc 2008-09-13 17:04:49 +02:00
parent a60c7487e9
commit 62f7881380
40 changed files with 1559 additions and 514 deletions

View file

@ -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<String,Object> map = (Map<String,Object>)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<String,Object> map = (Map<String,Object>)record;
map.put(field.getBackendName(), value);

View file

@ -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
*/

View file

@ -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<VascValidator> vascValidators = null;
private Map<String,String> properties = null;
private String parentEntryFieldTypeName = null;
public AbstractVascEntryFieldType() {
vascValidators = new ArrayList<VascValidator>(4);
properties = new HashMap<String,String>();
}
/**
* @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<String> getPropertyNames() {
return new ArrayList<String>(properties.keySet());
}
/**
* @see com.idcanet.vasc.core.VascEntryFieldType#getVascUIComponent()
*/
public VascUIComponent getVascUIComponent() {
return vascUIComponent;
}
/**
* @see com.idcanet.vasc.core.VascEntryFieldType#getVascValidators()
*/
public List<VascValidator> 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;
}
}

View file

@ -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();
}

View file

@ -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<Object> getEntryDataList();
/**
* @param entryDataList the entryDataList to set
*/
public void setEntryDataList(List<Object> 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<String> getEntryParameterKeys();
public VascFrontendData getVascFrontendData();
public void setVascFrontendData(VascFrontendData vascFrontendData);
}

View file

@ -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<String> getVascEntryNames();
}

View file

@ -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);

View file

@ -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<String> getVascEntryFieldTypeNames();
}

View file

@ -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();
}

View file

@ -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;
}

View file

@ -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<Object> getEntryDataList();
/**
* @param entryDataList the entryDataList to set
*/
public void setEntryDataList(List<Object> 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);
}

View file

@ -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;

View file

@ -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....

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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<VascEntryField> vascFields = null;
private List<Object> 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<RowVascAction> rowActions = null;
private List<ColumnVascAction> columnActions = null;
@ -91,10 +77,13 @@ public class DefaultVascEntry implements VascEntry {
private List<VascLinkEntry> vascLinkEntries = null;
private Map<String,Object> entryParameters = null;
private VascFrontendData vascFrontendData = null;
/**
* Te constructor
*/
public DefaultVascEntry() {
vascFields = new ArrayList<VascEntryField>(10);
entryDataList = new ArrayList<Object>(0);
vascFields = new ArrayList<VascEntryField>(10);
rowActions = new ArrayList<RowVascAction>(10);
columnActions = new ArrayList<ColumnVascAction>(10);
@ -105,7 +94,17 @@ public class DefaultVascEntry implements VascEntry {
entryParameters = new HashMap<String,Object>();
}
/**
* @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<Object> 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<Object> 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<String>(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;
}
}

View file

@ -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<Object> 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<Object>(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<Object> getEntryDataList() {
return entryDataList;
}
/**
* @param entryDataList the entryDataList to set
*/
public void setEntryDataList(List<Object> 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;
}
}

View file

@ -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<VascEventListener> eventListeners = null;
private List<VascExceptionListener> exceptionListeners = null;
//private List<VascEventListener> eventListeners = null;
//private List<VascExceptionListener> exceptionListeners = null;
public DefaultVascTableController() {
logger = Logger.getLogger(DefaultVascTableController.class.getName());
eventListeners = new ArrayList<VascEventListener>(2);
exceptionListeners = new ArrayList<VascExceptionListener>(2);
public DefaultVascFrontendHelper() {
logger = Logger.getLogger(DefaultVascFrontendHelper.class.getName());
//eventListeners = new ArrayList<VascEventListener>(2);
//exceptionListeners = new ArrayList<VascExceptionListener>(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;
}
*/
}

View file

@ -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);
}
}

View file

@ -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");
}

View file

@ -47,6 +47,6 @@ public class DeleteRowAction extends AbstractVascAction implements RowVascAction
if (rowObject==null) {
return;
}
entry.getVascFrontend().renderDelete(rowObject);
entry.getVascFrontendData().getVascFrontend().renderDelete(rowObject);
}
}

View file

@ -48,6 +48,6 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction {
if (rowObject==null) {
return;
}
entry.getVascFrontend().renderEdit(rowObject);
entry.getVascFrontendData().getVascFrontend().renderEdit(rowObject);
}
}

View file

@ -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
}
}

View file

@ -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("<xml version=\"1.0\"/>\n");
p.write("<data>\n");
for (Object o:entry.getEntryDataList()) {
for (Object o:entry.getVascFrontendData().getEntryDataList()) {
for (VascEntryField c:entry.getVascEntryFields()) {
p.write("<column name=\""+c.getName()+"\">");
p.write(""+c.getVascEntryFieldValue().getValue(c, o));

View file

@ -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 {
}

View file

@ -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<VascEntryFieldType> getTypes() {
List<VascEntryFieldType> result = new ArrayList<VascEntryFieldType>(4);
for (Element e:getElementContext().getRootElements()) {
VascEntryFieldType a = (VascEntryFieldType)e.getElementObject();
result.add(a);
}
return result;
}
}

View file

@ -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);
}

View file

@ -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()<getMinLenght()) {
return false;
}
if (getMaxLenght()!=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;
}
}