2
0
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

@ -10,9 +10,289 @@ Down load http://www.ehecht.com/eclipse_ve/ve.html (lin_mac version)
Unzip and move the plug ins and features into the plug in and features directory of eclipse. Unzip and move the plug ins and features into the plug in and features directory of eclipse.
Swing will run by default. Swing will run by default.
-- XyReasscan ?
zie tables statline.cbs.nl voor bs asielverzoeken nl
---- Object tree: ---- Object tree:
3 layers
- Data Backend
- JPA or Hibernate
- Meta Query
- LDAP
# List via geparametered xql query
# Save
# Merge
# Delete
# Create ?
FilteringDataSource
PagingDataSource
FilteringPagingDataSource
Ordering
Parameter
- Data Source Controller
- Data Access Controller
# User ACL on data items/columns
# Create new entry hooks
- Table Controller
- User Settings
- Data Frontends
- Extjs
- Swing
- WS
- SWT via SwingWT
- JSF (met utr plugin)
- default view field
- Admin fields and order
- Admin field groups -> 'collapse
- List filters auto by type
- search fields
verbose_name_plural
The plural name for the object:
verbose_name_plural = "stories"
If this isnt given, Django will use verbose_name + "s"
- plural
- ordering
- order_with_respect_to
# admin
- date_hierarchy
- fields = (
(None, {
'fields': ('url', 'title', 'content', 'sites')
}),
('Advanced options', {
'classes': 'collapse',
'fields' : ('enable_comments', 'registration_required', 'template_name')
'description' : 'sdf'
}),
)
- JS
- list_display_links
- list_filter = BooleanField, DateField, DateTimeField or ForeignKey.
- list_per_page
- ordering def
- save_as
- search_fields
@Entity
@VascAdmin(list=true,edit=true,create=true,delete=false)
public class BlogPost {
@VascPrimaryKey
@VascName(key="generic.id.name")
@VascDescription(key="generic.id.name")
@VascHelpId(key="generic.id.help")
@VascImage(key="generid.id.image");
Integer id;
@Column(columnName="title")
@VascDisplayName
@VascUserRoles(list="(floormanager&sitemanager)|admin" editViewOnly="floormanager" edit="sitemanager|admin")
String title;
@VascEditorType(type="slugField")
String slug;
@VascChoices()
@VascDefaultValue(key="")
String tags;
@VascRegex(regex="<(.*)>" key="generic.regex.html.tagsNotAllowed")
String content;
@VascEditorType(type="floatField" hints="max_digits=3,decimal_places=2")
@VascFieldOptions
@VascColumnWidth(width=130)
Float price;
@VascModelReference
@VascDefaultValue
@VascObjectNotNull
BlogStatus blogStatus;
@VascEditorType(type="dateField" hints="auto_now=true,auto_now_add=true")
@VascDefaultValue(key="new_date")
@VascUserRoles(list="admin")
Date createdDate
@VascEventChannel(channel="BlogPost.modifiedDate" create=true)
Date modifiedDate
@VascDateFuture
Date publicedDate
}
$it['ldap']['user']="uid=admin-sudo,ou=services,dc=m4n,dc=nl";
$it['ldap']['pass']="adminSudo";
$it['ldap']['baseDN']="ou=sudoers,dc=m4n,dc=nl";
$it['ldap']['key']="cn";
$it['columns'][0]['name']="Edit";
$it['columns'][0]['columnType']="edit";
$it['columns'][1]['name']="Delete";
$it['columns'][1]['columnType']="delete";
$it['columns'][2]['name']="User";
$it['columns'][2]['attr']="cn";
$it['columns'][3]['name']="Description";
$it['columns'][3]['attr']="description";
$it['columns'][4]['name']="sudoCommand";
$it['columns'][4]['attr']="sudocommand";
$it['columns'][4]['columnType']="list";
$it['columns'][5]['name']="sudoHost";
$it['columns'][5]['attr']="sudohost";
$it['columns'][5]['columnType']="list";
$it['columns'][6]['name']="sudoUser";
$it['columns'][6]['attr']="sudouser";
$it['columns'][6]['columnType']="list";
$it['list']['filter']="(&(objectClass=sudoRole))";
$it['list']['columns']="0,2,6,4,5,1";
$it['delete']['filter']="cn=%s";
$it['edit']['filter']="(cn=%s)";
$it['edit']['create_dn_key']="cn=%s";
$it['edit']['columns_edit']="2,3,4,5,6";
$it['edit']['columns_edit_readonly']="2";
$it['edit']['columns_create']="2,3,4,5,6";
$it['edit']['map']['objectclass'][]="sudoRole";
$it['edit']['map']['objectclass'][]="top";
$it['edit']['map']['cn']="\$key";
$it['edit']['map']['description']="\$formData['description']";
<servlet>
<name>vasc</name>
<class></class>
<property>admin=true</property>
<property>backend=extjs</property>
<property>path=/js/extjs/*</property>
</servlet>
<servlet-mapping>
<name>vasc</name>
<mapping>/vasc/*</mapping>
</servlet-mapping>
DefaultVascController r = new D..();
r.set
EmployeeDataSource dataSource = new EmployeeDataSource();
dataSource.setJdbcTemplate(new JdbcTemplate(employeeDataSource()));
FilteringPaginator filteringPaginator = new FilteringPaginator(dataSource, EmployeeReportObject.class);
JsfCrudAdapter adapter = new JsfCrudAdapter(filteringPaginator, (CrudController)empCrud().getController()){
public Serializable getEntity() {
Object object = ((Row)getModel().getRowData()).getObject();
EmployeeReportObject employeeReportObject = (EmployeeReportObject) object;
Employee employee = new Employee();
employee.setId(employeeReportObject.getId());
return employee;
}
};
return adapter;
EVt;
<a4j:form id="blogForm" enctype="multipart/form-data">
<vasc:form crud="${crud}" parentForm="blogForm"
propertyNames="firstName,lastName,department,description,file,age,numberOfPromotions,active,status,dob">
<vasc:compositePanel entity="${crud.entity.address}" name="address"
propertyNames="line_1,line2,zipCode" />
<vasc:detailListing
detailController="${directReportDetailController}"
propertyNames="firstName,lastName,description,age,numberOfPromotions" />
<vasc:detailListing detailController="${taskDetailController}"
propertyNames="name,startDate,endDate,complete" />
<vasc:detailListing detailController="${contactDetailController}"
propertyNames="name,phone" />
<vasc:selectMany jsfSelectManyController="${employeeToRoleController}"
propertyNames="name"
parentForm="employeeForm"/>
</vasc:form>
</a4j:form>
Table def:
@SuppressWarnings({ "unchecked", "serial" })
@Bean(scope = DefaultScopes.SESSION)
public JsfCrudAdapter empRecordCrud() {
EmployeeDataSource dataSource = new EmployeeDataSource();
dataSource.setJdbcTemplate(new JdbcTemplate(employeeDataSource()));
FilteringPaginator filteringPaginator = new FilteringPaginator(dataSource, EmployeeReportObject.class);
JsfCrudAdapter adapter = new JsfCrudAdapter(filteringPaginator, (CrudController)empCrud().getController()){
public Serializable getEntity() {
Object object = ((Row)getModel().getRowData()).getObject();
EmployeeReportObject employeeReportObject = (EmployeeReportObject) object;
Employee employee = new Employee();
employee.setId(employeeReportObject.getId());
return employee;
}
};
return adapter;
}
<a4j:form id="employeeListingForm">
<a4j:outputPanel ajaxRendered="true">
<h:panelGroup rendered="${empRecordCrud.controller.showForm}">
<crank:form
crud="${empRecordCrud.controller}"
parentForm="employeeListingForm"
propertyNames="firstName,lastName,numberOfPromotions,age,department" ajax="${true}" />
</h:panelGroup>
</a4j:outputPanel>
<crank:listing
jsfCrudAdapter="${empRecordCrud}"
propertyNames="firstName,lastName"
parentForm="employeeListingForm"
/>
</a4j:form>
<h:form id="expListForm" rendered="#{controllerBean.showListing}">
<crank:listing paginator="${paginators['Employee']}"
jsfCrudAdapter="${cruds['Employee']}"
propertyNames="firstName,lastName,active,dob,age,phone,email,department.name,description"
pageTitle="Employees"
parentForm="expListForm"
reRender="${reRender}"
crud="${cruds['Employee'].controller}"/>
</h:form>

Binary file not shown.

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<eld xmlns:eld="http://x4o.idcanet.com/eld/eld-lang.eld">
<!--
<eld:elementRefectionBindingHandler parentClass="com.idcanet.x4o.obj.TestObjectParent" childClass="com.idcanet.x4o.obj.TestObjectChild" method="addTestObjectChild"/>
<eld:elementRefectionBindingHandler parentClass="javax.swing.JComponent" childClass="javax.swing.JComponent" method="add"/>
<eld:elementClass tag="testObjectParent" objectClassName="com.idcanet.x4o.obj.TestObjectParent"/>
<eld:elementClass tag="testObjectChild" objectClassName="com.idcanet.x4o.obj.TestObjectChild"/>
-->
<eld:elementClass tag="fieldType" objectClassName="com.idcanet.vasc.impl.type.DefaultVascEntryFieldType">
<!--
<eld:elementClassParameterConverter parameterName="bounds" bean.class="com.idcanet.x4o.x4o.BoundsConverter"/>
-->
</eld:elementClass>
</eld>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>
Vasc namespace for the fieldtype language
</comment>
<entry key="eld.http://vasc.idcanet.com/eld/fieldtype-lang.eld">META-INF/fieldtype-lang.eld</entry>
</properties>

View file

@ -1,15 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<root> <fieldtype
xmlns:vf="http://vasc.idcanet.com/eld/fieldtype-lang.eld"
xmlns:x4o="http://x4o.idcanet.com/eld/x4o-lang.eld"
>
<!-- Verplichte impl field types --> <!-- Verplichte impl field types -->
<vasc:fieldType name="TextField"> <vf:fieldType id="TextField">
<vasc:fieldHint key="minlength" default="0"/> <x4o:property key="minlength" value="0"/>
<vasc:fieldHint key="maxlength" default="80"/> <x4o:property key="maxlength" value="80"/>
<vasc:fieldClass className="java.lang.String"/> </vf:fieldType>
</vasc:fieldType> <vf:fieldType id="ListField">
<vasc:fieldType name="ListField"> <x4o:property key="radio_edit" value="false"/>
<vasc:fieldHint key="radio_edit" default="false"/> </vf:fieldType>
</vasc:fieldType>
<!-- <!--
<vasc:fieldType name="TextAreaField"> <vasc:fieldType name="TextAreaField">
@ -18,8 +20,8 @@
<vasc:fieldClass className="java.lang.StringBuffer"/> <vasc:fieldClass className="java.lang.StringBuffer"/>
</vasc:fieldType> </vasc:fieldType>
--> -->
<!-- Native types --> <!-- Native types -->
<!--
<vasc:fieldType name="BooleanField"> <vasc:fieldType name="BooleanField">
<vasc:fieldClass className="java.lang.Boolean"/> <vasc:fieldClass className="java.lang.Boolean"/>
</vasc:fieldType> </vasc:fieldType>
@ -47,9 +49,11 @@
<vasc:fieldClass className="java.lang.Double"/> <vasc:fieldClass className="java.lang.Double"/>
<vasc:fieldConverter className="com.idcanet.x4o.converts.DoubleConverter"/> <vasc:fieldConverter className="com.idcanet.x4o.converts.DoubleConverter"/>
</vasc:fieldType> </vasc:fieldType>
-->
<!-- Date types --> <!-- Date types -->
<vasc:fieldType name="DateField"> <!--
<vasc:fieldType name="DateField" extends="TextField">
<vasc:fieldHint key="format"/> <vasc:fieldHint key="format"/>
<vasc:fieldConverter className="com.idcanet.x4o.converts.DateConverter"/> <vasc:fieldConverter className="com.idcanet.x4o.converts.DateConverter"/>
</vasc:fieldType> </vasc:fieldType>
@ -62,9 +66,10 @@
<vasc:fieldHint key="format" default="HH:mm"/> <vasc:fieldHint key="format" default="HH:mm"/>
<vasc:fieldConverter className="com.idcanet.x4o.converts.DateConverter"/> <vasc:fieldConverter className="com.idcanet.x4o.converts.DateConverter"/>
</vasc:fieldType> </vasc:fieldType>
-->
<!-- Internet fields --> <!-- Internet fields -->
<!--
<vasc:fieldType name="EmailField"> <vasc:fieldType name="EmailField">
<vasc:fieldHint key="validate" default="true"/> <vasc:fieldHint key="validate" default="true"/>
<vasc:fieldHint key="timeout" default="200"/> <vasc:fieldHint key="timeout" default="200"/>
@ -88,8 +93,10 @@
<vasc:fieldType name="SlugField"> <vasc:fieldType name="SlugField">
<vasc:fieldHint key="populate_from"/> <vasc:fieldHint key="populate_from"/>
</vasc:fieldType> </vasc:fieldType>
-->
<!-- XML fields --> <!-- XML fields -->
<!--
<vasc:fieldType name="XMLField"> <vasc:fieldType name="XMLField">
<vasc:fieldHint key="validate" default="true"/> <vasc:fieldHint key="validate" default="true"/>
<vasc:fieldHint key="schema_url"/> <vasc:fieldHint key="schema_url"/>
@ -98,8 +105,9 @@
<vasc:fieldHint key="validate" default="true"/> <vasc:fieldHint key="validate" default="true"/>
<vasc:fieldHint key="schema_url"/> <vasc:fieldHint key="schema_url"/>
</vasc:fieldType> </vasc:fieldType>
-->
<!-- Combined fields --> <!-- Combined fields -->
<!--
<vasc:fieldType name="SeparatedTypeField"> <vasc:fieldType name="SeparatedTypeField">
<vasc:fieldHint key="field_type" default="IntegerField"/> <vasc:fieldHint key="field_type" default="IntegerField"/>
<vasc:fieldHint key="seperator" default=","/> <vasc:fieldHint key="seperator" default=","/>
@ -115,8 +123,9 @@
<vasc:fieldType name="ColorField"> <vasc:fieldType name="ColorField">
<vasc:fieldConverter className="com.idcanet.x4o.converts.ColorConverter"/> <vasc:fieldConverter className="com.idcanet.x4o.converts.ColorConverter"/>
</vasc:fieldType> </vasc:fieldType>
-->
<!-- File fields --> <!-- File fields -->
<!--
<vasc:fieldType name="FileField"> <vasc:fieldType name="FileField">
<vasc:fieldHint key="base_path" default="/tmp"/> <vasc:fieldHint key="base_path" default="/tmp"/>
<vasc:fieldHint key="base_path_templateing" default="true"/> <vasc:fieldHint key="base_path_templateing" default="true"/>
@ -139,5 +148,5 @@
<vasc:fieldClass className="java.awt.Image"/> <vasc:fieldClass className="java.awt.Image"/>
<vasc:fieldClass className="javax.swing.Image"/> <vasc:fieldClass className="javax.swing.Image"/>
</vasc:fieldType> </vasc:fieldType>
-->
</root> </fieldtype>

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

View file

@ -26,11 +26,7 @@
package com.idcanet.vasc.backends.ldap; package com.idcanet.vasc.backends.ldap;
import java.security.Security;
import com.novell.ldap.LDAPConnection; import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPJSSESecureSocketFactory;
import com.novell.ldap.LDAPSocketFactory;
/** /**
* *
@ -46,7 +42,6 @@ public class SimpleLdapConnectionProvider implements LdapConnectionProvider {
private String bindUser = null; private String bindUser = null;
private String bindPass = null; private String bindPass = null;
/** /**
* @see com.idcanet.vasc.backends.ldap.LdapConnectionProvider#getLdapConnection() * @see com.idcanet.vasc.backends.ldap.LdapConnectionProvider#getLdapConnection()
*/ */
@ -71,7 +66,6 @@ public class SimpleLdapConnectionProvider implements LdapConnectionProvider {
} }
} }
/** /**
* @return the ldapHost * @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.ColumnVascAction;
import com.idcanet.vasc.core.actions.GlobalVascAction; import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction; 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 * @author Willem Cazander
* @version 1.0 Mar 21, 2007 * @version 1.0 Mar 21, 2007
*/ */
public interface VascEntry { public interface VascEntry extends Cloneable {
/** /**
* @return the id * @return the id
@ -130,22 +129,22 @@ public interface VascEntry {
/** /**
* @return the primaryKeyField * @return the primaryKeyField
*/ */
public String getPrimaryKeyField(); public String getPrimaryKeyFieldId();
/** /**
* @param primaryKeyField the primaryKeyField to set * @param primaryKeyField the primaryKeyField to set
*/ */
public void setPrimaryKeyField(String primaryKeyField); public void setPrimaryKeyFieldId(String primaryKeyField);
/** /**
* @return the displayNameField * @return the displayNameField
*/ */
public String getDisplayNameField(); public String getDisplayNameFieldId();
/** /**
* @param displayNameField the displayNameField to set * @param displayNameField the displayNameField to set
*/ */
public void setDisplayNameField(String displayNameField); public void setDisplayNameFieldId(String displayNameField);
/** /**
* @return the vascAdmimList * @return the vascAdmimList
@ -203,84 +202,9 @@ public interface VascEntry {
public void removeVascEntryField(VascEntryField vascField); public void removeVascEntryField(VascEntryField vascField);
/** /**
* @return the entryDataList * @return the vascField
*/ */
public List<Object> getEntryDataList(); public VascEntryField getVascEntryFieldById(String id);
/**
* @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);
/** /**
* @return the rowActions * @return the rowActions
@ -360,4 +284,7 @@ public interface VascEntry {
public Object getEntryParameter(String key); public Object getEntryParameter(String key);
public void setEntryParameter(String key,Object value); public void setEntryParameter(String key,Object value);
public List<String> getEntryParameterKeys(); public List<String> getEntryParameterKeys();
public VascFrontendData getVascFrontendData();
public void setVascFrontendData(VascFrontendData vascFrontendData);
} }

View file

@ -26,6 +26,8 @@
package com.idcanet.vasc.core; package com.idcanet.vasc.core;
import java.util.List;
/** /**
* *
@ -35,4 +37,6 @@ package com.idcanet.vasc.core;
public interface VascEntryController { public interface VascEntryController {
public VascEntry getVascEntry(String name); 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 interface VascEntryFieldType {
public String getName(); public String getId();
public void setName(String name); public void setId(String id);
public Class<?> getAutoFieldClass(); public Class<?> getAutoFieldClass();
public void setAutoFieldClass(Class<?> classObject); 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 * @author Willem Cazander
* @version 1.0 Sep 4, 2008 * @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 * @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 void finalizeVascEntry(VascEntry table) throws Exception;
public VascFrontendHelper getVascFrontendHelper();
} }

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 interface VascFrontendHelper {
public void finalizeVascEntry(VascEntry table) throws Exception;
public void finalizeVascEntryFields(VascEntry table) throws Exception;
public Integer getTotalColumnsWidth(VascEntry table); public Integer getTotalColumnsWidth(VascEntry table);
public void refreshData(VascEntry table) throws Exception; 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 { public void initEntry(VascEntry entry) throws Exception {
if (entry.getVascFrontend()==null) { if (entry.getVascFrontendData().getVascFrontend()==null) {
entry.setVascFrontend(this); entry.getVascFrontendData().setVascFrontend(this);
} else { } else {
if (entry.getVascFrontend()!=this) { if (entry.getVascFrontendData().getVascFrontend()!=this) {
throw new IllegalArgumentException("VascEntry has already a differtent VascViewRenderer attected"); throw new IllegalArgumentException("VascEntry has already a differtent VascViewRenderer attected");
} }
} }
entry.getVascFrontendController().getVascFrontendHelper().finalizeVascEntry(entry); entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
entry.getVascFrontendController().getVascFrontendHelper().finalizeVascEntryFields(entry);
entry.getVascFrontendController().getVascFrontendHelper().refreshData(entry);
/* /*
entry.putUIComponent(VascTextField.class, SwingTextField.class); entry.putUIComponent(VascTextField.class, SwingTextField.class);
entry.putUIComponent(VascList.class, SwingList.class); entry.putUIComponent(VascList.class, SwingList.class);
@ -129,7 +127,7 @@ public class SwingVascFrontend implements VascFrontend {
public ImageIcon getImageIcon(String imageResource) { public ImageIcon getImageIcon(String imageResource) {
/// TODO hack beter /// TODO hack beter
String key = entry.getVascEntryResourceResolver().getTextValue(imageResource); String key = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(imageResource);
//logger.fine("KEY======================="+key); //logger.fine("KEY======================="+key);
if (key.indexOf("META-INF")>0 | key.indexOf("resource")>0) { 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(); String beanValue = rowBean.toString();
if (entry.getDisplayNameField()!=null) { if (entry.getDisplayNameFieldId()!=null) {
Object vv = entry.getUIIdentifierVascEntryColomn().getVascColumnValue().getValue(entry.getUIIdentifierVascEntryColomn(), rowBean);
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
Object vv = v.getVascEntryFieldValue().getValue(v, rowBean);
if (vv==null) { if (vv==null) {
beanValue=""; beanValue="";
} else { } else {
@ -162,27 +163,28 @@ public class SwingVascFrontend implements VascFrontend {
beanValue=beanValue.substring(0, 30); 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(); Object result = dialog.openDialog();
logger.finest("OPEN closed : "+result); logger.finest("OPEN closed : "+result);
if(result==null) { if(result==null) {
return; return;
} }
entry.getVascFrontendController().getVascFrontendHelper().mergeObject(entry, result); entry.getVascFrontendData().getVascFrontendHelper().mergeObject(entry, result);
} }
public void renderDelete(Object rowBean) throws Exception { public void renderDelete(Object rowBean) throws Exception {
String beanValue = rowBean.toString(); String beanValue = rowBean.toString();
if (entry.getUIIdentifierVascEntryColomn()!=null) { if (entry.getDisplayNameFieldId()!=null) {
beanValue = ""+entry.getUIIdentifierVascEntryColomn().getVascColumnValue().getValue(entry.getUIIdentifierVascEntryColomn(), rowBean); VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
beanValue = ""+v.getVascEntryFieldValue().getValue(v, rowBean);
if (beanValue.length()>30) { if (beanValue.length()>30) {
beanValue=beanValue.substring(0, 30); beanValue=beanValue.substring(0, 30);
} }
} }
int response = JOptionPane.showOptionDialog( int response = JOptionPane.showOptionDialog(
parent // Center in window. parent // Center in window.
, entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.delete.message",beanValue) // Message , entry.getVascFrontendData().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.title") // Title in titlebar
, JOptionPane.YES_NO_OPTION // Option type , JOptionPane.YES_NO_OPTION // Option type
, JOptionPane.PLAIN_MESSAGE // messageType , JOptionPane.PLAIN_MESSAGE // messageType
, null // Icon (none) , null // Icon (none)
@ -190,10 +192,10 @@ public class SwingVascFrontend implements VascFrontend {
, null // Default button's label , null // Default button's label
); );
if (response==JOptionPane.YES_OPTION) { if (response==JOptionPane.YES_OPTION) {
entry.getVascBackend().delete(rowBean); entry.getVascFrontendData().getVascBackend().delete(rowBean);
entry.getEntryDataList().remove(rowBean); entry.getVascFrontendData().getEntryDataList().remove(rowBean);
entry.setEntryDataObject(null); entry.getVascFrontendData().setEntryDataObject(null);
entry.getVascFrontendController().getVascFrontendHelper().fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, rowBean); //entry.getVascFrontendController().getVascFrontendHelper().fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, rowBean);
} }
} }
@ -210,7 +212,7 @@ public class SwingVascFrontend implements VascFrontend {
this.headerText = headerText; this.headerText = headerText;
this.bean = bean; this.bean = bean;
setTitle(entry.getVascEntryResourceResolver().getTextValue(title)); setTitle(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(title));
setModal(true); setModal(true);
JPanel pane = new JPanel(); JPanel pane = new JPanel();
@ -250,7 +252,7 @@ public class SwingVascFrontend implements VascFrontend {
public void createHeader(JPanel header) { public void createHeader(JPanel header) {
JLabel l = new JLabel(); 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.setFont(new Font(null,Font.BOLD, 14));
//l.setToolTipText(entry.getVascTextValue().getTextValue(headerText)); //l.setToolTipText(entry.getVascTextValue().getTextValue(headerText));
header.add(l); header.add(l);
@ -260,7 +262,7 @@ public class SwingVascFrontend implements VascFrontend {
body.setLayout(new SpringLayout()); body.setLayout(new SpringLayout());
int column = 0; int column = 0;
for(VascEntryField c:entry.getVascEntryFields()) { for(VascEntryField c:entry.getVascEntryFields()) {
entry.getVascFrontendController().getVascFrontendHelper().initEditObjectColumn(c, bean); entry.getVascFrontendData().getVascFrontendHelper().initEditObjectColumn(c, bean);
if (c.isEdit()==false) { if (c.isEdit()==false) {
continue; continue;
} }
@ -269,16 +271,16 @@ public class SwingVascFrontend implements VascFrontend {
JLabel l = new JLabel(); JLabel l = new JLabel();
l.setHorizontalAlignment(JLabel.TRAILING); l.setHorizontalAlignment(JLabel.TRAILING);
l.setText(entry.getVascEntryResourceResolver().getTextValue(c.getName())); l.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getName()));
if(c.getDescription()!=null) { if(c.getDescription()!=null) {
l.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(c.getDescription())); l.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getDescription()));
} }
body.add(l); body.add(l);
if (c.isEditReadOnly()==true) { if (c.isEditReadOnly()==true) {
JLabel valueLabel = new JLabel(); JLabel valueLabel = new JLabel();
valueLabel.setText(""+c.getVascEntryFieldValue().getValue(c, bean)); valueLabel.setText(""+c.getVascEntryFieldValue().getValue(c, bean));
c.setColumnEditor(valueLabel); //c.setColumnEditor(valueLabel);
body.add(valueLabel); body.add(valueLabel);
continue; continue;
} }
@ -286,7 +288,7 @@ public class SwingVascFrontend implements VascFrontend {
if(c.getVascEntryFieldType().getVascUIComponent()==null) { if(c.getVascEntryFieldType().getVascUIComponent()==null) {
JLabel valueLabel = new JLabel(); JLabel valueLabel = new JLabel();
valueLabel.setText(""+c.getVascEntryFieldValue().getValue(c, bean)); valueLabel.setText(""+c.getVascEntryFieldValue().getValue(c, bean));
c.setColumnEditor(valueLabel); //c.setColumnEditor(valueLabel);
body.add(valueLabel); body.add(valueLabel);
} else { } else {
VascUIComponent comp = c.getVascEntryFieldType().getVascUIComponent(); VascUIComponent comp = c.getVascEntryFieldType().getVascUIComponent();
@ -294,7 +296,7 @@ public class SwingVascFrontend implements VascFrontend {
model.setValue(c.getVascEntryFieldValue().getValue(c, bean)); model.setValue(c.getVascEntryFieldValue().getValue(c, bean));
model.addListener(new VascColumnValueModelListener(c,bean)); model.addListener(new VascColumnValueModelListener(c,bean));
comp.createComponent(entry, model, body); comp.createComponent(entry, model, body);
c.setColumnEditor(comp); //c.setColumnEditor(comp);
} }
} }
//JComponent, rows, cols, initX, initY ,xPad, yPad //JComponent, rows, cols, initX, initY ,xPad, yPad
@ -305,11 +307,11 @@ public class SwingVascFrontend implements VascFrontend {
JButton saveButton = new JButton(); JButton saveButton = new JButton();
saveButton.setIcon(getImageIcon("vasc.dialog.save.image")); saveButton.setIcon(getImageIcon("vasc.dialog.save.image"));
saveButton.setText(entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.save.name")); saveButton.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.save.name"));
saveButton.setToolTipText(entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.save.tooltip")); saveButton.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.save.tooltip"));
saveButton.addActionListener(new ActionListener() { saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
if(entry.getVascFrontendController().getVascFrontendHelper().setUIComponentsBeanErrors(entry, bean)) { if(entry.getVascFrontendData().getVascFrontendHelper().setUIComponentsBeanErrors(entry, bean)) {
return; return;
} }
result = bean; result = bean;
@ -320,8 +322,8 @@ public class SwingVascFrontend implements VascFrontend {
JButton cancelButton = new JButton(); JButton cancelButton = new JButton();
cancelButton.setIcon(getImageIcon("vasc.dialog.cancel.image")); cancelButton.setIcon(getImageIcon("vasc.dialog.cancel.image"));
cancelButton.setText(entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.cancel.name")); cancelButton.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.cancel.name"));
cancelButton.setToolTipText(entry.getVascEntryResourceResolver().getTextValue("vasc.dialog.cancel.tooltip")); cancelButton.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue("vasc.dialog.cancel.tooltip"));
cancelButton.addActionListener(new ActionListener() { cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
result = null; result = null;
@ -361,7 +363,7 @@ public class SwingVascFrontend implements VascFrontend {
try { try {
exporter.doExport(out, entry); exporter.doExport(out, entry);
} catch (Exception e) { } catch (Exception e) {
entry.getVascFrontendController().getVascFrontendHelper().handleException(e, entry); entry.getVascFrontendData().getVascFrontendHelper().handleException(e, entry);
} finally { } finally {
if (out!=null) { if (out!=null) {
out.close(); out.close();
@ -410,17 +412,17 @@ public class SwingVascFrontend implements VascFrontend {
// TODO: hack images working // TODO: hack images working
l.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(entry.getHeaderImage())).getScaledInstance(32, 32, Image.SCALE_SMOOTH))); l.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(entry.getHeaderImage())).getScaledInstance(32, 32, Image.SCALE_SMOOTH)));
if (entry.getHeaderDescription()!=null) { if (entry.getHeaderDescription()!=null) {
l.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription())); l.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription()));
} }
header.add(l,BorderLayout.WEST); header.add(l,BorderLayout.WEST);
} }
if(entry.getHeaderName()!=null) { 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.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
l.setFont(new Font(null,Font.BOLD, 18)); l.setFont(new Font(null,Font.BOLD, 18));
if (entry.getHeaderDescription()!=null) { if (entry.getHeaderDescription()!=null) {
l.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription())); l.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(entry.getHeaderDescription()));
} }
header.add(l,BorderLayout.CENTER); header.add(l,BorderLayout.CENTER);
} }
@ -429,8 +431,8 @@ public class SwingVascFrontend implements VascFrontend {
//top.setBackground(Color.BLUE); //top.setBackground(Color.BLUE);
for (GlobalVascAction action:entry.getGlobalActions()) { for (GlobalVascAction action:entry.getGlobalActions()) {
JButton but = new JButton(); JButton but = new JButton();
but.setText(entry.getVascEntryResourceResolver().getTextValue(action.getName())); but.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getName()));
but.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(action.getToolTip())); but.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getToolTip()));
but.addActionListener(new GlobalActionListener(action)); but.addActionListener(new GlobalActionListener(action));
but.setIcon(getImageIcon(action.getImage())); but.setIcon(getImageIcon(action.getImage()));
top.add(but); top.add(but);
@ -481,7 +483,11 @@ public class SwingVascFrontend implements VascFrontend {
continue; continue;
} }
TableColumn t = new TableColumn(); TableColumn t = new TableColumn();
if (c.getSizeList()!=null) {
t.setPreferredWidth(c.getSizeList()); t.setPreferredWidth(c.getSizeList());
} else {
t.setPreferredWidth(200);
}
t.setHeaderValue(c); t.setHeaderValue(c);
t.setHeaderRenderer(renderer); t.setHeaderRenderer(renderer);
t.setModelIndex(counter); t.setModelIndex(counter);
@ -493,15 +499,15 @@ public class SwingVascFrontend implements VascFrontend {
table.addMouseListener(new MouseAdapter() { table.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (e.getClickCount() == 2) { if (e.getClickCount() == 2) {
Object o = entry.getEntryDataObject(); Object o = entry.getVascFrontendData().getEntryDataObject();
if (o==null) { if (o==null) {
return; return;
} }
try { try {
// TODO: fix this // TODO: fix this
entry.getVascFrontend().renderEdit(o); entry.getVascFrontendData().getVascFrontend().renderEdit(o);
} catch (Exception ee) { } 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) { if (rowIndex!=-1) {
// temp; gets index by sorter // temp; gets index by sorter
rowIndex = tableSorter.modelIndex(rowIndex); rowIndex = tableSorter.modelIndex(rowIndex);
Object data = entry.getEntryDataList().get(rowIndex); Object data = entry.getVascFrontendData().getEntryDataList().get(rowIndex);
entry.setEntryDataObject(data); entry.getVascFrontendData().setEntryDataObject(data);
} else { } else {
entry.setEntryDataObject(null); entry.getVascFrontendData().setEntryDataObject(null);
} }
} }
} }
@ -535,8 +541,8 @@ public class SwingVascFrontend implements VascFrontend {
private static final long serialVersionUID = 10L; private static final long serialVersionUID = 10L;
public Component getentryCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) { public Component getentryCellRendererComponent(JTable table, Object value, boolean isSelected,boolean hasFocus, int row, int column) {
VascEntryField c = (VascEntryField)value; VascEntryField c = (VascEntryField)value;
setText(c.getVascEntry().getVascEntryResourceResolver().getTextValue(c.getName())); setText(c.getVascEntry().getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getName()));
setToolTipText(c.getVascEntry().getVascEntryResourceResolver().getTextValue(c.getDescription())); setToolTipText(c.getVascEntry().getVascFrontendData().getVascEntryResourceResolver().getTextValue(c.getDescription()));
if(c.getImage()!=null) { if(c.getImage()!=null) {
setIcon(getImageIcon(c.getImage())); setIcon(getImageIcon(c.getImage()));
@ -563,8 +569,8 @@ public class SwingVascFrontend implements VascFrontend {
JPanel panel = new JPanel(); JPanel panel = new JPanel();
for(RowVascAction action:entry.getRowActions()) { for(RowVascAction action:entry.getRowActions()) {
JButton but = new JButton(); JButton but = new JButton();
but.setText(entry.getVascEntryResourceResolver().getTextValue(action.getName())); but.setText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getName()));
but.setToolTipText(entry.getVascEntryResourceResolver().getTextValue(action.getToolTip())); but.setToolTipText(entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(action.getToolTip()));
but.setIcon(getImageIcon(action.getImage())); but.setIcon(getImageIcon(action.getImage()));
but.addActionListener(new RowActionListener(action)); but.addActionListener(new RowActionListener(action));
panel.add(but); panel.add(but);
@ -585,9 +591,9 @@ public class SwingVascFrontend implements VascFrontend {
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
logger.fine("Row Action"); logger.fine("Row Action");
try { try {
action.doRowAction(entry, entry.getEntryDataObject()); action.doRowAction(entry, entry.getVascFrontendData().getEntryDataObject());
} catch (Exception e) { } 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 { try {
action.doGlobalAction(entry); action.doGlobalAction(entry);
} catch (Exception e) { } 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; private static final long serialVersionUID = 10L;
public void vascEvent(VascEventType e,Object o) { public void vascEvent(VascEventType e,Object o) {
@ -637,17 +643,17 @@ public class SwingVascFrontend implements VascFrontend {
* @see javax.swing.entry.entryModel#getRowCount() * @see javax.swing.entry.entryModel#getRowCount()
*/ */
public int getRowCount() { public int getRowCount() {
if (entry.getEntryDataList()==null) { if (entry.getVascFrontendData().getEntryDataList()==null) {
return 0; return 0;
} }
return entry.getEntryDataList().size(); return entry.getVascFrontendData().getEntryDataList().size();
} }
/** /**
* @see javax.swing.entry.entryModel#getValueAt(int, int) * @see javax.swing.entry.entryModel#getValueAt(int, int)
*/ */
public Object getValueAt(int rowIndex, int columnIndex) { 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); logger.finer("Rending column; "+columnIndex+" bean: "+bean);
// TODO: this is slowing.... // TODO: this is slowing....

View file

@ -65,6 +65,7 @@ import org.eclipse.swt.widgets.ToolItem;
import com.idcanet.fff.SwingImageHelper; import com.idcanet.fff.SwingImageHelper;
import com.idcanet.vasc.core.VascEntry; 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.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction; 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.List;
import java.util.Map; 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.VascEntry;
import com.idcanet.vasc.core.VascEntryController;
import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascEntryFieldSet; import com.idcanet.vasc.core.VascEntryFieldSet;
import com.idcanet.vasc.core.VascFrontend; import com.idcanet.vasc.core.VascFrontendData;
import com.idcanet.vasc.core.VascFrontendController;
import com.idcanet.vasc.core.VascLinkEntry; import com.idcanet.vasc.core.VascLinkEntry;
import com.idcanet.vasc.core.actions.ColumnVascAction; import com.idcanet.vasc.core.actions.ColumnVascAction;
import com.idcanet.vasc.core.actions.GlobalVascAction; import com.idcanet.vasc.core.actions.GlobalVascAction;
import com.idcanet.vasc.core.actions.RowVascAction; import com.idcanet.vasc.core.actions.RowVascAction;
import com.idcanet.vasc.core.entry.VascEntryResourceResolver;
/** /**
* VascEntry
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Mar 21, 2007 * @version 1.0 Mar 21, 2007
@ -64,8 +59,8 @@ public class DefaultVascEntry implements VascEntry {
private String headerImage = null; private String headerImage = null;
private String headerDescription = null; private String headerDescription = null;
private String primaryKeyField = null; private String primaryKeyFieldId = null;
private String displayNameField = null; private String displayNameFieldId = null;
private boolean vascAdmimList = true; private boolean vascAdmimList = true;
private boolean vascAdmimEdit = true; private boolean vascAdmimEdit = true;
@ -73,15 +68,6 @@ public class DefaultVascEntry implements VascEntry {
private boolean vascAdmimDelete = true; private boolean vascAdmimDelete = true;
private List<VascEntryField> vascFields = null; 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<RowVascAction> rowActions = null;
private List<ColumnVascAction> columnActions = null; private List<ColumnVascAction> columnActions = null;
@ -91,10 +77,13 @@ public class DefaultVascEntry implements VascEntry {
private List<VascLinkEntry> vascLinkEntries = null; private List<VascLinkEntry> vascLinkEntries = null;
private Map<String,Object> entryParameters = null; private Map<String,Object> entryParameters = null;
private VascFrontendData vascFrontendData = null;
/**
* Te constructor
*/
public DefaultVascEntry() { public DefaultVascEntry() {
vascFields = new ArrayList<VascEntryField>(10); vascFields = new ArrayList<VascEntryField>(10);
entryDataList = new ArrayList<Object>(0);
rowActions = new ArrayList<RowVascAction>(10); rowActions = new ArrayList<RowVascAction>(10);
columnActions = new ArrayList<ColumnVascAction>(10); columnActions = new ArrayList<ColumnVascAction>(10);
@ -105,6 +94,16 @@ public class DefaultVascEntry implements VascEntry {
entryParameters = new HashMap<String,Object>(); entryParameters = new HashMap<String,Object>();
} }
/**
* @see java.lang.Object#clone()
*/
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
/** /**
* @return the id * @return the id
@ -219,31 +218,31 @@ public class DefaultVascEntry implements VascEntry {
} }
/** /**
* @return the primaryKeyField * @return the primaryKeyFieldId
*/ */
public String getPrimaryKeyField() { public String getPrimaryKeyFieldId() {
return primaryKeyField; return primaryKeyFieldId;
} }
/** /**
* @param primaryKeyField the primaryKeyField to set * @param primaryKeyFieldId the primaryKeyFieldId to set
*/ */
public void setPrimaryKeyField(String primaryKeyField) { public void setPrimaryKeyFieldId(String primaryKeyFieldId) {
this.primaryKeyField = primaryKeyField; this.primaryKeyFieldId = primaryKeyFieldId;
} }
/** /**
* @return the displayNameField * @return the displayNameFieldId
*/ */
public String getDisplayNameField() { public String getDisplayNameFieldId() {
return displayNameField; return displayNameFieldId;
} }
/** /**
* @param displayNameField the displayNameField to set * @param displayNameFieldId the displayNameFieldId to set
*/ */
public void setDisplayNameField(String displayNameField) { public void setDisplayNameFieldId(String displayNameFieldId) {
this.displayNameField = displayNameField; this.displayNameFieldId = displayNameFieldId;
} }
/** /**
@ -324,115 +323,15 @@ public class DefaultVascEntry implements VascEntry {
} }
/** /**
* @return the entryDataList * @see com.idcanet.vasc.core.VascEntry#getVascEntryFieldById(java.lang.String)
*/ */
public List<Object> getEntryDataList() { public VascEntryField getVascEntryFieldById(String id) {
return entryDataList; for (VascEntryField v:vascFields) {
if (v.getId().equals(id)) {
return v;
} }
/**
* @param entryDataList the entryDataList to set
*/
public void setEntryDataList(List<Object> entryDataList) {
this.entryDataList = entryDataList;
} }
throw new IllegalArgumentException("Id not found as field");
/**
* @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;
} }
/** /**
@ -540,7 +439,6 @@ public class DefaultVascEntry implements VascEntry {
vascLinkEntries.remove(vascLinkEntry); vascLinkEntries.remove(vascLinkEntry);
} }
/** /**
* @see com.idcanet.vasc.core.VascEntry#getEntryParameter(java.lang.String) * @see com.idcanet.vasc.core.VascEntry#getEntryParameter(java.lang.String)
*/ */
@ -548,7 +446,6 @@ public class DefaultVascEntry implements VascEntry {
return entryParameters.get(key); return entryParameters.get(key);
} }
/** /**
* @see com.idcanet.vasc.core.VascEntry#getEntryParameterKeys() * @see com.idcanet.vasc.core.VascEntry#getEntryParameterKeys()
*/ */
@ -556,7 +453,6 @@ public class DefaultVascEntry implements VascEntry {
return new ArrayList<String>(entryParameters.keySet()); return new ArrayList<String>(entryParameters.keySet());
} }
/** /**
* @see com.idcanet.vasc.core.VascEntry#setEntryParameter(java.lang.String, java.lang.Object) * @see com.idcanet.vasc.core.VascEntry#setEntryParameter(java.lang.String, java.lang.Object)
*/ */
@ -564,5 +460,17 @@ public class DefaultVascEntry implements VascEntry {
entryParameters.put(key, 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 org.hibernate.validator.InvalidValue;
import com.idcanet.vasc.annotations.VascAnnotationParser; import com.idcanet.vasc.annotations.VascAnnotationParser;
import com.idcanet.vasc.core.VascEventListener; import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascExceptionListener; import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.VascTable; import com.idcanet.vasc.core.VascFrontendHelper;
import com.idcanet.vasc.core.VascTableController; import com.idcanet.vasc.core.entry.VascEntryEventListener;
import com.idcanet.vasc.core.column.VascAnnotationTableColumn; import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
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;
/** /**
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Apr 28, 2007 * @version 1.0 Apr 28, 2007
*/ */
public class DefaultVascTableController implements VascTableController { public class DefaultVascFrontendHelper implements VascFrontendHelper {
private Logger logger = null; private Logger logger = null;
private List<VascEventListener> eventListeners = null; //private List<VascEventListener> eventListeners = null;
private List<VascExceptionListener> exceptionListeners = null; //private List<VascExceptionListener> exceptionListeners = null;
public DefaultVascTableController() { public DefaultVascFrontendHelper() {
logger = Logger.getLogger(DefaultVascTableController.class.getName()); logger = Logger.getLogger(DefaultVascFrontendHelper.class.getName());
eventListeners = new ArrayList<VascEventListener>(2); //eventListeners = new ArrayList<VascEventListener>(2);
exceptionListeners = new ArrayList<VascExceptionListener>(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 { public void finalizeVascColumns(VascTable table) throws Exception {
VascAnnotationParser vap = new VascAnnotationParser(); VascAnnotationParser vap = new VascAnnotationParser();
@ -116,75 +283,6 @@ 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) { public void addEventListener(VascEventListener e) {
eventListeners.add(e); eventListeners.add(e);
@ -199,45 +297,6 @@ 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) { public void addExceptionListener(VascExceptionListener listener) {
exceptionListeners.add(listener); exceptionListeners.add(listener);
@ -246,21 +305,5 @@ public class DefaultVascTableController implements VascTableController {
public void removeExceptionListener(VascExceptionListener listener) { public void removeExceptionListener(VascExceptionListener listener) {
exceptionListeners.remove(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 { 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 { 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 { 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(c.getName()+"\t");
} }
p.write("\n"); p.write("\n");
for (Object o:entry.getEntryDataList()) { for (Object o:entry.getVascFrontendData().getEntryDataList()) {
for (VascEntryField c:entry.getVascEntryFields()) { for (VascEntryField c:entry.getVascEntryFields()) {
p.write(c.getVascEntryFieldValue().getValue(c, o)+"\t"); p.write(c.getVascEntryFieldValue().getValue(c, o)+"\t");
} }

View file

@ -47,6 +47,6 @@ public class DeleteRowAction extends AbstractVascAction implements RowVascAction
if (rowObject==null) { if (rowObject==null) {
return; 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) { if (rowObject==null) {
return; 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 { 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 { 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 { public void doExport(OutputStream out,VascEntry entry) throws Exception {
PrintWriter p = new PrintWriter(out); PrintWriter p = new PrintWriter(out);
p.write("<xml version=\"1.0\"/>\n"); p.write("<xml version=\"1.0\"/>\n");
p.write("<data>\n"); p.write("<data>\n");
for (Object o:entry.getEntryDataList()) { for (Object o:entry.getVascFrontendData().getEntryDataList()) {
for (VascEntryField c:entry.getVascEntryFields()) { for (VascEntryField c:entry.getVascEntryFields()) {
p.write("<column name=\""+c.getName()+"\">"); p.write("<column name=\""+c.getName()+"\">");
p.write(""+c.getVascEntryFieldValue().getValue(c, o)); 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 * @return
*/ */
int max() default 0; 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

@ -34,10 +34,49 @@ package com.idcanet.vasc.validators;
*/ */
public class VascStringLengthValidator implements VascValidator { public class VascStringLengthValidator implements VascValidator {
private Integer minLenght = null;
private Integer maxLenght = null;
/** /**
* @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object) * @see com.idcanet.vasc.validators.VascValidator#isObjectValid(java.lang.Object)
*/ */
public boolean isObjectValid(Object object) throws VascValidatorException { public boolean isObjectValid(Object object) throws VascValidatorException {
String result = (String)object;
if (getMinLenght()!=null && result.length()<getMinLenght()) {
return false; 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;
}
} }

View file

@ -10,7 +10,7 @@ handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = ALL java.util.logging.ConsoleHandler.level = ALL
# Set the default logging level for the root logger # Set the default logging level for the root logger
.level = ALL .level = FINE
com.idcanet.x4o = ALL com.idcanet.x4o = ALL

View file

@ -0,0 +1,64 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.vasc;
import java.io.InputStream;
import java.util.logging.LogManager;
import com.idcanet.vasc.core.VascEntryFieldType;
import com.idcanet.vasc.impl.type.FieldTypeParser;
import junit.framework.TestCase;
/**
* Tests a simple x4o xml language.
*
* @author Willem Cazander
* @version 1.0 Jul 24, 2006
*/
public class FieldTypesTest extends TestCase {
public void setUp() throws Exception {
// enable all logs
InputStream loggingProperties = this.getClass().getResourceAsStream("/META-INF/logging.properties");
LogManager.getLogManager().readConfiguration( loggingProperties );
loggingProperties.close();
}
public void tearDown() throws Exception {
}
public void testParse() throws Exception {
FieldTypeParser p = new FieldTypeParser();
p.parseVascFieldTypes();
System.out.println("Got types;");
for (VascEntryFieldType t:p.getTypes()) {
System.out.println("t= "+t.getId());
}
}
}

View file

@ -33,6 +33,7 @@ import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.frontends.swing.SwingVascFrontend;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -54,15 +55,6 @@ public class SwingTest extends TestCase {
public void tearDown() throws Exception { public void tearDown() throws Exception {
} }
/*
- default view field
- Admin fields and order
- Admin field groups -> 'collapse
- List filters auto by type
- search fields
*/
public void testAll() throws Exception { public void testAll() throws Exception {
JFrame.setDefaultLookAndFeelDecorated(false); JFrame.setDefaultLookAndFeelDecorated(false);
@ -73,15 +65,15 @@ public class SwingTest extends TestCase {
frame.setLocationRelativeTo(null); frame.setLocationRelativeTo(null);
// get table // get table
VascTable table = TestTable.getVascTable(); VascEntry entry = TestTable.getVascTable();
// define redering // define redering
JPanel panel = new JPanel(); JPanel panel = new JPanel();
SwingVascViewRenderer render = new SwingVascViewRenderer(panel); SwingVascFrontend render = new SwingVascFrontend(panel);
frame.add(panel); frame.add(panel);
// render // render
render.initTable(table); render.initEntry(entry);
//table.getTableColumns().get(0).set //table.getTableColumns().get(0).set

View file

@ -37,6 +37,7 @@ import com.idcanet.vasc.core.entry.VascEntryFieldValue;
import com.idcanet.vasc.core.entry.VascEntryRecordCreator; import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
import com.idcanet.vasc.core.ui.VascSelectItem; import com.idcanet.vasc.core.ui.VascSelectItem;
import com.idcanet.vasc.core.ui.VascSelectItemModel; import com.idcanet.vasc.core.ui.VascSelectItemModel;
import com.idcanet.vasc.impl.entry.BeanVascEntryRecordCreator;
import com.idcanet.vasc.models.TestModel; import com.idcanet.vasc.models.TestModel;
/** /**
@ -103,6 +104,6 @@ public class TestModelVascDataSource extends AbstractVascBackend implements Vasc
} }
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) { public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
return null; return new BeanVascEntryRecordCreator(TestModel.class);
} }
} }

View file

@ -28,12 +28,13 @@ package com.idcanet.vasc;
import java.util.Date; import java.util.Date;
import com.idcanet.vasc.core.VascController;
import com.idcanet.vasc.core.VascEntry; import com.idcanet.vasc.core.VascEntry;
import com.idcanet.vasc.core.VascEntryField; import com.idcanet.vasc.core.VascEntryField;
import com.idcanet.vasc.core.ui.VascList; import com.idcanet.vasc.core.ui.VascList;
import com.idcanet.vasc.impl.DefaultVascController;
import com.idcanet.vasc.impl.DefaultVascEntry; import com.idcanet.vasc.impl.DefaultVascEntry;
import com.idcanet.vasc.impl.DefaultVascEntryField; import com.idcanet.vasc.impl.DefaultVascEntryField;
import com.idcanet.vasc.impl.DefaultVascTableController;
import com.idcanet.vasc.impl.actions.AddRowAction; import com.idcanet.vasc.impl.actions.AddRowAction;
import com.idcanet.vasc.impl.actions.CSVExportGlobalAction; import com.idcanet.vasc.impl.actions.CSVExportGlobalAction;
import com.idcanet.vasc.impl.actions.DeleteRowAction; import com.idcanet.vasc.impl.actions.DeleteRowAction;
@ -52,6 +53,17 @@ import com.idcanet.vasc.models.TestModel;
*/ */
public class TestTable { public class TestTable {
static VascController getDefaultVascController() {
DefaultVascController c = new DefaultVascController();
//entry.setVascEntryResourceResolver(new VascI18nTextValue());
return c;
}
static public VascEntry getVascTable() throws Exception { static public VascEntry getVascTable() throws Exception {
// define query // define query
@ -63,6 +75,8 @@ public class TestTable {
*/ */
VascController c = getDefaultVascController();
TestModelVascDataSource data = new TestModelVascDataSource(); TestModelVascDataSource data = new TestModelVascDataSource();
// config table // config table
@ -72,24 +86,16 @@ public class TestTable {
entry.setHeaderDescription("Met een hele coole tooltip"); entry.setHeaderDescription("Met een hele coole tooltip");
entry.setHeaderImage("/resources/images/gabelfresser.gif"); entry.setHeaderImage("/resources/images/gabelfresser.gif");
entry.setHelpId("someKey"); entry.setHelpId("someKey");
//entry.setVascTableController(new DefaultVascTableController());
entry.setVascBackend(data);
//table.setVascTextValue(new DefaultVascTextValue());
entry.setVascEntryResourceResolver(new VascI18nTextValue());
// entry.setVascEntryRecordCreator(new BeanVascEntryRecordCreator(TestModel.class));
entry.addRowAction(new AddRowAction()); entry.addRowAction(new AddRowAction());
entry.addRowAction(new EditRowAction()); entry.addRowAction(new EditRowAction());
entry.addRowAction(new DeleteRowAction()); entry.addRowAction(new DeleteRowAction());
entry.addGlobalAction(new XMLExportGlobalAction()); entry.addGlobalAction(new XMLExportGlobalAction());
entry.addGlobalAction(new CSVExportGlobalAction()); entry.addGlobalAction(new CSVExportGlobalAction());
//table.addGlobalActions(new HTMLExportGlobalAction());
entry.addGlobalAction(new RefreshDataGlobalAction()); entry.addGlobalAction(new RefreshDataGlobalAction());
//table.addUserOptions(userOption); //table.addUserOptions(userOption);
//table.addColumnActions(new GraphColumnAction()); //table.addColumnActions(new GraphColumnAction());
VascEntryField field = new DefaultVascEntryField(); VascEntryField field = new DefaultVascEntryField();
@ -98,7 +104,12 @@ public class TestTable {
field.setDefaultValue("DEFFFFFF"); field.setDefaultValue("DEFFFFFF");
field.setHelpId("helpColumnKey"); field.setHelpId("helpColumnKey");
field.setImage("/META-INF/images/silk/png/tick.png"); field.setImage("/META-INF/images/silk/png/tick.png");
field.setVascEntryFieldType(vascEntryFieldType) try {
field.setVascEntryFieldType(c.getVascEntryFieldTypeControllerResolver().getVascEntryFieldTypeController().getVascEntryFieldType("TextField"));
} catch (Throwable e) {
e.printStackTrace();
}
field.setVascEntryFieldValue(new BeanPropertyVascEntryFieldValue("name")); field.setVascEntryFieldValue(new BeanPropertyVascEntryFieldValue("name"));
entry.addVascEntryField(field); entry.addVascEntryField(field);

View file

@ -39,10 +39,10 @@ import com.idcanet.vasc.annotations.VascHelpId;
import com.idcanet.vasc.annotations.VascImage; import com.idcanet.vasc.annotations.VascImage;
import com.idcanet.vasc.annotations.VascModelReference; import com.idcanet.vasc.annotations.VascModelReference;
import com.idcanet.vasc.annotations.VascName; import com.idcanet.vasc.annotations.VascName;
import com.idcanet.vasc.annotations.VascToolTip; import com.idcanet.vasc.annotations.VascDescription;
import com.idcanet.vasc.validator.VascDateFuture; import com.idcanet.vasc.validators.VascDateFuture;
import com.idcanet.vasc.validator.VascObjectNotNull; import com.idcanet.vasc.validators.VascObjectNotNull;
import com.idcanet.vasc.validator.VascStringLength; import com.idcanet.vasc.validators.VascStringLength;
/** /**
* TestModel * TestModel
@ -51,7 +51,7 @@ import com.idcanet.vasc.validator.VascStringLength;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Mar 28, 2007 * @version 1.0 Mar 28, 2007
*/ */
@VascToolTip(key="En een tooltip op het model") @VascDescription(key="En een tooltip op het model")
public class TestModel { public class TestModel {
private String name = null; private String name = null;
@ -82,7 +82,7 @@ public class TestModel {
* @return the description * @return the description
*/ */
@VascName(key="omscheiving") @VascName(key="omscheiving")
@VascToolTip(key="De omscheiving") @VascDescription(key="De omscheiving")
@VascHelpId(helpId="help.id") @VascHelpId(helpId="help.id")
@VascDefaultValue(defaultValue="xxxxx") @VascDefaultValue(defaultValue="xxxxx")
@VascColumnWidth(width=200) @VascColumnWidth(width=200)

View file

@ -80,15 +80,28 @@ Master
</v:viewController> </v:viewController>
<vasc:fieldType name="EmailField2">
<vasc:fieldHint key="validate" default="true"/>
<vasc:fieldHint key="timeout" default="200"/>
</vasc:fieldType>
<vasc:fieldType name="listField">
<vasc:fieldHint key="validate" default="true"/>
<vasc:fieldHint key="timeout" default="200"/>
</vasc:fieldType>
<v:viewController name="sudoers" primaryKey="user"> <v:viewController name="sudoers" primaryKey="user">
<v:field name="user" backendName="cn" readOnly="true"/> <v:field name="user" backendName="cn" readOnly="true"/>
<v:field name="description" backendName="description"> <v:field name="description" backendName="description">
<v:roles edit="admin" list="all"/> <v:roles edit="admin" list="all"/>
</v:field> </v:field>
<v:field name="sudoCommand" fieldEditor="listField"/> <v:field name="sudoCommand" fieldType="listField"/>
<v:field name="sudoHost" fieldEditor="listField"/> <v:field name="sudoHost" fieldType="listField"/>
<v:field name="sudoUser" fieldEditor="listField"/> <v:field name="sudoUser" fieldType="listField">
<v:fieldType>
<vasc:fieldHint key="timeout" default="200"/>
</v:fieldType>
</v:field>
<v:field name="sambaSID" fieldEditor="textField" edit="false" list="false" view="false" create="false" defaultValue="S-1-5-21-1200182392-965607725-1867741125-514"/> <v:field name="sambaSID" fieldEditor="textField" edit="false" list="false" view="false" create="false" defaultValue="S-1-5-21-1200182392-965607725-1867741125-514"/>
<v:field name="sambaGroupType" v.defaultValue="2"/> <v:field name="sambaGroupType" v.defaultValue="2"/>