[svn r380] added all kinds of objects
This commit is contained in:
parent
a9520b3804
commit
37fdf22282
|
@ -5,9 +5,7 @@
|
|||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="SWT_CONTAINER/JFACE/PLATFORM"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.wst.validation.validationbuilder"/>
|
||||
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
</launchConfiguration>
|
|
@ -7,7 +7,7 @@
|
|||
j2ee-spec="5.0"
|
||||
archive="com.idcanet.vasc.war">
|
||||
<attributes>
|
||||
<attribute name="webrootdir" value="www" />
|
||||
<attribute name="webrootdir" value="/www" />
|
||||
</attributes>
|
||||
</project-module>
|
||||
|
||||
|
|
10
.project
10
.project
|
@ -25,6 +25,16 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/org.eclipse.wst.validation.validationbuilder.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
|
|
4
.settings/com.genuitec.eclipse.core.prefs
Normal file
4
.settings/com.genuitec.eclipse.core.prefs
Normal file
|
@ -0,0 +1,4 @@
|
|||
#Thu Jan 08 18:05:54 CET 2009
|
||||
eclipse.preferences.version=1
|
||||
validator.Checked=target
|
||||
validator.Unchecked=
|
4
.settings/com.genuitec.eclipse.j2eedt.core.prefs
Normal file
4
.settings/com.genuitec.eclipse.j2eedt.core.prefs
Normal file
|
@ -0,0 +1,4 @@
|
|||
#Thu Jan 15 07:20:11 CET 2009
|
||||
defaultTldInfo=f\=http\://java.sun.com/jsf/core;http\://java.sun.com/jsf/html\=h;http\://struts.apache.org/tags-bean\=bean;http\://java.sun.com/jsp/jstl/fmt\=fmt;bean\=http\://struts.apache.org/tags-bean;nested\=http\://struts.apache.org/tags-nested;http\://java.sun.com/jsp/jstl/sql\=sql;fmt\=http\://java.sun.com/jsp/jstl/fmt;c\=http\://java.sun.com/jsp/jstl/core;http\://struts.apache.org/tags-logic\=logic;http\://java.sun.com/jsp/jstl/xml\=x;http\://java.sun.com/jsp/jstl/core\=c;logic\=http\://struts.apache.org/tags-logic;h\=http\://java.sun.com/jsf/html;http\://struts.apache.org/tags-tiles\=tiles;http\://java.sun.com/jsp/jstl/functions\=fn;tiles\=http\://struts.apache.org/tags-tiles;sql\=http\://java.sun.com/jsp/jstl/sql;http\://struts.apache.org/tags-html\=html;html\=http\://struts.apache.org/tags-html;http\://struts.apache.org/tags-nested\=nested;http\://java.sun.com/jsf/core\=f;fn\=http\://java.sun.com/jsp/jstl/functions;x\=http\://java.sun.com/jsp/jstl/xml
|
||||
eclipse.preferences.version=1
|
||||
j2ee.deployment.web.archive_dependent_projects=always
|
4
.settings/com.genuitec.eclipse.ws.blue.prefs
Normal file
4
.settings/com.genuitec.eclipse.ws.blue.prefs
Normal file
|
@ -0,0 +1,4 @@
|
|||
#Thu Jan 15 07:20:11 CET 2009
|
||||
blue.framework.id=
|
||||
blue.target.server=
|
||||
eclipse.preferences.version=1
|
17
doc/TODO.txt
17
doc/TODO.txt
|
@ -1,25 +1,30 @@
|
|||
|
||||
|
||||
- (30%) X4O client/server config
|
||||
- fix frontend event system
|
||||
- make event channels work
|
||||
- config prefix (and rest of default in finalizer)
|
||||
- (10%) update SWT frontend
|
||||
- create JSF frontend
|
||||
- Make annotations work.
|
||||
- Multiple SelectItems for addable null's etc.
|
||||
- make sorting work
|
||||
- make searching work
|
||||
- made options work
|
||||
- auto text converts
|
||||
|
||||
- Plugin validation
|
||||
- Plugin Role Parser
|
||||
- Finalizer plugins
|
||||
- X4O client/server config
|
||||
- Check user roles in frontend
|
||||
- Default/Full Table and templating
|
||||
- Ckeck all validators
|
||||
- Make annotations work.
|
||||
- Bind to x18n
|
||||
- MetaQuery support
|
||||
- config prefix (and rest of default in finalizer)
|
||||
- update SWT frontend
|
||||
- create JSF frontend
|
||||
- create JSF-extJS frontend
|
||||
- create XML-RPC frontend
|
||||
|
||||
- export interface + exports
|
||||
- graphs of numeric value columns
|
||||
|
||||
=== DONE ===
|
||||
|
||||
|
|
85
pom.xml
85
pom.xml
|
@ -4,8 +4,8 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.idcanet.vasc</groupId>
|
||||
<artifactId>vasc-main</artifactId>
|
||||
<version>0.3-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<name>vasc</name>
|
||||
<description>Simple crud'ing for all.</description>
|
||||
<url>http://www.x4o.org/vasc</url>
|
||||
|
@ -75,12 +75,12 @@
|
|||
<version>0.8-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Serv5 depency -->
|
||||
<dependency>
|
||||
<groupId>com.idcanet.serv5</groupId>
|
||||
<artifactId>serv5-main</artifactId>
|
||||
<version>0.6-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Xtes depency -->
|
||||
|
@ -88,6 +88,7 @@
|
|||
<groupId>com.idcanet.xtes</groupId>
|
||||
<artifactId>xtes-main</artifactId>
|
||||
<version>0.6-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- FFF depency -->
|
||||
|
@ -95,6 +96,7 @@
|
|||
<groupId>com.idcanet.fff</groupId>
|
||||
<artifactId>fff-main</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Ldap depency -->
|
||||
|
@ -102,6 +104,7 @@
|
|||
<groupId>com.novell.ldap</groupId>
|
||||
<artifactId>jldap</artifactId>
|
||||
<version>4.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Swing date editor depency -->
|
||||
|
@ -109,13 +112,64 @@
|
|||
<groupId>com.michaelbaranov</groupId>
|
||||
<artifactId>microba</artifactId>
|
||||
<version>0.4.4.1</version>
|
||||
<scope>compile</scope>
|
||||
<optional/>
|
||||
</dependency>
|
||||
|
||||
<!-- SWT depency TODO: linux only, wait for 3.4 !! -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse</groupId>
|
||||
<artifactId>swt</artifactId>
|
||||
<groupId>org.eclipse.swt.gtk.linux</groupId>
|
||||
<artifactId>x86</artifactId>
|
||||
<version>3.3.0-v3346</version>
|
||||
<scope>provided</scope>
|
||||
<optional/>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse</groupId>
|
||||
<artifactId>jface</artifactId>
|
||||
<version>3.3.0-I20070606-0010</version>
|
||||
<scope>provided</scope>
|
||||
<optional/>
|
||||
</dependency>
|
||||
|
||||
<!-- EE5 + JSF + etc -->
|
||||
<dependency>
|
||||
<groupId>org.apache.openejb</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<version>5.0-1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.faces</groupId>
|
||||
<artifactId>jsf-api</artifactId>
|
||||
<version>1.2_04</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet.jsp</groupId>
|
||||
<artifactId>jsp-api</artifactId>
|
||||
<version>2.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.faces</groupId>
|
||||
<artifactId>jsf-impl</artifactId>
|
||||
<version>1.2_04</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- tomahak jsf frontend -->
|
||||
<dependency>
|
||||
<groupId>org.apache.myfaces.tomahawk</groupId>
|
||||
<artifactId>tomahawk12</artifactId>
|
||||
<version>1.1.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Unit tests cases -->
|
||||
|
@ -123,9 +177,19 @@
|
|||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>5.8</version>
|
||||
<scope>test</scope>
|
||||
<classifier>jdk15</classifier>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- OVERRIDES -->
|
||||
|
||||
<!-- X4O depency for EL -->
|
||||
<dependency>
|
||||
<groupId>de.odysseus.juel</groupId>
|
||||
<artifactId>juel</artifactId>
|
||||
<version>2.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -184,6 +248,17 @@
|
|||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Package source -->
|
||||
<plugin>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals><goal>jar</goal></goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Generate site -->
|
||||
<plugin>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
|
|
|
@ -62,61 +62,165 @@ public class VascAnnotationParser {
|
|||
* @param property The property for the ToolTip
|
||||
* @return The i18n key for an ToolTip
|
||||
*/
|
||||
public String getVascDescriptionKey(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascDescription.class,property);
|
||||
public String getVascI18nDescription(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascI18n.class,property,"description");
|
||||
}
|
||||
|
||||
public String getVascDescriptionKey(Class<?> beanClass) {
|
||||
return (String)getValue(beanClass,VascDescription.class,null);
|
||||
public String getVascI18nDescription(Class<?> beanClass) {
|
||||
return (String)getValue(beanClass,VascI18n.class,null,"description");
|
||||
}
|
||||
|
||||
public String getVascI18nName(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascI18n.class,property,"name");
|
||||
}
|
||||
|
||||
public String getVascI18nName(Class<?> beanClass) {
|
||||
return (String)getValue(beanClass,VascI18n.class,null,"name");
|
||||
}
|
||||
|
||||
public String getVascI18nHelpId(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascI18n.class,property,"helpId");
|
||||
}
|
||||
|
||||
public String getVascI18nHelpId(Class<?> beanClass) {
|
||||
return (String)getValue(beanClass,VascI18n.class,null,"helpId");
|
||||
}
|
||||
|
||||
public String getVascI18nImage(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascI18n.class,property,"image");
|
||||
}
|
||||
|
||||
public String getVascI18nImage(Class<?> beanClass) {
|
||||
return (String)getValue(beanClass,VascI18n.class,null,"image");
|
||||
}
|
||||
|
||||
public Integer getVascOrderIndex(Class<?> beanClass,String property) {
|
||||
return (Integer)getValue(beanClass,VascFieldOrder.class,property,"orderIndex");
|
||||
}
|
||||
|
||||
|
||||
public Integer getVascStyleSizeList(Class<?> beanClass,String property) {
|
||||
return (Integer)getValue(beanClass,VascStyle.class,property,"sizeList");
|
||||
}
|
||||
public Integer getVascStyleSizeEdit(Class<?> beanClass,String property) {
|
||||
return (Integer)getValue(beanClass,VascStyle.class,property,"sizeEdit");
|
||||
}
|
||||
public String getVascStyleStyleList(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascStyle.class,property,"styleList");
|
||||
}
|
||||
public String getVascStyleStyleEdit(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascStyle.class,property,"styleEdit");
|
||||
}
|
||||
|
||||
|
||||
public String getVascFieldBackendName(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascField.class,property,"backendName");
|
||||
}
|
||||
public Boolean getVascFieldCreate(Class<?> beanClass,String property) {
|
||||
return (Boolean)getValue(beanClass,VascField.class,property,"create");
|
||||
}
|
||||
public Boolean getVascFieldEdit(Class<?> beanClass,String property) {
|
||||
return (Boolean)getValue(beanClass,VascField.class,property,"edit");
|
||||
}
|
||||
public Boolean getVascFieldEditReadOnly(Class<?> beanClass,String property) {
|
||||
return (Boolean)getValue(beanClass,VascField.class,property,"editReadOnly");
|
||||
}
|
||||
public Boolean getVascFieldEditBlank(Class<?> beanClass,String property) {
|
||||
return (Boolean)getValue(beanClass,VascField.class,property,"editBlank");
|
||||
}
|
||||
public Boolean getVascFieldList(Class<?> beanClass,String property) {
|
||||
return (Boolean)getValue(beanClass,VascField.class,property,"list");
|
||||
}
|
||||
public Boolean getVascFieldView(Class<?> beanClass,String property) {
|
||||
return (Boolean)getValue(beanClass,VascField.class,property,"view");
|
||||
}
|
||||
public Boolean getVascFieldOptional(Class<?> beanClass,String property) {
|
||||
return (Boolean)getValue(beanClass,VascField.class,property,"optional");
|
||||
}
|
||||
|
||||
|
||||
public String getVascFieldType(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascFieldType.class,property,"type");
|
||||
}
|
||||
public String[] getVascFieldTypeProperties(Class<?> beanClass,String property) {
|
||||
return (String[])getValue(beanClass,VascFieldType.class,property,"properties");
|
||||
}
|
||||
|
||||
|
||||
public String getVascRolesCreate(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascRoles.class,property,"rolesCreate");
|
||||
}
|
||||
public String getVascRolesEdit(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascRoles.class,property,"rolesEdit");
|
||||
}
|
||||
public String getVascRolesEditReadOnly(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascRoles.class,property,"rolesEditReadOnly");
|
||||
}
|
||||
public String getVascRolesList(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascRoles.class,property,"rolesList");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the key of the VascName key for the property of the class
|
||||
* @param beanClass The class to search for the property
|
||||
* @param property The property for the Labe
|
||||
* @return The i18n key for an Label
|
||||
* TODO: change this, because we need differnce between key and value instance
|
||||
* @param beanClass
|
||||
* @param property
|
||||
* @return
|
||||
*/
|
||||
public String getVascNameKey(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascName.class,property);
|
||||
}
|
||||
|
||||
public String getVascNameKey(Class<?> beanClass) {
|
||||
return (String)getValue(beanClass,VascName.class,null);
|
||||
}
|
||||
|
||||
|
||||
public Object getVascColumnWidth(Class<?> beanClass,String property) {
|
||||
return getValue(beanClass,VascColumnWidth.class,property);
|
||||
}
|
||||
|
||||
public Object getVascColumnWidth(Class<?> beanClass) {
|
||||
return getValue(beanClass,VascColumnWidth.class,null);
|
||||
}
|
||||
|
||||
public String getVascHelpId(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascHelpId.class,property);
|
||||
}
|
||||
|
||||
public String getVascHelpId(Class<?> beanClass) {
|
||||
return (String)getValue(beanClass,VascHelpId.class,null);
|
||||
}
|
||||
|
||||
public Object getVascDefaultValue(Class<?> beanClass,String property) {
|
||||
return getValue(beanClass,VascDefaultValue.class,property);
|
||||
return getValue(beanClass,VascDefaultValue.class,property,null);
|
||||
}
|
||||
|
||||
public Object getVascDefaultValue(Class<?> beanClass) {
|
||||
return getValue(beanClass,VascDefaultValue.class,null);
|
||||
}
|
||||
|
||||
public String getVascImage(Class<?> beanClass,String property) {
|
||||
return (String)getValue(beanClass,VascImage.class,property);
|
||||
}
|
||||
|
||||
public String getVascImage(Class<?> beanClass) {
|
||||
return (String)getValue(beanClass,VascImage.class,null);
|
||||
return getValue(beanClass,VascDefaultValue.class,null,null);
|
||||
}
|
||||
|
||||
public String getVascDisplayName(Class<?> beanClass) {
|
||||
for (Method method:beanClass.getMethods()) {
|
||||
if(method.getName().startsWith("get")==false) { //a bit durty
|
||||
continue;
|
||||
}
|
||||
Annotation anno = method.getAnnotation(VascDisplayName.class);
|
||||
if (anno==null) {
|
||||
continue;
|
||||
}
|
||||
return method.getName().substring(3,4).toLowerCase()+method.getName().substring(4); // field name without get
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public String getVascDisplayName(Class<?> beanClass,String property) {
|
||||
for (Method method:beanClass.getMethods()) {
|
||||
if (method.getName().equalsIgnoreCase("get"+property)==false) { //a bit durty
|
||||
continue;
|
||||
}
|
||||
VascI18nModelReference mt = method.getAnnotation(VascI18nModelReference.class);
|
||||
if (mt==null) {
|
||||
String result = (String)getValue(beanClass,VascField.class,property,"displayName");
|
||||
return result;
|
||||
}
|
||||
Class<?> typeClass = mt.type();
|
||||
if (Object.class==mt.type()) {
|
||||
typeClass = method.getReturnType();
|
||||
}
|
||||
String name = getVascDisplayName(typeClass);
|
||||
return name;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getVascPrimaryKey(Class<?> beanClass) {
|
||||
for (Method method:beanClass.getMethods()) {
|
||||
if(method.getName().startsWith("get")==false) { //a bit durty
|
||||
continue;
|
||||
}
|
||||
Annotation anno = method.getAnnotation(VascPrimaryKey.class);
|
||||
if (anno==null) {
|
||||
continue;
|
||||
}
|
||||
return method.getName().substring(3,4).toLowerCase()+method.getName().substring(4); // field name without get
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* No oop code here...refactor at some point in time
|
||||
|
@ -128,12 +232,16 @@ public class VascAnnotationParser {
|
|||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Object getValue(Class<?> beanClass,Class annotationType,String property) {
|
||||
private Object getValue(Class<?> beanClass,Class annotationType,String property,String field) {
|
||||
if(beanClass==null) { throw new NullPointerException("beanClass may not be null"); }
|
||||
if(annotationType==null){ throw new NullPointerException("annotationType may not be null"); }
|
||||
|
||||
Object result = null;
|
||||
if(property==null) {
|
||||
if (property==null) {
|
||||
String def = beanClass.getName()+"."+annotationType.getSimpleName();
|
||||
if (field!=null) {
|
||||
def = def+"."+field;
|
||||
}
|
||||
Annotation anno = beanClass.getAnnotation(annotationType);
|
||||
if (anno==null) {
|
||||
// no annotation == no default
|
||||
|
@ -146,7 +254,7 @@ public class VascAnnotationParser {
|
|||
return null;
|
||||
}
|
||||
} else {
|
||||
result = doAnnotation(anno);
|
||||
result = doAnnotation(anno,def,field);
|
||||
if(result!=null) {
|
||||
return result;
|
||||
}
|
||||
|
@ -154,31 +262,35 @@ public class VascAnnotationParser {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
return beanClass.getName()+"."+annotationType.getSimpleName();
|
||||
return def;
|
||||
}
|
||||
|
||||
String propRest = null;
|
||||
int index = property.indexOf(".");
|
||||
if(index>0) {
|
||||
if (index>0) {
|
||||
propRest = property.substring(index+1);
|
||||
property = property.substring(0,index);
|
||||
}
|
||||
|
||||
for(Method method:beanClass.getMethods()) {
|
||||
if(method.getName().equalsIgnoreCase("get"+property)==false) { //a bit durty
|
||||
String def = beanClass.getName()+"."+property+"."+annotationType.getSimpleName();
|
||||
if (field!=null) {
|
||||
def = def+"."+field;
|
||||
}
|
||||
for (Method method:beanClass.getMethods()) {
|
||||
if (method.getName().equalsIgnoreCase("get"+property)==false) { //a bit durty
|
||||
continue;
|
||||
}
|
||||
//logger.finer("Found property: "+property);
|
||||
VascModelReference mt = method.getAnnotation(VascModelReference.class);
|
||||
if(mt!=null) {
|
||||
VascI18nModelReference mt = method.getAnnotation(VascI18nModelReference.class);
|
||||
if (mt!=null && annotationType.equals(VascI18n.class)) {
|
||||
Class typeClass = mt.type();
|
||||
if(Object.class==mt.type()) {
|
||||
if (Object.class==mt.type()) {
|
||||
typeClass = method.getReturnType();
|
||||
//return returnType.getName()+"."+annotationType.toString();
|
||||
}
|
||||
|
||||
// recursif function:
|
||||
return getValue(typeClass,annotationType,propRest);
|
||||
return getValue(typeClass,annotationType,propRest,field);
|
||||
}
|
||||
|
||||
Annotation anno = method.getAnnotation(annotationType);
|
||||
|
@ -186,7 +298,7 @@ public class VascAnnotationParser {
|
|||
if (anno==null && annotationType.equals(VascDefaultValue.class)) {
|
||||
return null;
|
||||
}
|
||||
result = doAnnotation(anno);
|
||||
result = doAnnotation(anno,def,field);
|
||||
if(result!=null) {
|
||||
return result;
|
||||
}
|
||||
|
@ -195,62 +307,202 @@ public class VascAnnotationParser {
|
|||
}
|
||||
break; // return default
|
||||
}
|
||||
return beanClass.getName()+"."+property+"."+annotationType.getSimpleName();
|
||||
|
||||
if (annotationType.equals(VascField.class)) {
|
||||
try {
|
||||
if ("backendName".equals(field)) {
|
||||
return VascField.class.getMethod("backendName").getDefaultValue();
|
||||
}
|
||||
if ("displayName".equals(field)) {
|
||||
return VascField.class.getMethod("displayName").getDefaultValue();
|
||||
}
|
||||
if ("create".equals(field)) {
|
||||
return VascField.class.getMethod("create").getDefaultValue();
|
||||
}
|
||||
if ("edit".equals(field)) {
|
||||
return VascField.class.getMethod("edit").getDefaultValue();
|
||||
}
|
||||
if ("editReadOnly".equals(field)) {
|
||||
return VascField.class.getMethod("editReadOnly").getDefaultValue();
|
||||
}
|
||||
if ("editBlank".equals(field)) {
|
||||
return VascField.class.getMethod("editBlank").getDefaultValue();
|
||||
}
|
||||
if ("list".equals(field)) {
|
||||
return VascField.class.getMethod("list").getDefaultValue();
|
||||
}
|
||||
if ("view".equals(field)) {
|
||||
return VascField.class.getMethod("view").getDefaultValue();
|
||||
}
|
||||
if ("optional".equals(field)) {
|
||||
return VascField.class.getMethod("optional").getDefaultValue();
|
||||
}
|
||||
// This are the default value then....
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (annotationType.equals(VascFieldType.class)) {
|
||||
return null;
|
||||
}
|
||||
if (annotationType.equals(VascStyle.class)) {
|
||||
return null;
|
||||
}
|
||||
if (annotationType.equals(VascRoles.class)) {
|
||||
return null;
|
||||
}
|
||||
if (annotationType.equals(VascFieldOrder.class)) {
|
||||
int indexOrder = 0;
|
||||
for (Method method:beanClass.getMethods()) {
|
||||
if (method.getName().equalsIgnoreCase("get"+property)==false) { //a bit durty
|
||||
indexOrder = indexOrder + 100;
|
||||
continue;
|
||||
}
|
||||
return indexOrder;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
private Object doAnnotation(Annotation b) {
|
||||
private Object doAnnotation(Annotation b,String def,String field) {
|
||||
if (b==null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Class<?> a = b.annotationType();
|
||||
if (a.equals(VascName.class)) {
|
||||
VascName l = (VascName)b;
|
||||
if("".equals(l.key()) | "null".equals(l.key())) {
|
||||
return null;
|
||||
}
|
||||
return l.key();
|
||||
if (a.equals(VascI18n.class)) {
|
||||
VascI18n l = (VascI18n)b;
|
||||
String val = null;
|
||||
|
||||
if ("name".equals(field)) {
|
||||
val = l.name();
|
||||
}
|
||||
if ("description".equals(field)) {
|
||||
val = l.description();
|
||||
}
|
||||
if ("image".equals(field)) {
|
||||
val = l.image();
|
||||
}
|
||||
if ("helpId".equals(field)) {
|
||||
val = l.helpId();
|
||||
}
|
||||
if (val==null) {
|
||||
val = "";
|
||||
}
|
||||
if ("".equals(val)) {
|
||||
return def;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
if (a.equals(VascDescription.class)) {
|
||||
VascDescription t = (VascDescription)b;
|
||||
if("".equals(t.key()) | "null".equals(t.key())) {
|
||||
return null;
|
||||
}
|
||||
return t.key();
|
||||
}
|
||||
if (a.equals(VascHelpId.class)) {
|
||||
VascHelpId h = (VascHelpId)b;
|
||||
if("".equals(h.helpId()) | "null".equals(h.helpId())) {
|
||||
return null;
|
||||
}
|
||||
return h.helpId();
|
||||
if (a.equals(VascFieldOrder.class)) {
|
||||
VascFieldOrder v = (VascFieldOrder)b;
|
||||
return v.orderIndex();
|
||||
}
|
||||
if (a.equals(VascDefaultValue.class)) {
|
||||
VascDefaultValue v = (VascDefaultValue)b;
|
||||
|
||||
if(v.defaultValue().equals(Object.class)==false) {
|
||||
try {
|
||||
//return v.defaultValue().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new NullPointerException("Could not init defaultValueClass error: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
if ("null".equals(v.defaultValue())) {
|
||||
return "";
|
||||
}
|
||||
return v.defaultValue();
|
||||
}
|
||||
if (a.equals(VascColumnWidth.class)) {
|
||||
VascColumnWidth c = (VascColumnWidth)b;
|
||||
return c.width();
|
||||
}
|
||||
if (a.equals(VascImage.class)) {
|
||||
VascImage c = (VascImage)b;
|
||||
if("".equals(c.image()) | "null".equals(c.image())) {
|
||||
return null;
|
||||
if (a.equals(VascStyle.class)) {
|
||||
VascStyle c = (VascStyle)b;
|
||||
if ("sizeList".equals(field)) {
|
||||
return c.sizeList();
|
||||
}
|
||||
return c.image();
|
||||
if ("sizeEdit".equals(field)) {
|
||||
return c.sizeEdit();
|
||||
}
|
||||
if ("styleList".equals(field)) {
|
||||
return c.styleList();
|
||||
}
|
||||
if ("styleEdit".equals(field)) {
|
||||
return c.styleEdit();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (a.equals(VascField.class)) {
|
||||
VascField c = (VascField)b;
|
||||
if ("backendName".equals(field)) {
|
||||
if ("".equals(c.backendName())) {
|
||||
return null;
|
||||
}
|
||||
return c.backendName();
|
||||
}
|
||||
if ("displayName".equals(field)) {
|
||||
if ("".equals(c.displayName())) {
|
||||
return null;
|
||||
}
|
||||
return c.displayName();
|
||||
}
|
||||
if ("create".equals(field)) {
|
||||
return c.create();
|
||||
}
|
||||
if ("edit".equals(field)) {
|
||||
return c.edit();
|
||||
}
|
||||
if ("editReadOnly".equals(field)) {
|
||||
return c.editReadOnly();
|
||||
}
|
||||
if ("editBlank".equals(field)) {
|
||||
return c.editBlank();
|
||||
}
|
||||
if ("list".equals(field)) {
|
||||
return c.list();
|
||||
}
|
||||
if ("view".equals(field)) {
|
||||
return c.view();
|
||||
}
|
||||
if ("optional".equals(field)) {
|
||||
return c.optional();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (a.equals(VascFieldType.class)) {
|
||||
VascFieldType c = (VascFieldType)b;
|
||||
if ("type".equals(field)) {
|
||||
if ("".equals(c.type())) {
|
||||
return null;
|
||||
}
|
||||
return c.type();
|
||||
}
|
||||
if ("properties".equals(field)) {
|
||||
return c.properties();
|
||||
}
|
||||
}
|
||||
if (a.equals(VascRoles.class)) {
|
||||
VascRoles c = (VascRoles)b;
|
||||
if ("rolesCreate".equals(field)) {
|
||||
if ("".equals(c.rolesCreate())) {
|
||||
return null;
|
||||
}
|
||||
return c.rolesCreate();
|
||||
}
|
||||
if ("rolesEdit".equals(field)) {
|
||||
if ("".equals(c.rolesEdit())) {
|
||||
return null;
|
||||
}
|
||||
return c.rolesEdit();
|
||||
}
|
||||
if ("rolesEditReadOnly".equals(field)) {
|
||||
if ("".equals(c.rolesEditReadOnly())) {
|
||||
return null;
|
||||
}
|
||||
return c.rolesEditReadOnly();
|
||||
}
|
||||
if ("rolesList".equals(field)) {
|
||||
if ("".equals(c.rolesList())) {
|
||||
return null;
|
||||
}
|
||||
return c.rolesList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,231 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.vasc.annotations;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Parses the Vasc annotations and generates all i18n keys for you.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 23, 2009
|
||||
*/
|
||||
public class VascBundleKeyGenerator {
|
||||
|
||||
private List<Class<?>> models = null;
|
||||
private Map<String,String> keys = null;
|
||||
private boolean generateName = true;
|
||||
private boolean generateDescription = true;
|
||||
private boolean generateImage = true;
|
||||
private boolean generateHelpId = true;
|
||||
|
||||
public VascBundleKeyGenerator() {
|
||||
models = new ArrayList<Class<?>>(30);
|
||||
keys = new HashMap<String,String>(300);
|
||||
}
|
||||
|
||||
public void addModelClass(Class<?> model) {
|
||||
models.add(model);
|
||||
}
|
||||
|
||||
public List<Class<?>> getModelClasses() {
|
||||
return models;
|
||||
}
|
||||
|
||||
|
||||
public void generateMissingKeys(StringBuffer buffer,ResourceBundle bundle) {
|
||||
if (keys.isEmpty()==false) {
|
||||
keys.clear();
|
||||
}
|
||||
for (Class<?> modelClass:models) {
|
||||
generatorI18nKeys(modelClass);
|
||||
}
|
||||
|
||||
List<String> keys2 = new ArrayList<String>(keys.keySet());
|
||||
keys2.removeAll(bundle.keySet());
|
||||
Collections.sort(keys2);
|
||||
for (String key:keys2) {
|
||||
String value = keys.get(key);
|
||||
buffer.append(key);
|
||||
buffer.append(" = ");
|
||||
buffer.append(value);
|
||||
buffer.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
public void generateRemoveKeys(StringBuffer buffer,ResourceBundle bundle,String excludeRegex) {
|
||||
if (keys.isEmpty()==false) {
|
||||
keys.clear();
|
||||
}
|
||||
for (Class<?> modelClass:models) {
|
||||
generatorI18nKeys(modelClass);
|
||||
}
|
||||
|
||||
List<String> keys2 = new ArrayList<String>(bundle.keySet());
|
||||
keys2.removeAll(keys.keySet());
|
||||
Collections.sort(keys2);
|
||||
for (String key:keys2) {
|
||||
// exlude code and user keys
|
||||
if (excludeRegex!=null && key.matches(excludeRegex)) {
|
||||
continue;
|
||||
}
|
||||
buffer.append(key);
|
||||
buffer.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
public void generateKeys(StringBuffer buffer) {
|
||||
if (keys.isEmpty()==false) {
|
||||
keys.clear();
|
||||
}
|
||||
for (Class<?> modelClass:models) {
|
||||
generatorI18nKeys(modelClass);
|
||||
}
|
||||
List<String> keys2 = new ArrayList<String>(keys.keySet());
|
||||
Collections.sort(keys2);
|
||||
for (String key:keys2) {
|
||||
String value = keys.get(key);
|
||||
buffer.append(key);
|
||||
buffer.append(" = ");
|
||||
buffer.append(value);
|
||||
buffer.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
private void generatorI18nKeys(Class<?> bean) {
|
||||
VascAnnotationParser vap = new VascAnnotationParser();
|
||||
|
||||
String prop1 = bean.getName().substring(bean.getName().lastIndexOf('.')+1);
|
||||
if (isGenerateName()) {
|
||||
appendKey(vap.getVascI18nName(bean),prop1);
|
||||
}
|
||||
if (isGenerateDescription()) {
|
||||
appendKey(vap.getVascI18nDescription(bean),prop1);
|
||||
}
|
||||
if (isGenerateImage()) {
|
||||
appendKey(vap.getVascI18nImage(bean),"resources/images/models/"+prop1+".png");
|
||||
}
|
||||
if (isGenerateHelpId()) {
|
||||
appendKey(vap.getVascI18nHelpId(bean),prop1);
|
||||
}
|
||||
|
||||
|
||||
for (Method method:bean.getMethods()) {
|
||||
if (method.getName().startsWith("get")==false) { //a bit durty
|
||||
continue;
|
||||
}
|
||||
if (method.getName().equals("getClass")==true) {
|
||||
continue;
|
||||
}
|
||||
String prop = method.getName().substring(3);
|
||||
prop = prop.substring(0,1).toLowerCase()+prop.substring(1);
|
||||
|
||||
|
||||
if (isGenerateName()) {
|
||||
appendKey(vap.getVascI18nName(bean, prop),prop);
|
||||
}
|
||||
if (isGenerateDescription()) {
|
||||
appendKey(vap.getVascI18nDescription(bean, prop),prop);
|
||||
}
|
||||
if (isGenerateImage()) {
|
||||
appendKey(vap.getVascI18nImage(bean, prop),"resources/images/models/"+prop1+"-"+prop+".png");
|
||||
}
|
||||
if (isGenerateHelpId()) {
|
||||
appendKey(vap.getVascI18nHelpId(bean),prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void appendKey(String key,String value) {
|
||||
if (keys.containsKey(key)) {
|
||||
return;
|
||||
}
|
||||
keys.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the generateName
|
||||
*/
|
||||
public boolean isGenerateName() {
|
||||
return generateName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param generateName the generateName to set
|
||||
*/
|
||||
public void setGenerateName(boolean generateName) {
|
||||
this.generateName = generateName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the generateDescription
|
||||
*/
|
||||
public boolean isGenerateDescription() {
|
||||
return generateDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param generateDescription the generateDescription to set
|
||||
*/
|
||||
public void setGenerateDescription(boolean generateDescription) {
|
||||
this.generateDescription = generateDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the generateImage
|
||||
*/
|
||||
public boolean isGenerateImage() {
|
||||
return generateImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param generateImage the generateImage to set
|
||||
*/
|
||||
public void setGenerateImage(boolean generateImage) {
|
||||
this.generateImage = generateImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the generateHelpId
|
||||
*/
|
||||
public boolean isGenerateHelpId() {
|
||||
return generateHelpId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param generateHelpId the generateHelpId to set
|
||||
*/
|
||||
public void setGenerateHelpId(boolean generateHelpId) {
|
||||
this.generateHelpId = generateHelpId;
|
||||
}
|
||||
}
|
|
@ -35,6 +35,8 @@ import java.lang.annotation.Target;
|
|||
/**
|
||||
* Some choises options
|
||||
*
|
||||
* make also the field type to list
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 19, 2008
|
||||
*/
|
||||
|
@ -42,9 +44,9 @@ import java.lang.annotation.Target;
|
|||
@Target(ElementType.METHOD)
|
||||
public @interface VascChoices {
|
||||
|
||||
String[] choisesKeys();
|
||||
String[] choisesKeys() default {};
|
||||
|
||||
String[] choisesNames();
|
||||
|
||||
boolean editAsRadio() default true;
|
||||
boolean choisesAsRadio() default false;
|
||||
}
|
|
@ -42,12 +42,11 @@ import java.lang.annotation.Target;
|
|||
@Target(ElementType.METHOD)
|
||||
public @interface VascDefaultValue {
|
||||
|
||||
String key() default "null";
|
||||
//String key() default "";
|
||||
|
||||
/**
|
||||
* Note: special value for default, because else we can not set empty.
|
||||
* @return
|
||||
*/
|
||||
String defaultValue() default "null";
|
||||
|
||||
/**
|
||||
* The defaultValue of the method
|
||||
*/
|
||||
//Class<?> defaultValueClass() default Object.class;
|
||||
}
|
|
@ -41,13 +41,5 @@ import java.lang.annotation.Target;
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface VascDisplayName {
|
||||
|
||||
/**
|
||||
* The field or fields which are the display name.
|
||||
* If used on method then field may be left out.
|
||||
*
|
||||
*/
|
||||
String fields() default "null";
|
||||
|
||||
String format() default "null";
|
||||
|
||||
}
|
|
@ -40,13 +40,24 @@ import java.lang.annotation.Target;
|
|||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface VascAdmin {
|
||||
public @interface VascEntry {
|
||||
|
||||
boolean list() default true;
|
||||
String id() default "";
|
||||
|
||||
String headerName() default "";
|
||||
|
||||
String headerDescription() default "";
|
||||
|
||||
String headerImage() default "";
|
||||
|
||||
String helpId() default "";
|
||||
|
||||
|
||||
boolean vascAdminList() default true;
|
||||
|
||||
boolean create() default true;
|
||||
boolean vascAdminCreate() default true;
|
||||
|
||||
boolean update() default true;
|
||||
boolean vascAdminEdit() default true;
|
||||
|
||||
boolean delete() default true;
|
||||
boolean vascAdminDelete() default true;
|
||||
}
|
|
@ -39,7 +39,7 @@ import java.lang.annotation.Target;
|
|||
* @version 1.0 Aug 15, 2008
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface VascEventChannel {
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,17 +40,23 @@ import java.lang.annotation.Target;
|
|||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface VascFieldOptions {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
boolean blank() default false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
String choises() default "null"; // + radio admin
|
||||
|
||||
boolean editable() default true;
|
||||
public @interface VascField {
|
||||
|
||||
String backendName() default "";
|
||||
|
||||
String displayName() default "";
|
||||
|
||||
boolean create() default true;
|
||||
|
||||
boolean edit() default true;
|
||||
|
||||
boolean editReadOnly() default false;
|
||||
|
||||
boolean editBlank() default false;
|
||||
|
||||
boolean list() default true;
|
||||
|
||||
boolean view() default true;
|
||||
|
||||
boolean optional() default false;
|
||||
}
|
|
@ -33,17 +33,18 @@ import java.lang.annotation.Target;
|
|||
|
||||
|
||||
/**
|
||||
* Sets the helpId
|
||||
* Lets you order the fields to better UI bahaivur.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 28, 2007
|
||||
* @version 1.0 Apr 6, 2009
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD,ElementType.TYPE})
|
||||
public @interface VascHelpId {
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface VascFieldOrder {
|
||||
|
||||
/**
|
||||
* The defaultValue of the method
|
||||
* The editor of the method/field
|
||||
*/
|
||||
String helpId() default "null";
|
||||
int orderIndex() default 0;
|
||||
|
||||
}
|
|
@ -40,15 +40,15 @@ import java.lang.annotation.Target;
|
|||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface VascEditorType {
|
||||
public @interface VascFieldType {
|
||||
|
||||
/**
|
||||
* The editor of the method/field
|
||||
*/
|
||||
String type() default "null";
|
||||
String type() default "";
|
||||
|
||||
/**
|
||||
* Hints for the choosen editor
|
||||
*/
|
||||
String hints() default "null";
|
||||
String[] properties() default {};
|
||||
}
|
|
@ -40,12 +40,18 @@ import java.lang.annotation.Target;
|
|||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD,ElementType.TYPE})
|
||||
public @interface VascName {
|
||||
public @interface VascI18n {
|
||||
|
||||
/**
|
||||
* The key of the Label default to "null"
|
||||
* @see com.idcanet.i18n.I18nAnnotationParser#getI18nLabelKey(Class, String)
|
||||
* @return The key of the ToolTip
|
||||
*/
|
||||
String key() default "null";
|
||||
String name() default "";
|
||||
|
||||
String description() default "";
|
||||
|
||||
String image() default "";
|
||||
|
||||
String helpId() default "";
|
||||
}
|
|
@ -40,9 +40,7 @@ import java.lang.annotation.Target;
|
|||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface VascModelReference {
|
||||
|
||||
boolean editAsRadio() default true;
|
||||
|
||||
public @interface VascI18nModelReference {
|
||||
|
||||
Class<?> type() default Object.class;
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.vasc.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the VascImage property
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 27, 2006
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD,ElementType.TYPE})
|
||||
public @interface VascImage {
|
||||
|
||||
/**
|
||||
* The resource or key of the Image, default to "null"
|
||||
* @see com.idcanet.i18n.I18nAnnotationParser#getI18nLabelKey(Class, String)
|
||||
* @return The key of the ToolTip
|
||||
*/
|
||||
String image() default "null";
|
||||
}
|
|
@ -40,20 +40,23 @@ import java.lang.annotation.Target;
|
|||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface VascUserRoles {
|
||||
public @interface VascRoles {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
String list() default "null";
|
||||
String rolesCreate() default "";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
String edit() default "null";
|
||||
String rolesEdit() default "";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
String editViewOnly() default "null";
|
||||
String rolesEditReadOnly() default "";
|
||||
|
||||
|
||||
String rolesList() default "";
|
||||
}
|
|
@ -40,7 +40,10 @@ import java.lang.annotation.Target;
|
|||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface VascColumnWidth {
|
||||
public @interface VascStyle {
|
||||
|
||||
int width() default 150;
|
||||
int sizeList() default 0;
|
||||
int sizeEdit() default 0;
|
||||
String styleList() default "";
|
||||
String styleEdit() default "";
|
||||
}
|
|
@ -27,6 +27,7 @@
|
|||
package com.idcanet.vasc.backends.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -36,5 +37,5 @@ import java.sql.Connection;
|
|||
*/
|
||||
public interface JdbcConnectionProvider {
|
||||
|
||||
public Connection getJdbcConnection();
|
||||
public Connection getJdbcConnection() throws SQLException;
|
||||
}
|
|
@ -26,11 +26,18 @@
|
|||
|
||||
package com.idcanet.vasc.backends.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.idcanet.vasc.core.AbstractVascBackend;
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.VascException;
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
||||
|
||||
|
@ -42,6 +49,11 @@ import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
|||
public class JdbcVascBackend extends AbstractVascBackend {
|
||||
|
||||
private JdbcConnectionProvider jdbcConnectionProvider = null;
|
||||
private String sqlList = null;
|
||||
private String idColumn = null;
|
||||
private String sqlDelete = null;
|
||||
private String sqlUpdate = null;
|
||||
private String sqlInsert = null;
|
||||
|
||||
/**
|
||||
* @return the JdbcConnectionProvider
|
||||
|
@ -57,14 +69,33 @@ public class JdbcVascBackend extends AbstractVascBackend {
|
|||
this.jdbcConnectionProvider = jdbcConnectionProvider;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#execute()
|
||||
*/
|
||||
public List<Object> execute() throws Exception {
|
||||
return null;
|
||||
JdbcConnectionProvider prov = getJdbcConnectionProvider();
|
||||
Connection connection = prov.getJdbcConnection();
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
try {
|
||||
Statement s = connection.createStatement();
|
||||
s.execute(getSqlList());
|
||||
ResultSet rs = s.getResultSet();
|
||||
int cols = rs.getMetaData().getColumnCount();
|
||||
while (rs.next()) {
|
||||
Map<String,Object> map = new HashMap<String,Object>(cols);
|
||||
for (int i=1;i<=cols;i++) {
|
||||
String columnName = rs.getMetaData().getColumnName(i);
|
||||
Object columnObject = rs.getObject(i);
|
||||
map.put(columnName, columnObject);
|
||||
}
|
||||
result.add(map);
|
||||
}
|
||||
} finally {
|
||||
if (connection!=null) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,13 +121,59 @@ public class JdbcVascBackend extends AbstractVascBackend {
|
|||
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryFieldValue(com.idcanet.vasc.core.VascEntryField)
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return null;
|
||||
VascEntryFieldValue result = new VascEntryFieldValue() {
|
||||
/**
|
||||
* @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 VascException {
|
||||
Map<String,Object> map = (Map<String,Object>)record;
|
||||
Object o = map.get(field.getBackendName());
|
||||
return o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 VascException {
|
||||
Map<String,Object> map = (Map<String,Object>)record;
|
||||
map.put(field.getBackendName(), value);
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryRecordCreator(com.idcanet.vasc.core.VascEntry)
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return null;
|
||||
return new VascEntryRecordCreator() {
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
return Map.class;
|
||||
}
|
||||
|
||||
public Object newRecord(VascEntry entry) throws Exception {
|
||||
return new HashMap<String,Object>(10);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sqlList
|
||||
*/
|
||||
public String getSqlList() {
|
||||
return sqlList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sqlList the sqlList to set
|
||||
*/
|
||||
public void setSqlList(String sqlList) {
|
||||
this.sqlList = sqlList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -37,6 +37,7 @@ import java.util.Map;
|
|||
import com.idcanet.vasc.core.AbstractVascBackend;
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.VascException;
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
||||
import com.idcanet.xtes.xpql.query.QueryParameterValue;
|
||||
|
@ -65,33 +66,54 @@ public class JdbcXpqlVascBackend extends AbstractVascBackend {
|
|||
public void setJdbcConnectionProvider(JdbcConnectionProvider jdbcConnectionProvider) {
|
||||
this.jdbcConnectionProvider = jdbcConnectionProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the query
|
||||
*/
|
||||
public com.idcanet.xtes.xpql.query.Query getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param query the query to set
|
||||
*/
|
||||
public void setQuery(com.idcanet.xtes.xpql.query.Query query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#execute()
|
||||
*/
|
||||
public List<Object> execute() throws Exception {
|
||||
// Copy parameters
|
||||
for (String key:getDataParameterKeys()) {
|
||||
Object value = getDataParameter(key);
|
||||
query.setQueryParameter(key, value);
|
||||
}
|
||||
Connection c = getJdbcConnectionProvider().getJdbcConnection();
|
||||
try {
|
||||
PreparedStatement q = c.prepareStatement(query.toPreparedSQL(query));
|
||||
|
||||
List<QueryParameterValue> values = query.getOrderQueryParameterValues();
|
||||
int i = 0;
|
||||
int ii = 1;
|
||||
for (QueryParameterValue value:values) {
|
||||
q.setObject(i,value.getValue());
|
||||
i++;
|
||||
q.setObject(ii,value.getValue());
|
||||
ii++;
|
||||
}
|
||||
q.execute();
|
||||
ResultSet rs = q.getResultSet();
|
||||
|
||||
List<Object> data = new ArrayList<Object>(100);
|
||||
do {
|
||||
Map<String,Object> obj = new HashMap<String,Object>(10);
|
||||
for (i=0;i<rs.getMetaData().getColumnCount();i++) {
|
||||
obj.put(rs.getMetaData().getCatalogName(i), rs.getObject(i));
|
||||
}
|
||||
data.add(obj);
|
||||
} while (rs.next());
|
||||
return data;
|
||||
int cols = rs.getMetaData().getColumnCount();
|
||||
List<Object> result = new ArrayList<Object>(50);
|
||||
while (rs.next()) {
|
||||
Map<String,Object> map = new HashMap<String,Object>(cols);
|
||||
for (int i=1;i<=cols;i++) {
|
||||
String columnName = rs.getMetaData().getColumnName(i);
|
||||
Object columnObject = rs.getObject(i);
|
||||
map.put(columnName, columnObject);
|
||||
}
|
||||
result.add(map);
|
||||
}
|
||||
return result;
|
||||
} finally {
|
||||
if (c!=null) {
|
||||
c.close();
|
||||
|
@ -122,13 +144,42 @@ public class JdbcXpqlVascBackend extends AbstractVascBackend {
|
|||
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryFieldValue(com.idcanet.vasc.core.VascEntryField)
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return null;
|
||||
VascEntryFieldValue result = new VascEntryFieldValue() {
|
||||
/**
|
||||
* @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 VascException {
|
||||
Map<String,Object> map = (Map<String,Object>)record;
|
||||
Object o = map.get(field.getBackendName());
|
||||
return o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 VascException {
|
||||
Map<String,Object> map = (Map<String,Object>)record;
|
||||
map.put(field.getBackendName(), value);
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryRecordCreator(com.idcanet.vasc.core.VascEntry)
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return null;
|
||||
return new VascEntryRecordCreator() {
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
return Map.class;
|
||||
}
|
||||
|
||||
public Object newRecord(VascEntry entry) throws Exception {
|
||||
return new HashMap<String,Object>(10);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* 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.backends.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 15, 2009
|
||||
*/
|
||||
public class JdniDataSourceJdbcConnectionProvider implements JdbcConnectionProvider {
|
||||
|
||||
/** The context in which database data sources are found. */
|
||||
private String dataSourceContext = "java:comp/env/jdbc/";
|
||||
|
||||
private String dataSourceName = null;
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.backends.jdbc.JdbcConnectionProvider#getJdbcConnection()
|
||||
*/
|
||||
public Connection getJdbcConnection() throws SQLException {
|
||||
Connection connection = getDataSource(dataSourceName).getConnection();
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a DataSource out of the JNDI context.
|
||||
* <p>
|
||||
* @param name The name of the data source in the JDNI context.
|
||||
* @return The data source.
|
||||
*/
|
||||
private DataSource getDataSource(String name) throws SQLException {
|
||||
|
||||
try {
|
||||
Context initialContext = new InitialContext();
|
||||
if ( initialContext == null ) {
|
||||
throw new SQLException("Cannot get Initial Context");
|
||||
}
|
||||
DataSource datasource = (DataSource)initialContext.lookup(dataSourceContext+name);
|
||||
if ( datasource == null ) {
|
||||
throw new SQLException("Cannot lookup datasource: "+name);
|
||||
}
|
||||
return datasource;
|
||||
} catch ( NamingException e ) {
|
||||
throw new SQLException("Cannot get connection " + e,e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the dataSourceContext
|
||||
*/
|
||||
public String getDataSourceContext() {
|
||||
return dataSourceContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param dataSourceContext the dataSourceContext to set
|
||||
*/
|
||||
public void setDataSourceContext(String dataSourceContext) {
|
||||
this.dataSourceContext = dataSourceContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the dataSourceName
|
||||
*/
|
||||
public String getDataSourceName() {
|
||||
return dataSourceName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param dataSourceName the dataSourceName to set
|
||||
*/
|
||||
public void setDataSourceName(String dataSourceName) {
|
||||
this.dataSourceName = dataSourceName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* 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.backends.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 15, 2009
|
||||
*/
|
||||
public class SimpleJdbcConnectionProvider implements JdbcConnectionProvider {
|
||||
|
||||
private String driverClassName = null;
|
||||
private String dbUrl = null;
|
||||
private String dbUser = null;
|
||||
private String dbPassword = null;
|
||||
private boolean loadedDriver = false;
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.backends.jdbc.JdbcConnectionProvider#getJdbcConnection()
|
||||
*/
|
||||
public Connection getJdbcConnection() throws SQLException {
|
||||
if (loadedDriver==false) {
|
||||
try {
|
||||
Class.forName(driverClassName);
|
||||
loadedDriver = true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new SQLException("Could not load driver: "+driverClassName+" error: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
Connection connection = DriverManager.getConnection(dbUrl, dbUser, dbPassword);
|
||||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the driverClassName
|
||||
*/
|
||||
public String getDriverClassName() {
|
||||
return driverClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param driverClassName the driverClassName to set
|
||||
*/
|
||||
public void setDriverClassName(String driverClassName) {
|
||||
this.driverClassName = driverClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dbUrl
|
||||
*/
|
||||
public String getDbUrl() {
|
||||
return dbUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dbUrl the dbUrl to set
|
||||
*/
|
||||
public void setDbUrl(String dbUrl) {
|
||||
this.dbUrl = dbUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dbUser
|
||||
*/
|
||||
public String getDbUser() {
|
||||
return dbUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dbUser the dbUser to set
|
||||
*/
|
||||
public void setDbUser(String dbUser) {
|
||||
this.dbUser = dbUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dbPassword
|
||||
*/
|
||||
public String getDbPassword() {
|
||||
return dbPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dbPassword the dbPassword to set
|
||||
*/
|
||||
public void setDbPassword(String dbPassword) {
|
||||
this.dbPassword = dbPassword;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -37,19 +37,17 @@ import com.idcanet.vasc.core.AbstractVascBackend;
|
|||
*/
|
||||
abstract public class AbstractPersistenceVascBackend extends AbstractVascBackend {
|
||||
|
||||
/**
|
||||
* Provides a hibernate session which is closed !! when transaction is compleeted.
|
||||
* @return
|
||||
*/
|
||||
abstract EntityManager getEntityManager();
|
||||
|
||||
public void persist(Object object) throws Exception {
|
||||
EntityManager s = getEntityManager();
|
||||
try {
|
||||
s.getTransaction().begin();
|
||||
s.persist(object);
|
||||
s.getTransaction().commit();
|
||||
} finally {
|
||||
if (s!=null) {
|
||||
s.close();
|
||||
//s.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,10 +55,13 @@ abstract public class AbstractPersistenceVascBackend extends AbstractVascBackend
|
|||
public Object merge(Object object) throws Exception {
|
||||
EntityManager s = getEntityManager();
|
||||
try {
|
||||
return s.merge(object);
|
||||
s.getTransaction().begin();
|
||||
Object result = s.merge(object);
|
||||
s.getTransaction().commit();
|
||||
return result;
|
||||
} finally {
|
||||
if (s!=null) {
|
||||
s.close();
|
||||
//s.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,11 +69,13 @@ abstract public class AbstractPersistenceVascBackend extends AbstractVascBackend
|
|||
public void delete(Object object) throws Exception {
|
||||
EntityManager s = getEntityManager();
|
||||
try {
|
||||
s.getTransaction().begin();
|
||||
Object newObject = s.merge(object);
|
||||
s.remove(newObject);
|
||||
s.getTransaction().commit();
|
||||
} finally {
|
||||
if (s!=null) {
|
||||
s.close();
|
||||
//s.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2004-2008 IDCA. All rights reserved.
|
||||
* 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:
|
||||
|
@ -24,24 +24,17 @@
|
|||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.vasc.validators;
|
||||
package com.idcanet.vasc.backends.jpa;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
|
||||
/**
|
||||
* The VascValidator interface
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 5, 2008
|
||||
* @version 1.0 Mar 21, 2009
|
||||
*/
|
||||
public class VascValidatorField {
|
||||
|
||||
final private String propertyName = null;
|
||||
final private String message = null;
|
||||
final private Object value = null;
|
||||
final private Class beanClass = null;
|
||||
final private Object beanObject = null;
|
||||
public interface EntityManagerProvider {
|
||||
|
||||
public VascValidatorField() {
|
||||
|
||||
}
|
||||
public EntityManager getEntityManager();
|
||||
}
|
|
@ -64,11 +64,16 @@ public class Serv5XpqlHibernateVascBackend extends AbstractHibernateVascBackend
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> execute() throws Exception {
|
||||
// Copy parameters
|
||||
for (String key:getDataParameterKeys()) {
|
||||
Object value = getDataParameter(key);
|
||||
query.setQueryParameter(key, value);
|
||||
}
|
||||
Session s = getHibernateSession();
|
||||
try {
|
||||
Query q = s.createQuery(query.toPreparedSQL(query));
|
||||
List<QueryParameterValue> values = query.getOrderQueryParameterValues();
|
||||
int i = 0;
|
||||
int i = 1;
|
||||
for (QueryParameterValue value:values) {
|
||||
q.setParameter(i,value.getValue());
|
||||
i++;
|
||||
|
|
|
@ -0,0 +1,250 @@
|
|||
/*
|
||||
* 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.backends.jpa;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.VascException;
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
||||
import com.idcanet.x4o.element.ElementParameterHelper;
|
||||
import com.idcanet.x4o.impl.DefaultElementParameterHelper;
|
||||
import com.idcanet.xtes.xpql.query.QueryParameterValue;
|
||||
|
||||
/**
|
||||
* Manages persistance with xpql queries
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 17, 2009
|
||||
*/
|
||||
public class XpqlPersistanceVascBackend extends AbstractPersistenceVascBackend {
|
||||
|
||||
private EntityManagerProvider entityManagerProvider = null;
|
||||
|
||||
private com.idcanet.xtes.xpql.query.Query query = null;
|
||||
|
||||
private com.idcanet.xtes.xpql.query.Query queryTotal = null;
|
||||
|
||||
private Class<?> resultClass = null;
|
||||
|
||||
public XpqlPersistanceVascBackend() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.backends.jpa.AbstractPersistenceVascBackend#getEntityManager()
|
||||
*/
|
||||
@Override
|
||||
EntityManager getEntityManager() {
|
||||
return entityManagerProvider.getEntityManager();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> execute() throws Exception {
|
||||
|
||||
// Copy parameters
|
||||
for (String key:getDataParameterKeys()) {
|
||||
Object value = getDataParameter(key);
|
||||
query.setQueryParameter(key, value);
|
||||
if (queryTotal!=null) {
|
||||
queryTotal.setQueryParameter(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
//if (isPageable()) {
|
||||
//query.setQueryParameter("offset", getPageIndex());
|
||||
//query.setQueryParameter("limit", getPageSize());
|
||||
//}
|
||||
|
||||
EntityManager em = getEntityManager();
|
||||
try {
|
||||
if (queryTotal!=null) {
|
||||
Query q = em.createQuery(queryTotal.toPreparedSQL(queryTotal));
|
||||
List<QueryParameterValue> values = queryTotal.getOrderQueryParameterValues();
|
||||
int i = 1;
|
||||
for (QueryParameterValue value:values) {
|
||||
q.setParameter(i,value.getValue());
|
||||
i++;
|
||||
}
|
||||
Long resultTotal = (Long)q.getSingleResult();
|
||||
setPagesTotalRecords(resultTotal);
|
||||
}
|
||||
|
||||
Query q = em.createQuery(query.toPreparedSQL(query));
|
||||
List<QueryParameterValue> values = query.getOrderQueryParameterValues();
|
||||
int i = 1;
|
||||
for (QueryParameterValue value:values) {
|
||||
q.setParameter(i,value.getValue());
|
||||
i++;
|
||||
}
|
||||
if (isPageable()) {
|
||||
q.setFirstResult(getPageIndex());
|
||||
q.setMaxResults(getPageSize());
|
||||
}
|
||||
List<Object> data = q.getResultList();
|
||||
if (queryTotal==null) {
|
||||
setPagesTotalRecords(data.size());
|
||||
}
|
||||
return data;
|
||||
} finally {
|
||||
if (em!=null) {
|
||||
//em.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryFieldValue(com.idcanet.vasc.core.VascEntryField)
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
VascEntryFieldValue result = new VascEntryFieldValue() {
|
||||
|
||||
private ElementParameterHelper bean = new DefaultElementParameterHelper();
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#getValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object)
|
||||
*/
|
||||
public Object getValue(VascEntryField field, Object record) throws VascException {
|
||||
try {
|
||||
Object o = bean.getParameter(record,field.getBackendName());
|
||||
return o;
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.entry.VascEntryFieldValue#setValue(com.idcanet.vasc.core.VascEntryField, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void setValue(VascEntryField field, Object record,Object value) throws VascException {
|
||||
try {
|
||||
bean.setParameter(record, field.getBackendName(), value);
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryRecordCreator(com.idcanet.vasc.core.VascEntry)
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return new VascEntryRecordCreator() {
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
return resultClass;
|
||||
}
|
||||
|
||||
public Object newRecord(VascEntry entry) throws Exception {
|
||||
return resultClass.newInstance();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the query
|
||||
*/
|
||||
public com.idcanet.xtes.xpql.query.Query getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param query the query to set
|
||||
*/
|
||||
public void setQuery(com.idcanet.xtes.xpql.query.Query query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the queryTotal
|
||||
*/
|
||||
public com.idcanet.xtes.xpql.query.Query getQueryTotal() {
|
||||
return queryTotal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param queryTotal the queryTotal to set
|
||||
*/
|
||||
public void setQueryTotal(com.idcanet.xtes.xpql.query.Query queryTotal) {
|
||||
this.queryTotal = queryTotal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the resultClass
|
||||
*/
|
||||
public Class<?> getResultClass() {
|
||||
return resultClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resultClass the resultClass to set
|
||||
*/
|
||||
public void setResultClass(Class<?> resultClass) {
|
||||
this.resultClass = resultClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the entityManagerProvider
|
||||
*/
|
||||
public EntityManagerProvider getEntityManagerProvider() {
|
||||
return entityManagerProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entityManagerProvider the entityManagerProvider to set
|
||||
*/
|
||||
public void setEntityManagerProvider(EntityManagerProvider entityManagerProvider) {
|
||||
this.entityManagerProvider = entityManagerProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.AbstractVascBackend#isPageable()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPageable() {
|
||||
if (queryTotal==null) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if (query.getQueryParameterValue("offset")==null) {
|
||||
return false;
|
||||
}
|
||||
if (query.getQueryParameterValue("limit")==null) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -27,7 +27,6 @@
|
|||
package com.idcanet.vasc.backends.ldap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -94,7 +93,7 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
int searchScope = LDAPConnection.SCOPE_ONE;
|
||||
String searchBase = baseDN;
|
||||
|
||||
System.out.println("\n\tReading object :" + searchBase + " with filter: " + ldapFilter);
|
||||
//System.out.println("Reading object :" + searchBase + " with filter: " + ldapFilter);
|
||||
LDAPSearchResults searchResults = connection.search(
|
||||
searchBase, // object to read
|
||||
searchScope, // scope - read single object
|
||||
|
@ -102,18 +101,15 @@ public class LdapVascBackend extends AbstractVascBackend {
|
|||
null, // return all attributes
|
||||
false); // return attrs and values
|
||||
|
||||
System.out.println("Got object :" + searchResults.getCount());
|
||||
while (searchResults.hasMore()) {
|
||||
LDAPEntry entry = searchResults.next();
|
||||
System.out.println("We found "+entry.getDN());
|
||||
Map<String,Object> map = new HashMap<String,Object>(10);
|
||||
|
||||
LDAPAttributeSet attributeSet = entry.getAttributeSet();
|
||||
Iterator i = attributeSet.iterator();
|
||||
Iterator<LDAPAttribute> i = attributeSet.iterator();
|
||||
while (i.hasNext()) {
|
||||
LDAPAttribute attr = (LDAPAttribute)i.next();
|
||||
System.out.println("ATTR: "+attr.getName()+" value: "+attr.getStringValue());
|
||||
|
||||
LDAPAttribute attr = i.next();
|
||||
//System.out.println("ATTR: "+attr.getName()+" value: "+attr.getStringValue());
|
||||
map.put(attr.getName(), attr.getStringValueArray());
|
||||
}
|
||||
result.add(map);
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* 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.backends.meta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.idcanet.vasc.core.AbstractVascBackend;
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
||||
|
||||
import dk.eobjects.metamodel.query.Query;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 19, 2008
|
||||
*/
|
||||
public class MetaModelVascBackend extends AbstractVascBackend {
|
||||
|
||||
private Query listQuery = null;
|
||||
|
||||
// interface
|
||||
|
||||
public void delete(Object object) throws Exception {
|
||||
}
|
||||
|
||||
public List<Object> execute() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void persist(Object object) throws Exception {
|
||||
}
|
||||
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -26,7 +26,9 @@
|
|||
|
||||
package com.idcanet.vasc.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -44,6 +46,7 @@ abstract public class AbstractVascBackend implements VascBackend {
|
|||
private String sortField = null;
|
||||
private String searchString = null;
|
||||
private boolean ascending = true;
|
||||
private long pagesTotalRecords = 0;
|
||||
|
||||
public AbstractVascBackend() {
|
||||
parameters = new HashMap<String,Object>(10);
|
||||
|
@ -97,7 +100,13 @@ abstract public class AbstractVascBackend implements VascBackend {
|
|||
* @see com.idcanet.vasc.core.VascBackend#setPageIndex(int)
|
||||
*/
|
||||
public void setPageIndex(int pageIndex) {
|
||||
this.pageIndex=pageIndex;
|
||||
if (pageIndex<1) {
|
||||
pageIndex = 0;
|
||||
}
|
||||
if (pageIndex>(getPagesTotalRecords()/getPageSize())) {
|
||||
pageIndex = new Long(getPagesTotalRecords()/getPageSize()).intValue();
|
||||
}
|
||||
this.pageIndex=pageIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,20 +124,39 @@ abstract public class AbstractVascBackend implements VascBackend {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#getPagesTotal()
|
||||
* Returns the total amount of pages
|
||||
* @return
|
||||
*/
|
||||
public int getPagesTotal() {
|
||||
return 0;
|
||||
public List<VascBackendPageNumber> getVascBackendPageNumbers() {
|
||||
int pages = new Long(getPagesTotalRecords()/getPageSize()).intValue();
|
||||
List<VascBackendPageNumber> result = new ArrayList<VascBackendPageNumber>(pages);
|
||||
int counter = 0;
|
||||
for (int i=0;i<=pages;i++) {
|
||||
VascBackendPageNumber pn = new VascBackendPageNumber(i);
|
||||
if (getPageIndex()==i) {
|
||||
pn.setSelected(true);
|
||||
}
|
||||
result.add(pn);
|
||||
|
||||
counter++;
|
||||
if (counter>45) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#getPagesTotalRecords()
|
||||
*/
|
||||
public int getPagesTotalRecords() {
|
||||
return 0;
|
||||
public long getPagesTotalRecords() {
|
||||
return pagesTotalRecords;
|
||||
}
|
||||
|
||||
|
||||
protected void setPagesTotalRecords(long pagesTotalRecords) {
|
||||
this.pagesTotalRecords=pagesTotalRecords;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,233 @@
|
|||
/*
|
||||
* 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 java.util.Set;
|
||||
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||
import com.idcanet.vasc.core.entry.VascEntryRecordCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 1, 2009
|
||||
*/
|
||||
abstract public class AbstractVascBackendProxy implements VascBackend {
|
||||
|
||||
protected VascBackend backend = null;
|
||||
|
||||
public AbstractVascBackendProxy(VascBackend backend) {
|
||||
if (backend==null) {
|
||||
throw new NullPointerException("backend object mey not be null.");
|
||||
}
|
||||
this.backend=backend;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#getPagesTotalRecords()
|
||||
*/
|
||||
public long getPagesTotalRecords() {
|
||||
return backend.getPagesTotalRecords();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#isSortable()
|
||||
*/
|
||||
public boolean isSortable() {
|
||||
return backend.isSortable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#isSortAscending()
|
||||
*/
|
||||
public boolean isSortAscending() {
|
||||
return backend.isSortAscending();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#setSortAscending(boolean)
|
||||
*/
|
||||
public void setSortAscending(boolean ascending) {
|
||||
backend.setSortAscending(ascending);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#getSortField()
|
||||
*/
|
||||
public String getSortField() {
|
||||
return backend.getSortField();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#setSortField(java.lang.String)
|
||||
*/
|
||||
public void setSortField(String name) {
|
||||
backend.setSortField(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @see com.idcanet.vasc.core.VascBackend#execute()
|
||||
*/
|
||||
public List<Object> execute() throws Exception {
|
||||
return backend.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#delete(java.lang.Object)
|
||||
*/
|
||||
public void delete(Object object) throws Exception {
|
||||
backend.delete(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#getDataParameter(java.lang.String)
|
||||
*/
|
||||
public Object getDataParameter(String key) {
|
||||
return backend.getDataParameter(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#getDataParameterKeys()
|
||||
*/
|
||||
public Set<String> getDataParameterKeys() {
|
||||
return backend.getDataParameterKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#getVascBackendPageNumbers()
|
||||
*/
|
||||
public List<VascBackendPageNumber> getVascBackendPageNumbers() {
|
||||
return backend.getVascBackendPageNumbers();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#isPageable()
|
||||
*/
|
||||
public boolean isPageable() {
|
||||
return backend.isPageable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#isSearchable()
|
||||
*/
|
||||
public boolean isSearchable() {
|
||||
return backend.isSearchable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#merge(java.lang.Object)
|
||||
*/
|
||||
public Object merge(Object object) throws Exception {
|
||||
return backend.merge(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#persist(java.lang.Object)
|
||||
*/
|
||||
public void persist(Object object) throws Exception {
|
||||
backend.persist(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryFieldValue(com.idcanet.vasc.core.VascEntryField)
|
||||
*/
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
return backend.provideVascEntryFieldValue(field);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#provideVascEntryRecordCreator(com.idcanet.vasc.core.VascEntry)
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
return backend.provideVascEntryRecordCreator(vascEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#setDataParameter(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
public void setDataParameter(String key, Object data) {
|
||||
backend.setDataParameter(key, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#getId()
|
||||
*/
|
||||
public String getId() {
|
||||
return backend.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#setId(java.lang.String)
|
||||
*/
|
||||
public void setId(String id) {
|
||||
backend.setId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#getPageIndex()
|
||||
*/
|
||||
public int getPageIndex() {
|
||||
return backend.getPageIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#setPageIndex(int)
|
||||
*/
|
||||
public void setPageIndex(int index) {
|
||||
backend.setPageIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#getPageSize()
|
||||
*/
|
||||
public int getPageSize() {
|
||||
return backend.getPageSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#setPageSize(int)
|
||||
*/
|
||||
public void setPageSize(int size) {
|
||||
backend.setPageSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#getSearchString()
|
||||
*/
|
||||
public String getSearchString() {
|
||||
return backend.getSearchString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#setSearchString(java.lang.String)
|
||||
*/
|
||||
public void setSearchString(String searchString) {
|
||||
backend.setSearchString(searchString);
|
||||
}
|
||||
}
|
|
@ -42,20 +42,26 @@ import com.idcanet.vasc.validators.VascValidator;
|
|||
*/
|
||||
abstract public class AbstractVascEntryFieldType implements VascEntryFieldType {
|
||||
|
||||
private String id = null;
|
||||
private Class<?> autoDetectClass = null;
|
||||
private List<VascValidator> vascValidators = null;
|
||||
private Map<String,String> properties = null;
|
||||
protected String id = null;
|
||||
protected Class<?> autoDetectClass = null;
|
||||
protected List<VascValidator> vascValidators = null;
|
||||
protected Map<String,String> properties = null;
|
||||
|
||||
private Object dataObject = null;
|
||||
private String uiComponentId = null;
|
||||
private String inputMask = null;
|
||||
protected Object dataObject = null;
|
||||
protected String uiComponentId = null;
|
||||
protected String inputMask = null;
|
||||
|
||||
public AbstractVascEntryFieldType() {
|
||||
vascValidators = new ArrayList<VascValidator>(4);
|
||||
properties = new HashMap<String,String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
abstract public VascEntryFieldType clone() throws CloneNotSupportedException;
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascEntryFieldType#getId()
|
||||
*/
|
||||
|
|
|
@ -40,7 +40,7 @@ abstract public class AbstractVascFrontend implements VascFrontend {
|
|||
return entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key,params);
|
||||
}
|
||||
|
||||
protected VascEntry getVascEntry() {
|
||||
public VascEntry getVascEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,9 +81,13 @@ public interface VascBackend {
|
|||
* Returns the total amount of pages
|
||||
* @return
|
||||
*/
|
||||
public int getPagesTotal();
|
||||
public List<VascBackendPageNumber> getVascBackendPageNumbers();
|
||||
|
||||
public int getPagesTotalRecords();
|
||||
/**
|
||||
* Returns the total amount of records.
|
||||
* @return
|
||||
*/
|
||||
public long getPagesTotalRecords();
|
||||
|
||||
|
||||
public void setPageSize(int size);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
* 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:
|
||||
|
@ -24,28 +24,25 @@
|
|||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.vasc.annotations;
|
||||
package com.idcanet.vasc.core;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Sets the I18nToolTip(non default) an a Class property
|
||||
* Small class to wrap page number and the selected page number.
|
||||
* note: this can be removed when JSF has the combined EL.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 27, 2006
|
||||
* @version 1.0 Apr 25, 2006
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD,ElementType.TYPE})
|
||||
public @interface VascDescription {
|
||||
|
||||
/**
|
||||
* The key of the ToolTip default to "null"
|
||||
* @see com.idcanet.i18n.I18nAnnotationParser#getI18nToolTipKey(Class, String)
|
||||
* @return The key of the ToolTip
|
||||
*/
|
||||
String key() default "null";
|
||||
public class VascBackendPageNumber implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Integer pageNumber = null;
|
||||
private Boolean selected = false;
|
||||
public VascBackendPageNumber(Integer pageNumber) { this.pageNumber=pageNumber; }
|
||||
public Integer getPageNumber() { return pageNumber; }
|
||||
public Boolean getSelected() { return selected; }
|
||||
public Boolean getNotSelected() { return !selected; }
|
||||
public void setSelected(Boolean selected) { this.selected=selected; }
|
||||
}
|
|
@ -31,13 +31,13 @@ import java.util.List;
|
|||
import com.idcanet.vasc.core.actions.ColumnVascAction;
|
||||
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel;
|
||||
|
||||
/**
|
||||
*
|
||||
* TODO:
|
||||
* private List<VascUserOption> userOptions = null;
|
||||
* private List<VascListeners> listeners = null;
|
||||
* private Map<String,VascDetailView> vascLinks = null;
|
||||
* private Map<String,VascFunction> vascFunctions = null;
|
||||
*
|
||||
*
|
||||
|
@ -56,26 +56,6 @@ public interface VascEntry extends Cloneable {
|
|||
*/
|
||||
public void setId(String id);
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name);
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description);
|
||||
|
||||
/**
|
||||
* @return the helpId
|
||||
*/
|
||||
|
@ -147,44 +127,44 @@ public interface VascEntry extends Cloneable {
|
|||
public void setDisplayNameFieldId(String displayNameField);
|
||||
|
||||
/**
|
||||
* @return the vascAdmimList
|
||||
* @return the vascAdminList
|
||||
*/
|
||||
public boolean isVascAdmimList();
|
||||
public boolean isVascAdminList();
|
||||
|
||||
/**
|
||||
* @param vascAdmimList the vascAdmimList to set
|
||||
* @param vascAdminList the vascAdminList to set
|
||||
*/
|
||||
public void setVascAdmimList(boolean vascAdmimList);
|
||||
public void setVascAdminList(boolean vascAdminList);
|
||||
|
||||
/**
|
||||
* @return the vascAdmimEdit
|
||||
* @return the vascAdminEdit
|
||||
*/
|
||||
public boolean isVascAdmimEdit();
|
||||
public boolean isVascAdminEdit();
|
||||
|
||||
/**
|
||||
* @param vascAdmimEdit the vascAdmimEdit to set
|
||||
* @param vascAdminEdit the vascAdminEdit to set
|
||||
*/
|
||||
public void setVascAdmimEdit(boolean vascAdmimEdit);
|
||||
public void setVascAdminEdit(boolean vascAdminEdit);
|
||||
|
||||
/**
|
||||
* @return the vascAdmimCreate
|
||||
* @return the vascAdminCreate
|
||||
*/
|
||||
public boolean isVascAdmimCreate();
|
||||
public boolean isVascAdminCreate();
|
||||
|
||||
/**
|
||||
* @param vascAdmimCreate the vascAdmimCreate to set
|
||||
* @param vascAdminCreate the vascAdminCreate to set
|
||||
*/
|
||||
public void setVascAdmimCreate(boolean vascAdmimCreate);
|
||||
public void setVascAdminCreate(boolean vascAdminCreate);
|
||||
|
||||
/**
|
||||
* @return the vascAdmimDelete
|
||||
* @return the vascAdminDelete
|
||||
*/
|
||||
public boolean isVascAdmimDelete();
|
||||
public boolean isVascAdminDelete();
|
||||
|
||||
/**
|
||||
* @param vascAdmimDelete the vascAdmimDelete to set
|
||||
* @param vascAdminDelete the vascAdminDelete to set
|
||||
*/
|
||||
public void setVascAdmimDelete(boolean vascAdmimDelete);
|
||||
public void setVascAdminDelete(boolean vascAdminDelete);
|
||||
|
||||
/**
|
||||
* @return the vascFields
|
||||
|
@ -290,4 +270,34 @@ public interface VascEntry extends Cloneable {
|
|||
|
||||
public String getBackendId();
|
||||
public void setBackendId(String backendId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the vascDisplayOnly
|
||||
*/
|
||||
public boolean isVascDisplayOnly();
|
||||
|
||||
/**
|
||||
* @param vascDisplayOnly the vascDisplayOnly to set
|
||||
*/
|
||||
public void setVascDisplayOnly(boolean vascDisplayOnly);
|
||||
|
||||
|
||||
/**
|
||||
* @return the vascEntryFieldEventChannel
|
||||
*/
|
||||
public VascEntryFieldEventChannel getVascEntryFieldEventChannel();
|
||||
|
||||
/**
|
||||
* @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set
|
||||
*/
|
||||
public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel);
|
||||
|
||||
/**
|
||||
* Force impl to have public clone methode
|
||||
* @return
|
||||
* @throws CloneNotSupportedException
|
||||
*/
|
||||
public VascEntry clone() throws CloneNotSupportedException;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ package com.idcanet.vasc.core;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel;
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||
import com.idcanet.vasc.validators.VascValidator;
|
||||
|
||||
|
@ -40,7 +39,7 @@ import com.idcanet.vasc.validators.VascValidator;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public interface VascEntryField {
|
||||
public interface VascEntryField extends Cloneable {
|
||||
|
||||
/**
|
||||
* @return the VascEntry
|
||||
|
@ -91,17 +90,7 @@ public interface VascEntryField {
|
|||
* @param vascEntryFieldValue the vascEntryFieldValue to set
|
||||
*/
|
||||
public void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue);
|
||||
|
||||
/**
|
||||
* @return the vascEntryFieldEventChannel
|
||||
*/
|
||||
public VascEntryFieldEventChannel getVascEntryFieldEventChannel();
|
||||
|
||||
/**
|
||||
* @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set
|
||||
*/
|
||||
public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel);
|
||||
|
||||
|
||||
/**
|
||||
* @return the vascValidators
|
||||
*/
|
||||
|
@ -220,62 +209,62 @@ public interface VascEntryField {
|
|||
/**
|
||||
* @return the view
|
||||
*/
|
||||
public boolean isView();
|
||||
public Boolean getView();
|
||||
|
||||
/**
|
||||
* @param view the view to set
|
||||
*/
|
||||
public void setView(boolean view);
|
||||
public void setView(Boolean view);
|
||||
|
||||
/**
|
||||
* @return the optional
|
||||
*/
|
||||
public boolean isOptional();
|
||||
public Boolean getOptional();
|
||||
|
||||
/**
|
||||
* @param optional the optional to set
|
||||
*/
|
||||
public void setOptional(boolean optional);
|
||||
public void setOptional(Boolean optional);
|
||||
|
||||
/**
|
||||
* @return the create
|
||||
*/
|
||||
public boolean isCreate();
|
||||
public Boolean getCreate();
|
||||
|
||||
/**
|
||||
* @param create the create to set
|
||||
*/
|
||||
public void setCreate(boolean create);
|
||||
public void setCreate(Boolean create);
|
||||
|
||||
/**
|
||||
* @return the edit
|
||||
*/
|
||||
public boolean isEdit();
|
||||
public Boolean getEdit();
|
||||
|
||||
/**
|
||||
* @param edit the edit to set
|
||||
*/
|
||||
public void setEdit(boolean edit);
|
||||
public void setEdit(Boolean edit);
|
||||
|
||||
/**
|
||||
* @return the editReadOnly
|
||||
*/
|
||||
public boolean isEditReadOnly();
|
||||
public Boolean getEditReadOnly();
|
||||
|
||||
/**
|
||||
* @param editReadOnly the editReadOnly to set
|
||||
*/
|
||||
public void setEditReadOnly(boolean editReadOnly);
|
||||
public void setEditReadOnly(Boolean editReadOnly);
|
||||
|
||||
/**
|
||||
* @return the list
|
||||
*/
|
||||
public boolean isList();
|
||||
public Boolean getList();
|
||||
|
||||
/**
|
||||
* @param list the list to set
|
||||
*/
|
||||
public void setList(boolean list);
|
||||
public void setList(Boolean list);
|
||||
|
||||
/**
|
||||
* @return the rolesCreate
|
||||
|
@ -316,4 +305,82 @@ public interface VascEntryField {
|
|||
* @param rolesList the rolesList to set
|
||||
*/
|
||||
public void setRolesList(String rolesList);
|
||||
|
||||
|
||||
/**
|
||||
* @return the choicesAsRadio
|
||||
*/
|
||||
public Boolean getChoicesAsRadio();
|
||||
|
||||
/**
|
||||
* @param choicesAsRadio the choicesAsRadio to set
|
||||
*/
|
||||
public void setChoicesAsRadio(Boolean choicesAsRadio);
|
||||
|
||||
/**
|
||||
* @return the editBlank
|
||||
*/
|
||||
public Boolean getEditBlank();
|
||||
|
||||
/**
|
||||
* @param editBlank the editBlank to set
|
||||
*/
|
||||
public void setEditBlank(Boolean editBlank);
|
||||
|
||||
/**
|
||||
* @return the displayName
|
||||
*/
|
||||
public String getDisplayName();
|
||||
|
||||
/**
|
||||
* @param displayName the displayName to set
|
||||
*/
|
||||
public void setDisplayName(String displayName);
|
||||
|
||||
/**
|
||||
* @return the orderIndex
|
||||
*/
|
||||
public Integer getOrderIndex();
|
||||
|
||||
/**
|
||||
* @param orderIndex the orderIndex to set
|
||||
*/
|
||||
public void setOrderIndex(Integer orderIndex);
|
||||
|
||||
/**
|
||||
* @return the sortable
|
||||
*/
|
||||
public Boolean getSortable();
|
||||
|
||||
/**
|
||||
* @param sortable the sortable to set
|
||||
*/
|
||||
public void setSortable(Boolean sortable);
|
||||
|
||||
/**
|
||||
* @return the sumable
|
||||
*/
|
||||
public Boolean getSumable();
|
||||
|
||||
/**
|
||||
* @param sumable the sumable to set
|
||||
*/
|
||||
public void setSumable(Boolean sumable);
|
||||
|
||||
/**
|
||||
* @return the graphable
|
||||
*/
|
||||
public Boolean getGraphable();
|
||||
|
||||
/**
|
||||
* @param graphable the graphable to set
|
||||
*/
|
||||
public void setGraphable(Boolean graphable);
|
||||
|
||||
/**
|
||||
* Force impl to have public clone methode
|
||||
* @return
|
||||
* @throws CloneNotSupportedException
|
||||
*/
|
||||
public VascEntryField clone() throws CloneNotSupportedException;
|
||||
}
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 56, 2008
|
||||
*/
|
||||
public interface VascEntryFieldSet {
|
||||
public interface VascEntryFieldSet extends Cloneable {
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
|
@ -144,4 +144,11 @@ public interface VascEntryFieldSet {
|
|||
* @param vascEntryFieldIds the vascEntryFieldIds to remove
|
||||
*/
|
||||
public void removeVascEntryFieldId(String vascEntryFieldId);
|
||||
|
||||
/**
|
||||
* Force impl to have public clone methode
|
||||
* @return
|
||||
* @throws CloneNotSupportedException
|
||||
*/
|
||||
public VascEntryFieldSet clone() throws CloneNotSupportedException;
|
||||
}
|
|
@ -67,4 +67,11 @@ public interface VascEntryFieldType {
|
|||
public VascUIComponent provideLabelUIComponent(int index,VascEntryField entryField) throws VascException;
|
||||
public VascUIComponent provideEditorUIComponent(int index,VascEntryField entryField) throws VascException;
|
||||
public VascValueModel provideEditorVascValueModel(int index,VascEntryField entryField) throws VascException;
|
||||
|
||||
/**
|
||||
* Force impl to have public clone methode
|
||||
* @return
|
||||
* @throws CloneNotSupportedException
|
||||
*/
|
||||
public VascEntryFieldType clone() throws CloneNotSupportedException;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.vasc.core;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 19, 2008
|
||||
*/
|
||||
public interface VascEntryFieldTypeControllerLocal extends VascEntryFieldTypeController {
|
||||
|
||||
public void addVascEntryFieldType(VascEntryFieldType vascEntryFieldType);
|
||||
}
|
|
@ -34,5 +34,5 @@ package com.idcanet.vasc.core;
|
|||
*/
|
||||
public interface VascEventChannelController {
|
||||
|
||||
|
||||
public void publishEntryEvent(String entryId);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.vasc.core;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 19, 2008
|
||||
*/
|
||||
public interface VascEventChannelControllerLocal extends VascEventChannelController {
|
||||
|
||||
|
||||
}
|
|
@ -102,4 +102,14 @@ public interface VascFrontendData {
|
|||
public void addFieldVascUIComponents(VascEntryField field,VascUIComponent uiComponent,Object editor);
|
||||
public VascUIComponent getFieldVascUIComponent(VascEntryField field);
|
||||
public Object getFieldRealRenderer(VascEntryField field);
|
||||
|
||||
/**
|
||||
* @return the vascBackend
|
||||
*/
|
||||
public VascBackend getVascBackend();
|
||||
|
||||
/**
|
||||
* @param vascBackend the vascBackend to set
|
||||
*/
|
||||
public void setVascBackend(VascBackend vascBackend);
|
||||
}
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
package com.idcanet.vasc.core;
|
||||
|
||||
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||
import com.idcanet.vasc.core.entry.VascEntryEventListener;
|
||||
|
||||
|
||||
|
@ -36,6 +38,14 @@ import com.idcanet.vasc.core.entry.VascEntryEventListener;
|
|||
*/
|
||||
public interface VascFrontendHelper {
|
||||
|
||||
public boolean renderView(VascEntryField field);
|
||||
public boolean renderList(VascEntryField field);
|
||||
public boolean renderEdit(VascEntryField field);
|
||||
public boolean renderEditReadOnly(VascEntryField field);
|
||||
public boolean renderCreate(VascEntryField field);
|
||||
public boolean renderGlobalVascAction(GlobalVascAction action);
|
||||
public boolean renderRowVascAction(RowVascAction action);
|
||||
|
||||
public Integer getTotalColumnsWidth(VascEntry table);
|
||||
|
||||
public void refreshData(VascEntry table) throws Exception;
|
||||
|
|
|
@ -32,9 +32,34 @@ package com.idcanet.vasc.core;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 7, 2008
|
||||
*/
|
||||
public interface VascLinkEntry {
|
||||
public interface VascLinkEntry extends Cloneable {
|
||||
|
||||
public String getVascEntryName();
|
||||
public void setVascEntryName(String vascEntryName);
|
||||
public String getId();
|
||||
public void setId(String id);
|
||||
|
||||
public String getVascEntryId();
|
||||
public void setVascEntryId(String vascEntryId);
|
||||
|
||||
public String getParameterName();
|
||||
public void setParameterName(String parameterName);
|
||||
|
||||
public String getValueFieldId();
|
||||
public void setValueFieldId(String valueFieldId);
|
||||
|
||||
/**
|
||||
* @return the viewAsDetail
|
||||
*/
|
||||
public Boolean getViewAsDetail();
|
||||
|
||||
/**
|
||||
* @param viewAsDetail the viewAsDetail to set
|
||||
*/
|
||||
public void setViewAsDetail(Boolean viewAsDetail);
|
||||
|
||||
/**
|
||||
* Force impl to have public clone methode
|
||||
* @return
|
||||
* @throws CloneNotSupportedException
|
||||
*/
|
||||
public VascLinkEntry clone() throws CloneNotSupportedException;
|
||||
}
|
|
@ -41,4 +41,6 @@ public interface VascUserRoleController {
|
|||
public String getUserName();
|
||||
|
||||
public List<String> getUserRoles();
|
||||
|
||||
public boolean hasRole(String roles);
|
||||
}
|
|
@ -35,29 +35,63 @@ package com.idcanet.vasc.core.actions;
|
|||
*/
|
||||
abstract public class AbstractVascAction implements VascAction {
|
||||
|
||||
private String id = null;
|
||||
private String name = null;
|
||||
private String toolTip = null;
|
||||
private String image = null;
|
||||
private String helpId = null;
|
||||
|
||||
|
||||
public VascAction clone() throws CloneNotSupportedException {
|
||||
VascAction action;
|
||||
try {
|
||||
action = this.getClass().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new CloneNotSupportedException("Could not create action from myClass: "+e.getMessage());
|
||||
}
|
||||
action.setId(id);
|
||||
action.setName(name);
|
||||
action.setToolTip(toolTip);
|
||||
action.setImage(image);
|
||||
action.setHelpId(helpId);
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.actions.VascAction#getId()
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.actions.VascAction#setId(java.lang.String)
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id=id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the toolTip
|
||||
*/
|
||||
public String getToolTip() {
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param toolTip the toolTip to set
|
||||
*/
|
||||
|
|
|
@ -35,5 +35,7 @@ import com.idcanet.vasc.core.VascEntry;
|
|||
*/
|
||||
public interface RowVascAction extends VascAction {
|
||||
|
||||
public boolean isMultiRowAction();
|
||||
|
||||
public void doRowAction(VascEntry vascEntry,Object rowObject) throws Exception;
|
||||
}
|
|
@ -31,7 +31,11 @@ package com.idcanet.vasc.core.actions;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public interface VascAction {
|
||||
public interface VascAction extends Cloneable {
|
||||
|
||||
public String getId();
|
||||
|
||||
public void setId(String id);
|
||||
|
||||
public String getName();
|
||||
|
||||
|
@ -48,4 +52,11 @@ public interface VascAction {
|
|||
public String getHelpId();
|
||||
|
||||
public void setHelpId(String helpId);
|
||||
|
||||
/**
|
||||
* Force impl to have public clone methode
|
||||
* @return
|
||||
* @throws CloneNotSupportedException
|
||||
*/
|
||||
public VascAction clone() throws CloneNotSupportedException;
|
||||
}
|
|
@ -27,6 +27,7 @@
|
|||
package com.idcanet.vasc.core.entry;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
|
||||
|
@ -36,7 +37,7 @@ import com.idcanet.vasc.core.VascEntry;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 May 19, 2007
|
||||
*/
|
||||
public interface VascEntryExporter {
|
||||
public interface VascEntryExporter extends Serializable {
|
||||
|
||||
public void doExport(OutputStream out,VascEntry vascEntry) throws Exception;
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ public class VascSelectItem {
|
|||
|
||||
private String label = null;
|
||||
private Object value = null;
|
||||
private String keyValue = null;
|
||||
private boolean disabled = false;
|
||||
|
||||
public VascSelectItem() {
|
||||
|
||||
|
@ -43,7 +45,11 @@ public class VascSelectItem {
|
|||
setLabel(label);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
public VascSelectItem(String label,Object value,String keyValue) {
|
||||
setLabel(label);
|
||||
setValue(value);
|
||||
setKeyValue(keyValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the label
|
||||
|
@ -72,4 +78,32 @@ public class VascSelectItem {
|
|||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the keyValue
|
||||
*/
|
||||
public String getKeyValue() {
|
||||
return keyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyValue the keyValue to set
|
||||
*/
|
||||
public void setKeyValue(String keyValue) {
|
||||
this.keyValue = keyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the disabled
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return disabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param disabled the disabled to set
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
this.disabled = disabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ package com.idcanet.vasc.core.ui;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
|
@ -35,5 +38,5 @@ import java.util.List;
|
|||
*/
|
||||
public interface VascSelectItemModel {
|
||||
|
||||
public List<VascSelectItem> getVascSelectItems();
|
||||
public List<VascSelectItem> getVascSelectItems(VascEntry entry) throws VascException;
|
||||
}
|
|
@ -114,7 +114,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
|
||||
// optional UI components
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_BOOLEAN , SwingBoolean.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_DATE , SwingDate.class.getName());
|
||||
//vfd.putVascUIComponent(VascUIComponent.VASC_DATE , SwingDate.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_TEXTAREA, SwingTextArea.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_COLOR, SwingColorChooser.class.getName());
|
||||
}
|
||||
|
@ -172,13 +172,13 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
|
||||
public void renderDelete(Object rowBean) throws Exception {
|
||||
String beanValue = rowBean.toString();
|
||||
if (entry.getDisplayNameFieldId()!=null) {
|
||||
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
|
||||
beanValue = ""+v.getVascEntryFieldValue().getValue(v, rowBean);
|
||||
if (beanValue.length()>30) {
|
||||
beanValue=beanValue.substring(0, 30);
|
||||
}
|
||||
|
||||
VascEntryField v = entry.getVascEntryFieldById(entry.getDisplayNameFieldId());
|
||||
beanValue = ""+v.getVascEntryFieldValue().getValue(v, rowBean);
|
||||
if (beanValue.length()>30) {
|
||||
beanValue=beanValue.substring(0, 30);
|
||||
}
|
||||
|
||||
int response = JOptionPane.showOptionDialog(
|
||||
parent // Center in window.
|
||||
, i18n("vasc.dialog.delete.message",beanValue) // Message
|
||||
|
@ -190,7 +190,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
, null // Default button's label
|
||||
);
|
||||
if (response==JOptionPane.YES_OPTION) {
|
||||
entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()).delete(rowBean);
|
||||
entry.getVascFrontendData().getVascBackend().delete(rowBean);
|
||||
entry.getVascFrontendData().getEntryDataList().remove(rowBean);
|
||||
entry.getVascFrontendData().setEntryDataObject(null);
|
||||
//entry.getVascFrontendController().getVascFrontendHelper().fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, rowBean);
|
||||
|
@ -261,7 +261,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
int column = 0;
|
||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().initEditObjectColumn(c, bean);
|
||||
if (c.isEdit()==false) {
|
||||
if (c.getEdit()==false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -466,7 +466,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
TableCellRenderer renderer = new JComponentTableHeaderCellRenderer();
|
||||
int counter=0;
|
||||
for(VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (c.isList()==false) {
|
||||
if (c.getList()==false) {
|
||||
continue;
|
||||
}
|
||||
TableColumn t = new TableColumn();
|
||||
|
@ -619,7 +619,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
public int getColumnCount() {
|
||||
int result = 0;
|
||||
for(VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (c.isList()==false) {
|
||||
if (c.getList()==false) {
|
||||
continue;
|
||||
}
|
||||
result++;
|
||||
|
@ -647,7 +647,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
// TODO: this is slowing....
|
||||
List<VascEntryField> list = new ArrayList<VascEntryField>();
|
||||
for(VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (c.isList()==false) {
|
||||
if (c.getList()==false) {
|
||||
continue;
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class SwingDate implements VascUIComponent {
|
|||
|
||||
private DatePicker datePicker = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
datePicker = new DatePicker();
|
||||
orgBackgroundColor = datePicker.getBackground();
|
||||
|
|
|
@ -60,7 +60,7 @@ public class SwingList implements VascUIComponent {
|
|||
if (items==null) {
|
||||
comboBox = new JComboBox();
|
||||
} else {
|
||||
comboBox = new JComboBox(items.getVascSelectItems().toArray());
|
||||
comboBox = new JComboBox(items.getVascSelectItems(table).toArray());
|
||||
}
|
||||
orgBackgroundColor = comboBox.getBackground();
|
||||
((JComponent)gui).add(comboBox);
|
||||
|
|
|
@ -28,6 +28,7 @@ package com.idcanet.vasc.frontends.swing.ui;
|
|||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
|
@ -51,6 +52,8 @@ public class SwingTextArea implements VascUIComponent {
|
|||
|
||||
public Object createComponent(VascEntry entry,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
textArea = new JTextArea();
|
||||
textArea.setBorder(BorderFactory.createEtchedBorder());
|
||||
textArea.setRows(8);
|
||||
|
||||
//entryField.getVascEntryFieldType().getProperty(name)
|
||||
|
||||
|
|
|
@ -70,10 +70,14 @@ import com.idcanet.vasc.core.VascFrontendData;
|
|||
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||
import com.idcanet.vasc.core.entry.VascEntryExporter;
|
||||
import com.idcanet.vasc.core.ui.VascColumnValueModelListener;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.frontends.swing.ui.SwingLabel;
|
||||
import com.idcanet.vasc.frontends.swing.ui.SwingList;
|
||||
import com.idcanet.vasc.frontends.swing.ui.SwingText;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
import com.idcanet.vasc.frontends.swt.ui.SwtBoolean;
|
||||
import com.idcanet.vasc.frontends.swt.ui.SwtButton;
|
||||
import com.idcanet.vasc.frontends.swt.ui.SwtLabel;
|
||||
import com.idcanet.vasc.frontends.swt.ui.SwtText;
|
||||
import com.idcanet.vasc.frontends.swt.ui.SwtTextArea;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -97,15 +101,15 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
VascFrontendData vfd = getVascEntry().getVascFrontendData();
|
||||
|
||||
// required UI components
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_LABEL,SwingLabel.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_TEXT, SwingText.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_LIST, SwingList.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_LABEL,SwtLabel.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_TEXT, SwtText.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_BUTTON, SwtButton.class.getName());
|
||||
|
||||
// optional UI components
|
||||
//vfd.putVascUIComponent(VascUIComponent.VASC_BOOLEAN , SwingBoolean.class.getName());
|
||||
//vfd.putVascUIComponent(VascUIComponent.VASC_DATE , SwingDate.class.getName());
|
||||
//vfd.putVascUIComponent(VascUIComponent.VASC_TEXTAREA, SwingTextArea.class.getName());
|
||||
//vfd.putVascUIComponent(VascUIComponent.VASC_COLOR, SwingColorChooser.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_BOOLEAN , SwtBoolean.class.getName());
|
||||
//vfd.putVascUIComponent(VascUIComponent.VASC_DATE , SwtDate.class.getName());
|
||||
vfd.putVascUIComponent(VascUIComponent.VASC_TEXTAREA, SwtTextArea.class.getName());
|
||||
//vfd.putVascUIComponent(VascUIComponent.VASC_COLOR, SwtColorChooser.class.getName());
|
||||
}
|
||||
|
||||
|
||||
|
@ -143,7 +147,8 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
public void renderEdit(Object object) throws Exception {
|
||||
|
||||
logger.fine("Rending Edit View");
|
||||
entry.getVascFrontendData().getVascFrontendHelper().initEditObject(entry, object);
|
||||
|
||||
object = entry.getVascFrontendData().getVascFrontendHelper().initEditObject(entry, object);
|
||||
|
||||
SwtVascEditDialog dialog = new SwtVascEditDialog(Display.getCurrent().getActiveShell(),object,"Vasc Edit","Edit");
|
||||
Object result = dialog.open();
|
||||
|
@ -237,7 +242,12 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
footer.setLayoutData(new GridData(SWT.NONE));
|
||||
|
||||
//createHeader(header);
|
||||
createBody(body);
|
||||
try {
|
||||
createBody(body);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
//createFooter(footer);
|
||||
|
||||
// should be last
|
||||
|
@ -257,45 +267,35 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void createBody(Composite body) {
|
||||
public void createBody(Composite body) throws Exception {
|
||||
body.setLayout(new GridLayout(2, true));
|
||||
body.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
for(VascEntryField c:entry.getVascEntryFields()) {
|
||||
Label l = new Label(body, SWT.WRAP);
|
||||
l.setText(i18n(c.getName()));
|
||||
|
||||
if(c.getDescription()!=null) {
|
||||
l.setToolTipText(i18n(c.getDescription()));
|
||||
}
|
||||
|
||||
try {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().initEditObjectColumn(c, bean);
|
||||
|
||||
//if(c.getVascColumnEditor()==null) {
|
||||
Label valueLabel = new Label(body, SWT.WRAP);
|
||||
valueLabel.setText(""+c.getVascEntryFieldValue().getValue(c, bean));
|
||||
//c.setColumnEditor(valueLabel);
|
||||
/*
|
||||
} else {
|
||||
c.setColumnEditor(c.getVascColumnEditor().createColumnEditor(c,bean,body));
|
||||
}
|
||||
*/
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"Error making column editor: '"+c.getVascEntryFieldValue()+"' error: "+e.getMessage(),e);
|
||||
}
|
||||
|
||||
/*
|
||||
if(c.getColumnEditor() instanceof Control) {
|
||||
Control editor = (Control)c.getColumnEditor();
|
||||
GridData gridData = new GridData();
|
||||
gridData.grabExcessHorizontalSpace = true;
|
||||
gridData.grabExcessVerticalSpace = true;
|
||||
gridData.horizontalAlignment = GridData.FILL;
|
||||
gridData.verticalAlignment = GridData.FILL;
|
||||
editor.setLayoutData(gridData);
|
||||
}
|
||||
*/
|
||||
|
||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().initEditObjectColumn(c, bean);
|
||||
if (c.getEdit()==false) {
|
||||
continue;
|
||||
}
|
||||
//if (c.isEditReadOnly()==true) {
|
||||
|
||||
for (int i=0;i<c.getVascEntryFieldType().getUIComponentCount(c);i++) {
|
||||
|
||||
VascUIComponent label = c.getVascEntryFieldType().provideLabelUIComponent(i,c);
|
||||
VascValueModel model = new VascValueModel();
|
||||
model.setValue(i18n(c.getName()));
|
||||
label.createComponent(entry,c,model,body);
|
||||
|
||||
VascUIComponent editor = c.getVascEntryFieldType().provideEditorUIComponent(i,c);
|
||||
model = new VascValueModel(c.getVascEntryFieldType().provideEditorVascValueModel(i,c));
|
||||
model.setValue(c.getVascEntryFieldValue().getValue(c, bean));
|
||||
model.addListener(new VascColumnValueModelListener(c,bean));
|
||||
Object g = editor.createComponent(entry,c,model,body);
|
||||
|
||||
if (i==0) {
|
||||
entry.getVascFrontendData().addFieldVascUIComponents(c, editor,g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// create some spaceing , should replace by seperator
|
||||
|
@ -591,6 +591,7 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
logger.fine("Table with columns created: "+table2.getColumnCount());
|
||||
|
||||
tableViewer.setInput(entry);
|
||||
tableViewer.refresh();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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.frontends.swt.ui;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 13, 2009
|
||||
*/
|
||||
public class SwtBoolean implements VascUIComponent {
|
||||
|
||||
private Button button = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
private Color errorColor = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
button = new Button((Composite)gui, SWT.CHECK);
|
||||
orgBackgroundColor = button.getBackground();
|
||||
errorColor = new Color(((Composite)gui).getDisplay(),255,0,0);
|
||||
//button.setImage(getImageDescriptor("vasc.dialog.save.image").createImage());
|
||||
button.setText(model.getValue()+"");
|
||||
//button.setToolTipText(i18n("vasc.dialog.save.tooltip"));
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
}
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (button==null) {
|
||||
return null;
|
||||
}
|
||||
return button.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (button==null) {
|
||||
return;
|
||||
}
|
||||
button.setToolTipText(text);
|
||||
if (text==null) {
|
||||
button.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
button.setBackground(errorColor);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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.frontends.swt.ui;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 13, 2009
|
||||
*/
|
||||
public class SwtButton implements VascUIComponent {
|
||||
|
||||
private Button button = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
private Color errorColor = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
button = new Button((Composite)gui, SWT.NONE);
|
||||
orgBackgroundColor = button.getBackground();
|
||||
errorColor = new Color(((Composite)gui).getDisplay(),255,0,0);
|
||||
//button.setImage(getImageDescriptor("vasc.dialog.save.image").createImage());
|
||||
button.setText(model.getValue()+"");
|
||||
//button.setToolTipText(i18n("vasc.dialog.save.tooltip"));
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
}
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (button==null) {
|
||||
return null;
|
||||
}
|
||||
return button.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (button==null) {
|
||||
return;
|
||||
}
|
||||
button.setToolTipText(text);
|
||||
if (text==null) {
|
||||
button.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
button.setBackground(errorColor);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* 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.frontends.swt.ui;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 13, 2009
|
||||
*/
|
||||
public class SwtLabel implements VascUIComponent {
|
||||
|
||||
private Label label = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
private Color errorColor = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
label = new Label((Composite)gui, SWT.NONE);
|
||||
orgBackgroundColor = label.getBackground();
|
||||
errorColor = new Color(((Composite)gui).getDisplay(),255,0,0);
|
||||
label.setText(model.getValue()+"");
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (label==null) {
|
||||
return null;
|
||||
}
|
||||
return label.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (label==null) {
|
||||
return;
|
||||
}
|
||||
label.setToolTipText(text);
|
||||
if (text==null) {
|
||||
label.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
label.setBackground(errorColor);
|
||||
}
|
||||
}
|
||||
}
|
93
src/main/java/com/idcanet/vasc/frontends/swt/ui/SwtText.java
Normal file
93
src/main/java/com/idcanet/vasc/frontends/swt/ui/SwtText.java
Normal file
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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.frontends.swt.ui;
|
||||
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 13, 2009
|
||||
*/
|
||||
public class SwtText implements VascUIComponent {
|
||||
|
||||
private Text text = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
private Color errorColor = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
text = new Text((Composite)gui, SWT.NONE);
|
||||
orgBackgroundColor = text.getBackground();
|
||||
errorColor = new Color(((Composite)gui).getDisplay(),255,0,0);
|
||||
text.setText(model.getValue()+"");
|
||||
text.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
}
|
||||
});
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (text==null) {
|
||||
return null;
|
||||
}
|
||||
return text.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (text==null) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
text.setToolTipText(text);
|
||||
if (text==null) {
|
||||
text.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
text.setBackground(errorColor);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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.frontends.swt.ui;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 13, 2009
|
||||
*/
|
||||
public class SwtTextArea implements VascUIComponent {
|
||||
|
||||
private Text text = null;
|
||||
private Color orgBackgroundColor = null;
|
||||
private Color errorColor = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
text = new Text((Composite)gui, SWT.MULTI);
|
||||
orgBackgroundColor = text.getBackground();
|
||||
errorColor = new Color(((Composite)gui).getDisplay(),255,0,0);
|
||||
text.setText(model.getValue()+"");
|
||||
text.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
}
|
||||
});
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
if (text==null) {
|
||||
return null;
|
||||
}
|
||||
return text.getToolTipText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (text==null) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
text.setToolTipText(text);
|
||||
if (text==null) {
|
||||
text.setBackground(orgBackgroundColor);
|
||||
} else {
|
||||
text.setBackground(errorColor);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package com.idcanet.vasc.frontends.web.jsf;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author willemc
|
||||
*
|
||||
*/
|
||||
public class VascActionBean {
|
||||
|
||||
private String searchString = null;
|
||||
private Map<String,Object> values = new HashMap<String,Object>(10);
|
||||
|
||||
|
||||
/**
|
||||
* @return the searchString
|
||||
*/
|
||||
public String getSearchString() {
|
||||
return searchString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param searchString the searchString to set
|
||||
*/
|
||||
public void setSearchString(String searchString) {
|
||||
this.searchString = searchString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the values
|
||||
*/
|
||||
public Map<String, Object> getValues() {
|
||||
return values;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* 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.frontends.web.jsf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.faces.FactoryFinder;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.FacesContextFactory;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import javax.faces.lifecycle.LifecycleFactory;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Parses the Request info path info 3 vasc attributes an dispatches the request to the templateFile.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2009
|
||||
*/
|
||||
public class VascRequestFacesFilter implements Filter {
|
||||
|
||||
private static final long serialVersionUID = 10l;
|
||||
private Logger logger = null;
|
||||
private String templateFile = null;
|
||||
private ServletContext servletContext = null;
|
||||
|
||||
/**
|
||||
* @see javax.servlet.Filter#destroy()
|
||||
*/
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
|
||||
*/
|
||||
public void init(FilterConfig config) throws ServletException {
|
||||
logger = Logger.getLogger(VascRequestFacesFilter.class.getName());
|
||||
templateFile=config.getInitParameter("templateFile");
|
||||
if (templateFile==null) {
|
||||
throw new ServletException("No templateFile init-param found.");
|
||||
}
|
||||
servletContext=config.getServletContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
|
||||
*/
|
||||
public void doFilter(ServletRequest servletRequest,ServletResponse servletResponse,FilterChain chain) throws IOException, ServletException {
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest)servletRequest;
|
||||
HttpServletResponse response = (HttpServletResponse)servletResponse;
|
||||
|
||||
// request info
|
||||
String path = request.getRequestURI();
|
||||
String v = "/vasc/";
|
||||
if (path.contains(v)) {
|
||||
path = path.substring(path.indexOf(v)+v.length());
|
||||
}
|
||||
|
||||
// stuff to fill
|
||||
String entityName = null;
|
||||
String actionName = null;
|
||||
String actionRecordId = null;
|
||||
|
||||
// parse request info
|
||||
//path = path.substring(1); // rm /
|
||||
int index = path.indexOf("/"); // check next /
|
||||
String actionString = null;
|
||||
if (index>0) {
|
||||
actionString = path.substring(index+1);
|
||||
entityName = path.substring(0,index);
|
||||
} else {
|
||||
entityName = path;
|
||||
}
|
||||
|
||||
if (actionString!=null) {
|
||||
index = actionString.indexOf("/");
|
||||
String recordString = null;
|
||||
if (index>0) {
|
||||
recordString = actionString.substring(index+1);
|
||||
actionName = actionString.substring(0,index);
|
||||
} else {
|
||||
actionName = actionString;
|
||||
}
|
||||
if (recordString!=null) {
|
||||
actionRecordId = recordString;
|
||||
}
|
||||
}
|
||||
|
||||
//log
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.log(Level.INFO,"entityName="+entityName+" actionName="+actionName+" actionRecordId="+actionRecordId);
|
||||
}
|
||||
|
||||
// add to response
|
||||
request.setAttribute("requestScopeVascEntityName", entityName);
|
||||
request.setAttribute("requestScopeVascActionName", actionName);
|
||||
request.setAttribute("requestScopeVascRecordId" , actionRecordId);
|
||||
|
||||
// Acquire the FacesContext instance for this request
|
||||
FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||
if (facesContext == null) {
|
||||
logger.info("Creating new context");
|
||||
FacesContextFactory facesContextFactory = (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
|
||||
LifecycleFactory lifecycleFactory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
|
||||
Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
|
||||
|
||||
facesContext = facesContextFactory.getFacesContext(servletContext, request, response, lifecycle);
|
||||
ProtectedFacesContext.setFacesContextAsCurrentInstance(facesContext);
|
||||
|
||||
|
||||
UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext,entityName+actionName);
|
||||
facesContext.setViewRoot(viewRoot);
|
||||
logger.info("view Root: "+viewRoot);
|
||||
}
|
||||
request.getRequestDispatcher(templateFile).include(request, response);
|
||||
// done
|
||||
}
|
||||
private abstract static class ProtectedFacesContext extends FacesContext {
|
||||
protected static void setFacesContextAsCurrentInstance(FacesContext facesContext) {
|
||||
FacesContext.setCurrentInstance(facesContext);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -26,13 +26,11 @@
|
|||
|
||||
package com.idcanet.vasc.frontends.web.jsf;
|
||||
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIComponentBase;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
import javax.faces.render.Renderer;
|
||||
import javax.faces.webapp.UIComponentTag;
|
||||
import javax.faces.webapp.UIComponentELTag;
|
||||
import javax.servlet.jsp.JspException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -40,40 +38,113 @@ import javax.faces.webapp.UIComponentTag;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 16, 2008
|
||||
*/
|
||||
public class VascUIComponentTag extends UIComponentTag {
|
||||
public class VascUIComponentTag extends UIComponentELTag {
|
||||
|
||||
protected ValueExpression bar;
|
||||
private ValueExpression vascController = null;
|
||||
private ValueExpression vascFrontendData = null;
|
||||
private ValueExpression entryName = null;
|
||||
private ValueExpression bundleName = null;
|
||||
private ValueExpression locale = null;
|
||||
|
||||
/**
|
||||
* @see javax.faces.webapp.UIComponentELTag#setProperties(javax.faces.component.UIComponent)
|
||||
*/
|
||||
@Override
|
||||
protected void setProperties(UIComponent comp) {
|
||||
super.setProperties(comp);
|
||||
VascUIComponent component = (VascUIComponent)comp;
|
||||
component.setVascController(vascController);
|
||||
component.setEntryName(entryName);
|
||||
component.setVascFrontendData(vascFrontendData);
|
||||
component.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.webapp.UIComponentClassicTagBase#doStartTag()
|
||||
*/
|
||||
@Override
|
||||
public int doStartTag() throws JspException {
|
||||
int result = super.doStartTag();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return VascUIComponent.COMPONENT_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRendererType() {
|
||||
return VascUIComponent.COMPONENT_TYPE;
|
||||
return null;
|
||||
}
|
||||
|
||||
public ValueExpression getBar() {
|
||||
return bar;
|
||||
}
|
||||
|
||||
protected void setProperties(UIComponent component) {
|
||||
super.setProperties(component);
|
||||
VascUIComponent download = null;
|
||||
try {
|
||||
//foo = (VascUIComponent) component;
|
||||
} catch (ClassCastException cce) {
|
||||
throw new IllegalStateException("Component " + component.toString() +
|
||||
" not expected type. Expected: com.foo.Foo. Perhaps you're missing a tag?");
|
||||
}
|
||||
|
||||
if (bar != null) {
|
||||
//foo.setValueExpression("bar", bar);
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
super.release();
|
||||
bar = null;
|
||||
/**
|
||||
* @return the vascController
|
||||
*/
|
||||
public ValueExpression getVascController() {
|
||||
return vascController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascController the vascController to set
|
||||
*/
|
||||
public void setVascController(ValueExpression vascController) {
|
||||
this.vascController = vascController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the entryName
|
||||
*/
|
||||
public ValueExpression getEntryName() {
|
||||
return entryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entryName the entryName to set
|
||||
*/
|
||||
public void setEntryName(ValueExpression entryName) {
|
||||
this.entryName = entryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bundleName
|
||||
*/
|
||||
public ValueExpression getBundleName() {
|
||||
return bundleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bundleName the bundleName to set
|
||||
*/
|
||||
public void setBundleName(ValueExpression bundleName) {
|
||||
this.bundleName = bundleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the locale
|
||||
*/
|
||||
public ValueExpression getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param locale the locale to set
|
||||
*/
|
||||
public void setLocale(ValueExpression locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascFrontendData
|
||||
*/
|
||||
public ValueExpression getVascFrontendData() {
|
||||
return vascFrontendData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascFrontendData the vascFrontendData to set
|
||||
*/
|
||||
public void setVascFrontendData(ValueExpression vascFrontendData) {
|
||||
this.vascFrontendData = vascFrontendData;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* 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.frontends.web.jsf.ui;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlSelectBooleanCheckbox;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 28, 2009
|
||||
*/
|
||||
public class JSFBoolean implements VascUIComponent {
|
||||
|
||||
private HtmlSelectBooleanCheckbox component = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
Application application = FacesContext.getCurrentInstance().getApplication();
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
component = (HtmlSelectBooleanCheckbox)application.createComponent(HtmlSelectBooleanCheckbox.COMPONENT_TYPE);
|
||||
component.setId(viewRoot.createUniqueId());
|
||||
if (entryField.getEditReadOnly()) {
|
||||
component.setDisabled(true);
|
||||
}
|
||||
((UIComponent)gui).getChildren().add(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* 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.frontends.web.jsf.ui;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlOutputText;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 25, 2009
|
||||
*/
|
||||
public class JSFLabel implements VascUIComponent {
|
||||
|
||||
private HtmlOutputText component = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
Application application = FacesContext.getCurrentInstance().getApplication();
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
component = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
component.setId(viewRoot.createUniqueId());
|
||||
component.setValue(""+model.getValue());
|
||||
((UIComponent)gui).getChildren().add(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
}
|
||||
}
|
167
src/main/java/com/idcanet/vasc/frontends/web/jsf/ui/JSFList.java
Normal file
167
src/main/java/com/idcanet/vasc/frontends/web/jsf/ui/JSFList.java
Normal file
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* 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.frontends.web.jsf.ui;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UISelectItems;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlSelectOneMenu;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
import javax.faces.convert.ConverterException;
|
||||
import javax.faces.model.SelectItem;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.ui.VascSelectItem;
|
||||
import com.idcanet.vasc.core.ui.VascSelectItemModel;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 28, 2009
|
||||
*/
|
||||
public class JSFList implements VascUIComponent {
|
||||
|
||||
private HtmlSelectOneMenu component = null;
|
||||
|
||||
public Object createComponent(VascEntry entry,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
Application application = FacesContext.getCurrentInstance().getApplication();
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
component = (HtmlSelectOneMenu)application.createComponent(HtmlSelectOneMenu.COMPONENT_TYPE);
|
||||
component.setId(viewRoot.createUniqueId());
|
||||
if (entryField.getEditReadOnly()) {
|
||||
component.setDisabled(true);
|
||||
}
|
||||
|
||||
VascSelectItemModel itemModel = (VascSelectItemModel)entryField.getVascEntryFieldType().getDataObject();
|
||||
List<VascSelectItem> items = itemModel.getVascSelectItems(entry);
|
||||
|
||||
String id = entry.getId()+"_"+entryField.getId();
|
||||
((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true)).setAttribute(id, items);
|
||||
component.setConverter(new VascConverter(id));
|
||||
|
||||
List<SelectItem> value = new ArrayList<SelectItem>(50);
|
||||
for (VascSelectItem v:items) {
|
||||
SelectItem si = new SelectItem();
|
||||
si.setLabel(v.getLabel());
|
||||
si.setValue(v.getValue());
|
||||
si.setDisabled(v.isDisabled());
|
||||
value.add(si);
|
||||
}
|
||||
UISelectItems item = (UISelectItems)application.createComponent(UISelectItems.COMPONENT_TYPE);
|
||||
item.setId(viewRoot.createUniqueId());
|
||||
item.setValue(value);
|
||||
component.getChildren().add(item);
|
||||
|
||||
((UIComponent)gui).getChildren().add(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (text==null) {
|
||||
return;
|
||||
}
|
||||
FacesMessage message = new FacesMessage(text);
|
||||
message.setSeverity(FacesMessage.SEVERITY_ERROR);
|
||||
FacesContext.getCurrentInstance().addMessage(component.getId(),message);
|
||||
}
|
||||
}
|
||||
class VascConverter implements Converter,Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6198813637409531713L;
|
||||
private String id = null;
|
||||
|
||||
public VascConverter(String id) {
|
||||
this.id=id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert an ID to an Object
|
||||
*/
|
||||
public Object getAsObject(FacesContext context,UIComponent component,String value) throws ConverterException {
|
||||
//System.out.println("getAsObject: "+component+" value: "+value);
|
||||
if (context == null) { throw new NullPointerException("context may not be null"); }
|
||||
if (component == null) { throw new NullPointerException("component may not be null"); }
|
||||
if (value == null) { return null; }
|
||||
if ((value=value.trim()).length() == 0) { return null; }
|
||||
|
||||
List<VascSelectItem> items = (List<VascSelectItem>)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true)).getAttribute(id);
|
||||
for (VascSelectItem v:items) {
|
||||
//System.out.println("Check: "+value+" key: "+v.getKeyValue());
|
||||
if (value.equals(v.getKeyValue())) {
|
||||
//System.out.println("FOUND VALUE");
|
||||
return v.getValue();
|
||||
}
|
||||
}
|
||||
throw new ConverterException("Could not convert value: "+value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an Object to an ID.
|
||||
*/
|
||||
public String getAsString(FacesContext context,UIComponent component,Object value) throws ConverterException {
|
||||
//System.out.println("getAsString: "+component+" value: "+value);
|
||||
if (context == null) { throw new NullPointerException("context may not be null"); }
|
||||
if (component == null) { throw new NullPointerException("component may not be null"); }
|
||||
if (value == null) { return ""; }
|
||||
|
||||
List<VascSelectItem> items = (List<VascSelectItem>)((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true)).getAttribute(id);
|
||||
for (VascSelectItem v:items) {
|
||||
//System.out.println("Check: "+value+" key: "+v.getKeyValue());
|
||||
if (value.equals(v.getValue())) {
|
||||
//System.out.println("FOUND");
|
||||
return v.getKeyValue();
|
||||
}
|
||||
}
|
||||
throw new ConverterException("Could not convert value: "+value);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* 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.frontends.web.jsf.ui;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlInputText;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 25, 2009
|
||||
*/
|
||||
public class JSFText implements VascUIComponent {
|
||||
|
||||
private HtmlInputText component = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
Application application = FacesContext.getCurrentInstance().getApplication();
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
component = (HtmlInputText)application.createComponent(HtmlInputText.COMPONENT_TYPE);
|
||||
component.setId(viewRoot.createUniqueId());
|
||||
Integer sizeEdit = entryField.getSizeEdit();
|
||||
if (sizeEdit!=null) {
|
||||
component.setSize(sizeEdit);
|
||||
}
|
||||
if (entryField.getEditReadOnly()) {
|
||||
component.setDisabled(true);
|
||||
}
|
||||
((UIComponent)gui).getChildren().add(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (text==null) {
|
||||
return;
|
||||
}
|
||||
FacesMessage message = new FacesMessage(text);
|
||||
message.setSeverity(FacesMessage.SEVERITY_ERROR);
|
||||
FacesContext.getCurrentInstance().addMessage(component.getId(),message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* 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.frontends.web.jsf.ui;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlInputTextarea;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
import com.idcanet.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 25, 2009
|
||||
*/
|
||||
public class JSFTextArea implements VascUIComponent {
|
||||
|
||||
private HtmlInputTextarea component = null;
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws Exception {
|
||||
Application application = FacesContext.getCurrentInstance().getApplication();
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
component = (HtmlInputTextarea)application.createComponent(HtmlInputTextarea.COMPONENT_TYPE);
|
||||
component.setId(viewRoot.createUniqueId());
|
||||
if (entryField.getEditReadOnly()) {
|
||||
component.setDisabled(true);
|
||||
}
|
||||
String cols = entryField.getVascEntryFieldType().getProperty("editor.columns");
|
||||
if (cols!=null && "".equals(cols)==false) {
|
||||
component.setCols(new Integer(cols));
|
||||
}
|
||||
String rows = entryField.getVascEntryFieldType().getProperty("editor.rows");
|
||||
if (rows!=null && "".equals(rows)==false) {
|
||||
component.setRows(new Integer(rows));
|
||||
}
|
||||
((UIComponent)gui).getChildren().add(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
if (text==null) {
|
||||
return;
|
||||
}
|
||||
FacesMessage message = new FacesMessage(text);
|
||||
message.setSeverity(FacesMessage.SEVERITY_ERROR);
|
||||
FacesContext.getCurrentInstance().addMessage(component.getId(),message);
|
||||
}
|
||||
}
|
|
@ -26,6 +26,9 @@
|
|||
|
||||
package com.idcanet.vasc.impl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.idcanet.vasc.core.VascBackend;
|
||||
import com.idcanet.vasc.core.VascController;
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
|
@ -89,12 +92,6 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
}
|
||||
|
||||
// entry fields
|
||||
if (entry.getName()==null) {
|
||||
entry.setName("vasc.entry."+id+".name");
|
||||
}
|
||||
if (entry.getDescription()==null) {
|
||||
entry.setDescription("vasc.entry."+id+".description");
|
||||
}
|
||||
if (entry.getImage()==null) {
|
||||
entry.setImage("vasc.entry."+id+".image");
|
||||
}
|
||||
|
@ -150,6 +147,7 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
|
||||
|
||||
// Check fields
|
||||
int orderIndex = 0;
|
||||
for (VascEntryField vef:entry.getVascEntryFields()) {
|
||||
String vid = vef.getId();
|
||||
|
||||
|
@ -161,6 +159,12 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
vef.setVascEntry(entry);
|
||||
}
|
||||
|
||||
//System.out.println("Field: "+vef.getId()+" order: "+vef.getOrderIndex()+" else: "+orderIndex);
|
||||
if (vef.getOrderIndex()==null) {
|
||||
vef.setOrderIndex(orderIndex);
|
||||
}
|
||||
orderIndex = orderIndex+100;
|
||||
|
||||
// fill up properties
|
||||
if (vef.getName()==null) {
|
||||
vef.setName("vasc.entry."+id+"."+vid+".name");
|
||||
|
@ -185,10 +189,6 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
// vef.setDefaultValue("vasc.entry."+id+"."+vid+".defaultValue");
|
||||
//}
|
||||
|
||||
|
||||
if (vef.getVascEntryFieldEventChannel()==null) {
|
||||
//vef.setStyleList("vasc.entry."+id+"."+vid+".styleEdit");
|
||||
}
|
||||
if (vef.getVascEntryFieldValue()==null) {
|
||||
VascBackend back2 = vascController.getVascBackendControllerResolver().getVascBackendController().getVascBackendById( entry.getBackendId() );
|
||||
vef.setVascEntryFieldValue(back2.provideVascEntryFieldValue(vef));
|
||||
|
@ -217,11 +217,33 @@ public class DefaultVascBackedEntryFinalizer implements VascEntryFinalizer {
|
|||
//for (VascValidator vv:vef.getVascValidators()) {
|
||||
//}
|
||||
}
|
||||
Collections.sort(entry.getVascEntryFields(),new Comparator() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
VascEntryField v1 = (VascEntryField)o1;
|
||||
VascEntryField v2 = (VascEntryField)o2;
|
||||
return v1.getOrderIndex().compareTo(v2.getOrderIndex());
|
||||
}
|
||||
});
|
||||
|
||||
// place primary key in front
|
||||
int index = 0;
|
||||
for (VascEntryField vef:entry.getVascEntryFields()) {
|
||||
if (entry.getPrimaryKeyFieldId().equals(vef.getId())) {
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
VascEntryField idField = entry.getVascEntryFields().remove(index);
|
||||
entry.getVascEntryFields().add(0, idField);
|
||||
|
||||
// Check if link entries excists
|
||||
for (VascLinkEntry vle:entry.getVascLinkEntries()) {
|
||||
vle.getVascEntryName();
|
||||
|
||||
// check id
|
||||
String vid = vle.getId();
|
||||
if (vid==null) {
|
||||
throw new IllegalArgumentException("All VascLinkEntry need an id");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class DefaultVascBackendController implements VascBackendControllerLocal
|
|||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackendController#getVascBackendById(java.lang.String)
|
||||
*/
|
||||
public VascBackend getVascBackendById(String id) {
|
||||
public VascBackend getVascBackendById(String id) {
|
||||
return backends.get(id);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,8 +57,7 @@ public class DefaultVascController implements VascController {
|
|||
/**
|
||||
* @param vascEventChannelControllerResolver the vascEventChannelControllerResolver to set
|
||||
*/
|
||||
public void setVascEventChannelControllerResolver(
|
||||
VascEventChannelControllerResolver vascEventChannelControllerResolver) {
|
||||
public void setVascEventChannelControllerResolver(VascEventChannelControllerResolver vascEventChannelControllerResolver) {
|
||||
this.vascEventChannelControllerResolver = vascEventChannelControllerResolver;
|
||||
}
|
||||
|
||||
|
@ -114,8 +113,7 @@ public class DefaultVascController implements VascController {
|
|||
/**
|
||||
* @param vascUserRoleControllerResolver the vascUserRoleControllerResolver to set
|
||||
*/
|
||||
public void setVascUserRoleControllerResolver(
|
||||
VascUserRoleControllerResolver vascUserRoleControllerResolver) {
|
||||
public void setVascUserRoleControllerResolver(VascUserRoleControllerResolver vascUserRoleControllerResolver) {
|
||||
this.vascUserRoleControllerResolver = vascUserRoleControllerResolver;
|
||||
}
|
||||
}
|
|
@ -39,6 +39,8 @@ import com.idcanet.vasc.core.VascLinkEntry;
|
|||
import com.idcanet.vasc.core.actions.ColumnVascAction;
|
||||
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||
import com.idcanet.vasc.core.actions.VascAction;
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel;
|
||||
|
||||
/**
|
||||
* VascEntry
|
||||
|
@ -50,8 +52,6 @@ public class DefaultVascEntry implements VascEntry {
|
|||
|
||||
private String id = null;
|
||||
|
||||
private String name = null;
|
||||
private String description = null;
|
||||
private String helpId = null;
|
||||
private String image = null;
|
||||
|
||||
|
@ -62,10 +62,11 @@ public class DefaultVascEntry implements VascEntry {
|
|||
private String primaryKeyFieldId = null;
|
||||
private String displayNameFieldId = null;
|
||||
|
||||
private boolean vascAdmimList = true;
|
||||
private boolean vascAdmimEdit = true;
|
||||
private boolean vascAdmimCreate = true;
|
||||
private boolean vascAdmimDelete = true;
|
||||
private boolean vascDisplayOnly = false;
|
||||
private boolean vascAdminList = true;
|
||||
private boolean vascAdminEdit = true;
|
||||
private boolean vascAdminCreate = true;
|
||||
private boolean vascAdminDelete = true;
|
||||
|
||||
private List<VascEntryField> vascFields = null;
|
||||
|
||||
|
@ -76,6 +77,7 @@ public class DefaultVascEntry implements VascEntry {
|
|||
private List<VascEntryFieldSet> vascEntryFieldSets = null;
|
||||
private List<VascLinkEntry> vascLinkEntries = null;
|
||||
private Map<String,Object> entryParameters = null;
|
||||
private VascEntryFieldEventChannel vascEntryFieldEventChannel = null;
|
||||
|
||||
private String backendId = null;
|
||||
private VascFrontendData vascFrontendData = null;
|
||||
|
@ -99,8 +101,53 @@ public class DefaultVascEntry implements VascEntry {
|
|||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
public VascEntry clone() throws CloneNotSupportedException {
|
||||
|
||||
DefaultVascEntry result = new DefaultVascEntry();
|
||||
result.id=id;
|
||||
result.helpId=helpId;
|
||||
result.image=image;
|
||||
result.headerName=headerName;
|
||||
result.headerDescription=headerDescription;
|
||||
result.headerImage=headerImage;
|
||||
result.primaryKeyFieldId=primaryKeyFieldId;
|
||||
result.displayNameFieldId=displayNameFieldId;
|
||||
result.vascDisplayOnly=vascDisplayOnly;
|
||||
result.vascAdminList=vascAdminList;
|
||||
result.vascAdminCreate=vascAdminCreate;
|
||||
result.vascAdminEdit=vascAdminEdit;
|
||||
result.vascAdminDelete=vascAdminDelete;
|
||||
result.backendId=backendId;
|
||||
result.vascEntryFieldEventChannel=vascEntryFieldEventChannel;
|
||||
// skipping 'vascFrontendData' because it should always be null when cloning happens.
|
||||
|
||||
for (VascEntryField f:vascFields) {
|
||||
VascEntryField ff = f.clone();
|
||||
ff.setVascEntry(result); // mmm remove this ?
|
||||
result.vascFields.add(ff);
|
||||
}
|
||||
for (VascAction a:rowActions) {
|
||||
result.rowActions.add((RowVascAction)a.clone());
|
||||
}
|
||||
for (VascAction a:columnActions) {
|
||||
result.columnActions.add((ColumnVascAction)a.clone());
|
||||
}
|
||||
for (VascAction a:globalActions) {
|
||||
result.globalActions.add((GlobalVascAction)a.clone());
|
||||
}
|
||||
for (VascEntryFieldSet s:vascEntryFieldSets) {
|
||||
result.vascEntryFieldSets.add(s.clone());
|
||||
}
|
||||
for (VascLinkEntry l:vascLinkEntries) {
|
||||
result.vascLinkEntries.add(l.clone());
|
||||
}
|
||||
|
||||
// no cloning of the values here ?
|
||||
for (String key:entryParameters.keySet()) {
|
||||
Object value = entryParameters.get(key);
|
||||
result.setEntryParameter(key, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,34 +167,6 @@ public class DefaultVascEntry implements VascEntry {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the helpId
|
||||
*/
|
||||
|
@ -247,59 +266,59 @@ public class DefaultVascEntry implements VascEntry {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the vascAdmimList
|
||||
* @return the vascAdminList
|
||||
*/
|
||||
public boolean isVascAdmimList() {
|
||||
return vascAdmimList;
|
||||
public boolean isVascAdminList() {
|
||||
return vascAdminList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascAdmimList the vascAdmimList to set
|
||||
* @param vascAdminList the vascAdminList to set
|
||||
*/
|
||||
public void setVascAdmimList(boolean vascAdmimList) {
|
||||
this.vascAdmimList = vascAdmimList;
|
||||
public void setVascAdminList(boolean vascAdminList) {
|
||||
this.vascAdminList = vascAdminList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascAdmimEdit
|
||||
* @return the vascAdminEdit
|
||||
*/
|
||||
public boolean isVascAdmimEdit() {
|
||||
return vascAdmimEdit;
|
||||
public boolean isVascAdminEdit() {
|
||||
return vascAdminEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascAdmimEdit the vascAdmimEdit to set
|
||||
* @param vascAdminEdit the vascAdminEdit to set
|
||||
*/
|
||||
public void setVascAdmimEdit(boolean vascAdmimEdit) {
|
||||
this.vascAdmimEdit = vascAdmimEdit;
|
||||
public void setVascAdminEdit(boolean vascAdminEdit) {
|
||||
this.vascAdminEdit = vascAdminEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascAdmimCreate
|
||||
* @return the vascAdminCreate
|
||||
*/
|
||||
public boolean isVascAdmimCreate() {
|
||||
return vascAdmimCreate;
|
||||
public boolean isVascAdminCreate() {
|
||||
return vascAdminCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascAdmimCreate the vascAdmimCreate to set
|
||||
* @param vascAdminCreate the vascAdminCreate to set
|
||||
*/
|
||||
public void setVascAdmimCreate(boolean vascAdmimCreate) {
|
||||
this.vascAdmimCreate = vascAdmimCreate;
|
||||
public void setVascAdminCreate(boolean vascAdminCreate) {
|
||||
this.vascAdminCreate = vascAdminCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascAdmimDelete
|
||||
* @return the vascAdminDelete
|
||||
*/
|
||||
public boolean isVascAdmimDelete() {
|
||||
return vascAdmimDelete;
|
||||
public boolean isVascAdminDelete() {
|
||||
return vascAdminDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascAdmimDelete the vascAdmimDelete to set
|
||||
* @param vascAdminDelete the vascAdminDelete to set
|
||||
*/
|
||||
public void setVascAdmimDelete(boolean vascAdmimDelete) {
|
||||
this.vascAdmimDelete = vascAdmimDelete;
|
||||
public void setVascAdminDelete(boolean vascAdminDelete) {
|
||||
this.vascAdminDelete = vascAdminDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -332,7 +351,7 @@ public class DefaultVascEntry implements VascEntry {
|
|||
return v;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Id not found as field");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -488,4 +507,32 @@ public class DefaultVascEntry implements VascEntry {
|
|||
public void setBackendId(String backendId) {
|
||||
this.backendId = backendId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascDisplayOnly
|
||||
*/
|
||||
public boolean isVascDisplayOnly() {
|
||||
return vascDisplayOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascDisplayOnly the vascDisplayOnly to set
|
||||
*/
|
||||
public void setVascDisplayOnly(boolean vascDisplayOnly) {
|
||||
this.vascDisplayOnly = vascDisplayOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascEntryFieldEventChannel
|
||||
*/
|
||||
public VascEntryFieldEventChannel getVascEntryFieldEventChannel() {
|
||||
return vascEntryFieldEventChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set
|
||||
*/
|
||||
public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel) {
|
||||
this.vascEntryFieldEventChannel = vascEntryFieldEventChannel;
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@
|
|||
package com.idcanet.vasc.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -60,14 +61,27 @@ public class DefaultVascEntryController implements VascEntryControllerLocal {
|
|||
* @see com.idcanet.vasc.core.VascEntryController#getVascEntryById(java.lang.String)
|
||||
*/
|
||||
public VascEntry getVascEntryById(String id) {
|
||||
return entries.get(id);
|
||||
VascEntry entry = entries.get(id);
|
||||
try {
|
||||
return entry.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new NullPointerException("Could not clone entry: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public VascEntry getRealVascEntryById(String id) {
|
||||
VascEntry entry = entries.get(id);
|
||||
return entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascEntryController#getVascEntryIds()
|
||||
*/
|
||||
public List<String> getVascEntryIds() {
|
||||
return new ArrayList<String>(entries.keySet());
|
||||
List<String> result = new ArrayList<String>(entries.keySet());
|
||||
Collections.sort(result); // lets do abc for consistance behauvior.
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,10 +90,11 @@ public class DefaultVascEntryController implements VascEntryControllerLocal {
|
|||
public List<String> getVascEntryAdminIds() {
|
||||
List<String> adminIds = new ArrayList<String>(30);
|
||||
for (VascEntry e:entries.values()) {
|
||||
if (Boolean.TRUE.equals(e.isVascAdmimList())) {
|
||||
if (Boolean.TRUE.equals(e.isVascAdminList())) {
|
||||
adminIds.add(e.getId());
|
||||
}
|
||||
}
|
||||
Collections.sort(adminIds); // lets do abc for consistance behauvior.
|
||||
return adminIds;
|
||||
}
|
||||
}
|
|
@ -32,7 +32,6 @@ import java.util.List;
|
|||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.VascEntryFieldType;
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldEventChannel;
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||
import com.idcanet.vasc.validators.VascValidator;
|
||||
|
||||
|
@ -45,44 +44,40 @@ import com.idcanet.vasc.validators.VascValidator;
|
|||
public class DefaultVascEntryField implements VascEntryField {
|
||||
|
||||
private VascEntry vascEntry = null;
|
||||
|
||||
/** The vasc id for this field */
|
||||
private String id = null;
|
||||
|
||||
/** The vasc Field Type for this field entry. */
|
||||
private VascEntryFieldType vascEntryFieldType = null;
|
||||
|
||||
/** The backendName, default to the name. **/
|
||||
private String backendName = null;
|
||||
|
||||
private String id = null;
|
||||
private String backendName = null;
|
||||
private String displayName = null;
|
||||
|
||||
private VascEntryFieldType vascEntryFieldType = null;
|
||||
private VascEntryFieldValue vascEntryFieldValue = null;
|
||||
|
||||
private VascEntryFieldEventChannel vascEntryFieldEventChannel = null;
|
||||
|
||||
private List<VascValidator> vascValidators = null;
|
||||
|
||||
/** Some VascField fields**/
|
||||
private String name = null;
|
||||
private String description = null;
|
||||
private String helpId = null;
|
||||
private String image = null;
|
||||
private Integer orderIndex = null;
|
||||
private Object defaultValue = null;
|
||||
|
||||
private Integer sizeList = null;
|
||||
private Integer sizeEdit = null;
|
||||
private String styleList = null;
|
||||
private String styleEdit = null;
|
||||
|
||||
private String choices = null;
|
||||
private Boolean choicesAsRadio = null;
|
||||
|
||||
/** Defines if this columns is used in interface list,create,edit **/
|
||||
private boolean view = true;
|
||||
private boolean optional = false;
|
||||
private Boolean view = null;
|
||||
private Boolean optional = null;
|
||||
|
||||
/** Defines per view state of this field **/
|
||||
private boolean create = true;
|
||||
private boolean edit = true;
|
||||
private boolean editReadOnly = false;
|
||||
private boolean list = true;
|
||||
private Boolean create = null;
|
||||
private Boolean edit = null;
|
||||
private Boolean editReadOnly = null;
|
||||
private Boolean editBlank = null;
|
||||
private Boolean list = null;
|
||||
|
||||
/** Defines the roles stuff if all up is true **/
|
||||
private String rolesCreate = null;
|
||||
|
@ -90,6 +85,10 @@ public class DefaultVascEntryField implements VascEntryField {
|
|||
private String rolesEditReadOnly = null;
|
||||
private String rolesList = null;
|
||||
|
||||
private Boolean sortable = null;
|
||||
private Boolean sumable = null;
|
||||
private Boolean graphable = null;
|
||||
|
||||
public DefaultVascEntryField() {
|
||||
vascValidators = new ArrayList<VascValidator>(5);
|
||||
}
|
||||
|
@ -99,6 +98,52 @@ public class DefaultVascEntryField implements VascEntryField {
|
|||
setId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public VascEntryField clone() throws CloneNotSupportedException {
|
||||
DefaultVascEntryField result = new DefaultVascEntryField();
|
||||
result.id=id;
|
||||
result.backendName=backendName;
|
||||
result.displayName=displayName;
|
||||
result.vascEntryFieldType=vascEntryFieldType;
|
||||
result.name=name;
|
||||
result.description=description;
|
||||
result.helpId=helpId;
|
||||
result.image=image;
|
||||
result.defaultValue=defaultValue;
|
||||
result.orderIndex=orderIndex;
|
||||
result.sizeList=sizeList;
|
||||
result.sizeEdit=sizeEdit;
|
||||
result.styleList=styleList;
|
||||
result.styleEdit=styleEdit;
|
||||
result.choices=choices;
|
||||
result.choicesAsRadio=choicesAsRadio;
|
||||
result.view=view;
|
||||
result.optional=optional;
|
||||
result.create=create;
|
||||
result.edit=edit;
|
||||
result.editReadOnly=editReadOnly;
|
||||
result.editBlank=editBlank;
|
||||
result.list=list;
|
||||
|
||||
result.rolesCreate=rolesCreate;
|
||||
result.rolesEdit=rolesEdit;
|
||||
result.rolesEditReadOnly=rolesEditReadOnly;
|
||||
result.rolesList=rolesList;
|
||||
|
||||
result.sortable=sortable;
|
||||
result.sumable=sumable;
|
||||
result.graphable=graphable;
|
||||
|
||||
result.vascEntryFieldValue=vascEntryFieldValue;
|
||||
|
||||
result.vascValidators.addAll(vascValidators);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public VascEntry getVascEntry() {
|
||||
return vascEntry;
|
||||
}
|
||||
|
@ -162,21 +207,7 @@ public class DefaultVascEntryField implements VascEntryField {
|
|||
public void setVascEntryFieldValue(VascEntryFieldValue vascEntryFieldValue) {
|
||||
this.vascEntryFieldValue = vascEntryFieldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascEntryFieldEventChannel
|
||||
*/
|
||||
public VascEntryFieldEventChannel getVascEntryFieldEventChannel() {
|
||||
return vascEntryFieldEventChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascEntryFieldEventChannel the vascEntryFieldEventChannel to set
|
||||
*/
|
||||
public void setVascEntryFieldEventChannel(VascEntryFieldEventChannel vascEntryFieldEventChannel) {
|
||||
this.vascEntryFieldEventChannel = vascEntryFieldEventChannel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the vascValidators
|
||||
*/
|
||||
|
@ -341,84 +372,84 @@ public class DefaultVascEntryField implements VascEntryField {
|
|||
/**
|
||||
* @return the view
|
||||
*/
|
||||
public boolean isView() {
|
||||
public Boolean getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param view the view to set
|
||||
*/
|
||||
public void setView(boolean view) {
|
||||
public void setView(Boolean view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the optional
|
||||
*/
|
||||
public boolean isOptional() {
|
||||
public Boolean getOptional() {
|
||||
return optional;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param optional the optional to set
|
||||
*/
|
||||
public void setOptional(boolean optional) {
|
||||
public void setOptional(Boolean optional) {
|
||||
this.optional = optional;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the create
|
||||
*/
|
||||
public boolean isCreate() {
|
||||
public Boolean getCreate() {
|
||||
return create;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param create the create to set
|
||||
*/
|
||||
public void setCreate(boolean create) {
|
||||
public void setCreate(Boolean create) {
|
||||
this.create = create;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the edit
|
||||
*/
|
||||
public boolean isEdit() {
|
||||
public Boolean getEdit() {
|
||||
return edit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param edit the edit to set
|
||||
*/
|
||||
public void setEdit(boolean edit) {
|
||||
public void setEdit(Boolean edit) {
|
||||
this.edit = edit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the editReadOnly
|
||||
*/
|
||||
public boolean isEditReadOnly() {
|
||||
public Boolean getEditReadOnly() {
|
||||
return editReadOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param editReadOnly the editReadOnly to set
|
||||
*/
|
||||
public void setEditReadOnly(boolean editReadOnly) {
|
||||
public void setEditReadOnly(Boolean editReadOnly) {
|
||||
this.editReadOnly = editReadOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list
|
||||
*/
|
||||
public boolean isList() {
|
||||
public Boolean getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list the list to set
|
||||
*/
|
||||
public void setList(boolean list) {
|
||||
public void setList(Boolean list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
|
@ -477,4 +508,102 @@ public class DefaultVascEntryField implements VascEntryField {
|
|||
public void setRolesList(String rolesList) {
|
||||
this.rolesList = rolesList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the choicesAsRadio
|
||||
*/
|
||||
public Boolean getChoicesAsRadio() {
|
||||
return choicesAsRadio;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param choicesAsRadio the choicesAsRadio to set
|
||||
*/
|
||||
public void setChoicesAsRadio(Boolean choicesAsRadio) {
|
||||
this.choicesAsRadio = choicesAsRadio;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the editBlank
|
||||
*/
|
||||
public Boolean getEditBlank() {
|
||||
return editBlank;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param editBlank the editBlank to set
|
||||
*/
|
||||
public void setEditBlank(Boolean editBlank) {
|
||||
this.editBlank = editBlank;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the displayName
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param displayName the displayName to set
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the orderIndex
|
||||
*/
|
||||
public Integer getOrderIndex() {
|
||||
return orderIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param orderIndex the orderIndex to set
|
||||
*/
|
||||
public void setOrderIndex(Integer orderIndex) {
|
||||
this.orderIndex = orderIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sortable
|
||||
*/
|
||||
public Boolean getSortable() {
|
||||
return sortable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sortable the sortable to set
|
||||
*/
|
||||
public void setSortable(Boolean sortable) {
|
||||
this.sortable = sortable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sumable
|
||||
*/
|
||||
public Boolean getSumable() {
|
||||
return sumable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sumable the sumable to set
|
||||
*/
|
||||
public void setSumable(Boolean sumable) {
|
||||
this.sumable = sumable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the graphable
|
||||
*/
|
||||
public Boolean getGraphable() {
|
||||
return graphable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param graphable the graphable to set
|
||||
*/
|
||||
public void setGraphable(Boolean graphable) {
|
||||
this.graphable = graphable;
|
||||
}
|
||||
}
|
|
@ -57,6 +57,26 @@ public class DefaultVascEntryFieldSet implements VascEntryFieldSet {
|
|||
vascEntryFieldIds = new ArrayList<String>(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public VascEntryFieldSet clone() throws CloneNotSupportedException {
|
||||
DefaultVascEntryFieldSet result = new DefaultVascEntryFieldSet();
|
||||
result.id=id;
|
||||
result.name=name;
|
||||
result.description=description;
|
||||
result.helpId=helpId;
|
||||
result.image=image;
|
||||
result.styleList=styleList;
|
||||
result.styleEdit=styleEdit;
|
||||
result.collapsed=collapsed;
|
||||
result.optional=optional;
|
||||
result.vascEntryFieldIds.addAll(vascEntryFieldIds);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.idcanet.vasc.core.VascBackend;
|
||||
import com.idcanet.vasc.core.VascController;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.VascEntryFinalizer;
|
||||
|
@ -52,6 +53,7 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
|||
private List<Object> entryDataList = null;
|
||||
private Object entryDataObject = null;
|
||||
private VascFrontend vascFrontend = null;
|
||||
private VascBackend vascBackend = null;
|
||||
private VascEntryFinalizer vascEntryFinalizer = null;
|
||||
private VascFrontendHelper vascFrontendHelper = null;
|
||||
private VascEntryResourceResolver vascEntryResourceResolver = null;
|
||||
|
@ -160,6 +162,12 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
|||
cl = rendererId.getClass().getClassLoader(); // fallback
|
||||
}
|
||||
String componentClass = getVascUIComponentClass(rendererId);
|
||||
if (componentClass==null) {
|
||||
|
||||
// TODO: auto wire text <-> object converts
|
||||
|
||||
componentClass = getVascUIComponentClass(VascUIComponent.VASC_TEXT);
|
||||
}
|
||||
if (componentClass==null) {
|
||||
throw new VascException("No component Class found for frontend UIComponent: "+rendererId);
|
||||
}
|
||||
|
@ -219,4 +227,18 @@ public class DefaultVascFrontendData implements VascFrontendData {
|
|||
public VascUIComponent getFieldVascUIComponent(VascEntryField field) {
|
||||
return fieldComps.get(field);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascBackend
|
||||
*/
|
||||
public VascBackend getVascBackend() {
|
||||
return vascBackend;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascBackend the vascBackend to set
|
||||
*/
|
||||
public void setVascBackend(VascBackend vascBackend) {
|
||||
this.vascBackend = vascBackend;
|
||||
}
|
||||
}
|
|
@ -32,6 +32,9 @@ import java.util.logging.Logger;
|
|||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.VascFrontendHelper;
|
||||
import com.idcanet.vasc.core.VascUserRoleController;
|
||||
import com.idcanet.vasc.core.actions.GlobalVascAction;
|
||||
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||
import com.idcanet.vasc.core.entry.VascEntryEventListener;
|
||||
import com.idcanet.vasc.core.entry.VascEntryEventListener.VascEventType;
|
||||
import com.idcanet.vasc.core.ui.VascUIComponent;
|
||||
|
@ -55,6 +58,98 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
|||
//exceptionListeners = new ArrayList<VascExceptionListener>(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascFrontendHelper#renderView(com.idcanet.vasc.core.VascEntryField)
|
||||
*/
|
||||
public boolean renderView(VascEntryField field) {
|
||||
if (field.getView()==false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascFrontendHelper#renderCreate(com.idcanet.vasc.core.VascEntryField)
|
||||
*/
|
||||
public boolean renderCreate(VascEntryField field) {
|
||||
if (renderView(field)==false) {
|
||||
return false;
|
||||
}
|
||||
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController();
|
||||
if (field.getRolesCreate()!=null && u.hasRole(field.getRolesCreate())) {
|
||||
return true;
|
||||
}
|
||||
if (field.getCreate()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascFrontendHelper#renderEdit(com.idcanet.vasc.core.VascEntryField)
|
||||
*/
|
||||
public boolean renderEdit(VascEntryField field) {
|
||||
if (renderView(field)==false) {
|
||||
return false;
|
||||
}
|
||||
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController();
|
||||
if (field.getRolesEdit()!=null && u.hasRole(field.getRolesEdit())) {
|
||||
return true;
|
||||
}
|
||||
if (field.getEdit()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascFrontendHelper#renderEditReadOnly(com.idcanet.vasc.core.VascEntryField)
|
||||
*/
|
||||
public boolean renderEditReadOnly(VascEntryField field) {
|
||||
if (renderView(field)==false) {
|
||||
return false;
|
||||
}
|
||||
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController();
|
||||
if (field.getRolesEditReadOnly()!=null && u.hasRole(field.getRolesEditReadOnly())) {
|
||||
return true;
|
||||
}
|
||||
if (field.getEditReadOnly()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascFrontendHelper#renderList(com.idcanet.vasc.core.VascEntryField)
|
||||
*/
|
||||
public boolean renderList(VascEntryField field) {
|
||||
if (renderView(field)==false) {
|
||||
return false;
|
||||
}
|
||||
VascUserRoleController u = field.getVascEntry().getVascFrontendData().getVascController().getVascUserRoleControllerResolver().getVascUserRoleController();
|
||||
if (field.getRolesList()!=null && u.hasRole(field.getRolesList())) {
|
||||
return true;
|
||||
}
|
||||
if (field.getList()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascFrontendHelper#renderGlobalVascAction(com.idcanet.vasc.core.actions.GlobalVascAction)
|
||||
*/
|
||||
public boolean renderGlobalVascAction(GlobalVascAction action) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascFrontendHelper#renderRowVascAction(com.idcanet.vasc.core.actions.RowVascAction)
|
||||
*/
|
||||
public boolean renderRowVascAction(RowVascAction action) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascFrontendHelper#addEventListener(com.idcanet.vasc.core.entry.VascEntryEventListener)
|
||||
*/
|
||||
|
@ -119,7 +214,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
|||
if (object!=null) {
|
||||
return object;
|
||||
}
|
||||
object = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()).provideVascEntryRecordCreator(entry).newRecord(entry);
|
||||
object = entry.getVascFrontendData().getVascBackend().provideVascEntryRecordCreator(entry).newRecord(entry);
|
||||
//fireVascEvent(VascEventListener.VascEventType.BEAN_INIT, object);
|
||||
return object;
|
||||
}
|
||||
|
@ -145,7 +240,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
|||
public Object mergeObject(VascEntry entry, Object object) {
|
||||
Object result = null;
|
||||
try {
|
||||
object = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()).merge(object);
|
||||
object = entry.getVascFrontendData().getVascBackend().merge(object);
|
||||
//fireVascEvent(VascEventListener.VascEventType.BEAN_MERGE,object);
|
||||
// todo: make faster
|
||||
// add to table at position old old object
|
||||
|
@ -164,7 +259,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
|||
*/
|
||||
public void refreshData(VascEntry entry) throws Exception {
|
||||
entry.getVascFrontendData().setEntryDataObject(null);
|
||||
entry.getVascFrontendData().setEntryDataList(entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(entry.getBackendId()).execute());
|
||||
entry.getVascFrontendData().setEntryDataList(entry.getVascFrontendData().getVascBackend().execute());
|
||||
//fireVascEvent(VascEventListener.VascEventType.DATA_UPDATE, null);
|
||||
}
|
||||
|
||||
|
@ -189,7 +284,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
|||
*/
|
||||
public boolean setUIComponentsBeanErrors(VascEntry entry, Object bean) {
|
||||
boolean error = false;
|
||||
if(bean==null) {
|
||||
if (bean==null) {
|
||||
logger.finest("No bean to check.");
|
||||
return true; // nothing to check
|
||||
}
|
||||
|
@ -198,7 +293,7 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
|||
//InvalidValue[] ival = val.getInvalidValues(bean);
|
||||
//logger.fine("Got invaliled value: "+ival.length);
|
||||
|
||||
for(VascEntryField col:entry.getVascEntryFields()) {
|
||||
for (VascEntryField col:entry.getVascEntryFields()) {
|
||||
|
||||
try {
|
||||
Object object = col.getVascEntryFieldValue().getValue(col, bean);
|
||||
|
@ -256,57 +351,8 @@ public class DefaultVascFrontendHelper implements VascFrontendHelper {
|
|||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public void finalizeVascColumns(VascTable table) throws Exception {
|
||||
VascAnnotationParser vap = new VascAnnotationParser();
|
||||
|
||||
for(VascTableColumn c:table.getTableColumns()) {
|
||||
if (c instanceof VascAnnotationTableColumn) {
|
||||
VascAnnotationTableColumn column = (VascAnnotationTableColumn)c;
|
||||
|
||||
if (c.getName()==null) {
|
||||
c.setName(vap.getVascNameKey(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
|
||||
}
|
||||
if (c.getToolTip()==null) {
|
||||
c.setToolTip(vap.getVascToolTipKey(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
|
||||
}
|
||||
if (c.getDefaultValue()==null) {
|
||||
c.setDefaultValue(vap.getVascDefaultValue(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
|
||||
}
|
||||
if (c.getWidth()==null) {
|
||||
Object obj = vap.getVascColumnWidth(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty());
|
||||
if (obj instanceof Integer) {
|
||||
c.setWidth((Integer)obj);
|
||||
}
|
||||
c.setWidth(100);
|
||||
// get KEY
|
||||
}
|
||||
if (c.getHelpId()==null) {
|
||||
c.setHelpId(vap.getVascHelpId(table.getVascRecordCreator().getObjectClass(), column.getBeanProperty()));
|
||||
}
|
||||
if (c.getVascColumnValue()==null) {
|
||||
c.setVascColumnValue(new BeanPropertyVascColumnValue(column.getBeanProperty()));
|
||||
}
|
||||
if (c.getImage()==null) {
|
||||
c.setImage(vap.getVascImage(table.getVascRecordCreator().getObjectClass(),column.getBeanProperty()));
|
||||
}
|
||||
}
|
||||
if (c.getVascUIComponent()==null) {
|
||||
if (c.getDefaultValue() instanceof Boolean) {
|
||||
c.setVascUIComponent(new VascToggle());
|
||||
} else if (c.getDefaultValue() instanceof Date) {
|
||||
c.setVascUIComponent(new VascDate());
|
||||
} else {
|
||||
c.setVascUIComponent(new VascTextField());
|
||||
}
|
||||
}
|
||||
if (c.getVascColumnRenderer()==null) {
|
||||
//c.setVascColumnRenderer(new DefaultVascColumnRenderer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void addEventListener(VascEventListener e) {
|
||||
eventListeners.add(e);
|
||||
}
|
||||
|
|
|
@ -36,20 +36,94 @@ import com.idcanet.vasc.core.VascLinkEntry;
|
|||
* @version 1.0 Oct 27, 2007
|
||||
*/
|
||||
public class DefaultVascLinkEntry implements VascLinkEntry {
|
||||
|
||||
private String vascEntryName = null;
|
||||
|
||||
private String id;
|
||||
private String vascEntryId = null;
|
||||
private String parameterName = null;
|
||||
private String valueFieldId = null;
|
||||
private Boolean viewAsDetail = null;
|
||||
|
||||
/**
|
||||
* @return the vascEntryName
|
||||
* @return the id
|
||||
*/
|
||||
public String getVascEntryName() {
|
||||
return vascEntryName;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascEntryName the vascEntryName to set
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setVascEntryName(String vascEntryName) {
|
||||
this.vascEntryName = vascEntryName;
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parameterName
|
||||
*/
|
||||
public String getParameterName() {
|
||||
return parameterName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parameterName the parameterName to set
|
||||
*/
|
||||
public void setParameterName(String parameterName) {
|
||||
this.parameterName = parameterName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the valueFieldId
|
||||
*/
|
||||
public String getValueFieldId() {
|
||||
return valueFieldId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param valueFieldId the valueFieldId to set
|
||||
*/
|
||||
public void setValueFieldId(String valueFieldId) {
|
||||
this.valueFieldId = valueFieldId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascEntryId
|
||||
*/
|
||||
public String getVascEntryId() {
|
||||
return vascEntryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascEntryId the vascEntryId to set
|
||||
*/
|
||||
public void setVascEntryId(String vascEntryId) {
|
||||
this.vascEntryId = vascEntryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the viewAsDetail
|
||||
*/
|
||||
public Boolean getViewAsDetail() {
|
||||
return viewAsDetail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param viewAsDetail the viewAsDetail to set
|
||||
*/
|
||||
public void setViewAsDetail(Boolean viewAsDetail) {
|
||||
this.viewAsDetail = viewAsDetail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public VascLinkEntry clone() throws CloneNotSupportedException {
|
||||
DefaultVascLinkEntry result = new DefaultVascLinkEntry();
|
||||
result.viewAsDetail=viewAsDetail;
|
||||
result.vascEntryId=vascEntryId;
|
||||
result.parameterName=parameterName;
|
||||
result.valueFieldId=valueFieldId;
|
||||
result.id=id;
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* Copyright 2004-2008 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.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.VascException;
|
||||
import com.idcanet.vasc.core.ui.VascSelectItem;
|
||||
import com.idcanet.vasc.core.ui.VascSelectItemModel;
|
||||
|
||||
|
||||
/**
|
||||
* The DefaultVascLinkEntry
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Oct 27, 2007
|
||||
*/
|
||||
public class DefaultVascSelectItemModel implements VascSelectItemModel {
|
||||
|
||||
private String entryId = null;
|
||||
private String keyFieldId = null;
|
||||
private String displayFieldId = null;
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.ui.VascSelectItemModel#getVascSelectItems(com.idcanet.vasc.core.VascEntry)
|
||||
*/
|
||||
public List<VascSelectItem> getVascSelectItems(VascEntry entry) throws VascException {
|
||||
List<VascSelectItem> result = new ArrayList<VascSelectItem>(100);
|
||||
VascEntry ve = entry.getVascFrontendData().getVascController().getVascEntryControllerResolver().getVascEntryController().getVascEntryById(entryId);
|
||||
VascEntryField key = ve.getVascEntryFieldById(keyFieldId);
|
||||
VascEntryField dis = ve.getVascEntryFieldById(displayFieldId);
|
||||
if (key==null) {
|
||||
throw new VascException("Could not find: "+keyFieldId+" from: "+ve.getId());
|
||||
}
|
||||
if (dis==null) {
|
||||
throw new VascException("Could not find: "+displayFieldId+" from: "+ve.getId());
|
||||
}
|
||||
|
||||
VascBackend back = entry.getVascFrontendData().getVascController().getVascBackendControllerResolver().getVascBackendController().getVascBackendById(ve.getBackendId());
|
||||
try {
|
||||
for (Object o:back.execute()) {
|
||||
String keyId = ""+key.getVascEntryFieldValue().getValue(key, o);
|
||||
// hackje
|
||||
if (dis.getDisplayName()!=null && "".equals(dis.getDisplayName())==false) {
|
||||
dis.setBackendName(dis.getDisplayName());
|
||||
}
|
||||
String nameId = ""+dis.getVascEntryFieldValue().getValue(dis, o);
|
||||
VascSelectItem item = new VascSelectItem(nameId,o,keyId);
|
||||
result.add(item);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the entryId
|
||||
*/
|
||||
public String getEntryId() {
|
||||
return entryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entryId the entryId to set
|
||||
*/
|
||||
public void setEntryId(String entryId) {
|
||||
this.entryId = entryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the keyFieldId
|
||||
*/
|
||||
public String getKeyFieldId() {
|
||||
return keyFieldId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyFieldId the keyFieldId to set
|
||||
*/
|
||||
public void setKeyFieldId(String keyFieldId) {
|
||||
this.keyFieldId = keyFieldId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the displayFieldId
|
||||
*/
|
||||
public String getDisplayFieldId() {
|
||||
return displayFieldId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param displayFieldId the displayFieldId to set
|
||||
*/
|
||||
public void setDisplayFieldId(String displayFieldId) {
|
||||
this.displayFieldId = displayFieldId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* 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.VascUserRoleController;
|
||||
|
||||
/**
|
||||
* Simple default user controller for wrapping user info into vasc
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 13, 2009
|
||||
*/
|
||||
public class DefaultVascUserRoleController implements VascUserRoleController {
|
||||
|
||||
private Long userId = null;
|
||||
private String userName = null;
|
||||
private List<String> userRoles = null;
|
||||
|
||||
|
||||
public DefaultVascUserRoleController(Long userId,String userName) {
|
||||
if (userId==null) {
|
||||
throw new NullPointerException("userId may not be null.");
|
||||
}
|
||||
if (userName==null) {
|
||||
throw new NullPointerException("userName may not be null");
|
||||
}
|
||||
this.userId=userId;
|
||||
this.userName=userName;
|
||||
userRoles = new ArrayList<String>(10);
|
||||
}
|
||||
|
||||
public DefaultVascUserRoleController(Long userId,String userName,String...roles) {
|
||||
this(userId,userName);
|
||||
for (String role:roles) {
|
||||
userRoles.add(role);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascUserRoleController#getUserId()
|
||||
*/
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascUserRoleController#getUserName()
|
||||
*/
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascUserRoleController#getUserRoles()
|
||||
*/
|
||||
public List<String> getUserRoles() {
|
||||
return userRoles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascUserRoleController#hasRole(java.lang.String)
|
||||
*/
|
||||
public boolean hasRole(String roles) {
|
||||
if (roles==null) {
|
||||
return false;
|
||||
}
|
||||
// input: admin|superAdmin
|
||||
// input: (admin|superAdmin)&login
|
||||
String[] r = roles.split("|");
|
||||
for (String rr:r) {
|
||||
if (userRoles.contains(rr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -48,8 +48,7 @@ public class DefaultVascUserRoleControllerResolver implements VascUserRoleContro
|
|||
/**
|
||||
* @param vascUserRoleController the vascUserRoleController to set
|
||||
*/
|
||||
public void setVascUserRoleController(
|
||||
VascUserRoleController vascUserRoleController) {
|
||||
public void setVascUserRoleController(VascUserRoleController vascUserRoleController) {
|
||||
this.vascUserRoleController = vascUserRoleController;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright 2004-2008 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.AbstractVascBackendProxy;
|
||||
import com.idcanet.vasc.core.VascBackend;
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
|
||||
|
||||
/**
|
||||
* Simulates a real pages backend.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Oct 27, 2007
|
||||
*/
|
||||
public class VascBackendProxyPaged extends AbstractVascBackendProxy {
|
||||
|
||||
private long records = 0;
|
||||
|
||||
public VascBackendProxyPaged(VascBackend backend,VascEntry entry) {
|
||||
super(backend);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#isPageable()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPageable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#execute()
|
||||
*/
|
||||
@Override
|
||||
public List<Object> execute() throws Exception {
|
||||
List<Object> allData = backend.execute();
|
||||
List<Object> paged = new ArrayList<Object>(getPageSize());
|
||||
int off = getPageIndex()*getPageSize();
|
||||
int offMax = off+getPageSize();
|
||||
for (int i=off;i<offMax;i++) {
|
||||
if (i>=allData.size()) {
|
||||
break;
|
||||
}
|
||||
Object o = allData.get(i);
|
||||
paged.add(o);
|
||||
}
|
||||
records = allData.size();
|
||||
return paged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPagesTotalRecords() {
|
||||
return records;
|
||||
}
|
||||
}
|
125
src/main/java/com/idcanet/vasc/impl/VascBackendProxySearch.java
Normal file
125
src/main/java/com/idcanet/vasc/impl/VascBackendProxySearch.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Copyright 2004-2008 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.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.idcanet.vasc.core.AbstractVascBackendProxy;
|
||||
import com.idcanet.vasc.core.VascBackend;
|
||||
import com.idcanet.vasc.core.VascBackendPageNumber;
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
|
||||
|
||||
/**
|
||||
* Simple text search
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Oct 27, 2007
|
||||
*/
|
||||
public class VascBackendProxySearch extends AbstractVascBackendProxy {
|
||||
|
||||
private long records = 0;
|
||||
|
||||
public VascBackendProxySearch(VascBackend backend,VascEntry entry) {
|
||||
super(backend);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#isSearchable()
|
||||
*/
|
||||
@Override
|
||||
public boolean isSearchable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#execute()
|
||||
*/
|
||||
@Override
|
||||
public List<Object> execute() throws Exception {
|
||||
List<Object> result = backend.execute();
|
||||
if (getSearchString()==null) {
|
||||
records = backend.getPagesTotalRecords();
|
||||
return result;
|
||||
}
|
||||
String searchString = getSearchString().toLowerCase();
|
||||
List<Object> search = new ArrayList<Object>(result.size()/4);
|
||||
for (Object o:result) {
|
||||
for (Method method:o.getClass().getMethods()) {
|
||||
if (method.getName().startsWith("get")==false) { //a bit durty
|
||||
continue;
|
||||
}
|
||||
if (method.getName().equals("getClass")) {
|
||||
continue;
|
||||
}
|
||||
if (method.getReturnType().isAssignableFrom(Collection.class)) {
|
||||
continue;
|
||||
}
|
||||
if (method.getReturnType().isAssignableFrom(List.class)) {
|
||||
continue;
|
||||
}
|
||||
if (method.getReturnType().isAssignableFrom(Set.class)) {
|
||||
continue;
|
||||
}
|
||||
if (method.getReturnType().isAssignableFrom(Map.class)) {
|
||||
continue;
|
||||
}
|
||||
Object res = method.invoke(o,null);
|
||||
if (res==null) {
|
||||
continue;
|
||||
}
|
||||
String r = res.toString().toLowerCase();
|
||||
if (r.contains(searchString)) {
|
||||
search.add(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
records = search.size();
|
||||
return search;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPagesTotalRecords() {
|
||||
return records;
|
||||
}
|
||||
@Override
|
||||
public List<VascBackendPageNumber> getVascBackendPageNumbers() {
|
||||
if (getSearchString()==null) {
|
||||
return backend.getVascBackendPageNumbers();
|
||||
}
|
||||
// limit the pages to the number of search results.
|
||||
List<VascBackendPageNumber> r = backend.getVascBackendPageNumbers();
|
||||
int pages = new Long(getPagesTotalRecords()/getPageSize()).intValue();
|
||||
return r.subList(0, pages);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright 2004-2008 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.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.idcanet.vasc.core.AbstractVascBackendProxy;
|
||||
import com.idcanet.vasc.core.VascBackend;
|
||||
import com.idcanet.vasc.core.VascEntry;
|
||||
import com.idcanet.vasc.core.VascEntryField;
|
||||
import com.idcanet.vasc.core.VascException;
|
||||
import com.idcanet.vasc.core.entry.VascEntryFieldValue;
|
||||
|
||||
|
||||
/**
|
||||
* Add an sortware sort an a backend
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Oct 27, 2007
|
||||
*/
|
||||
public class VascBackendProxySort extends AbstractVascBackendProxy {
|
||||
|
||||
private VascEntry entry = null;
|
||||
|
||||
public VascBackendProxySort(VascBackend backend,VascEntry entry) {
|
||||
super(backend);
|
||||
this.entry=entry;
|
||||
}
|
||||
|
||||
// sort stuff
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.VascBackend#execute()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<Object> execute() throws Exception {
|
||||
List<Object> result = backend.execute();
|
||||
if (getSortField()==null) {
|
||||
return result;
|
||||
}
|
||||
final VascEntryField field = entry.getVascEntryFieldById(getSortField());
|
||||
final VascEntryFieldValue fieldValue = backend.provideVascEntryFieldValue(field);
|
||||
Collections.sort(result, new Comparator() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
try {
|
||||
Comparable c1 = (Comparable)fieldValue.getValue(field, o1);
|
||||
Comparable c2 = (Comparable)fieldValue.getValue(field, o2);
|
||||
if (isSortAscending()) {
|
||||
return c1.compareTo(c2);
|
||||
} else {
|
||||
return c2.compareTo(c1);
|
||||
}
|
||||
} catch (VascException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ import com.idcanet.vasc.core.actions.RowVascAction;
|
|||
public class AddRowAction extends AbstractVascAction implements RowVascAction {
|
||||
|
||||
public AddRowAction() {
|
||||
setId("addRowAction");
|
||||
setName("vasc.action.add.name");
|
||||
setToolTip("vasc.action.add.tooltip");
|
||||
setImage("vasc.action.add.image");
|
||||
|
@ -46,4 +47,11 @@ public class AddRowAction extends AbstractVascAction implements RowVascAction {
|
|||
public void doRowAction(VascEntry enty,Object rowObject) throws Exception {
|
||||
enty.getVascFrontendData().getVascFrontend().renderEdit(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.actions.RowVascAction#isMultiRowAction()
|
||||
*/
|
||||
public boolean isMultiRowAction() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -43,6 +43,7 @@ import com.idcanet.vasc.core.actions.GlobalVascAction;
|
|||
public class CSVExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascEntryExporter {
|
||||
|
||||
public CSVExportGlobalAction() {
|
||||
setId("CSVExportGlobalAction");
|
||||
setName("vasc.action.csv.name");
|
||||
setToolTip("vasc.action.csv.tooltip");
|
||||
setImage("vasc.action.csv.image");
|
||||
|
@ -71,7 +72,7 @@ public class CSVExportGlobalAction extends AbstractVascAction implements GlobalV
|
|||
}
|
||||
|
||||
public String getMineType() {
|
||||
return "csv";
|
||||
return "text/csv";
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.idcanet.vasc.core.actions.RowVascAction;
|
|||
public class DeleteRowAction extends AbstractVascAction implements RowVascAction {
|
||||
|
||||
public DeleteRowAction() {
|
||||
setId("deleteRowAction");
|
||||
setName("vasc.action.del.name");
|
||||
setToolTip("vasc.action.del.tooltip");
|
||||
setImage("vasc.action.del.image");
|
||||
|
@ -49,4 +50,11 @@ public class DeleteRowAction extends AbstractVascAction implements RowVascAction
|
|||
}
|
||||
entry.getVascFrontendData().getVascFrontend().renderDelete(rowObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.actions.RowVascAction#isMultiRowAction()
|
||||
*/
|
||||
public boolean isMultiRowAction() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ import com.idcanet.vasc.core.actions.RowVascAction;
|
|||
public class EditRowAction extends AbstractVascAction implements RowVascAction {
|
||||
|
||||
public EditRowAction() {
|
||||
setId("editRowAction");
|
||||
setName("vasc.action.edit.name");
|
||||
setToolTip("vasc.action.edit.tooltip");
|
||||
setImage("vasc.action.edit.image");
|
||||
|
@ -50,4 +51,12 @@ public class EditRowAction extends AbstractVascAction implements RowVascAction {
|
|||
}
|
||||
entry.getVascFrontendData().getVascFrontend().renderEdit(rowObject);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see com.idcanet.vasc.core.actions.RowVascAction#isMultiRowAction()
|
||||
*/
|
||||
public boolean isMultiRowAction() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ import com.idcanet.vasc.core.actions.GlobalVascAction;
|
|||
public class RefreshDataGlobalAction extends AbstractVascAction implements GlobalVascAction {
|
||||
|
||||
public RefreshDataGlobalAction() {
|
||||
setId("refreshDataGlobalAction");
|
||||
setName("vasc.action.refresh.name");
|
||||
setToolTip("vasc.action.refresh.tooltip");
|
||||
setImage("vasc.action.refresh.image");
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.idcanet.vasc.core.entry.VascEntryExporter;
|
|||
public class XMLExportGlobalAction extends AbstractVascAction implements GlobalVascAction,VascEntryExporter {
|
||||
|
||||
public XMLExportGlobalAction() {
|
||||
setId("XMLExportGlobalAction");
|
||||
setName("vasc.action.xml.name");
|
||||
setToolTip("vasc.action.xml.tooltip");
|
||||
setImage("vasc.action.xml.image");
|
||||
|
@ -58,9 +59,9 @@ public class XMLExportGlobalAction extends AbstractVascAction implements GlobalV
|
|||
p.write("<data>\n");
|
||||
for (Object o:entry.getVascFrontendData().getEntryDataList()) {
|
||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||
p.write("<column name=\""+c.getName()+"\">");
|
||||
p.write("<column name=\""+c.getName()+"\"><![CDATA[");
|
||||
p.write(""+c.getVascEntryFieldValue().getValue(c, o));
|
||||
p.write("</column>\n");
|
||||
p.write("]]></column>\n");
|
||||
}
|
||||
p.flush();
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue