Revision: 1179
Author:   jhoskens
Date:     2006-05-23 00:01:00 -0700 (Tue, 23 May 2006)
ViewCVS:  http://svn.sourceforge.net/spring-rich-c/?rev=1179&view=rev

Log Message:
-----------
Form: 
- added removeChildForm() and some methods for ValidationResultsReporters.
- remove/addChildForm() will take care of FormModel and 
ValidationResultsReporters coupling
ValidationResultsReporter:
- added removeChild()/removeParent() remove two way connection
- added createChild(ValidationResultsModel) to be able to copy basic 
functionality of parent but with
different ValidationResultsModel and add this as child.

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/AbstractForm.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/Form.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/SimpleValidationResultsReporter.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/ValidationResultsReporter.java
Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/AbstractForm.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/AbstractForm.java
 2006-05-22 12:04:43 UTC (rev 1178)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/AbstractForm.java
 2006-05-23 07:01:00 UTC (rev 1179)
@@ -17,8 +17,10 @@
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 import javax.swing.JButton;
@@ -82,6 +84,8 @@
     private BindingFactory bindingFactory;
 
     private Map childForms = new HashMap();
+    
+    private List validationResultsReporters = new ArrayList();
 
     protected AbstractForm() {
         init();
@@ -183,14 +187,55 @@
      * 
      * @param childForm to add
      */
-    protected void addChildForm(Form childForm) {
-        if( isControlCreated() ) {
-            throw new IllegalStateException( "Cannot add child forms once the 
form control is created" );
+    public void addChildForm(Form childForm) {
+        childForms.put( childForm.getId(), childForm );
+        getFormModel().addChild(childForm.getFormModel());
+        Iterator it = validationResultsReporters.iterator();
+        while (it.hasNext())
+        {
+            ValidationResultsReporter reporter = 
(ValidationResultsReporter)it.next();
+            
childForm.addValidationResultsReporter(reporter.createChild(childForm.getFormModel().getValidationResults()));
         }
-        childForms.put( childForm.getId(), childForm );
     }
+    
+    /**
+     * @inheritDoc
+     */
+    public List getValidationResultsReporters()
+    {
+        return validationResultsReporters;
+    }
 
     /**
+     * @inheritDoc
+     */
+    public void addValidationResultsReporter(ValidationResultsReporter 
reporter)
+    {
+        this.validationResultsReporters.add(reporter);
+    }
+    
+    /**
+     * @inheritDoc
+     */
+    public void removeValidationResultsReporter(ValidationResultsReporter 
reporter)
+    {
+        this.validationResultsReporters.remove(reporter);
+    }
+    
+    /**
+     * @inheritDoc
+     */
+    public void removeChildForm(Form childForm) {
+        getFormModel().removeChild(childForm.getFormModel());
+        childForms.remove(childForm.getId());
+        Iterator it = childForm.getValidationResultsReporters().iterator();
+        while (it.hasNext())
+        {
+            ValidationResultsReporter reporter = 
(ValidationResultsReporter)it.next();
+            reporter.removeParent();
+        }
+    }
+    /**
      * Return a child form of this form with the given form id.
      * @param id of child form
      * @return child form, null if no child form with the given id has been 
registered
@@ -609,7 +654,8 @@
             reporter.addChild( child );
             childForm.getFormModel().validate();    // Force an initial 
validation
         }
-
+        validationResultsReporters.add(reporter);
+        
         return reporter;
     }
 

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/Form.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/Form.java
 2006-05-22 12:04:43 UTC (rev 1178)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/Form.java
 2006-05-23 07:01:00 UTC (rev 1179)
@@ -16,6 +16,8 @@
 
 package org.springframework.richclient.form;
 
+import java.util.List;
+
 import org.springframework.binding.form.ValidatingFormModel;
 import org.springframework.binding.validation.ValidationListener;
 import org.springframework.binding.value.ValueModel;
@@ -44,6 +46,39 @@
     public void removeValidationListener(ValidationListener listener);
 
     public ValidationResultsReporter newSingleLineResultsReporter(Guarded 
guarded, Messagable messageAreaPane);
+    
+    /**
+     * @return The list of ValidationResultsReporters of this Form. 
+     */
+    public List getValidationResultsReporters();
+    
+    /**
+     * Add a ValidationResultsReporter to this Form.
+     * 
+     * @param validationResultsReporter
+     */
+    public void addValidationResultsReporter(ValidationResultsReporter 
validationResultsReporter);
+    
+    /**
+     * Remove a ValidationResultsReporter from this Form.
+     * 
+     * @param validationResultsReporter
+     */
+    public void removeValidationResultsReporter(ValidationResultsReporter 
validationResultsReporter);
+    
+    /**
+     * Add a child to this Form. Models and available ResultsReporters will be 
coupled as well.
+     *  
+     * @param form The childForm to add.
+     */
+    public void addChildForm(Form form);
+    
+    /**
+     * Remove a child from this Form. Models and available ResultsReporters 
will be decoupled as well.
+     * 
+     * @param form The childForm to remove.
+     */
+    public void removeChildForm(Form form);
 
     public boolean hasErrors();
 

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/SimpleValidationResultsReporter.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/SimpleValidationResultsReporter.java
      2006-05-22 12:04:43 UTC (rev 1178)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/SimpleValidationResultsReporter.java
      2006-05-23 07:01:00 UTC (rev 1179)
@@ -66,7 +66,7 @@
         this.messageReceiver = messageReceiver;
         init();
     }
-
+    
     private void init() {
         resultsModel.addValidationListener( this );
 
@@ -178,7 +178,38 @@
         child.setParent( this );
         validationResultsChanged( null ); // Force a re-reporting
     }
+    
+    /**
+     * @inheritDoc
+     */
+    public void removeChild(ValidationResultsReporter child)
+    {
+        _children.remove(child);
+        validationResultsChanged(null);
+    }
+    
+    /**
+     * @inheritDoc
+     */
+    public void removeParent()
+    {
+        if (getParent() != null)
+        {
+            getParent().removeChild(this);
+            setParent(null);
+        }
+    }
 
+    /**
+     * @inheritDoc
+     */
+    public ValidationResultsReporter createChild(ValidationResultsModel 
validationResultsModel)
+    {
+        SimpleValidationResultsReporter simpleValidationResultsReporter = new 
SimpleValidationResultsReporter(validationResultsModel, this.guarded, 
this.messageReceiver);
+        addChild(simpleValidationResultsReporter);
+        return simpleValidationResultsReporter;
+    }
+    
     /*
      * (non-Javadoc)
      * @see 
org.springframework.richclient.form.ValidationResultsReporter#getParent()

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/ValidationResultsReporter.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/ValidationResultsReporter.java
    2006-05-22 12:04:43 UTC (rev 1178)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/ValidationResultsReporter.java
    2006-05-23 07:01:00 UTC (rev 1179)
@@ -16,6 +16,7 @@
 package org.springframework.richclient.form;
 
 import org.springframework.binding.validation.ValidationListener;
+import org.springframework.binding.validation.ValidationResultsModel;
 
 public interface ValidationResultsReporter extends ValidationListener {
 
@@ -36,8 +37,28 @@
      * @param child to add
      */
     public void addChild(ValidationResultsReporter child);
+    
+    /**
+     * Remove the childReporter from the children list.
+     * 
+     * @param child
+     */
+    public void removeChild(ValidationResultsReporter child);
+    
+    /**
+     * Remove this reporter's parent.
+     */
+    public void removeParent();
 
     /**
+     * Create a child based upon this Reporter.
+     * 
+     * @param validationResultsModel The specific ResultsModel for the new 
reporter.
+     * @return A new Reporter that reacts on the given ValidationResultsModel 
and is a child of this reporter.
+     */
+    public ValidationResultsReporter createChild(ValidationResultsModel 
validationResultsModel);
+
+    /**
      * Get the parent results reporter. If this reporter has not been added as 
a child to
      * some other reporter, then this will return null.
      * @return parent reporter or null


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



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
spring-rich-c-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to