/**
* <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.
}
// Assures the visual refresh
+ // FIXME: Is this really needed? Header captions should not affect
+ // content so requestRepaint() should be sufficient.
resetPageBuffer();
refreshRenderedCells();
}
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();
}
}
}
+ /**
+ * 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() {
--- /dev/null
+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