[svn r236] fixed swt test and added annotations
This commit is contained in:
parent
5e425bd032
commit
54ca574e58
|
@ -3,16 +3,15 @@
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="tests"/>
|
<classpathentry kind="src" path="tests"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="lib" path="lib/junit-4.1.jar"/>
|
|
||||||
<classpathentry kind="lib" path="lib/idcanet-x4o-bin.jar"/>
|
<classpathentry kind="lib" path="lib/idcanet-x4o-bin.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/juel-2.1.0-rc1.jar"/>
|
<classpathentry kind="lib" path="lib/juel-2.1.0-rc1.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/juel-2.1.0-rc1-impl.jar"/>
|
<classpathentry kind="lib" path="lib/juel-2.1.0-rc1-impl.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/idcanet-xtes-bin.jar"/>
|
<classpathentry kind="lib" path="lib/idcanet-xtes-bin.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/idcanet-serv5-bin.jar"/>
|
<classpathentry kind="lib" path="lib/idcanet-serv5-bin.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/hibernate3.jar"/>
|
<classpathentry kind="lib" path="lib/hibernate3.jar"/>
|
||||||
<classpathentry kind="con" path="SWT_CONTAINER/PLATFORM"/>
|
|
||||||
<classpathentry kind="lib" path="lib/jgoodies-binding.jar"/>
|
<classpathentry kind="lib" path="lib/jgoodies-binding.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/swtbinding-20051212111010.jar"/>
|
<classpathentry kind="con" path="SWT_CONTAINER/JFACE/PLATFORM"/>
|
||||||
<classpathentry kind="lib" path="lib/org.eclipse.jface_3.2.1.jar"/>
|
<classpathentry kind="lib" path="lib/idcanet-jmx-bin.jar"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
BIN
lib/idcanet-jmx-bin.jar
Normal file
BIN
lib/idcanet-jmx-bin.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
204
src/com/idcanet/vasc/annotations/VascAnnotationParser.java
Normal file
204
src/com/idcanet/vasc/annotations/VascAnnotationParser.java
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
/*
|
||||||
|
* 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.Annotation;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the Vasc annotations
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 27, 2006
|
||||||
|
*/
|
||||||
|
public class VascAnnotationParser {
|
||||||
|
|
||||||
|
/** Determens if no when no annotation is found null will return or default key */
|
||||||
|
private Boolean noAnnotationNullReturn = null;
|
||||||
|
|
||||||
|
private Logger logger = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an VascAnnotationParser
|
||||||
|
*/
|
||||||
|
public VascAnnotationParser() {
|
||||||
|
setNoAnnotationNullReturn(false);
|
||||||
|
logger = Logger.getLogger(VascAnnotationParser.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determens if no when no annotation is found null will return or default key
|
||||||
|
* default is false
|
||||||
|
* @param noAnnotationNullReturn
|
||||||
|
*/
|
||||||
|
public VascAnnotationParser(boolean noAnnotationNullReturn) {
|
||||||
|
setNoAnnotationNullReturn(noAnnotationNullReturn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the key of the VascToolTip key for the property of the class
|
||||||
|
* @param beanClass The class to search for the property
|
||||||
|
* @param property The property for the ToolTip
|
||||||
|
* @return The i18n key for an ToolTip
|
||||||
|
*/
|
||||||
|
public String getVascToolTipKey(Class beanClass,String property) {
|
||||||
|
return (String)getValue(beanClass,VascToolTip.class,property);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVascToolTipKey(Class beanClass) {
|
||||||
|
return (String)getValue(beanClass,VascToolTip.class,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
public String getVascNameKey(Class beanClass,String property) {
|
||||||
|
return (String)getValue(beanClass,VascName.class,property);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVascLabelKey(Class beanClass) {
|
||||||
|
return (String)getValue(beanClass,VascName.class,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No oop code here...refactor at some point in time
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param beanClass
|
||||||
|
* @param property
|
||||||
|
* @param annotationType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Object getValue(Class beanClass,Class annotationType,String property) {
|
||||||
|
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) {
|
||||||
|
result = doAnnotation(beanClass.getAnnotation(annotationType));
|
||||||
|
if(result!=null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (noAnnotationNullReturn) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return beanClass.getName()+"."+annotationType.getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
String propRest = null;
|
||||||
|
int index = property.indexOf(".");
|
||||||
|
if(index>0) {
|
||||||
|
propRest = property.substring(index+1);
|
||||||
|
property = property.substring(0,index);
|
||||||
|
logger.finest("slit property into: '"+propRest+"' and '"+property+"'");
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
Class typeClass = mt.type();
|
||||||
|
if(Object.class==mt.type()) {
|
||||||
|
typeClass = method.getReturnType();
|
||||||
|
//return returnType.getName()+"."+annotationType.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// recursif function:
|
||||||
|
return getValue(typeClass,annotationType,propRest);
|
||||||
|
}
|
||||||
|
result = doAnnotation(method.getAnnotation(annotationType));
|
||||||
|
if(result!=null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (noAnnotationNullReturn) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
break; // return default
|
||||||
|
}
|
||||||
|
return beanClass.getName()+"."+property+"."+annotationType.getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object doAnnotation(Annotation a) {
|
||||||
|
|
||||||
|
if (a.equals(VascName.class)) {
|
||||||
|
VascName l = (VascName)a;
|
||||||
|
if("".equals(l.key()) | "null".equals(l.key())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return l.key();
|
||||||
|
}
|
||||||
|
if (a.equals(VascToolTip.class)) {
|
||||||
|
VascToolTip t = (VascToolTip)a;
|
||||||
|
if("".equals(t.key()) | "null".equals(t.key())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return t.key();
|
||||||
|
}
|
||||||
|
if (a.equals(VascHelpId.class)) {
|
||||||
|
VascHelpId h = (VascHelpId)a;
|
||||||
|
if("".equals(h.helpId()) | "null".equals(h.helpId())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return h.helpId();
|
||||||
|
}
|
||||||
|
if (a.equals(VascDefaultValue.class)) {
|
||||||
|
VascDefaultValue v = (VascDefaultValue)a;
|
||||||
|
if (v.defaultValue()==null) {
|
||||||
|
return null; // error ??
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return v.defaultValue().newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.log(Level.WARNING,e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default is false
|
||||||
|
* @return Returns the noAnnotationNullReturn.
|
||||||
|
*/
|
||||||
|
public Boolean getNoAnnotationNullReturn() {
|
||||||
|
return noAnnotationNullReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param noAnnotationNullReturn The noAnnotationNullReturn to set.
|
||||||
|
*/
|
||||||
|
public void setNoAnnotationNullReturn(Boolean noAnnotationNullReturn) {
|
||||||
|
this.noAnnotationNullReturn = noAnnotationNullReturn;
|
||||||
|
}
|
||||||
|
}
|
49
src/com/idcanet/vasc/annotations/VascDefaultValue.java
Normal file
49
src/com/idcanet/vasc/annotations/VascDefaultValue.java
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* 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 defaultValue
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Mar 28, 2007
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.METHOD,ElementType.TYPE})
|
||||||
|
public @interface VascDefaultValue {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The defaultValue of the method
|
||||||
|
*/
|
||||||
|
Class defaultValue();
|
||||||
|
}
|
49
src/com/idcanet/vasc/annotations/VascHelpId.java
Normal file
49
src/com/idcanet/vasc/annotations/VascHelpId.java
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* 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 helpId
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Mar 28, 2007
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.METHOD,ElementType.TYPE})
|
||||||
|
public @interface VascHelpId {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The defaultValue of the method
|
||||||
|
*/
|
||||||
|
String helpId() default "null";
|
||||||
|
}
|
46
src/com/idcanet/vasc/annotations/VascModelReference.java
Normal file
46
src/com/idcanet/vasc/annotations/VascModelReference.java
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When plased on a getter is will redirect the label and tooltip text to the type of the return type
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 27, 2006
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface VascModelReference {
|
||||||
|
|
||||||
|
Class type() default Object.class;
|
||||||
|
}
|
51
src/com/idcanet/vasc/annotations/VascName.java
Normal file
51
src/com/idcanet/vasc/annotations/VascName.java
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* 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 I18nLabel(non default) an a Class property
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 27, 2006
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.METHOD,ElementType.TYPE})
|
||||||
|
public @interface VascName {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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";
|
||||||
|
}
|
51
src/com/idcanet/vasc/annotations/VascToolTip.java
Normal file
51
src/com/idcanet/vasc/annotations/VascToolTip.java
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* 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 I18nToolTip(non default) an a Class property
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 May 27, 2006
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.METHOD,ElementType.TYPE})
|
||||||
|
public @interface VascToolTip {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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";
|
||||||
|
}
|
143
src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java
Normal file
143
src/com/idcanet/vasc/impl/swing/SwingVascViewRenderer.java
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
/*
|
||||||
|
* 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.swing;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
import javax.swing.table.TableColumn;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.core.VascTable;
|
||||||
|
import com.idcanet.vasc.core.VascUserOption;
|
||||||
|
import com.idcanet.vasc.core.VascViewRenderer;
|
||||||
|
import com.idcanet.vasc.core.actions.RowVascAction;
|
||||||
|
import com.idcanet.vasc.core.column.VascTableColumn;;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Mar 21, 2007
|
||||||
|
*/
|
||||||
|
public class SwingVascViewRenderer implements VascViewRenderer {
|
||||||
|
|
||||||
|
private Logger logger = null;
|
||||||
|
private JComponent parent = null;
|
||||||
|
private VascTable table = null;
|
||||||
|
|
||||||
|
public SwingVascViewRenderer(JComponent parent) {
|
||||||
|
logger = Logger.getLogger(SwingVascViewRenderer.class.getName());
|
||||||
|
this.parent=parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see com.idcanet.vasc.core.VascViewRenderer#renderView(com.idcanet.vasc.core.VascTable)
|
||||||
|
*/
|
||||||
|
public void renderView(VascTable table) {
|
||||||
|
this.table=table;
|
||||||
|
try {
|
||||||
|
table.setTableData(table.getVascDataSource().executeQuery(table.getQuery()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JPanel topPanel = new JPanel();
|
||||||
|
renderHeader(topPanel);
|
||||||
|
renderBody(topPanel);
|
||||||
|
renderFooter(topPanel);
|
||||||
|
parent.add(topPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderHeader(JComponent parent2) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderBody(JComponent parent2) {
|
||||||
|
JTable jTable = new JTable(new VascColumnModel());
|
||||||
|
|
||||||
|
|
||||||
|
for(VascTableColumn c:table.getTableColumns()) {
|
||||||
|
VascJTableColumn t = new VascJTableColumn();
|
||||||
|
t.setPreferredWidth(c.getWidth());
|
||||||
|
t.setHeaderValue(c.getName());
|
||||||
|
|
||||||
|
jTable.addColumn(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane(jTable);
|
||||||
|
parent2.add(scrollPane);
|
||||||
|
}
|
||||||
|
private void renderFooter(JComponent parent2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
class VascJTableColumn extends TableColumn {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class VascColumnModel extends AbstractTableModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see javax.swing.table.TableModel#getColumnCount()
|
||||||
|
*/
|
||||||
|
public int getColumnCount() {
|
||||||
|
return table.getTableColumns().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see javax.swing.table.TableModel#getRowCount()
|
||||||
|
*/
|
||||||
|
public int getRowCount() {
|
||||||
|
if (table.getTableData()==null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return table.getTableData().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see javax.swing.table.TableModel#getValueAt(int, int)
|
||||||
|
*/
|
||||||
|
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||||
|
Object bean = table.getTableData().get(rowIndex);
|
||||||
|
System.out.println("Rending column; "+columnIndex+" bean: "+bean);
|
||||||
|
VascTableColumn vtc = table.getTableColumns().get(columnIndex);
|
||||||
|
if (vtc.getColumnRenderer()!=null) {
|
||||||
|
//do iets
|
||||||
|
return "RENDER";
|
||||||
|
} else {
|
||||||
|
return ""+vtc.getVascColumnValue().getValue(vtc,bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -163,8 +163,6 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
||||||
// Set the content and label providers
|
// Set the content and label providers
|
||||||
tableViewer.setContentProvider(new ListConverterContentProvider());
|
tableViewer.setContentProvider(new ListConverterContentProvider());
|
||||||
tableViewer.setLabelProvider(new DefaultLabelProvider(table));
|
tableViewer.setLabelProvider(new DefaultLabelProvider(table));
|
||||||
//tv.setSorter(new PlayerViewerSorter());
|
|
||||||
tableViewer.setInput(table);
|
|
||||||
|
|
||||||
for(VascTableColumn c:table.getTableColumns()) {
|
for(VascTableColumn c:table.getTableColumns()) {
|
||||||
TableColumn tc = new TableColumn(table2, SWT.LEFT);
|
TableColumn tc = new TableColumn(table2, SWT.LEFT);
|
||||||
|
@ -224,22 +222,10 @@ public class SwtVascViewRenderer implements VascViewRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.fine("Table with columns created: "+table2.getColumnCount());
|
logger.fine("Table with columns created: "+table2.getColumnCount());
|
||||||
|
|
||||||
|
tableViewer.setInput(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
private static AbstractColumn[] getTableColumns(VascTable crudTable) {
|
|
||||||
AbstractColumn[] cols = new AbstractColumn[crudTable.getCrudTableColumns().size()];
|
|
||||||
int i=0;
|
|
||||||
for(VascTableColumn c:crudTable.getTableColumns()) {
|
|
||||||
AbstractColumn ac = new PropertyColumn(crudTable.i18n(c.getName()),c.getObjectProperty());
|
|
||||||
ac.setEditable(false);
|
|
||||||
ac.setReorderable(true);
|
|
||||||
ac.setSortable(true);
|
|
||||||
cols[i]=ac;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return cols;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public void createFooter(Composite footer) {
|
public void createFooter(Composite footer) {
|
||||||
logger.finest("Creating footer");
|
logger.finest("Creating footer");
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
<xtes xmlns="http://xtes.idcanet.com/eld/xtes-lang.eld"
|
<xtes xmlns="http://xtes.idcanet.com/eld/xtes-lang.eld"
|
||||||
xmlns:x4o="http://x4o.idcanet.com/eld/x4o-lang.eld"
|
xmlns:x4o="http://x4o.idcanet.com/eld/x4o-lang.eld"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<xslt>
|
||||||
|
# Convert from xml -> csv and html or xitext
|
||||||
|
</xslt>
|
||||||
|
-->
|
||||||
|
|
||||||
<query name="limit">
|
<query name="limit">
|
||||||
<sql>
|
<sql>
|
||||||
LIMIT <parameter name="limit"/>
|
LIMIT <parameter name="limit"/>
|
||||||
|
|
|
@ -51,7 +51,7 @@ import junit.framework.TestCase;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Jul 24, 2006
|
* @version 1.0 Jul 24, 2006
|
||||||
*/
|
*/
|
||||||
public class SimpleTest extends TestCase {
|
public class SWTTest extends TestCase {
|
||||||
|
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
// enable all logs
|
// enable all logs
|
||||||
|
@ -88,7 +88,7 @@ public class SimpleTest extends TestCase {
|
||||||
table.setToolTip("tooltip text");
|
table.setToolTip("tooltip text");
|
||||||
table.setDescription("en de omscheiving");
|
table.setDescription("en de omscheiving");
|
||||||
table.setHelpId("someKey");
|
table.setHelpId("someKey");
|
||||||
table.setVascDataSource(new Serv5HibernateVascDataSource("flowstats"));
|
table.setVascDataSource(new TestModelVascDataSource());
|
||||||
table.setVascTextValue(new DefaultVascTextValue());
|
table.setVascTextValue(new DefaultVascTextValue());
|
||||||
table.setVascViewRenderer(render);
|
table.setVascViewRenderer(render);
|
||||||
table.setQuery(query);
|
table.setQuery(query);
|
||||||
|
@ -102,7 +102,18 @@ public class SimpleTest extends TestCase {
|
||||||
column.setWidth(200);
|
column.setWidth(200);
|
||||||
//column.setVascColumnEditor(vascColumnEditor);
|
//column.setVascColumnEditor(vascColumnEditor);
|
||||||
//column.setVascColumnRenderer(vascColumnRenderer);
|
//column.setVascColumnRenderer(vascColumnRenderer);
|
||||||
column.setVascColumnValue(new BeanPropertyVascColumnValue("someValue"));
|
column.setVascColumnValue(new BeanPropertyVascColumnValue("name"));
|
||||||
|
table.addTableColumns(column);
|
||||||
|
|
||||||
|
column = new VascTableColumn();
|
||||||
|
column.setName("test2");
|
||||||
|
column.setToolTip("tooltip2");
|
||||||
|
column.setDefaultValue("DEFF2FFFF");
|
||||||
|
column.setHelpId("helpColum2nKey");
|
||||||
|
column.setWidth(200);
|
||||||
|
//column.setVascColumnEditor(vascColumnEditor);
|
||||||
|
//column.setVascColumnRenderer(vascColumnRenderer);
|
||||||
|
column.setVascColumnValue(new BeanPropertyVascColumnValue("description"));
|
||||||
table.addTableColumns(column);
|
table.addTableColumns(column);
|
||||||
|
|
||||||
// render
|
// render
|
131
tests/com/idcanet/vasc/tests/SwingTest.java
Normal file
131
tests/com/idcanet/vasc/tests/SwingTest.java
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
* 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.tests;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.logging.LogManager;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.core.VascTable;
|
||||||
|
import com.idcanet.vasc.core.column.VascTableColumn;
|
||||||
|
import com.idcanet.vasc.impl.BeanVascRecordCreator;
|
||||||
|
import com.idcanet.vasc.impl.DefaultVascTextValue;
|
||||||
|
import com.idcanet.vasc.impl.column.BeanPropertyVascColumnValue;
|
||||||
|
import com.idcanet.vasc.impl.serv5.Serv5HibernateVascDataSource;
|
||||||
|
import com.idcanet.vasc.impl.swing.SwingVascViewRenderer;
|
||||||
|
import com.idcanet.vasc.impl.swt.SwtVascViewRenderer;
|
||||||
|
import com.idcanet.xtes.core.TemplateStore;
|
||||||
|
import com.idcanet.xtes.core.XTESParser;
|
||||||
|
import com.idcanet.xtes.xpql.query.Query;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests a simple x4o xml language.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Jul 24, 2006
|
||||||
|
*/
|
||||||
|
public class SwingTest extends TestCase {
|
||||||
|
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
// enable all logs
|
||||||
|
InputStream loggingProperties = this.getClass().getResourceAsStream("/META-INF/logging.properties");
|
||||||
|
LogManager.getLogManager().readConfiguration( loggingProperties );
|
||||||
|
loggingProperties.close();
|
||||||
|
|
||||||
|
// load xtes queries
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAll() throws Exception {
|
||||||
|
|
||||||
|
// get GUI
|
||||||
|
JFrame frame = new JFrame();
|
||||||
|
frame.setTitle("Hello, world!");
|
||||||
|
frame.setDefaultLookAndFeelDecorated(false);
|
||||||
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
frame.pack();
|
||||||
|
frame.setBounds(150,150,700,500);
|
||||||
|
|
||||||
|
|
||||||
|
// define query
|
||||||
|
XTESParser parser = new XTESParser();
|
||||||
|
parser.parseResource("/META-INF/xtes/tests.xml");
|
||||||
|
TemplateStore store = XTESParser.getTemplateStore(parser.getElementContext());
|
||||||
|
Query query = store.getQuery("testUsers2");
|
||||||
|
|
||||||
|
// define redering
|
||||||
|
SwingVascViewRenderer render = new SwingVascViewRenderer(frame.getRootPane());
|
||||||
|
|
||||||
|
// config table
|
||||||
|
VascTable table = new VascTable();
|
||||||
|
table.setName("Testje");
|
||||||
|
table.setHeaderName("TableHeader");
|
||||||
|
table.setToolTip("tooltip text");
|
||||||
|
table.setDescription("en de omscheiving");
|
||||||
|
table.setHelpId("someKey");
|
||||||
|
table.setVascDataSource(new TestModelVascDataSource());
|
||||||
|
table.setVascTextValue(new DefaultVascTextValue());
|
||||||
|
table.setVascViewRenderer(render);
|
||||||
|
table.setQuery(query);
|
||||||
|
table.setVascRecordCreator(new BeanVascRecordCreator());
|
||||||
|
|
||||||
|
VascTableColumn column = new VascTableColumn();
|
||||||
|
column.setName("test");
|
||||||
|
column.setToolTip("tooltip");
|
||||||
|
column.setDefaultValue("DEFFFFFF");
|
||||||
|
column.setHelpId("helpColumnKey");
|
||||||
|
column.setWidth(200);
|
||||||
|
//column.setVascColumnEditor(vascColumnEditor);
|
||||||
|
//column.setVascColumnRenderer(vascColumnRenderer);
|
||||||
|
column.setVascColumnValue(new BeanPropertyVascColumnValue("name"));
|
||||||
|
table.addTableColumns(column);
|
||||||
|
|
||||||
|
// render
|
||||||
|
render.renderView(table);
|
||||||
|
|
||||||
|
// view
|
||||||
|
frame.getContentPane().validate();
|
||||||
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
String test="34";
|
||||||
|
while (true) {
|
||||||
|
test+=test+"34566";
|
||||||
|
if(test.length()>1000000) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
tests/com/idcanet/vasc/tests/TestModelVascDataSource.java
Normal file
75
tests/com/idcanet/vasc/tests/TestModelVascDataSource.java
Normal file
|
@ -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.tests;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.core.VascDataSource;
|
||||||
|
import com.idcanet.vasc.tests.models.TestModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Mar 21, 2007
|
||||||
|
*/
|
||||||
|
public class TestModelVascDataSource implements VascDataSource {
|
||||||
|
|
||||||
|
private List<Object> testModels = null;
|
||||||
|
|
||||||
|
public TestModelVascDataSource() {
|
||||||
|
testModels = new ArrayList<Object>(2);
|
||||||
|
|
||||||
|
TestModel t = new TestModel();
|
||||||
|
t.setDate(new Date());
|
||||||
|
t.setDescription("yoyo test");
|
||||||
|
t.setName("this Name");
|
||||||
|
t.setPrice(34.1f);
|
||||||
|
testModels.add(t);
|
||||||
|
|
||||||
|
t = new TestModel();
|
||||||
|
t.setDate(new Date());
|
||||||
|
t.setDescription("Model2 test");
|
||||||
|
t.setName("BeanSourde");
|
||||||
|
t.setPrice(19.2f);
|
||||||
|
testModels.add(t);
|
||||||
|
}
|
||||||
|
public TestModelVascDataSource(List<Object> testModels) {
|
||||||
|
this.testModels=testModels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Object> executeQuery(com.idcanet.xtes.xpql.query.Query query) throws Exception {
|
||||||
|
return testModels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void persist(Object object) throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
106
tests/com/idcanet/vasc/tests/models/TestModel.java
Normal file
106
tests/com/idcanet/vasc/tests/models/TestModel.java
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.tests.models;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.idcanet.vasc.annotations.VascName;
|
||||||
|
import com.idcanet.vasc.annotations.VascToolTip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TestModel
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Mar 28, 2007
|
||||||
|
*/
|
||||||
|
public class TestModel {
|
||||||
|
|
||||||
|
private String name = null;
|
||||||
|
private String description = null;
|
||||||
|
private Float price = null;
|
||||||
|
private Date date = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the date
|
||||||
|
*/
|
||||||
|
public Date getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param date the date to set
|
||||||
|
*/
|
||||||
|
public void setDate(Date date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the description
|
||||||
|
*/
|
||||||
|
@VascName(key="omscheiving")
|
||||||
|
@VascToolTip(key="De omscheiving")
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param description the description to set
|
||||||
|
*/
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name the name to set
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the price
|
||||||
|
*/
|
||||||
|
public Float getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param price the price to set
|
||||||
|
*/
|
||||||
|
public void setPrice(Float price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue