diff options
author | Artur Signell <artur.signell@itmill.com> | 2009-11-26 15:20:11 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2009-11-26 15:20:11 +0000 |
commit | 26d228c3ba20d09cb38d14e6682fd2d00626cc7b (patch) | |
tree | 2e4d1fac17869accdfa4337cf8fc66e138daa4af /src | |
parent | 2406a8b6f5ffaf2899646c962ed904923d644b77 (diff) | |
download | vaadin-framework-26d228c3ba20d09cb38d14e6682fd2d00626cc7b.tar.gz vaadin-framework-26d228c3ba20d09cb38d14e6682fd2d00626cc7b.zip |
Patch that fixes #3772 - Add notifier interfaces for focus and blur events
svn changeset:10079/svn branch:6.2
Diffstat (limited to 'src')
-rw-r--r-- | src/com/vaadin/event/FieldEvents.java | 74 | ||||
-rw-r--r-- | src/com/vaadin/ui/TextField.java | 24 |
2 files changed, 77 insertions, 21 deletions
diff --git a/src/com/vaadin/event/FieldEvents.java b/src/com/vaadin/event/FieldEvents.java index fc9f225b8f..b298590a8c 100644 --- a/src/com/vaadin/event/FieldEvents.java +++ b/src/com/vaadin/event/FieldEvents.java @@ -12,6 +12,80 @@ import com.vaadin.ui.Component; public interface FieldEvents {
/**
+ * The interface for adding and removing <code>FocusEvent</code> listeners.
+ * By implementing this interface a class explicitly announces that it will
+ * generate a <code>FocusEvent</code> when it receives keyboard focus.
+ * <p>
+ * Note: The general Java convention is not to explicitly declare that a
+ * class generates events, but to directly define the
+ * <code>addListener</code> and <code>removeListener</code> methods. That
+ * way the caller of these methods has no real way of finding out if the
+ * class really will send the events, or if it just defines the methods to
+ * be able to implement an interface.
+ * </p>
+ * @since 6.2
+ * @see FocusListener
+ * @see FocusEvent
+ */
+ public interface FocusNotifier {
+ /**
+ * Adds a <code>FocusListener</code> to the Component which gets fired
+ * when a <code>Field</code> receives keyboard focus.
+ *
+ * @param listener
+ * @see FocusListener
+ * @since 6.2
+ */
+ public void addListener(FocusListener listener);
+
+ /**
+ * Removes a <code>FocusListener</code> from the Component.
+ *
+ * @param listener
+ * @see FocusListener
+ * @since 6.2
+ */
+ public void removeListener(FocusListener listener);
+ }
+
+ /**
+ * The interface for adding and removing <code>BlurEvent</code> listeners.
+ * By implementing this interface a class explicitly announces that it will
+ * generate a <code>BlurEvent</code> when it loses keyboard focus.
+ * <p>
+ * Note: The general Java convention is not to explicitly declare that a
+ * class generates events, but to directly define the
+ * <code>addListener</code> and <code>removeListener</code> methods. That
+ * way the caller of these methods has no real way of finding out if the
+ * class really will send the events, or if it just defines the methods to
+ * be able to implement an interface.
+ * </p>
+ * @since 6.2
+ * @see BlurListener
+ * @see BlurEvent
+ */
+ public interface BlurNotifier {
+ /**
+ * Adds a <code>BlurListener</code> to the Component which gets fired
+ * when a <code>Field</code> loses keyboard focus.
+ *
+ * @param listener
+ * @see BlurListener
+ * @since 6.2
+ */
+ public void addListener(BlurListener listener);
+
+ /**
+ * Removes a <code>BlurListener</code> from the Component.
+ *
+ * @param listener
+ * @see BlurListener
+ * @since 6.2
+ */
+ public void removeListener(BlurListener listener);
+ }
+
+ /**
* <code>FocusEvent</code> class for holding additional event information.
* Fired when a <code>Field</code> receives keyboard focus.
*
diff --git a/src/com/vaadin/ui/TextField.java b/src/com/vaadin/ui/TextField.java index 59cf6640ce..aa7923ed8b 100644 --- a/src/com/vaadin/ui/TextField.java +++ b/src/com/vaadin/ui/TextField.java @@ -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); } |