]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge remote-tracking branch 'origin/6.8'
authorArtur Signell <artur@vaadin.com>
Thu, 12 Apr 2012 06:53:11 +0000 (09:53 +0300)
committerArtur Signell <artur@vaadin.com>
Thu, 12 Apr 2012 06:53:11 +0000 (09:53 +0300)
Conflicts:
src/com/vaadin/ui/AbstractField.java

1  2 
src/com/vaadin/ui/AbstractField.java

index 3b9d035a9a6393a8ec68935b67251e08a5fc10cd,e1d32702254e7881cc6d745c854c2c6acd080bf3..9f5516a6cef547dad2ccac76bd773106a6980277
@@@ -1360,8 -1133,17 +1376,14 @@@ public abstract class AbstractField<T> 
      @Override
      public void attach() {
          super.attach();
-         // No-op if listeners already registered
-         addPropertyListeners();
 -        if (actionManager != null) {
 -            actionManager.setViewer(getWindow());
 -        }
+         if (!isListeningToPropertyEvents) {
+             addPropertyListeners();
+             if (!isModified() && isReadThrough()) {
+                 // Update value from data source
+                 discard();
+             }
+         }
      }
  
      @Override
          }
      }
  
 +    /**
 +     * Gets the converter used to convert the property data source value to the
 +     * field value.
 +     * 
 +     * @return The converter or null if none is set.
 +     */
 +    public Converter<T, Object> getConverter() {
 +        return converter;
 +    }
 +
 +    /**
 +     * Sets the converter used to convert the field value to property data
 +     * source type. The converter must have a presentation type that matches the
 +     * field type.
 +     * 
 +     * @param converter
 +     *            The new converter to use.
 +     */
 +    public void setConverter(Converter<T, ?> converter) {
 +        this.converter = (Converter<T, Object>) converter;
 +        requestRepaint();
 +    }
 +
 +    @Override
 +    public AbstractFieldState getState() {
 +        return (AbstractFieldState) super.getState();
 +    }
 +
 +    @Override
 +    public void updateState() {
 +        super.updateState();
 +
 +        // Hide the error indicator if needed
 +        getState().setHideErrors(shouldHideErrors());
 +    }
 +
+     /**
+      * Registers this as an event listener for events sent by the data source
+      * (if any). Does nothing if
+      * <code>isListeningToPropertyEvents == true</code>.
+      */
      private void addPropertyListeners() {
-         if (!isListening) {
+         if (!isListeningToPropertyEvents) {
              if (dataSource instanceof Property.ValueChangeNotifier) {
                  ((Property.ValueChangeNotifier) dataSource).addListener(this);
              }
                  ((Property.ReadOnlyStatusChangeNotifier) dataSource)
                          .removeListener(this);
              }
-             isListening = false;
+             isListeningToPropertyEvents = false;
          }
      }
 -}
 +}