summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-02-13 19:31:17 +0200
committerLeif Åstrand <leif@vaadin.com>2012-02-13 19:31:17 +0200
commit4bba7b05bb57bc0783a2d72b98a9fcfce681d35a (patch)
tree7b09ef95886d98e6eb3dcfbe8a93bf4181711954
parenta24fcb25eff21920d3e2785d7bad040e7f9a2bc4 (diff)
downloadvaadin-framework-4bba7b05bb57bc0783a2d72b98a9fcfce681d35a.tar.gz
vaadin-framework-4bba7b05bb57bc0783a2d72b98a9fcfce681d35a.zip
Update Window to work with MeasureManager (#8313)
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindow.java51
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java19
2 files changed, 22 insertions, 48 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
index d4c8f74605..ff1608cb71 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
@@ -7,7 +7,6 @@ package com.vaadin.terminal.gwt.client.ui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
-import java.util.Set;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
@@ -30,10 +29,8 @@ import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.Console;
-import com.vaadin.terminal.gwt.client.Container;
import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.Focusable;
-import com.vaadin.terminal.gwt.client.RenderSpace;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
@@ -43,9 +40,8 @@ import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHan
*
* @author Vaadin Ltd
*/
-public class VWindow extends VOverlay implements Container,
- ShortcutActionHandlerOwner, ScrollHandler, KeyDownHandler,
- FocusHandler, BlurHandler, Focusable {
+public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
+ ScrollHandler, KeyDownHandler, FocusHandler, BlurHandler, Focusable {
/**
* Minimum allowed height of a window. This refers to the content area, not
@@ -150,9 +146,6 @@ public class VWindow extends VOverlay implements Container,
// resizes the window.
boolean centered = false;
- private RenderSpace renderSpace = new RenderSpace(MIN_CONTENT_AREA_WIDTH,
- MIN_CONTENT_AREA_HEIGHT, true);
-
private String width;
private String height;
@@ -804,8 +797,6 @@ public class VWindow extends VOverlay implements Container,
DOM.setStyleAttribute(getElement(), "width", rootWidth + "px");
}
- renderSpace.setWidth(contentAreaInnerWidth);
-
updateShadowSizeAndPosition();
}
}
@@ -830,10 +821,6 @@ public class VWindow extends VOverlay implements Container,
if (height == null || "".equals(height)) {
getElement().getStyle().clearHeight();
contentPanel.getElement().getStyle().clearHeight();
- // Reset to default, the exact value does not actually
- // matter as an undefined-height parent should not have
- // a relative-height child anyway.
- renderSpace.setHeight(MIN_CONTENT_AREA_HEIGHT);
} else {
getElement().getStyle().setProperty("height", height);
int contentHeight = getElement().getOffsetHeight()
@@ -844,7 +831,6 @@ public class VWindow extends VOverlay implements Container,
getElement().getStyle()
.setProperty("height", rootHeight + "px");
}
- renderSpace.setHeight(contentHeight);
contentPanel.getElement().getStyle()
.setProperty("height", contentHeight + "px");
}
@@ -852,11 +838,8 @@ public class VWindow extends VOverlay implements Container,
updateShadowSizeAndPosition();
}
- private int extraH = 0;
-
int getExtraHeight() {
- extraH = header.getOffsetHeight() + footer.getOffsetHeight();
- return extraH;
+ return header.getOffsetHeight() + footer.getOffsetHeight();
}
private void onDragEvent(Event event) {
@@ -974,38 +957,12 @@ public class VWindow extends VOverlay implements Container,
setHeight(height);
}
- public RenderSpace getAllocatedSpace(Widget child) {
- if (child == layout.getWidgetForPaintable()) {
- return renderSpace;
- } else {
- // Exception ??
- return null;
- }
- }
-
- public boolean hasChildComponent(Widget component) {
- if (component == layout.getWidgetForPaintable()) {
- return true;
- } else {
- return false;
- }
- }
-
- public void replaceChildComponent(Widget oldComponent, Widget newComponent) {
- contentPanel.setWidget(newComponent);
- }
-
- public boolean requestLayout(Set<Widget> children) {
+ void requestLayout() {
if (dynamicWidth && !layoutRelativeWidth) {
setNaturalWidth();
}
- if (centered) {
- center();
- }
- updateShadowSizeAndPosition();
// layout size change may affect its available space (scrollbars)
client.handleComponentRelativeSize(layout.getWidgetForPaintable());
- return true;
}
public ShortcutActionHandler getShortcutActionHandler() {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java
index e77aefc25b..a79379746c 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java
@@ -19,7 +19,8 @@ import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener;
public class VWindowPaintable extends VAbstractPaintableWidgetContainer
- implements BeforeShortcutActionListener {
+ implements BeforeShortcutActionListener, ResizeRequired,
+ LayoutPhaseListener {
private static final String CLICK_EVENT_IDENTIFIER = VPanelPaintable.CLICK_EVENT_IDENTIFIER;
@@ -303,4 +304,20 @@ public class VWindowPaintable extends VAbstractPaintableWidgetContainer
return GWT.create(VWindow.class);
}
+ public void onResize() {
+ getWidgetForPaintable().requestLayout();
+ }
+
+ public void beforeLayout() {
+
+ }
+
+ public void afterLayout() {
+ VWindow window = getWidgetForPaintable();
+ if (window.centered) {
+ window.center();
+ window.updateShadowSizeAndPosition();
+ }
+ }
+
}