]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merged [11391],[11473],[11474],[11475],[11477] from 6.2
authorArtur Signell <artur.signell@itmill.com>
Tue, 23 Feb 2010 10:17:00 +0000 (10:17 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 23 Feb 2010 10:17:00 +0000 (10:17 +0000)
Fix and test case for #4222

svn changeset:11485/svn branch:6.3

src/com/vaadin/ui/Table.java
src/com/vaadin/ui/Window.java
tests/src/com/vaadin/tests/server/components/TestWindow.java [new file with mode: 0644]

index 0563756d40e869b829feba5674184b5da6528329..3804f8979e35315f0341cb6376e849d032356112 100644 (file)
@@ -36,14 +36,20 @@ import com.vaadin.terminal.gwt.client.ui.VScrollTable;
 
 /**
  * <p>
- * <code>TableComponent</code> is used for representing data or components in
- * pageable and selectable table.
+ * <code>Table</code> is used for representing data or components in a pageable
+ * and selectable table.
  * </p>
  * 
  * <p>
- * Note! Since version 5, components in Table will not have their caption nor
- * icon rendered. In order to workaround this limitation, wrap your component in
- * a Layout.
+ * Scalability of the Table is largely dictated by the container. A table does
+ * not have a limit for the number of items and is just as fast with hundreds of
+ * thousands of items as with just a few. The current GWT implementation with
+ * scrolling however limits the number of rows to around 500000, depending on
+ * the browser and the pixel height of rows.
+ * </p>
+ * 
+ * <p>
+ * Components in a Table will not have their caption nor icon rendered.
  * </p>
  * 
  * @author IT Mill Ltd.
@@ -502,6 +508,8 @@ public class Table extends AbstractSelect implements Action.Container,
         }
 
         // Assures the visual refresh
+        // FIXME: Is this really needed? Header captions should not affect
+        // content so requestRepaint() should be sufficient.
         resetPageBuffer();
         refreshRenderedCells();
     }
@@ -971,6 +979,8 @@ public class Table extends AbstractSelect implements Action.Container,
         columnHeaders.put(propertyId, header);
 
         // Assures the visual refresh
+        // FIXME: Is this really needed? Header captions should not affect
+        // content so requestRepaint() should be sufficient.
         refreshRenderedCells();
     }
 
index 63daabdf90d8742730e2696b555d28aabdc7d3a8..f4657d81f6af9fc59b0a99f006c02fcd88954408 100644 (file)
@@ -1053,28 +1053,63 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
         }
     }
 
+    /**
+     * An interface used for listening to Window close events. Add the
+     * CloseListener to a browser level window or a sub window and
+     * {@link CloseListener#windowClose(CloseEvent)} will be called whenever the
+     * user closes the window.
+     * 
+     * <p>
+     * Note that removing windows using {@link #removeWindow(Window)} will not
+     * fire the CloseListener.
+     * </p>
+     */
     public interface CloseListener extends Serializable {
+        /**
+         * Called when the user closes a window. Use
+         * {@link CloseEvent#getWindow()} to get a reference to the
+         * {@link Window} that was closed.
+         * 
+         * @param e
+         *            Event containing
+         */
         public void windowClose(CloseEvent e);
     }
 
     /**
-     * Adds the listener.
+     * Adds a CloseListener to the window.
+     * 
+     * For a sub window the CloseListener is fired when the user closes it
+     * (clicks on the close button).
+     * 
+     * For a browser level window the CloseListener is fired when the browser
+     * level window is closed. Note that closing a browser level window does not
+     * mean it will be destroyed.
+     * 
+     * <p>
+     * Note that removing windows using {@link #removeWindow(Window)} will not
+     * fire the CloseListener.
+     * </p>
      * 
      * @param listener
-     *            the listener to add.
+     *            the CloseListener to add.
      */
     public void addListener(CloseListener listener) {
         addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD);
     }
 
     /**
-     * Removes the listener.
+     * Removes the CloseListener from the window.
+     * 
+     * <p>
+     * For more information on CloseListeners see {@link CloseListener}.
+     * </p>
      * 
      * @param listener
-     *            the listener to remove.
+     *            the CloseListener to remove.
      */
     public void removeListener(CloseListener listener) {
-        addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD);
+        removeListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD);
     }
 
     protected void fireClose() {
diff --git a/tests/src/com/vaadin/tests/server/components/TestWindow.java b/tests/src/com/vaadin/tests/server/components/TestWindow.java
new file mode 100644 (file)
index 0000000..05604ab
--- /dev/null
@@ -0,0 +1,90 @@
+package com.vaadin.tests.server.components;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import junit.framework.TestCase;\r
+\r
+import org.easymock.EasyMock;\r
+\r
+import com.vaadin.ui.Window;\r
+import com.vaadin.ui.Window.CloseEvent;\r
+import com.vaadin.ui.Window.CloseListener;\r
+import com.vaadin.ui.Window.ResizeEvent;\r
+import com.vaadin.ui.Window.ResizeListener;\r
+\r
+public class TestWindow extends TestCase {\r
+\r
+    private Window window;\r
+\r
+    @Override\r
+    protected void setUp() throws Exception {\r
+        window = new Window();\r
+    }\r
+\r
+    public void testCloseListener() {\r
+        CloseListener cl = EasyMock.createMock(Window.CloseListener.class);\r
+\r
+        // Expectations\r
+        cl.windowClose(EasyMock.isA(CloseEvent.class));\r
+\r
+        // Start actual test\r
+        EasyMock.replay(cl);\r
+\r
+        // Add listener and send a close event -> should end up in listener once\r
+        window.addListener(cl);\r
+        sendClose(window);\r
+\r
+        // Ensure listener was called once\r
+        EasyMock.verify(cl);\r
+\r
+        // Remove the listener and send close event -> should not end up in\r
+        // listener\r
+        window.removeListener(cl);\r
+        sendClose(window);\r
+\r
+        // Ensure listener still has been called only once\r
+        EasyMock.verify(cl);\r
+\r
+    }\r
+\r
+    public void testResizeListener() {\r
+        ResizeListener rl = EasyMock.createMock(Window.ResizeListener.class);\r
+\r
+        // Expectations\r
+        rl.windowResized(EasyMock.isA(ResizeEvent.class));\r
+\r
+        // Start actual test\r
+        EasyMock.replay(rl);\r
+\r
+        // Add listener and send a resize event -> should end up in listener\r
+        // once\r
+        window.addListener(rl);\r
+        sendResize(window);\r
+\r
+        // Ensure listener was called once\r
+        EasyMock.verify(rl);\r
+\r
+        // Remove the listener and send close event -> should not end up in\r
+        // listener\r
+        window.removeListener(rl);\r
+        sendResize(window);\r
+\r
+        // Ensure listener still has been called only once\r
+        EasyMock.verify(rl);\r
+\r
+    }\r
+\r
+    private void sendResize(Window window2) {\r
+        Map<String, Object> variables = new HashMap<String, Object>();\r
+        variables.put("height", 1234);\r
+        window.changeVariables(window, variables);\r
+\r
+    }\r
+\r
+    private static void sendClose(Window window) {\r
+        Map<String, Object> variables = new HashMap<String, Object>();\r
+        variables.put("close", true);\r
+        window.changeVariables(window, variables);\r
+    }\r
+}\r