Revision: 1769
          http://svn.sourceforge.net/spring-rich-c/?rev=1769&view=rev
Author:   anodos
Date:     2007-06-26 09:10:58 -0700 (Tue, 26 Jun 2007)

Log Message:
-----------
RCP-478 - Pass Form reference to FormUIProvider.bind to support binding child 
forms

Modified Paths:
--------------
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/AbstractFormUIProvider.java
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/FormUIProvider.java
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/GeneratedForm.java
    
trunk/spring-richclient/sandbox/src/test/java/org/springframework/richclient/form/DefaultFormUIProviderTests.java

Modified: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/AbstractFormUIProvider.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/AbstractFormUIProvider.java
       2007-06-18 06:37:41 UTC (rev 1768)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/AbstractFormUIProvider.java
       2007-06-26 16:10:58 UTC (rev 1769)
@@ -36,7 +36,7 @@
     private String[] properties;
     private Map contextMap = new HashMap();
 
-    public void bind(BindingFactory factory) {
+    public void bind(BindingFactory factory, Form form) {
         Assert.state(properties != null && properties.length > 0, "Properties 
must be set");
 
         bound = true;

Modified: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/FormUIProvider.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/FormUIProvider.java
       2007-06-18 06:37:41 UTC (rev 1768)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/FormUIProvider.java
       2007-06-26 16:10:58 UTC (rev 1769)
@@ -44,8 +44,9 @@
    * 
    * @param factory the <code>BindingFactory</code> this form provider should
    *        use to bind the provided form.
+   * @param form the <code>Form</code> being bound.
    */
-  void bind(BindingFactory factory);
+  void bind(BindingFactory factory, Form form);
 
   /**
    * Provides access to individual components of this pre-generated form.
@@ -54,7 +55,7 @@
    * typically these IDs will be the same as the property names of the
    * object backing the form.
    *
-   * @param componentId
+   * @param componentId component id to lookup
    *
    * @return component with the specified id, or <code>null</code> if no
    *         component exists in this pre-generated form with the given id.

Modified: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/GeneratedForm.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/GeneratedForm.java
        2007-06-18 06:37:41 UTC (rev 1768)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/form/GeneratedForm.java
        2007-06-26 16:10:58 UTC (rev 1769)
@@ -21,6 +21,10 @@
 
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.util.Assert;
+import org.springframework.binding.form.FormModel;
+import org.springframework.binding.form.HierarchicalFormModel;
+import org.springframework.binding.form.ValidatingFormModel;
+import org.springframework.binding.value.ValueModel;
 
 /**
  * Convenience class for producing a Spring Rich [EMAIL PROTECTED] Form} based 
on a
@@ -29,44 +33,141 @@
  * the most common case where a developer designs a form and wants to display
  * it without any custom functionality beyond what Spring Rich already
  * provides.
+ * <p/>
+ * In order to better facilitate the common usage scenarios and to avoid
+ * developers having to subclass <code>GeneratedForm</code>, many convenience
+ * constructors are provided, along with making the
+ * [EMAIL PROTECTED] #setFormModel(ValidatingFormModel)} and [EMAIL PROTECTED] 
#setId(String)}
+ * methods public. 
  *
  * @author Andy DePue
  * @author Peter De Bruycker
  */
 public class GeneratedForm extends AbstractForm implements InitializingBean {
-  private FormUIProvider formUIProvider;
+    private FormUIProvider formUIProvider;
 
-  //
-  // METHODS FROM CLASS AbstractForm
-  //
+    public GeneratedForm() {
+        super();
+    }
 
-  protected JComponent createFormControl() {
-    this.formUIProvider.bind(getBindingFactory());
-    return this.formUIProvider.getControl();
-  }
+    public GeneratedForm(String formId) {
+        super(formId);
+    }
 
+    public GeneratedForm(Object formObject) {
+        super(formObject);
+    }
 
+    public GeneratedForm(FormModel pageFormModel) {
+        super(pageFormModel);
+    }
 
-  //
-  // METHODS FROM INTERFACE InitializingBean
-  //
+    public GeneratedForm(FormModel formModel, String formId) {
+        super(formModel, formId);
+    }
 
-  public void afterPropertiesSet() throws Exception {
-    Assert.notNull(this.formUIProvider, "formUIProvider must be set");
-  }
+    public GeneratedForm(HierarchicalFormModel parentFormModel, String formId, 
String childFormObjectPropertyPath) {
+        super(parentFormModel, formId, childFormObjectPropertyPath);
+    }
 
+    public GeneratedForm(HierarchicalFormModel parentFormModel, String formId, 
ValueModel childFormObjectHolder) {
+        super(parentFormModel, formId, childFormObjectHolder);
+    }
 
+    public GeneratedForm(final FormUIProvider formUIProvider) {
+        this.formUIProvider = formUIProvider;
+    }
 
+    public GeneratedForm(String formId, final FormUIProvider formUIProvider) {
+        super(formId);
+        this.formUIProvider = formUIProvider;
+    }
 
-  //
-  // SIMPLE PROPERTY ACCESSORS
-  //
+    public GeneratedForm(Object formObject, final FormUIProvider 
formUIProvider) {
+        super(formObject);
+        this.formUIProvider = formUIProvider;
+    }
 
-  public FormUIProvider getFormUIProvider() {
-    return formUIProvider;
-  }
+    public GeneratedForm(Object formObject, String formId, final 
FormUIProvider formUIProvider) {
+        super(formObject);
+        setId(formId);
+        this.formUIProvider = formUIProvider;
+    }
 
-  public void setFormUIProvider(final FormUIProvider formUIProvider) {
-    this.formUIProvider = formUIProvider;
-  }
+    public GeneratedForm(FormModel pageFormModel, final FormUIProvider 
formUIProvider) {
+        super(pageFormModel);
+        this.formUIProvider = formUIProvider;
+    }
+
+    public GeneratedForm(FormModel formModel, String formId, final 
FormUIProvider formUIProvider) {
+        super(formModel, formId);
+        this.formUIProvider = formUIProvider;
+    }
+
+    public GeneratedForm(HierarchicalFormModel parentFormModel, String formId, 
String childFormObjectPropertyPath, final FormUIProvider formUIProvider) {
+        super(parentFormModel, formId, childFormObjectPropertyPath);
+        this.formUIProvider = formUIProvider;
+    }
+
+    public GeneratedForm(HierarchicalFormModel parentFormModel, String formId, 
ValueModel childFormObjectHolder, final FormUIProvider formUIProvider) {
+        super(parentFormModel, formId, childFormObjectHolder);
+        this.formUIProvider = formUIProvider;
+    }
+    
+
+    //
+    // METHODS FROM CLASS AbstractForm
+    //
+
+    protected JComponent createFormControl() {
+        this.formUIProvider.bind(getBindingFactory(), this);
+        return this.formUIProvider.getControl();
+    }
+
+    /**
+     * Provides public access to this method as a convenience.
+     *
+     * @param formModel
+     */
+    public void setFormModel(ValidatingFormModel formModel) {
+        super.setFormModel(formModel);
+    }
+
+
+    /**
+     * Provides public access to this method as a convenience.
+     *
+     * @param formId
+     */
+    public void setId(String formId) {
+        super.setId(formId);
+    }
+    
+    
+    
+    
+    
+
+    //
+    // METHODS FROM INTERFACE InitializingBean
+    //
+
+    public void afterPropertiesSet() throws Exception {
+        Assert.notNull(this.formUIProvider, "formUIProvider must be set");
+    }
+
+
+
+
+    //
+    // SIMPLE PROPERTY ACCESSORS
+    //
+
+    public FormUIProvider getFormUIProvider() {
+        return formUIProvider;
+    }
+
+    public void setFormUIProvider(final FormUIProvider formUIProvider) {
+        this.formUIProvider = formUIProvider;
+    }
 }

Modified: 
trunk/spring-richclient/sandbox/src/test/java/org/springframework/richclient/form/DefaultFormUIProviderTests.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/test/java/org/springframework/richclient/form/DefaultFormUIProviderTests.java
   2007-06-18 06:37:41 UTC (rev 1768)
+++ 
trunk/spring-richclient/sandbox/src/test/java/org/springframework/richclient/form/DefaultFormUIProviderTests.java
   2007-06-26 16:10:58 UTC (rev 1769)
@@ -35,7 +35,7 @@
 
         formUIProvider.setContext("comboProperty", context);
 
-        formUIProvider.bind(bindingFactory);
+        formUIProvider.bind(bindingFactory, null);
         assertEquals(3, bindingFactory.getBindControlCount());
 
         // string property


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
spring-rich-c-cvs mailing list
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to