diff options
author | Artur Signell <artur.signell@itmill.com> | 2011-04-26 15:37:03 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2011-04-26 15:37:03 +0000 |
commit | 96f2068af62353155cce230276011984ae68fb96 (patch) | |
tree | d9345cc64d551dfd7e7d827d658feb9b00eba170 | |
parent | edce21e05216e13cb04e5b085640cdd40b1d365e (diff) | |
download | vaadin-framework-96f2068af62353155cce230276011984ae68fb96.tar.gz vaadin-framework-96f2068af62353155cce230276011984ae68fb96.zip |
#6716 Support for resizeLazy for sub window
svn changeset:18479/svn branch:6.6
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VWindow.java | 22 | ||||
-rw-r--r-- | tests/src/com/vaadin/tests/components/window/LazyWindowResize.java | 49 |
2 files changed, 71 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java index dd09559078..aae6cf0049 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java @@ -11,6 +11,7 @@ import java.util.Iterator; import java.util.Set; import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.DomEvent.Type; @@ -136,6 +137,8 @@ public class VWindow extends VOverlay implements Container, private boolean draggable = true; + private boolean resizeLazy = false; + private Element modalityCurtain; private Element draggingCurtain; @@ -178,6 +181,14 @@ public class VWindow extends VOverlay implements Container, private int bringToFrontSequence = -1; + private VLazyExecutor delayedContentsSizeUpdater = new VLazyExecutor(200, + new ScheduledCommand() { + + public void execute() { + updateContentsSize(); + } + }); + public VWindow() { super(false, false, true); // no autohide, not modal, shadow // Different style of shadow for windows @@ -297,6 +308,7 @@ public class VWindow extends VOverlay implements Container, if (uidl.getBooleanAttribute("resizable") != resizable) { setResizable(!resizable); } + resizeLazy = uidl.hasAttribute(VView.RESIZE_LAZY); setDraggable(!uidl.hasAttribute("fixedposition")); } @@ -1020,6 +1032,16 @@ public class VWindow extends VOverlay implements Container, client.updateVariable(id, "height", h, immediate); } + if (updateVariables || !resizeLazy) { + // Resize has finished or is not lazy + updateContentsSize(); + } else { + // Lazy resize - wait for a while before re-rendering contents + delayedContentsSizeUpdater.trigger(); + } + } + + private void updateContentsSize() { // Update child widget dimensions if (client != null) { client.handleComponentRelativeSize((Widget) layout); diff --git a/tests/src/com/vaadin/tests/components/window/LazyWindowResize.java b/tests/src/com/vaadin/tests/components/window/LazyWindowResize.java index 072343a604..6c051f4b1e 100644 --- a/tests/src/com/vaadin/tests/components/window/LazyWindowResize.java +++ b/tests/src/com/vaadin/tests/components/window/LazyWindowResize.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.window; import com.vaadin.tests.components.AbstractTestCase; +import com.vaadin.tests.util.Log; import com.vaadin.tests.util.LoremIpsum; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; @@ -8,12 +9,29 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; import com.vaadin.ui.Window; +import com.vaadin.ui.Window.ResizeEvent; +import com.vaadin.ui.Window.ResizeListener; public class LazyWindowResize extends AbstractTestCase { private Window mainWindow; private Window subWindow; private Button lazyMode; + private Log log = new Log(5); + private CheckBox resizeListenerCheckBox; + + protected ResizeListener resizeListener = new ResizeListener() { + + public void windowResized(ResizeEvent e) { + if (e.getWindow() == mainWindow) { + log.log("Main window resized"); + } else { + log.log("Sub window resized"); + } + + } + }; + private CheckBox immediateCheckBox;;; @Override protected String getDescription() { @@ -44,7 +62,38 @@ public class LazyWindowResize extends AbstractTestCase { setLazy(lazyMode.booleanValue()); } }); + + resizeListenerCheckBox = new CheckBox("Resize listener"); + resizeListenerCheckBox.setImmediate(true); + resizeListenerCheckBox.addListener(new ClickListener() { + + public void buttonClick(ClickEvent event) { + if (resizeListenerCheckBox.booleanValue()) { + subWindow.addListener(resizeListener); + mainWindow.addListener(resizeListener); + } else { + subWindow.removeListener(resizeListener); + mainWindow.removeListener(resizeListener); + } + + } + + }); + immediateCheckBox = new CheckBox("Windows immediate"); + immediateCheckBox.setImmediate(true); + immediateCheckBox.addListener(new ClickListener() { + + public void buttonClick(ClickEvent event) { + mainWindow.setImmediate(immediateCheckBox.booleanValue()); + subWindow.setImmediate(immediateCheckBox.booleanValue()); + + } + + }); mainWindow.addComponent(lazyMode); + mainWindow.addComponent(resizeListenerCheckBox); + mainWindow.addComponent(immediateCheckBox); + mainWindow.addComponent(log); mainWindow.addComponent(new Label("<br/><br/>", Label.CONTENT_XHTML)); mainWindow.addComponent(new Label(LoremIpsum.get(10000))); |