From: Eric C. <ecr...@us...> - 2006-10-01 01:44:47
|
User: ecrutchfield Date: 06/09/30 18:44:47 Modified: andromda-aspdotnet/src/main/resources/META-INF/andromda cartridge.xml Added: andromda-aspdotnet/src/main/resources/templates/aspdotnet/forms formImplMacros.vm formMacros.vm formImpl.cs.vsl Form.cs.vsl andromda-aspdotnet/src/main/resources/templates/aspdotnet/controllers ControllerImpl.cs.vsl Controller.cs.vm Controller.cs.vsl Removed: andromda-aspdotnet/src/main/resources/templates/aspdotnet/uicontrollers UIPController.cs.vsl Controller.cs.vm formImplMacros.vm Form.cs.vsl formMacros.vm formImpl.cs.vsl UIPControllerImpl.cs.vsl Log: rename/move files/folders to more appropriate places/names Revision Changes Path 1.1 cartridges/andromda-aspdotnet/src/main/resources/templates/aspdotnet/forms/formImplMacros.vm Index: formImplMacros.vm =================================================================== ## ## This macro renders the backing list support for the form implementation ## #macro(renderBackingListImplSupport $field $ownerParameter) #if ($field.name) #set ($labelListName = "${field.name}LabelList") #set ($valueListName = "${field.name}ValueList") #set ($backingListName = "${field.name}BackingList") #else #set ($labelListName = $field.getLabelListName($ownerParameter)) #set ($valueListName = $field.getValueListName($ownerParameter)) #set ($backingListName = $field.getBackingListName($ownerParameter)) #end #set ($listType = "System.Object[]") #set ($labelListMethod = $stringUtils.capitalize($labelListName)) #set ($valueListMethod = $stringUtils.capitalize($valueListName)) #set ($backingListMethod = $stringUtils.capitalize($backingListName)) System.Web.UI.WebControls.ListItemCollection _${backingListName} = null; string[] _${labelListName} = null; string[] _${valueListName} = null; /// <summary> /// Get the backing list for the ${action.name} field. You must have first set the labels /// and values via the <cref="Set${labelListMethod}"/> and <cref="Set${valueListMethod}"/> methods. /// </summary> public System.Web.UI.WebControls.ListItemCollection Get${backingListMethod}() { //return an empty collection if they never set the backing list labels and values. if (this._${labelListName} == null || this._${valueListName} == null) return new System.Web.UI.WebControls.ListItemCollection(); if (this._${labelListName}.Length != this._${valueListName}.Length) throw new InvalidOperationException("The number of values and labels are not the same."); if (this._${backingListName} == null) { this._${backingListName} = new System.Web.UI.WebControls.ListItemCollection(); } else this._${backingListName}.Clear(); for (int i = 0; i < this._${labelListName}.Length; i++) { System.Web.UI.WebControls.ListItem listItem = new System.Web.UI.WebControls.ListItem(this._${labelListName}[i], this._${valueListName}[i]); this._${backingListName}.Add(listItem); } return this._${backingListName}; } /// <summary> /// Set the backing list labels for the ${action.name} field. You must also call /// <see cref="Set${valueListMethod}"/> passing in the same number of items. /// </summary> /// <param name="list">a string array of the labels</param> public void Set${labelListMethod}(string[] list) { this._${labelListName} = list; } /// <summary> /// Set the backing list values for the ${action.name} field. You must also call /// <see cref="Set${labelListMethod}"/> passing in the same number of items. /// </summary> /// <param name="list">a string array of the values</param> public void Set${valueListMethod}(string[] list) { this._${valueListName} = list; } #end ## ## This macro renders the code that sets the property ## of the form using the value of the input field defined on the page. ## #macro( populateFormProperties ) #if(!$action.tableAction && !$action.tableLink) #foreach($parameter in ${action.parameters}) #if(!${parameter.inputHidden} && !${parameter.inputTable}) #set($viewType = ${parameter.viewType}) #set($fieldName = "this.$stringUtils.lowerCamelCaseName(${action.name})_${parameter.name}$viewType") ## if we can't get the value from the field (e.g. Label) then we need to get it from it's Hidden counterpart. #if($viewType.equalsIgnoreCase("HyperLink") || $viewType.equalsIgnoreCase("Label")) #set($fieldName = "this.$stringUtils.lowerCamelCaseName(${action.name})_${parameter.name}Hidden") #end #set($formProperty = "$parameter.capitalisedName") org.andromda.cartridges.aspdotnet.FormPopulator.PopulateForm(${fieldName}, base.Controller.${action.formImplementationPropertyName}, "${formProperty}"); #end #end #end #end ## ## This macro renders the date/time formatters within the form implementation ## #macro(renderDateTimeFormatters $field $ownerParameter) #if ($field.backingListName) #set ($dateFormatter = $field.dateFormatter) #set ($timeFormatter = $field.timeFormatter) #set ($fieldName = $field.name) #else #set ($dateFormatter = $field.getDateFormatter($ownerParameter)) #set ($timeFormatter = $field.getTimeFormatter($ownerParameter)) #set ($fieldName = $field.getFormPropertyName($ownerParameter)) #end #set ($lenient = !$field.strictDateFormat) #if ($field.type.dateType) java.text.DateFormat $dateFormatter = new java.text.SimpleDateFormat("$field.format"); ${dateFormatter}.setLenient($lenient); this.dateTimeFormatters.put("$fieldName", $dateFormatter); #elseif ($field.type.timeType) java.text.DateFormat $timeFormatter = new java.text.SimpleDateFormat("$field.format"); this.dateTimeFormatters.put("$fieldName", $timeFormatter); #end #end 1.1 cartridges/andromda-aspdotnet/src/main/resources/templates/aspdotnet/forms/formMacros.vm Index: formMacros.vm =================================================================== ## ## This macro renders the backing list support for the form implementation ## #macro(renderBackingListSupport $field $ownerParameter) #if ($field.name) #set ($labelListName = "${field.name}LabelList") #set ($valueListName = "${field.name}ValueList") #set ($backingListName = "${field.name}BackingList") #else #set ($labelListName = $field.getLabelListName($ownerParameter)) #set ($valueListName = $field.getValueListName($ownerParameter)) #set ($backingListName = $field.getBackingListName($ownerParameter)) #end #set ($listType = "System.Object[]") #set ($labelListMethod = $stringUtils.capitalize($labelListName)) #set ($valueListMethod = $stringUtils.capitalize($valueListName)) #set ($backingListMethod = $stringUtils.capitalize($backingListName)) /// <summary> /// Get the backing list for the ${action.name} field. You must have first set the labels /// and values via the <cref="Set${labelListMethod}"/> and <cref="Set${valueListMethod}"/> methods. /// </summary> System.Web.UI.WebControls.ListItemCollection Get${backingListMethod}(); /// <summary> /// Set the backing list labels for the ${field.name} field. You must also call /// <see cref="Set${valueListMethod}"/> passing in the same number of items. /// </summary> /// <param name="list">a string array of the labels</param> void Set${labelListMethod}(string[] list); /// <summary> /// Set the backing list values for the ${field.name} field. You must also call /// <see cref="Set${labelListMethod}"/> passing in the same number of items. /// </summary> /// <param name="list">a string array of the values</param> void Set${valueListMethod}(string[] list); #end 1.1 cartridges/andromda-aspdotnet/src/main/resources/templates/aspdotnet/forms/formImpl.cs.vsl Index: formImpl.cs.vsl =================================================================== #if($is2005Solution) #set($folder = "App_Code/target/src/") #else #set($folder = "target/src/") #end #set($generatedFile = "${folder}${action.fullyQualifiedFormImplementationPath}.cs") using System; using System.Collections; namespace ${action.packageName} { /// <summary> $action.getDocumentation(" /// ", 80, false) /// </summary> [Serializable] public class $action.formImplementationName #if ($stringUtils.isNotBlank($action.formImplementationInterfaceList)) : $action.formImplementationInterfaceList#end { ## ## Constructor ## #region Constructor public ${action.formImplementationName}() {} #endregion #foreach ($field in $action.formFields) #region Getter/Setter for ${stringUtils.capitalize($field.name)} #if ($field.type.collectionType) #set ($fieldTypeName = "System.Collections.IList") #elseif ($field.type.fileType) #set ($fieldTypeName = "$fileTypeName") #else #set ($fieldTypeName = $field.type.fullyQualifiedName) #end private $fieldTypeName _$field.name#if ($field.defaultValuePresent) = $field.defaultValue#end; /// <summary> /// Get/set the value for the ${field.name} field. /// </summary> /// <remarks> $field.getDocumentation(" /// ", 80, false) /// </remarks> public $fieldTypeName ${stringUtils.capitalize($field.name)} { get { return this._${field.name}; } set { this._${field.name} = value; } } #if (!$field.complex && !$field.defaultValuePresent && $field.selectable) #renderBackingListImplSupport($field "") #end #endregion #end } } 1.1 cartridges/andromda-aspdotnet/src/main/resources/templates/aspdotnet/forms/Form.cs.vsl Index: Form.cs.vsl =================================================================== #if($is2005Solution) #set($folder = "App_Code/target/src/") #else #set($folder = "target/src/") #end #set ($generatedFile = "${folder}${operation.fullyQualifiedFormPath}/I${operation.formName}.cs") // license-header cs merge-point using System; namespace $operation.owner.packageName { /// <summary> /// This interface encapsulates the fields that are used in the execution of the /// <code>$operation.name</code> method, which is located on the /// <see cref="$operation.owner.fullyQualifiedName"/> controller. /// <seealso cref="${operation.owner.fullyQualifiedName}.${operation.signature}"/> /// </summary> /// <remarks> $operation.getDocumentation(" /// ", 80, false) /// </remarks> public interface I${operation.formName} { #foreach ($field in $operation.formFields) #if ($field.type.collectionType) #set ($fieldTypeName = "System.Collections.IList") #elseif ($field.type.fileType) #set ($fieldTypeName = "$fileTypeName") #else #set ($fieldTypeName = $field.type.fullyQualifiedName) #end /// <summary> $field.getDocumentation(" /// ", 80, false) /// </summary> $fieldTypeName $stringUtils.capitalize(${field.name}) { get; ## - don't allow fields with default values to be set #if (!$field.defaultValuePresent) set; #end } ## - don't allow fields with default values to be set #if (!$field.defaultValuePresent) #if (!$field.complex && $field.selectable) #renderBackingListSupport($field "") #end #if ($field.backingValueRequired) //renderBackingValueSupport($field "") #end #foreach ($attribute in $field.attributes) #if ($attribute.isSelectable($field)) #renderBackingListSupport($attribute $field) #elseif ($attribute.isBackingValueRequired($field)) //renderBackingValueSupport($attribute $field) #end #end #end #end } } 1.1 cartridges/andromda-aspdotnet/src/main/resources/templates/aspdotnet/controllers/ControllerImpl.cs.vsl Index: ControllerImpl.cs.vsl =================================================================== #if($is2005Solution) #set($folder = "App_Code/src/main/") #else #set($folder = "src/main/") #end #set($generatedFile = "${folder}${controller.fullyQualifiedImplementationPath}.cs") using System; using System.Collections; namespace $controller.packageName { /// <summary> /// <see cref="${controller.fullyQualifiedName}"/> /// </summary> public class ${controller.implementationName} : ${controller.fullyQualifiedName} { ## ## create an overriden method for all operations on the controller ## #foreach($operation in ${controller.operations}) /// <summary> /// <see cref="$controller.fullyQualifiedName.$operation.signature"/> /// </summary> ${operation.implementationFormSignature} { //${toDoTag} add an implementation for ${controller.implementationName}.${operation.name}() #if(${operation.returnType.booleanType}) return false; #elseif(${operation.returnTypePresent}) return null; #end } #end } } 1.1 cartridges/andromda-aspdotnet/src/main/resources/templates/aspdotnet/controllers/Controller.cs.vm Index: Controller.cs.vm =================================================================== ## ## This macro determines what to do when processing a transition ## #macro (processTransition $transition) #if (!$transition) null; #elseif ($transition.enteringFinalState) #set ($targetUseCase = $transition.target.targetUseCase) "~/target/src/${targetUseCase.fullyQualifiedPath}/${targetUseCase.normalizedName}UC.aspx"; #elseif ($transition.enteringView) "~/target/src/${transition.target.fullyQualifiedPath}/${transition.target.normalizedName}.aspx"; #elseif ($transition.enteringDecisionPoint) __${transition.operationCall.name}(#if (!$action.formFields.empty)form#end); #else ${transition.target.actionMethodName}(#if (!$action.formFields.empty)form#end); #end #end 1.1 cartridges/andromda-aspdotnet/src/main/resources/templates/aspdotnet/controllers/Controller.cs.vsl Index: Controller.cs.vsl =================================================================== #if($is2005Solution) #set($folder = "App_Code/target/src/") #else #set($folder = "target/src/") #end #set($generatedFile = "${folder}${controller.fullyQualifiedNamePath}.cs") using System; using System.Collections; using System.Web; namespace $controller.packageName { /// <summary> $controller.getDocumentation(" /// ", 80, false) /// </summary> public abstract class $controller.name { ## ## Contructor of the controller that will instanciate(if it is null) the formData(s) ## #region Constructor public ${controller.name}() { //Instantiate the Form objects to hold data from the pages during transitions //between action states. #foreach ($action in $controller.useCase.actions) if (this.${action.formImplementationPropertyName} == null) this.${action.formImplementationPropertyName} = new ${action.fullyQualifiedFormImplementationName}(); #end } #endregion ## ## Navigation from the initial state to the first action. ## /// <summary> /// Calling this method starts the use case. The user will be redirected to /// the starting WebForm. /// </summary> public void StartUseCase() { this.${stringUtils.capitalize(${controller.useCase.normalizedName})}(); } ## ## controller methods ## #region Abstract methods #foreach($operation in ${controller.operations}) /// <summary> $operation.getDocumentation(" /// ", 80, false) /// </summary> ${operation.formSignature}; #end #endregion ## ## form data ## #region Public properties #foreach ($action in $controller.useCase.actions) /// <summary> /// Get/set the <see cref="${action.fullyQualifiedFormImplementationName}"/> from HttpSession. /// </summary> public ${action.fullyQualifiedFormImplementationName} ${action.formImplementationPropertyName} { get { return HttpContext.Current.Session["${action.controller.fullyQualifiedName}.${action.formImplementationName}"] as ${action.fullyQualifiedFormImplementationName}; } set { HttpContext.Current.Session["${action.controller.fullyQualifiedName}.${action.formImplementationName}"] = value; } } #end #endregion ##todo add public method that can be called from base page #region Controller Action methods #foreach ($action in $controller.useCase.actions) /// <summary> $action.getDocumentation(" /// ", 80, false) /// </summary> public virtual void ${stringUtils.capitalize(${action.triggerName})}() { string forward = String.Empty; ${action.fullyQualifiedFormImplementationName} form = this.${action.formImplementationPropertyName}; forward = #processTransition($action) this.${action.formImplementationPropertyName} = form; HttpContext.Current.Response.Redirect(forward); } #foreach ($actionState in $action.actionStates) /// <summary> $actionState.getDocumentation(" /// ", 80, false) /// </summary> private string ${actionState.actionMethodName}(#if (!$action.formFields.empty) $action.fullyQualifiedFormImplementationName form#end) { string forward = null; #if ($actionState.controllerCalls.empty) forward = #processTransition($actionState.forward) #else #foreach ($controllerCall in $actionState.controllerCalls) #if (!$action.actionFormFields.empty) this.${controllerCall.formCall}; #else // We pass an empty form implementation to the controller. // We know there are no parameters on this operation because the // cartridge would have issued a model validation error this.${controllerCall.name}(new ${controllerCall.interfaceName}()); #end #end forward = #processTransition($actionState.forward) #end return forward; } #end #end #endregion #if (!$controller.serviceReferences.isEmpty()) #region Service references #foreach ($serviceRef in $controller.serviceReferences) #if ($stringUtils.isNotBlank($serviceRef.targetElement.accessorImplementation)) /// <summary> /// Returns a reference to the $serviceRef.name back-end service. /// </summary> protected $serviceRef.targetElement.fullyQualifiedName ${serviceRef.getterName}() { try { return $serviceRef.targetElement.accessorImplementation; } catch (Exception ex) { throw new InvalidOperationException(ex); } } #end #end #endregion #end #if(!$controller.sessionObjects.isEmpty()) #region Session Object references #foreach ($sessionObject in $controller.sessionObjects) #set ($targetElement = $sessionObject.targetElement) /// <summary> $sessionObject.getDocumentation(" /// ", 80, false) /// </summary> public $targetElement.fullyQualifiedName ${stringUtils.capitalize($sessionObject.name)} { get { return HttpContext.Current.Session["${sessionObject.fullyQualifiedName}"] as $targetElement.fullyQualifiedName; } set { HttpContext.Current.Session["${sessionObject.fullyQualifiedName}"] = value; } } #end #endregion #end } } 1.5 +7 -7 cartridges/andromda-aspdotnet/src/main/resources/META-INF/andromda/cartridge.xml Index: cartridge.xml =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-aspdotnet/src/main/resources/META-INF/andromda/cartridge.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- cartridge.xml 28 Sep 2006 05:35:30 -0000 1.4 +++ cartridge.xml 1 Oct 2006 01:44:47 -0000 1.5 @@ -5,9 +5,9 @@ <macrolibrary name="templates/aspdotnet/web2003/tables.vm"/> <macrolibrary name="templates/aspdotnet/web2005/tables.vm"/> <macrolibrary name="templates/aspdotnet/validation.vm"/> - <macrolibrary name="templates/aspdotnet/uicontrollers/formImplMacros.vm"/> - <macrolibrary name="templates/aspdotnet/uicontrollers/formMacros.vm"/> - <macrolibrary name="templates/aspdotnet/uicontrollers/Controller.cs.vm"/> + <macrolibrary name="templates/aspdotnet/forms/formImplMacros.vm"/> + <macrolibrary name="templates/aspdotnet/forms/formMacros.vm"/> + <macrolibrary name="templates/aspdotnet/controllers/Controller.cs.vm"/> <!-- cartridge-macrolibrary merge-point--> </templateEngine> @@ -325,7 +325,7 @@ </template> <template - path="templates/aspdotnet/uicontrollers/UIPControllerImpl.cs.vsl" + path="templates/aspdotnet/controllers/ControllerImpl.cs.vsl" outputPattern="$generatedFile" outlet="web" overwrite="false"> @@ -342,7 +342,7 @@ </template> <template - path="templates/aspdotnet/uicontrollers/UIPController.cs.vsl" + path="templates/aspdotnet/controllers/Controller.cs.vsl" outputPattern="$generatedFile" outlet="web" overwrite="true"> @@ -356,7 +356,7 @@ </modelElements> </template> <template - path="templates/aspdotnet/uicontrollers/Form.cs.vsl" + path="templates/aspdotnet/forms/Form.cs.vsl" outputPattern="$generatedFile" outlet="web" overwrite="true"> @@ -370,7 +370,7 @@ </template> <template - path="templates/aspdotnet/uicontrollers/formImpl.cs.vsl" + path="templates/aspdotnet/forms/formImpl.cs.vsl" outputPattern="$generatedFile" outlet="web" overwrite="true"> |