]> source.dussan.org Git - vaadin-framework.git/commitdiff
Javadoc
authorArtur Signell <artur.signell@itmill.com>
Wed, 25 Nov 2009 19:14:23 +0000 (19:14 +0000)
committerArtur Signell <artur.signell@itmill.com>
Wed, 25 Nov 2009 19:14:23 +0000 (19:14 +0000)
svn changeset:10045/svn branch:event-framework-3234

src/TestListeners.java
src/com/vaadin/ui/AbsoluteLayout.java
src/com/vaadin/ui/AbstractOrderedLayout.java
src/com/vaadin/ui/Embedded.java
src/com/vaadin/ui/GridLayout.java
src/com/vaadin/ui/Panel.java

index 9650c2269a3048a00e00eb6fcc9edf63a44f5a07..87255b4eac02996e1923bca28a1b590106e46bce 100644 (file)
@@ -8,6 +8,7 @@ import com.vaadin.event.LayoutEvents.LayoutClickListener;
 import com.vaadin.event.MouseEvents.ClickEvent;
 import com.vaadin.event.MouseEvents.ClickListener;
 import com.vaadin.terminal.ExternalResource;
+import com.vaadin.terminal.gwt.client.MouseEventDetails;
 import com.vaadin.ui.AbsoluteLayout;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.Embedded;
@@ -28,19 +29,6 @@ public class TestListeners extends Application implements LayoutClickListener,
         setMainWindow(w);
         HorizontalLayout hl = new HorizontalLayout();
         w.setContent(hl);
-        // Panel p = new Panel("My panel");
-        // p.addListener(new ClickListener() {
-        //
-        // public void click(ClickEvent event) {
-        // getMainWindow().showNotification("Clicked!");
-        //
-        // }
-        // });
-        // w.addComponent(p);
-        // if (true) {
-        // return;
-        // }
-        // VerticalLayout vl = new VerticalLayout();
 
         final AbsoluteLayout al = new AbsoluteLayout();
         al.setWidth("200px");
@@ -186,7 +174,17 @@ public class TestListeners extends Application implements LayoutClickListener,
     public void click(ClickEvent event) {
         getMainWindow().showNotification(
                 "Clicked on " + event.getComponent() + " using "
-                        + event.getButton());
+                        + getButton(event));
+    }
+
+    private String getButton(ClickEvent event) {
+        if (event.getButton() == MouseEventDetails.BUTTON_LEFT) {
+            return "left";
+        } else if (event.getButton() == MouseEventDetails.BUTTON_RIGHT) {
+            return "right";
+        } else {
+            return "middle";
+        }
     }
 
     public void focus(FocusEvent event) {
index 849538b49a63ebf9b03f1802b04052461623cfb1..d32ba913b1c5f3f360c03c05a57a10a5ec5b88e1 100644 (file)
@@ -375,11 +375,33 @@ public class AbsoluteLayout extends AbstractLayout {
         fireEvent(new LayoutClickEvent(this, mouseDetails, childComponent));
     }
 
+    /**
+     * Add a click listener to the layout. The listener is called whenever the
+     * user clicks inside the layout. Also when the click targets a component
+     * inside the Panel, provided the targeted component does not prevent the
+     * click event from propagating. A caption is not considered part of a
+     * component.
+     * 
+     * The child component that was clicked is included in the
+     * {@link LayoutClickEvent}.
+     * 
+     * Use {@link #removeListener(LayoutClickListener)} to remove the listener.
+     * 
+     * @param listener
+     *            The listener to add
+     */
     public void addListener(LayoutClickListener listener) {
         addListener(CLICK_EVENT, LayoutClickEvent.class, listener,
                 LayoutClickListener.clickMethod);
     }
 
+    /**
+     * Remove a click listener from the layout. The listener should earlier have
+     * been added using {@link #addListener(LayoutClickListener)}.
+     * 
+     * @param listener
+     *            The listener to remove
+     */
     public void removeListener(LayoutClickListener listener) {
         removeListener(CLICK_EVENT, LayoutClickEvent.class, listener);
     }
index 2a6bd84771e53e96a88787768cdb67245664b142..dc722bbd126c94e632bef2b3eb684f203d7d7732 100644 (file)
@@ -330,11 +330,33 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
         fireEvent(new LayoutClickEvent(this, mouseDetails, childComponent));
     }
 
+    /**
+     * Add a click listener to the layout. The listener is called whenever the
+     * user clicks inside the layout. Also when the click targets a component
+     * inside the Panel, provided the targeted component does not prevent the
+     * click event from propagating. A caption is not considered part of a
+     * component.
+     * 
+     * The child component that was clicked is included in the
+     * {@link LayoutClickEvent}.
+     * 
+     * Use {@link #removeListener(LayoutClickListener)} to remove the listener.
+     * 
+     * @param listener
+     *            The listener to add
+     */
     public void addListener(LayoutClickListener listener) {
         addListener(CLICK_EVENT, LayoutClickEvent.class, listener,
                 LayoutClickListener.clickMethod);
     }
 
+    /**
+     * Remove a click listener from the layout. The listener should earlier have
+     * been added using {@link #addListener(LayoutClickListener)}.
+     * 
+     * @param listener
+     *            The listener to remove
+     */
     public void removeListener(LayoutClickListener listener) {
         removeListener(CLICK_EVENT, LayoutClickEvent.class, listener);
     }
index 7d5d7ff14403dc703fa3675dc8f0a0ff67265296..298953d1b113b9779923f65d1e635c5247ff45b2 100644 (file)
@@ -420,11 +420,28 @@ public class Embedded extends AbstractComponent {
         }
     }
 
+    /**
+     * Add a click listener to the component. The listener is called whenever
+     * the user clicks inside the component. Depending on the content the event
+     * may be blocked and in that case no event is fired.
+     * 
+     * Use {@link #removeListener(ClickListener)} to remove the listener.
+     * 
+     * @param listener
+     *            The listener to add
+     */
     public void addListener(ClickListener listener) {
         addListener(CLICK_EVENT, ClickEvent.class, listener,
                 ClickListener.clickMethod);
     }
 
+    /**
+     * Remove a click listener from the component. The listener should earlier
+     * have been added using {@link #addListener(ClickListener)}.
+     * 
+     * @param listener
+     *            The listener to remove
+     */
     public void removeListener(ClickListener listener) {
         removeListener(CLICK_EVENT, ClickEvent.class, listener);
     }
index 602703980e5b74d7dc32a3b651867b2cf252a1b8..856565194cdd760ed25565804fb9daeddf7e60fe 100644 (file)
@@ -1322,11 +1322,33 @@ public class GridLayout extends AbstractLayout implements
         fireEvent(new LayoutClickEvent(this, mouseDetails, childComponent));
     }
 
+    /**
+     * Add a click listener to the layout. The listener is called whenever the
+     * user clicks inside the layout. Also when the click targets a component
+     * inside the Panel, provided the targeted component does not prevent the
+     * click event from propagating. A caption is not considered part of a
+     * component.
+     * 
+     * The child component that was clicked is included in the
+     * {@link LayoutClickEvent}.
+     * 
+     * Use {@link #removeListener(LayoutClickListener)} to remove the listener.
+     * 
+     * @param listener
+     *            The listener to add
+     */
     public void addListener(LayoutClickListener listener) {
         addListener(CLICK_EVENT, LayoutClickEvent.class, listener,
                 LayoutClickListener.clickMethod);
     }
 
+    /**
+     * Remove a click listener from the layout. The listener should earlier have
+     * been added using {@link #addListener(LayoutClickListener)}.
+     * 
+     * @param listener
+     *            The listener to remove
+     */
     public void removeListener(LayoutClickListener listener) {
         removeListener(CLICK_EVENT, LayoutClickEvent.class, listener);
     }
index 789fca5feac3c101da02aab15108dfa54149f64d..d21de3d31322eda527b029563e3ecd50f54eb8c4 100644 (file)
@@ -553,11 +553,29 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
         }
     }
 
+    /**
+     * Add a click listener to the Panel. The listener is called whenever the
+     * user clicks inside the Panel. Also when the click targets a component
+     * inside the Panel, provided the targeted component does not prevent the
+     * click event from propagating.
+     * 
+     * Use {@link #removeListener(ClickListener)} to remove the listener.
+     * 
+     * @param listener
+     *            The listener to add
+     */
     public void addListener(ClickListener listener) {
         addListener(CLICK_EVENT, ClickEvent.class, listener,
                 ClickListener.clickMethod);
     }
 
+    /**
+     * Remove a click listener from the Panel. The listener should earlier have
+     * been added using {@link #addListener(ClickListener)}.
+     * 
+     * @param listener
+     *            The listener to remove
+     */
     public void removeListener(ClickListener listener) {
         removeListener(CLICK_EVENT, ClickEvent.class, listener);
     }