Revision: 1270
Author:   mathiasbr
Date:     2006-08-05 14:29:19 -0700 (Sat, 05 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/spring-rich-c/?rev=1270&view=rev

Log Message:
-----------
fix for RCP-386
form model is only added as a child if its parent is not already the form model 
to which is should be added.

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/AbstractFormModel.java

Added Paths:
-----------
    
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/form/AbstractFormTests.java
Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/AbstractFormModel.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/AbstractFormModel.java
       2006-08-05 20:11:52 UTC (rev 1269)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/binding/form/support/AbstractFormModel.java
       2006-08-05 21:29:19 UTC (rev 1270)
@@ -236,6 +236,8 @@
      */
     public void addChild(HierarchicalFormModel child) {
         Assert.required(child, "child");
+        if(child.getParent() == this)
+            return;
         Assert.isTrue(child.getParent() == null, "Child form model '" + child 
+ "' already has a parent");
         child.setParent(this);
         children.add(child);

Added: 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/form/AbstractFormTests.java
===================================================================
--- 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/form/AbstractFormTests.java
                            (rev 0)
+++ 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/form/AbstractFormTests.java
    2006-08-05 21:29:19 UTC (rev 1270)
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.richclient.form;
+
+import javax.swing.JComponent;
+
+import junit.framework.TestCase;
+
+import org.springframework.binding.form.FormModel;
+import org.springframework.binding.form.HierarchicalFormModel;
+import org.springframework.binding.form.ValidatingFormModel;
+import org.springframework.binding.form.support.DefaultFormModel;
+import org.springframework.binding.support.TestBean;
+import org.springframework.binding.value.ValueModel;
+import org.springframework.richclient.test.SpringRichTestCase;
+
+/**
+ * @author Mathias Broekelmann
+ * 
+ */
+public class AbstractFormTests extends SpringRichTestCase {
+
+    /**
+     * Test method for
+     * [EMAIL PROTECTED] 
org.springframework.richclient.form.AbstractForm#addChildForm(org.springframework.richclient.form.Form)}.
+     */
+    public void testAddChildForm() {
+        TestBean testBean = new TestBean();
+        testBean.setNestedProperty(new TestBean());
+        HierarchicalFormModel model = new DefaultFormModel(testBean);
+        ValidatingFormModel childModel = 
FormModelHelper.createChildPageFormModel(model, "test", "nestedProperty");
+        AbstractForm form = new TestAbstractForm(model);
+        form.addChildForm(new TestAbstractForm(childModel));
+    }
+
+    private static class TestAbstractForm extends AbstractForm {
+
+        public TestAbstractForm() {
+            super();
+        }
+
+        public TestAbstractForm(FormModel formModel, String formId) {
+            super(formModel, formId);
+        }
+
+        public TestAbstractForm(FormModel pageFormModel) {
+            super(pageFormModel);
+        }
+
+        public TestAbstractForm(HierarchicalFormModel parentFormModel, String 
formId, ValueModel childFormObjectHolder) {
+            super(parentFormModel, formId, childFormObjectHolder);
+        }
+
+        public TestAbstractForm(String formId) {
+            super(formId);
+        }
+
+        public TestAbstractForm(Object formObject) {
+            super(formObject);
+        }
+
+        public TestAbstractForm(HierarchicalFormModel parentFormModel, String 
formId, String childFormObjectPropertyPath) {
+            super(parentFormModel, formId, childFormObjectPropertyPath);
+        }
+
+        protected JComponent createFormControl() {
+            return null;
+        }
+
+    }
+}


Property changes on: 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/form/AbstractFormTests.java
___________________________________________________________________
Name: svn:keywords
   + Revision Author Date Id
Name: svn:eol-style
   + native


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


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
spring-rich-c-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to