]> source.dussan.org Git - vaadin-framework.git/commitdiff
Patch that fixes #3772 - Add notifier interfaces for focus and blur events
authorArtur Signell <artur.signell@itmill.com>
Thu, 26 Nov 2009 15:20:11 +0000 (15:20 +0000)
committerArtur Signell <artur.signell@itmill.com>
Thu, 26 Nov 2009 15:20:11 +0000 (15:20 +0000)
svn changeset:10079/svn branch:6.2

src/com/vaadin/event/FieldEvents.java
src/com/vaadin/ui/TextField.java

index fc9f225b8f331c2bb68a3ae9266759d6e55df9a9..b298590a8cec933eaa51d765574fe7aec827f502 100644 (file)
@@ -11,6 +11,80 @@ import com.vaadin.ui.Component;
 \r
 public interface FieldEvents {\r
 \r
+    /**\r
+     * The interface for adding and removing <code>FocusEvent</code> listeners.\r
+     * By implementing this interface a class explicitly announces that it will\r
+     * generate a <code>FocusEvent</code> when it receives keyboard focus.\r
+     * <p>\r
+     * Note: The general Java convention is not to explicitly declare that a\r
+     * class generates events, but to directly define the\r
+     * <code>addListener</code> and <code>removeListener</code> methods. That\r
+     * way the caller of these methods has no real way of finding out if the\r
+     * class really will send the events, or if it just defines the methods to\r
+     * be able to implement an interface.\r
+     * </p>\r
+     * @since 6.2\r
+     * @see FocusListener\r
+     * @see FocusEvent\r
+     */\r
+    public interface FocusNotifier {\r
+        /**\r
+         * Adds a <code>FocusListener</code> to the Component which gets fired\r
+         * when a <code>Field</code> receives keyboard focus.\r
+         * \r
+         * @param listener\r
+         * @see FocusListener\r
+         * @since 6.2\r
+         */\r
+        public void addListener(FocusListener listener);\r
+\r
+        /**\r
+         * Removes a <code>FocusListener</code> from the Component.\r
+         * \r
+         * @param listener\r
+         * @see FocusListener\r
+         * @since 6.2\r
+         */\r
+        public void removeListener(FocusListener listener);\r
+    }\r
+\r
+    /**\r
+     * The interface for adding and removing <code>BlurEvent</code> listeners.\r
+     * By implementing this interface a class explicitly announces that it will\r
+     * generate a <code>BlurEvent</code> when it loses keyboard focus.\r
+     * <p>\r
+     * Note: The general Java convention is not to explicitly declare that a\r
+     * class generates events, but to directly define the\r
+     * <code>addListener</code> and <code>removeListener</code> methods. That\r
+     * way the caller of these methods has no real way of finding out if the\r
+     * class really will send the events, or if it just defines the methods to\r
+     * be able to implement an interface.\r
+     * </p>\r
+     * @since 6.2\r
+     * @see BlurListener\r
+     * @see BlurEvent\r
+     */\r
+    public interface BlurNotifier {\r
+        /**\r
+         * Adds a <code>BlurListener</code> to the Component which gets fired\r
+         * when a <code>Field</code> loses keyboard focus.\r
+         * \r
+         * @param listener\r
+         * @see BlurListener\r
+         * @since 6.2\r
+         */\r
+        public void addListener(BlurListener listener);\r
+\r
+        /**\r
+         * Removes a <code>BlurListener</code> from the Component.\r
+         * \r
+         * @param listener\r
+         * @see BlurListener\r
+         * @since 6.2\r
+         */\r
+        public void removeListener(BlurListener listener);\r
+    }\r
+\r
     /**\r
      * <code>FocusEvent</code> class for holding additional event information.\r
      * Fired when a <code>Field</code> receives keyboard focus.\r
index 59cf6640cecfb5f987acff2186dba41fc4062d7a..aa7923ed8bce6eecec5ad521d463eac21cdbd798 100644 (file)
@@ -8,6 +8,7 @@ import java.text.Format;
 import java.util.Map;
 
 import com.vaadin.data.Property;
+import com.vaadin.event.FieldEvents;
 import com.vaadin.event.FieldEvents.BlurEvent;
 import com.vaadin.event.FieldEvents.BlurListener;
 import com.vaadin.event.FieldEvents.FocusEvent;
@@ -38,7 +39,8 @@ import com.vaadin.terminal.gwt.client.ui.VTextField;
  */
 @SuppressWarnings("serial")
 @ClientWidget(VTextField.class)
-public class TextField extends AbstractField {
+public class TextField extends AbstractField implements
+        FieldEvents.BlurNotifier, FieldEvents.FocusNotifier {
 
     /* Private members */
 
@@ -624,40 +626,20 @@ public class TextField extends AbstractField {
         fireEvent(new BlurEvent(this));
     }
 
-    /**
-     * TODO
-     * 
-     * @param listener
-     */
     public void addListener(FocusListener listener) {
         addListener(FOCUS_EVENT, FocusEvent.class, listener,
                 FocusListener.focusMethod);
     }
 
-    /**
-     * TODO
-     * 
-     * @param listener
-     */
     public void removeListener(FocusListener listener) {
         removeListener(FOCUS_EVENT, FocusEvent.class, listener);
     }
 
-    /**
-     * TODO
-     * 
-     * @param listener
-     */
     public void addListener(BlurListener listener) {
         addListener(BLUR_EVENT, BlurEvent.class, listener,
                 BlurListener.blurMethod);
     }
 
-    /**
-     * TODO
-     * 
-     * @param listener
-     */
     public void removeListener(BlurListener listener) {
         removeListener(BLUR_EVENT, BlurEvent.class, listener);
     }