]> source.dussan.org Git - vaadin-framework.git/commitdiff
Experimental patch to block sending back variables that are just updated. Now only...
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Wed, 27 Jun 2007 14:02:19 +0000 (14:02 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Wed, 27 Jun 2007 14:02:19 +0000 (14:02 +0000)
svn changeset:1795/svn branch:trunk

src/com/itmill/toolkit/ui/AbstractField.java
src/com/itmill/toolkit/ui/Select.java
src/com/itmill/toolkit/ui/TextField.java
src/com/itmill/toolkit/ui/Tree.java

index 2609cecc686979ad88a0247fc7fefe4e454ba404..1cf7b69ac48a0ba37522aa5fd20ea3560c762ac5 100644 (file)
@@ -290,7 +290,7 @@ public abstract class AbstractField extends AbstractComponent implements Field,
                        if ((newValue == null && value != null)
                                        || (newValue != null && !newValue.equals(value))) {
                                setInternalValue(newValue);
-                               fireValueChange();
+                               fireValueChange(false);
                        }
 
                        // If the value did not change, but the modification status did
@@ -351,7 +351,7 @@ public abstract class AbstractField extends AbstractComponent implements Field,
                readTroughMode = readTrough;
                if (!isModified() && readTroughMode && dataSource != null) {
                        setInternalValue(dataSource.getValue());
-                       fireValueChange();
+                       fireValueChange(false);
                }
        }
 
@@ -387,7 +387,7 @@ public abstract class AbstractField extends AbstractComponent implements Field,
                if ((newValue == null && value != null)
                                || (newValue != null && !newValue.equals(value))) {
                        setInternalValue(newValue);
-                       fireValueChange();
+                       fireValueChange(false);
                }
 
                return newValue;
@@ -403,6 +403,20 @@ public abstract class AbstractField extends AbstractComponent implements Field,
         */
        public void setValue(Object newValue) throws Property.ReadOnlyException,
                        Property.ConversionException {
+               setValue(newValue, false);
+       }
+               
+       /**
+        * Sets the value of the field.
+        * 
+        * @param newValue
+        *            the New value of the field.
+        * @param repaintIsNotNeeded True iff caller is sure that repaint is not needed. 
+        * @throws Property.ReadOnlyException
+        * @throws Property.ConversionException
+        */
+       protected void setValue(Object newValue, boolean repaintIsNotNeeded) throws Property.ReadOnlyException,
+               Property.ConversionException {
 
                if ((newValue == null && value != null)
                                || (newValue != null && !newValue.equals(value))) {
@@ -453,7 +467,7 @@ public abstract class AbstractField extends AbstractComponent implements Field,
                        }
 
                        // Fires the value change
-                       fireValueChange();
+                       fireValueChange(repaintIsNotNeeded);
                }
        }
 
@@ -534,7 +548,7 @@ public abstract class AbstractField extends AbstractComponent implements Field,
                // Fires value change if the value has changed
                if ((value != oldValue)
                                && ((value != null && !value.equals(oldValue)) || value == null))
-                       fireValueChange();
+                       fireValueChange(false);
        }
 
        /* Validation ****************************************************** */
@@ -735,9 +749,10 @@ public abstract class AbstractField extends AbstractComponent implements Field,
         * Emits the value change event. The value contained in the field is
         * validated before the event is created.
         */
-       protected void fireValueChange() {
+       protected void fireValueChange(boolean repaintIsNotNeeded) {
                fireEvent(new AbstractField.ValueChangeEvent(this));
-               requestRepaint();
+               if (!repaintIsNotNeeded)
+                       requestRepaint();
        }
 
        /* Read-only status change events *************************************** */
@@ -831,7 +846,7 @@ public abstract class AbstractField extends AbstractComponent implements Field,
         */
        public void valueChange(Property.ValueChangeEvent event) {
                if (isReadThrough() || !isModified())
-                       fireValueChange();
+                       fireValueChange(false);
        }
 
        /**
index b986e84e08d7f99109e893b1f329220a51e363ca..88120ca81050cd309086dc4d59a820eea495e3be 100644 (file)
@@ -406,6 +406,8 @@ public class Select extends AbstractField implements Container,
                        // Multiselect mode
                        if (isMultiSelect()) {
 
+                               // TODO Optimize by adding repaintNotNeeded whan applicaple
+                               
                                // Converts the key-array to id-set
                                LinkedList s = new LinkedList();
                                for (int i = 0; i < ka.length; i++) {
@@ -440,15 +442,15 @@ public class Select extends AbstractField implements Container,
                                        Object current = getValue();
                                        Collection visible = getVisibleItemIds();
                                        if (visible != null && visible.contains(current))
-                                               setValue(null);
+                                               setValue(null, true);
                                } else {
                                        Object id = itemIdMapper.get(ka[0]);
                                        if (id != null && id.equals(getNullSelectionItemId()))
-                                               setValue(null);
+                                               setValue(null, true);
                                        else if (itemIdMapper.isNewIdKey(ka[0]))
                                                setValue(newitem);
                                        else
-                                               setValue(id);
+                                               setValue(id, true);
                                }
                        }
                }
@@ -534,14 +536,33 @@ public class Select extends AbstractField implements Container,
         */
        public void setValue(Object newValue) throws Property.ReadOnlyException,
                        Property.ConversionException {
+               setValue(newValue, false);
+       }
+
+       /**
+        * Sets the visible value of the property.
+        * 
+        * <p>
+        * The value of the select is the selected item id. If the select is in
+        * multiselect-mode, the value is a set of selected item keys. In
+        * multiselect mode all collections of id:s can be assigned.
+        * </p>
+        * 
+        * @param newValue
+        *            the New selected item or collection of selected items.
+        * @param repaintIsNotNeeded True iff caller is sure that repaint is not needed. 
+        * @see com.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object, java.lang.Boolean)
+        */
+       protected void setValue(Object newValue, boolean repaintIsNotNeeded) throws Property.ReadOnlyException,
+                       Property.ConversionException {
 
                if (isMultiSelect()) {
                        if (newValue == null)
-                               super.setValue(new HashSet());
+                               super.setValue(new HashSet(), repaintIsNotNeeded);
                        else if (Collection.class.isAssignableFrom(newValue.getClass()))
-                               super.setValue(new HashSet((Collection) newValue));
+                               super.setValue(new HashSet((Collection) newValue), repaintIsNotNeeded);
                } else if (newValue == null || items.containsId(newValue))
-                       super.setValue(newValue);
+                       super.setValue(newValue, repaintIsNotNeeded);
        }
 
        /* Container methods **************************************************** */
@@ -798,7 +819,7 @@ public class Select extends AbstractField implements Container,
                        }
 
                        // TODO: This should be conditional
-                       fireValueChange();
+                       fireValueChange(false);
                }
        }
 
index 8d4bf0a45960b9b2f128e1b10f4dac4296827d35..a8d1bd279c32894380dbbc8865a65cf2d87cd93f 100644 (file)
@@ -243,7 +243,7 @@ public class TextField extends AbstractField {
                                newValue = null;
                        if (newValue != oldValue
                                        && (newValue == null || !newValue.equals(oldValue)))
-                               setValue(newValue);
+                               setValue(newValue,true);
                }
 
        }
index 1d3f303aa3f505abe3878cb83e95eeba8de2c3d5..a4440c2cbcb3158f18382197053203fe40da3a1c 100644 (file)
@@ -305,8 +305,10 @@ public class Tree extends Select implements Container.Hierarchical,
                        String[] keys = (String[]) variables.get("collapse");
                        for (int i = 0; i < keys.length; i++) {
                                Object id = itemIdMapper.get(keys[i]);
-                               if (id != null)
-                                       collapseItem(id);
+                               if (id != null && isExpanded(id)) {
+                                       expanded.remove(id);
+                                       fireCollapseEvent(id);
+                               }
                        }
                }
 
@@ -548,7 +550,7 @@ public class Tree extends Select implements Container.Hierarchical,
                boolean success = ((Container.Hierarchical) items).setChildrenAllowed(
                                itemId, areChildrenAllowed);
                if (success)
-                       fireValueChange();
+                       fireValueChange(false);
                return success;
        }