Thread: [Ejtools-cvs] CVS: build beaninfo.j,NONE,1.1 build.bat,1.3,1.4 build_application.xml,1.6,1.7
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-05-13 20:38:04
|
Update of /cvsroot/ejtools/build In directory usw-pr-cvs1:/tmp/cvs-serv24965 Modified Files: build.bat build_application.xml Added Files: beaninfo.j Log Message: Add BeanInfo generation by XDoclet (part 1) --- NEW FILE: beaninfo.j --- /* * */ package <XDtPackage:packageOf><XDtClass:fullClassName/></XDtPackage:packageOf>; import java.awt.Image; import java.beans.BeanDescriptor; import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.MethodDescriptor; import java.beans.ParameterDescriptor; import java.beans.PropertyDescriptor; import java.beans.SimpleBeanInfo; import java.beans.beancontext.BeanContextSupport; import java.lang.reflect.Method; import java.util.ResourceBundle; import java.util.Vector; /** * */ public class <XDtClass:classOf><XDtClass:fullClassName/></XDtClass:classOf>BeanInfo extends SimpleBeanInfo { /** Description of the Field */ protected BeanDescriptor bd = new BeanDescriptor(<XDtClass:fullClassName/>.class<XDtClass:ifHasClassTag tagName="beaninfo:class" paramName="customizer">, <XDtClass:classTagValue tagName="beaninfo:class" paramName="customizer"/>.class</XDtClass:ifHasClassTag>); /** Description of the Field */ protected Image iconMono16<XDtClass:ifHasClassTag tagName="beaninfo:icons" paramName="mono16"> = loadImage("<XDtClass:classTagValue tagName="beaninfo:icons" paramName="mono16"/>")</XDtClass:ifHasClassTag>; /** Description of the Field */ protected Image iconColor16<XDtClass:ifHasClassTag tagName="beaninfo:icons" paramName="color16"> = loadImage("<XDtClass:classTagValue tagName="beaninfo:icons" paramName="color16"/>")</XDtClass:ifHasClassTag>; /** Description of the Field */ protected Image iconMono32<XDtClass:ifHasClassTag tagName="beaninfo:icons" paramName="mono32"> = loadImage("<XDtClass:classTagValue tagName="beaninfo:icons" paramName="mono32"/>")</XDtClass:ifHasClassTag>; /** Description of the Field */ protected Image iconColor32<XDtClass:ifHasClassTag tagName="beaninfo:icons" paramName="color32"> = loadImage("<XDtClass:classTagValue tagName="beaninfo:icons" paramName="color32"/>")</XDtClass:ifHasClassTag>; /** Description of the Field */ private final static ResourceBundle res = ResourceBundle.getBundle("<XDtClass:fullClassName/>BeanInfo"); /** Constructor for the <XDtClass:classOf><XDtClass:fullClassName/></XDtClass:classOf>BeanInfo object */ public <XDtClass:classOf><XDtClass:fullClassName/></XDtClass:classOf>BeanInfo() { try { BeanInfo info = Introspector.getBeanInfo(getBeanDescriptor().getBeanClass().getSuperclass()); String order = info.getBeanDescriptor().getValue("propertyorder") == null ? "" : (String) info.getBeanDescriptor().getValue("propertyorder"); PropertyDescriptor[] pd = getPropertyDescriptors(); for (int i = 0; i != pd.length; i++) { if (order.indexOf(pd[i].getName()) == -1) { order = order + (order.length() == 0 ? "" : ":") + pd[i].getName(); } } getBeanDescriptor().setValue("propertyorder", order); } catch (Exception e) { // Ignore it } } /** * Gets the additionalBeanInfo ... * * @return The additionalBeanInfo value */ public BeanInfo[] getAdditionalBeanInfo() { Vector bi = new Vector(); BeanInfo[] biarr = null; try { <XDtClass:ifHasClassTag tagName="beaninfo:class" paramName="stopClass"> for (Class cl = <XDtClass:fullClassName/>.class.getSuperclass(); !cl.equals(<XDtClass:classTagValue tagName="beaninfo:class" paramName="stopClass"/>.class.getSuperclass()); cl = cl.getSuperclass()) { bi.addElement(Introspector.getBeanInfo(cl)); } biarr = new BeanInfo[bi.size()]; bi.copyInto(biarr); </XDtClass:ifHasClassTag> } catch (Exception e) { System.err.println(e); } return biarr; } /** * Gets the beanDescriptor attribute ... * * @return The beanDescriptor value */ public BeanDescriptor getBeanDescriptor() { <XDtClass:ifHasClassTag tagName="beaninfo:class" paramName="name">bd.setName("<XDtClass:classTagValue tagName="beaninfo:class" paramName="name"/>");</XDtClass:ifHasClassTag> <XDtClass:ifHasClassTag tagName="beaninfo:class" paramName="displayName">bd.setDisplayName("<XDtClass:classTagValue tagName="beaninfo:class" paramName="displayName"/>");</XDtClass:ifHasClassTag> <XDtClass:ifHasClassTag tagName="beaninfo:class" paramName="shortDescription">bd.setShortDescription("<XDtClass:classTagValue tagName="beaninfo:class" paramName="shortDescription"/>");</XDtClass:ifHasClassTag> <XDtClass:ifHasClassTag tagName="beaninfo:class" paramName="expert">bd.setExpert(<XDtClass:classTagValue tagName="beaninfo:class" paramName="expert" values="true,false"/>);</XDtClass:ifHasClassTag> <XDtClass:ifHasClassTag tagName="beaninfo:class" paramName="hidden">bd.setHidden(<XDtClass:classTagValue tagName="beaninfo:class" paramName="hidden" values="true,false"/>);</XDtClass:ifHasClassTag> <XDtClass:ifHasClassTag tagName="beaninfo:class" paramName="preferred">bd.setPreferred(<XDtClass:classTagValue tagName="beaninfo:class" paramName="preferred" values="true,false"/>);</XDtClass:ifHasClassTag> <XDtClass:forAllClassTags tagName="beaninfo:attribute"> bd.setValue("<XDtClass:classTagValue tagName="beaninfo:attribute" paramName="name"/>","<XDtClass:classTagValue tagName="beaninfo:attribute" paramName="value"/>"); </XDtClass:forAllClassTags> return bd; } /** * Gets the defaultPropertyIndex attribute ... * * @return The defaultPropertyIndex value */ public int getDefaultPropertyIndex() { String defName = "<XDtClass:classTagValue tagName="beaninfo:class" paramName="defaultProperty" default=""/>"; if (defName.equals("")) return -1; PropertyDescriptor[] pd = getPropertyDescriptors(); for (int i = 0; i < pd.length; i++) { if (pd[i].getName().equals(defName)) { return i; } } return -1; } /** * Gets the icon attribute of the ... * * @param type Description of the Parameter * @return The icon value */ public Image getIcon(int type) { if (type == BeanInfo.ICON_COLOR_16x16) { return iconColor16; } if (type == BeanInfo.ICON_MONO_16x16) { return iconMono16; } if (type == BeanInfo.ICON_COLOR_32x32) { return iconColor32; } if (type == BeanInfo.ICON_MONO_32x32) { return iconMono32; } return null; } /** * Gets the methodDescriptors attribute ... * * @return The methodDescriptors value */ public MethodDescriptor[] getMethodDescriptors() { // MethodDescriptor[] methods = new MethodDescriptor[<methodCount/>]; int i = 0; Method[] m; Method method; // <method> try { m = Class.forName("<beanClass/>").getMethods(); } catch (ClassNotFoundException e) { System.err.println(e); return new MethodDescriptor[0]; } method = null; for (int j = 0; j != m.length; j++) { if (m[j].getName().equals("<methodName/>")) { method = m[j]; break; } } if (method != null) { ParameterDescriptor[] pd = new ParameterDescriptor[method.getParameterTypes().length]; int pidx = 0; // <parameter> pd[pidx] = new ParameterDescriptor(); // <hasPropertyEditor>pd[pidx].setValue("propertyeditor","<propertyEditor/>");</hasPropertyEditor> pd[pidx++].setDisplayName(res.getString("parameter.<methodName/>." + pidx + ".displayname")); // </parameter> if (pidx == 0) { methods[i] = new MethodDescriptor(method); } else { methods[i] = new MethodDescriptor(method, pd); } methods[i].setName("<methodName/>"); // <hasDisplayName>methods[i].setDisplayName(res.getString("method.<methodName/>.displayname"));</hasDisplayName> // <hasShortDescription>methods[i].setShortDescription(res.getString("method.<methodName/>.shortdescription"));</hasShortDescription> // <isExpert>methods[i].setExpert(true);</isExpert> // <isHidden>methods[i].setHidden(true);</isHidden> // <attribute> methods[i].setValue("<attributeName/>", "<attributeValue/>"); // </attribute> i++; } // </method> return methods; } /** * Gets the propertyDescriptors attribute ... * * @return The propertyDescriptors value */ public PropertyDescriptor[] getPropertyDescriptors() { try { // PropertyDescriptor[] properties = new PropertyDescriptor[<propertyCount/>]; int i = 0; // <property> try { // <isReadOnly>if (false)</isReadOnly> // properties[i] = new PropertyDescriptor("<propertyName/>",<beanClass/>.class); // <isReadOnly>else // properties[i] = new PropertyDescriptor("<propertyName/>",<beanClass/>.class, "<getter/>",null); // </isReadOnly> } catch (IntrospectionException e) { // properties[i] = new PropertyDescriptor("<propertyName/>",<beanClass/>.class, "<getter/>",null); } // <isBound>properties[i].setBound(true);</isBound> // <isConstrained>properties[i].setConstrained(true);</isConstrained> // <hasPropertyEditor>properties[i].setPropertyEditorClass(Class.forName("<propertyEditor/>"));</hasPropertyEditor> // <hasDisplayName>properties[i].setDisplayName(res.getString("property.<propertyName/>.displayname"));</hasDisplayName> // <hasShortDescription>properties[i].setShortDescription(res.getString("property.<propertyName/>.shortdescription"));</hasShortDescription> // <isExpert>properties[i].setExpert(true);</isExpert> // <isHidden>properties[i].setHidden(true);</isHidden> // <attribute> properties[i].setValue("<attributeName/>", "<attributeValue/>"); // </attribute> i++; // </property> return properties; } catch (Exception e) { System.err.println(e); return null; } } } Index: build.bat =================================================================== RCS file: /cvsroot/ejtools/build/build.bat,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** build.bat 6 May 2002 20:36:15 -0000 1.3 --- build.bat 13 May 2002 20:30:47 -0000 1.4 *************** *** 29,33 **** set CP=%CP%;%THIRDPARTY%\dreambean\codegen\ set CP=%CP%;%THIRDPARTY%\dreambean\codegen\codegen.jar ! REM set CP=%CP%;%THIRDPARTY%\dreambean\xmlbeans\i18nbeans.jar set CP=%CP%;%THIRDPARTY%\dreambean\xmlbeans\xmlbeans.jar --- 29,33 ---- set CP=%CP%;%THIRDPARTY%\dreambean\codegen\ set CP=%CP%;%THIRDPARTY%\dreambean\codegen\codegen.jar ! set CP=%CP%;%THIRDPARTY%\dreambean\xmlbeans\ set CP=%CP%;%THIRDPARTY%\dreambean\xmlbeans\xmlbeans.jar Index: build_application.xml =================================================================== RCS file: /cvsroot/ejtools/build/build_application.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** build_application.xml 6 May 2002 20:36:15 -0000 1.6 --- build_application.xml 13 May 2002 20:30:47 -0000 1.7 *************** *** 16,19 **** --- 16,20 ---- <!-- ==================== Task Definitions ======================== --> <taskdef name="xmlbean" classname="com.dreambean.xmlbeans.ant.XMLBeans"/> + <taskdef name="xdoclet" classname="xdoclet.DocletTask"/> <taskdef name="todo" classname="xdoclet.doc.DocumentDocletTask"/> <!-- ==================== Module Definition ======================== --> *************** *** 131,138 **** --- 132,148 ---- <target name="xmlbeans" depends="compile" if="has.dir.etc.beaninfo"> <mkdir dir="${build.src}"/> + <xdoclet sourcepath="${src.main}" destdir="${build.src}" classpathref="compile.classpath"> + <fileset dir="${src.main}"> + <include name="**/*.java"/> + <exclude name="**/CVS/**"/> + </fileset> + <template templateFile="build/beaninfo.j" destinationFile="{0}BeanInfo.java" havingClassTag="beaninfo:class"/> + </xdoclet> + <!-- <xmlbean destdir="${build.src}" srcdir="../${src.etc}/beaninfo" includes="**" excludes="**/CVS/**"/> <javac srcdir="${build.src}" destdir="${build.classes}" classpath="${classpath}" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}" includes="**/*BeanInfo.java" excludes="**/CVS/**"> <classpath refid="compile.classpath"/> </javac> + --> </target> <!-- ==================== Build Target ===================================== --> |