click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r749070 - in /incubator/click/branches/click-2.0.x: documentation/docs/ framework/src/org/apache/click/control/ framework/test/org/apache/click/control/
Date Sun, 01 Mar 2009 18:33:05 GMT
Author: sabob
Date: Sun Mar  1 18:33:05 2009
New Revision: 749070

URL: http://svn.apache.org/viewvc?rev=749070&view=rev
Log:
fixed fieldset parent bug. backported CLK-497

Modified:
    incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html
    incubator/click/branches/click-2.0.x/framework/src/org/apache/click/control/FieldSet.java
    incubator/click/branches/click-2.0.x/framework/test/org/apache/click/control/FieldSetTest.java
    incubator/click/branches/click-2.0.x/framework/test/org/apache/click/control/FormTest.java

Modified: incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html?rev=749070&r1=749069&r2=749070&view=diff
==============================================================================
--- incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/branches/click-2.0.x/documentation/docs/roadmap-changes.html Sun Mar 
1 18:33:05 2009
@@ -83,6 +83,10 @@
     </div>
     <ul style="padding: 0em; margin-left:0em;margin-bottom: 2em">
       <li class="change">
+          Fixed a bug where FieldSet was not set as the parent of its child controls
+          [<a target='_blank' href="https://issues.apache.org/click/browse/CLK-497">497</a>].
+      </li>
+      <li class="change">
           Fixed Column sorting to recognize numbers inside strings
           [<a target='_blank' href="https://issues.apache.org/click/browse/CLK-489">489</a>].
       </li>

Modified: incubator/click/branches/click-2.0.x/framework/src/org/apache/click/control/FieldSet.java
URL: http://svn.apache.org/viewvc/incubator/click/branches/click-2.0.x/framework/src/org/apache/click/control/FieldSet.java?rev=749070&r1=749069&r2=749070&view=diff
==============================================================================
--- incubator/click/branches/click-2.0.x/framework/src/org/apache/click/control/FieldSet.java
(original)
+++ incubator/click/branches/click-2.0.x/framework/src/org/apache/click/control/FieldSet.java
Sun Mar  1 18:33:05 2009
@@ -1107,6 +1107,7 @@
          */
         public Control insert(Control control, int index) {
             super.insert(control, index);
+            control.setParent(FieldSet.this);
 
             if (control instanceof Field) {
                 Field field = (Field) control;
@@ -1145,6 +1146,9 @@
         public boolean remove(Control control) {
 
             boolean removed = super.remove(control);
+            if (control.getParent() == FieldSet.this) {
+                control.setParent(null);
+            }
 
             if (removed && control instanceof Field) {
                 Field field = (Field) control;

Modified: incubator/click/branches/click-2.0.x/framework/test/org/apache/click/control/FieldSetTest.java
URL: http://svn.apache.org/viewvc/incubator/click/branches/click-2.0.x/framework/test/org/apache/click/control/FieldSetTest.java?rev=749070&r1=749069&r2=749070&view=diff
==============================================================================
--- incubator/click/branches/click-2.0.x/framework/test/org/apache/click/control/FieldSetTest.java
(original)
+++ incubator/click/branches/click-2.0.x/framework/test/org/apache/click/control/FieldSetTest.java
Sun Mar  1 18:33:05 2009
@@ -19,6 +19,7 @@
 package org.apache.click.control;
 
 import junit.framework.TestCase;
+import org.apache.click.Control;
 import org.apache.click.MockContext;
 
 /**
@@ -377,6 +378,66 @@
     }
 
     /**
+     * Test that Fields added to FieldSet, correctly returns FieldSet as their
+     * parent.
+     *
+     * CLK-497
+     */
+    public void testFieldParent() {
+        // Initially fieldSet contains 1 hidden field
+        assertTrue(fieldSet.getControls().size() == 1);
+
+        TextField nameField = new TextField("score");
+        fieldSet.add(nameField);
+
+        assertTrue(fieldSet.getControls().size() == 2);
+
+        // Test that Field parent is a FieldSet
+        assertEquals(FieldSet.class, nameField.getParent().getClass());
+
+        assertTrue(fieldSet.remove((Control) nameField));
+
+        assertTrue(nameField.getParent() == null);
+        assertTrue(fieldSet.getControls().size() == 1);
+    }
+
+    /**
+     * Test the isDisabled() for a child component. Intent is to ensure that a child
+     * component of the FieldSet is disabled when the FieldSet is itself disabled.
+     */
+    public void testIsDisabled() {
+    	// Fieldset is not disabled.
+    	assertFalse(this.fieldSet.isDisabled());
+
+    	// Textfield inside is not disabled.
+    	assertFalse(this.trackField.isDisabled());
+
+    	// Change fieldset state.
+    	this.fieldSet.setDisabled(true);
+
+    	// Textfield is now disabled too.
+    	assertTrue(this.trackField.isDisabled());
+    }
+
+    /**
+     * Test the isReadonly() for a child component. Intent is to ensure that a child
+     * component of the FieldSet is disabled when the FieldSet is itself disabled.
+     */
+    public void testIsReadonly() {
+    	  // Fieldset is not disabled.
+   	    assertFalse(this.fieldSet.isReadonly());
+
+    	  // Textfield inside is not disabled.
+    	  assertFalse(this.trackField.isReadonly());
+
+    	  // Change fieldset state.
+    	  this.fieldSet.setReadonly(true);
+
+    	  // Textfield is now disabled too.
+    	  assertTrue(this.trackField.isReadonly());
+    }
+
+    /**
      * A custom Div container.
      */
     static class Div extends AbstractContainer {

Modified: incubator/click/branches/click-2.0.x/framework/test/org/apache/click/control/FormTest.java
URL: http://svn.apache.org/viewvc/incubator/click/branches/click-2.0.x/framework/test/org/apache/click/control/FormTest.java?rev=749070&r1=749069&r2=749070&view=diff
==============================================================================
--- incubator/click/branches/click-2.0.x/framework/test/org/apache/click/control/FormTest.java
(original)
+++ incubator/click/branches/click-2.0.x/framework/test/org/apache/click/control/FormTest.java
Sun Mar  1 18:33:05 2009
@@ -708,6 +708,42 @@
     }
 
     /**
+     * Test the isDisabled() for a child component. Intent is to ensure that a
+     * child component of the Form is disabled when the Form is itself disabled.
+     */
+    public void testIsDisabled() {
+        // Form is not disabled.
+        assertFalse(this.form.isDisabled());
+
+        // Hiddenfield inside is not disabled.
+        assertFalse(this.trackField.isDisabled());
+
+        // Change form state.
+        this.form.setDisabled(true);
+
+        // Hiddenfield is now disabled too.
+        assertTrue(this.trackField.isDisabled());
+    }
+
+    /**
+     * Test the isReadonly() for a child component. Intent is to ensure that a
+     * child component of the Form is disabled when the Form is itself disabled.
+     */
+    public void testIsReadonly() {
+        // Form is not disabled.
+        assertFalse(this.form.isReadonly());
+
+        // Hiddenfield inside is not disabled.
+        assertFalse(this.trackField.isReadonly());
+
+        // Change form state.
+        this.form.setReadonly(true);
+
+        // Hiddenfield is now disabled too.
+        assertTrue(this.trackField.isReadonly());
+    }
+
+    /**
      * Populate the given Form with hidden fields.
      *
      * @param count the number of hidden fields to add



Mime
View raw message