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;
private boolean draggable = true;
+ private boolean resizeLazy = false;
+
private Element modalityCurtain;
private Element draggingCurtain;
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
if (uidl.getBooleanAttribute("resizable") != resizable) {
setResizable(!resizable);
}
+ resizeLazy = uidl.hasAttribute(VView.RESIZE_LAZY);
setDraggable(!uidl.hasAttribute("fixedposition"));
}
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);
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;
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() {
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)));