From: Wouter Z. <dra...@us...> - 2005-07-30 12:09:13
|
User: draftdog Date: 05/07/30 05:09:04 Modified: andromda-bpm4struts/src/templates/bpm4struts/forms ActionForm.java.vsl ActionFormInterface.java.vsl andromda-bpm4struts/src/test/expected cartridge-output.zip uml/uml14/src/java/org/andromda/metafacades/uml14 ClassifierFacadeLogicImpl.java FrontEndParameterLogicImpl.java andromda-bpm4struts/src/templates/bpm4struts/controllers ControllerImpl.java.vsl online-store/mda/src/uml online-store.xml.zip andromda-bpm4struts/src/templates/bpm4struts/pages page-table.jspf.vsl Log: improved row selection form fields, simplified code, added a deferrable event to the online store to prove row selection takes into account the type of the field (in the xxxAsArray method), hints should only be shown when requested by the configuration, dummy code generation takes into account row selection Revision Changes Path 1.14 +33 -17 cartridges/andromda-bpm4struts/src/templates/bpm4struts/forms/ActionForm.java.vsl Index: ActionForm.java.vsl =================================================================== RCS file: /cvsroot/andromda/cartridges/andromda-bpm4struts/src/templates/bpm4struts/forms/ActionForm.java.vsl,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -r1.13 -r1.14 --- ActionForm.java.vsl 29 Jul 2005 17:25:17 -0000 1.13 +++ ActionForm.java.vsl 30 Jul 2005 12:08:34 -0000 1.14 @@ -24,9 +24,8 @@ private org.apache.struts.upload.FormFile $field.name = null; #elseif ($field.table) private $field.type.fullyQualifiedName $field.name = null; -#if (!$field.tableGlobalActions.empty) +#elseif ($action.actionParameters.contains($field) && $action.tableAction) private java.util.List ${field.name}RowSelection = null; -#end #elseif($field.type.mapType) private java.util.Map $field.name = new java.util.HashMap(); #else @@ -71,6 +70,15 @@ this.${fieldName}.clear(); } +#elseif ($action.actionParameters.contains($field) && $action.tableAction) + /** + * Resets the given <code>${fieldName}RowSelection</code>. + */ + public void ${field.resetName}() + { + this.${fieldName}RowSelection = null; + } + #else /** * Resets the given <code>$fieldName</code>. @@ -111,28 +119,32 @@ return ($fieldName == null) ? null : ${fieldName}.toArray(); } -#elseif (!$field.tableGlobalActions.empty) -#set ($fieldType = "java.util.List") +#elseif ($action.actionParameters.contains($field) && $action.tableAction) #set ($fieldName = $field.name) +#if ($field.type.primitive) +#set ($fieldType = "$field.type.wrapperName") +#else +#set ($fieldType = "$field.type.fullyQualifiedName") +#end #set ($accessSuffix = "RowSelection") - public void ${field.setterName}${accessSuffix}($fieldType $fieldName${accessSuffix}) + public void ${field.setterName}${accessSuffix}(java.util.List $fieldName${accessSuffix}) { this.$fieldName${accessSuffix} = $fieldName${accessSuffix}; } - public $fieldType ${field.getterName}${accessSuffix}() + public java.util.List ${field.getterName}${accessSuffix}() { return this.$fieldName${accessSuffix}; } - public void ${field.setterName}${accessSuffix}AsArray(Object[] $fieldName${accessSuffix}) + public void ${field.setterName}${accessSuffix}AsArray(${fieldType}[] $fieldName${accessSuffix}) { this.$fieldName${accessSuffix} = ($fieldName${accessSuffix} == null) ? null : java.util.Arrays.asList($fieldName${accessSuffix}); } - public java.lang.Object[] ${field.getterName}${accessSuffix}AsArray() + public ${fieldType}[] ${field.getterName}${accessSuffix}AsArray() { - return ($fieldName${accessSuffix} == null) ? null : ${fieldName}${accessSuffix}.toArray(); + return ($fieldName${accessSuffix} == null) ? null : (${fieldType}[])${fieldName}${accessSuffix}.toArray(new ${fieldType}[${fieldName}${accessSuffix}.size()]); } #elseif ($field.date || $field.time) @@ -223,7 +235,7 @@ * @see ${action.formBeanType}${hash}${field.getterName} * @see ${action.formBeanType}${hash}${field.getterName}As${asType} */ - public final static java.text.DateFormat ${field.getterName}${asType}Formatter() + public static java.text.DateFormat ${field.getterName}${asType}Formatter() { #if ($field.date) return ${formBeanClassName}.${dateFormatter}; @@ -284,7 +296,6 @@ } #end - #set ($listType = "Object[]") #set ($backingListName = $field.backingListName) #set ($backingListMethod = $stringUtils.capitalize($backingListName)) @@ -387,7 +398,7 @@ this.$field.labelListName = new java.lang.Object[0]; #end #end -#if (!$field.tableGlobalActions.empty) +#if ($action.actionParameters.contains($field) && $action.tableAction) this.${field.name}RowSelection = null; #end #end @@ -401,9 +412,13 @@ #if ($field.password) builder.append("$field.name", "***"); #else +#if ($action.actionParameters.contains($field) && $action.tableAction) + builder.append("${field.name}RowSelection", this.${field.name}RowSelection); +#else builder.append("$field.name", this.$field.name); #end #end +#end return builder.toString(); } @@ -415,14 +430,15 @@ public void clean() { #foreach ($field in $fields) +#if ($action.actionParameters.contains($field) && $action.tableAction) + this.${field.name}RowSelection = null; +#else this.$field.name = $field.nullValue; +#end #if ($field.selectable) this.$field.valueListName = null; this.$field.labelListName = null; #end -#if (!$field.tableGlobalActions.empty) - this.${field.name}RowSelection = null; -#end #end } 1.6 +57 -46 cartridges/andromda-bpm4struts/src/templates/bpm4struts/forms/ActionFormInterface.java.vsl Index: ActionFormInterface.java.vsl =================================================================== RCS file: /cvsroot/andromda/cartridges/andromda-bpm4struts/src/templates/bpm4struts/forms/ActionFormInterface.java.vsl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -r1.5 -r1.6 --- ActionFormInterface.java.vsl 28 Jul 2005 22:17:04 -0000 1.5 +++ ActionFormInterface.java.vsl 30 Jul 2005 12:08:41 -0000 1.6 @@ -16,6 +16,10 @@ #foreach ($field in $operation.formFields) #set ($fieldType = $field.type.fullyQualifiedName) #set ($fieldName = $field.name) +#set ($tableActionFound = false) +#foreach ($action in $operation.deferringActions) +#if($action.tableAction)#foreach($parameter in $action.actionParameters)#if($parameter.name==$field.name)#set($tableActionFound=true)#end#end#end +#end #if ($field.type.collectionType) /** * This field is a collection type, and this method allows you to set it into the form. @@ -55,52 +59,6 @@ */ public java.lang.Object[] ${field.getterName}AsArray(); -#elseif (!$field.tableGlobalActions.empty) -#set ($fieldType = "java.util.List") -#set ($fieldName = $field.name) -#set ($accessSuffix = "RowSelection") - /** - * This field represents a selection of rows from the <em>$field.tableGlobalActionParameter.name</em> table - * page-variable, this method allows you to set it into the form. - * -$field.getDocumentation(" * ") - * - * @see #${field.setterName}${accessSuffix}AsArray(Object[]) - */ - public void ${field.setterName}${accessSuffix}($fieldType $fieldName${accessSuffix}); - - /** - * This field represents a selection of rows from the <em>$field.tableGlobalActionParameter.name</em> table - * page-variable, this method allows you to get it from the form. - * -$field.getDocumentation(" * ") - * - * @see #${field.getterName}${accessSuffix}AsArray() - */ - public $fieldType ${field.getterName}${accessSuffix}(); - - /** - * This field represents a selection of rows from the <em>$field.tableGlobalActionParameter.name</em> table - * page-variable, this method allows you to set it as an array into the form, conversion will be - * automatically performed. - * -$field.getDocumentation(" * ") - * - * @see #${field.setterName}${accessSuffix}($fieldType) - */ - public void ${field.setterName}${accessSuffix}AsArray(Object[] $fieldName${accessSuffix}); - - /** - * This field represents a selection of rows from the <em>$field.tableGlobalActionParameter.name</em> table - * page-variable, this method allows you to get it as an - * array from the form, conversion will be automatically performed. - * -$field.getDocumentation(" * ") - * - * @see #${field.getterName}${accessSuffix}() - */ - public java.lang.Object[] ${field.getterName}${accessSuffix}AsArray(); - #elseif ($field.date || $field.time) #if ($field.date) #set ($asType = "Date") @@ -196,6 +154,59 @@ */ public org.apache.struts.upload.FormFile ${field.getterName}(); +## +## if this field is used as a row selection parameter somewhere then we need to include that dedicated field too +## +#elseif ($tableActionFound) +#set ($fieldName = $field.name) +#if ($field.type.primitive) +#set ($fieldType = "$field.type.wrapperName") +#else +#set ($fieldType = "$field.type.fullyQualifiedName") +#end +#set ($accessSuffix = "RowSelection") + /** + * This field represents a selection of rows from the <em>$field.tableGlobalActionParameter.name</em> table + * page-variable, this method allows you to set it into the form. + * +$field.getDocumentation(" * ") + * + * @see #${field.setterName}${accessSuffix}AsArray(${fieldType}[]) + */ + public void ${field.setterName}${accessSuffix}(java.util.List $fieldName${accessSuffix}); + + /** + * This field represents a selection of rows from the <em>$field.tableGlobalActionParameter.name</em> table + * page-variable, this method allows you to get it from the form. + * +$field.getDocumentation(" * ") + * + * @see #${field.getterName}${accessSuffix}AsArray() + */ + public java.util.List ${field.getterName}${accessSuffix}(); + + /** + * This field represents a selection of rows from the <em>$field.tableGlobalActionParameter.name</em> table + * page-variable, this method allows you to set it as an array into the form, conversion will be + * automatically performed. + * +$field.getDocumentation(" * ") + * + * @see #${field.setterName}${accessSuffix}(java.util.List) + */ + public void ${field.setterName}${accessSuffix}AsArray(${fieldType}[] $fieldName${accessSuffix}); + + /** + * This field represents a selection of rows from the <em>$field.tableGlobalActionParameter.name</em> table + * page-variable, this method allows you to get it as an + * array from the form, conversion will be automatically performed. + * +$field.getDocumentation(" * ") + * + * @see #${field.getterName}${accessSuffix}() + */ + public ${fieldType}[] ${field.getterName}${accessSuffix}AsArray(); + #else /** * Sets the <code>$field.name</code> field. 1.304 +748 -787 cartridges/andromda-bpm4struts/src/test/expected/cartridge-output.zip <<Binary file>> 1.86 +5 -5 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ClassifierFacadeLogicImpl.java Index: ClassifierFacadeLogicImpl.java =================================================================== RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ClassifierFacadeLogicImpl.java,v retrieving revision 1.85 retrieving revision 1.86 diff -u -w -r1.85 -r1.86 --- ClassifierFacadeLogicImpl.java 27 Jul 2005 05:34:28 -0000 1.85 +++ ClassifierFacadeLogicImpl.java 30 Jul 2005 12:09:03 -0000 1.86 @@ -102,7 +102,7 @@ * * @return the array suffix. */ - private final String getArraySuffix() + private String getArraySuffix() { return String.valueOf(this.getConfiguredProperty(UMLMetafacadeProperties.ARRAY_NAME_SUFFIX)); } @@ -134,7 +134,7 @@ final String propertyName = UMLMetafacadeProperties.WRAPPER_MAPPINGS_URI; final Object property = this.getConfiguredProperty(propertyName); TypeMappings mappings = null; - String uri = null; + String uri; if (property instanceof String) { uri = (String)property; @@ -497,7 +497,7 @@ */ protected String handleGetJavaNullString() { - String javaNullString = null; + String javaNullString; if (isPrimitive()) { if (UMLMetafacadeUtils.isType( @@ -591,7 +591,7 @@ * * @return the serial version UID of this classifier. */ - private final Long calculateDefaultSUID() + private Long calculateDefaultSUID() { final StringBuffer buffer = new StringBuffer(); @@ -664,7 +664,7 @@ */ protected Long handleGetSerialVersionUID() { - Long serialVersionUID = null; + Long serialVersionUID; String serialVersionString = UML14MetafacadeUtils.getSerialVersionUID(this); if (serialVersionString != null) { 1.4 +1 -1 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/FrontEndParameterLogicImpl.java Index: FrontEndParameterLogicImpl.java =================================================================== RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/FrontEndParameterLogicImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -r1.3 -r1.4 --- FrontEndParameterLogicImpl.java 20 Jul 2005 22:01:35 -0000 1.3 +++ FrontEndParameterLogicImpl.java 30 Jul 2005 12:09:03 -0000 1.4 @@ -80,7 +80,7 @@ protected boolean handleIsActionParameter() { final FrontEndAction action = this.getAction(); - return action == null ? false : action.getParameters().contains(this.THIS()); + return action != null && action.getParameters().contains(this.THIS()); } /** 1.5 +9 -1 cartridges/andromda-bpm4struts/src/templates/bpm4struts/controllers/ControllerImpl.java.vsl Index: ControllerImpl.java.vsl =================================================================== RCS file: /cvsroot/andromda/cartridges/andromda-bpm4struts/src/templates/bpm4struts/controllers/ControllerImpl.java.vsl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- ControllerImpl.java.vsl 14 Jul 2005 20:57:24 -0000 1.4 +++ ControllerImpl.java.vsl 30 Jul 2005 12:09:03 -0000 1.5 @@ -38,13 +38,21 @@ #if ($formFields.empty) // nothing to be done for this operation, there are no properties that can be set #else - // all properties receive a default value, just to have the application running properly #foreach ($field in $formFields) +#set ($tableActionFound = false) +#foreach ($action in $operation.deferringActions) +#if($action.tableAction)#foreach($parameter in $action.actionParameters)#if($parameter.name==$field.name)#set($tableActionFound=true)#end#end#end +#end #if ($field.table) + // populating the table with a dummy list form.${field.setterName}(${field.name}DummyList); #elseif ($field.date) + // setting a date form.${field.setterName}AsDate($field.resetValue); +#elseif ($tableActionFound) + // we don't set row selection parameters such as ${field.name}RowSelection #else + // this property receives a default value, just to have the application running on dummy data form.${field.setterName}($field.resetValue); #end #if ($field.selectable) 1.44 +82 -79 samples/online-store/mda/src/uml/online-store.xml.zip <<Binary file>> 1.9 +1 -1 cartridges/andromda-bpm4struts/src/templates/bpm4struts/pages/page-table.jspf.vsl Index: page-table.jspf.vsl =================================================================== RCS file: /cvsroot/andromda/cartridges/andromda-bpm4struts/src/templates/bpm4struts/pages/page-table.jspf.vsl,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -r1.8 -r1.9 --- page-table.jspf.vsl 29 Jul 2005 17:25:16 -0000 1.8 +++ page-table.jspf.vsl 30 Jul 2005 12:09:04 -0000 1.9 @@ -24,7 +24,7 @@ <display:column media="html"> #set ($actionParameter = $table.tableGlobalActionParameter) #set ($checkboxValue = "row.$actionParameter.name") - <input type="checkbox" name="${actionParameter.name}RowSelectionAsArray" value="${${checkboxValue}}" title='<bean:message key="select.deselect.this.row"/>'/> + <input type="checkbox" name="${actionParameter.name}RowSelectionAsArray" value="${${checkboxValue}}"#if($hints=="true") title='<bean:message key="select.deselect.this.row"/>'#end/> </display:column> #end #foreach ($column in $table.tableColumns) |