aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/terminal/gwt
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-01-30 08:58:36 +0200
committerLeif Åstrand <leif@vaadin.com>2012-01-30 08:59:32 +0200
commitc34f2b73a7760dad603c977aa80c63f6a1e7c39a (patch)
tree9da157d9751e12aadbea66a0b496e75f06a79195 /src/com/vaadin/terminal/gwt
parent09b65b226147bb7d0d6eb4d99305288591c18d69 (diff)
downloadvaadin-framework-c34f2b73a7760dad603c977aa80c63f6a1e7c39a.tar.gz
vaadin-framework-c34f2b73a7760dad603c977aa80c63f6a1e7c39a.zip
Initial removal of %-conversions, many components need fixes (#8312)
Diffstat (limited to 'src/com/vaadin/terminal/gwt')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ApplicationConnection.java193
-rw-r--r--src/com/vaadin/terminal/gwt/client/ComponentDetail.java15
-rw-r--r--src/com/vaadin/terminal/gwt/client/VPaintableMap.java25
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java74
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java15
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java3
6 files changed, 10 insertions, 315 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index e659a18477..4252ab0aa6 100644
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -29,13 +29,11 @@ import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
-import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.Focusable;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConfiguration.ErrorMessage;
-import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize;
import com.vaadin.terminal.gwt.client.RenderInformation.Size;
import com.vaadin.terminal.gwt.client.ui.Field;
import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
@@ -160,7 +158,6 @@ public class ApplicationConnection {
/** redirectTimer scheduling interval in seconds */
private int sessionExpirationInterval;
- private ArrayList<VPaintableWidget> relativeSizeChanges = new ArrayList<VPaintableWidget>();
private ArrayList<Widget> componentCaptionSizeChanges = new ArrayList<Widget>();
private Date requestStartTime;
@@ -1001,7 +998,6 @@ public class ApplicationConnection {
JsArray<ValueMap> changes = json.getJSValueMapArray("changes");
ArrayList<VPaintableWidget> updatedVPaintableWidgets = new ArrayList<VPaintableWidget>();
- relativeSizeChanges.clear();
componentCaptionSizeChanges.clear();
int length = changes.length();
@@ -1052,7 +1048,6 @@ public class ApplicationConnection {
// Check which widgets' size has been updated
Set<Widget> sizeUpdatedWidgets = new HashSet<Widget>();
- updatedVPaintableWidgets.addAll(relativeSizeChanges);
sizeUpdatedWidgets.addAll(componentCaptionSizeChanges);
for (VPaintableWidget paintable : updatedVPaintableWidgets) {
@@ -1809,44 +1804,11 @@ public class ApplicationConnection {
String h = uidl.hasAttribute("height") ? uidl
.getStringAttribute("height") : "";
- float relativeWidth = Util.parseRelativeSize(w);
- float relativeHeight = Util.parseRelativeSize(h);
-
- // First update maps so they are correct in the setHeight/setWidth calls
- if (relativeHeight >= 0.0 || relativeWidth >= 0.0) {
- // One or both is relative
- FloatSize relativeSize = new FloatSize(relativeWidth,
- relativeHeight);
-
- if (paintableMap.getRelativeSize(paintable) == null
- && paintableMap.getOffsetSize(paintable) != null) {
- // The component has changed from absolute size to relative size
- relativeSizeChanges.add(paintable);
- }
- paintableMap.setRelativeSize(paintable, relativeSize);
- } else if (relativeHeight < 0.0 && relativeWidth < 0.0) {
- if (paintableMap.getRelativeSize(paintable) != null) {
- // The component has changed from relative size to absolute size
- relativeSizeChanges.add(paintable);
- }
- paintableMap.setRelativeSize(paintable, null);
- }
-
Widget component = paintableMap.getWidget(paintable);
- // Set absolute sizes
- if (relativeHeight < 0.0) {
- component.setHeight(h);
- }
- if (relativeWidth < 0.0) {
- component.setWidth(w);
- }
-
- // Set relative sizes
- if (relativeHeight >= 0.0 || relativeWidth >= 0.0) {
- // One or both is relative
- handleComponentRelativeSize(paintable);
- }
+ // Set defined sizes
+ component.setHeight(h);
+ component.setWidth(w);
}
/**
@@ -1924,143 +1886,7 @@ public class ApplicationConnection {
* @return true if the child has a relative size
*/
private boolean handleComponentRelativeSize(VPaintableWidget paintable) {
- if (paintable == null) {
- return false;
- }
- boolean debugSizes = true;
-
- FloatSize relativeSize = paintableMap.getRelativeSize(paintable);
- if (relativeSize == null) {
- return false;
- }
- Widget widget = paintableMap.getWidget(paintable);
-
- boolean horizontalScrollBar = false;
- boolean verticalScrollBar = false;
-
- Container parentPaintable = Util.getLayout(widget);
- RenderSpace renderSpace;
-
- // Parent-less components (like sub-windows) are relative to browser
- // window.
- if (parentPaintable == null) {
- renderSpace = new RenderSpace(Window.getClientWidth(),
- Window.getClientHeight());
- } else {
- renderSpace = parentPaintable.getAllocatedSpace(widget);
- }
-
- if (relativeSize.getHeight() >= 0) {
- if (renderSpace != null) {
-
- if (renderSpace.getScrollbarSize() > 0) {
- if (relativeSize.getWidth() > 100) {
- horizontalScrollBar = true;
- } else if (relativeSize.getWidth() < 0
- && renderSpace.getWidth() > 0) {
- int offsetWidth = widget.getOffsetWidth();
- int width = renderSpace.getWidth();
- if (offsetWidth > width) {
- horizontalScrollBar = true;
- }
- }
- }
-
- int height = renderSpace.getHeight();
- if (horizontalScrollBar) {
- height -= renderSpace.getScrollbarSize();
- }
- if (validatingLayouts && height <= 0) {
- zeroHeightComponents.add(paintable);
- }
-
- height = (int) (height * relativeSize.getHeight() / 100.0);
-
- if (height < 0) {
- height = 0;
- }
-
- if (debugSizes) {
- VConsole.log("Widget "
- + Util.getSimpleName(widget)
- + "/"
- + paintableMap.getPid(paintable)
- + " relative height "
- + relativeSize.getHeight()
- + "% of "
- + renderSpace.getHeight()
- + "px (reported by "
-
- + Util.getSimpleName(parentPaintable)
- + "/"
- + (parentPaintable == null ? "?" : parentPaintable
- .hashCode()) + ") : " + height + "px");
- }
- widget.setHeight(height + "px");
- } else {
- widget.setHeight(relativeSize.getHeight() + "%");
- VConsole.error(Util.getLayout(widget).getClass().getName()
- + " did not produce allocatedSpace for "
- + widget.getClass().getName());
- }
- }
-
- if (relativeSize.getWidth() >= 0) {
-
- if (renderSpace != null) {
-
- int width = renderSpace.getWidth();
-
- if (renderSpace.getScrollbarSize() > 0) {
- if (relativeSize.getHeight() > 100) {
- verticalScrollBar = true;
- } else if (relativeSize.getHeight() < 0
- && renderSpace.getHeight() > 0
- && widget.getOffsetHeight() > renderSpace
- .getHeight()) {
- verticalScrollBar = true;
- }
- }
-
- if (verticalScrollBar) {
- width -= renderSpace.getScrollbarSize();
- }
- if (validatingLayouts && width <= 0) {
- zeroWidthComponents.add(paintable);
- }
-
- width = (int) (width * relativeSize.getWidth() / 100.0);
-
- if (width < 0) {
- width = 0;
- }
-
- if (debugSizes) {
- VConsole.log("Widget "
- + Util.getSimpleName(widget)
- + "/"
- + paintableMap.getPid(paintable)
- + " relative width "
- + relativeSize.getWidth()
- + "% of "
- + renderSpace.getWidth()
- + "px (reported by "
- + Util.getSimpleName(parentPaintable)
- + "/"
- + (parentPaintable == null ? "?" : paintableMap
- .getPid(parentPaintable)) + ") : " + width
- + "px");
- }
- widget.setWidth(width + "px");
- } else {
- widget.setWidth(relativeSize.getWidth() + "%");
- VConsole.error(Util.getLayout(widget).getClass().getName()
- + " did not produce allocatedSpace for "
- + widget.getClass().getName());
- }
- }
-
- return true;
+ return false;
}
/**
@@ -2075,17 +1901,6 @@ public class ApplicationConnection {
}
/**
- * Gets the specified Paintables relative size (percent).
- *
- * @param widget
- * the paintable whose size is needed
- * @return the the size if the paintable is relatively sized, -1 otherwise
- */
- public FloatSize getRelativeSize(Widget widget) {
- return paintableMap.getRelativeSize(paintableMap.getPaintable(widget));
- }
-
- /**
* Get either existing or new Paintable for given UIDL.
*
* If corresponding Paintable has been previously painted, return it.
diff --git a/src/com/vaadin/terminal/gwt/client/ComponentDetail.java b/src/com/vaadin/terminal/gwt/client/ComponentDetail.java
index 8e4e13aa1c..04e990ddea 100644
--- a/src/com/vaadin/terminal/gwt/client/ComponentDetail.java
+++ b/src/com/vaadin/terminal/gwt/client/ComponentDetail.java
@@ -6,7 +6,6 @@ package com.vaadin.terminal.gwt.client;
import java.util.HashMap;
import com.google.gwt.core.client.JsArrayString;
-import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize;
import com.vaadin.terminal.gwt.client.RenderInformation.Size;
class ComponentDetail {
@@ -44,24 +43,10 @@ class ComponentDetail {
this.tooltipInfo = tooltipInfo;
}
- private FloatSize relativeSize;
private Size offsetSize;
private HashMap<Object, TooltipInfo> additionalTooltips;
/**
- * @return the relativeSize
- */
- FloatSize getRelativeSize() {
- return relativeSize;
- }
-
- /**
- * @param relativeSize
- * the relativeSize to set
- */
- void setRelativeSize(FloatSize relativeSize) {
- this.relativeSize = relativeSize;
- }
/**
* @return the offsetSize
diff --git a/src/com/vaadin/terminal/gwt/client/VPaintableMap.java b/src/com/vaadin/terminal/gwt/client/VPaintableMap.java
index f21d85558c..c810d56e51 100644
--- a/src/com/vaadin/terminal/gwt/client/VPaintableMap.java
+++ b/src/com/vaadin/terminal/gwt/client/VPaintableMap.java
@@ -16,7 +16,6 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.Paintable;
-import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize;
import com.vaadin.terminal.gwt.client.RenderInformation.Size;
public class VPaintableMap {
@@ -307,34 +306,10 @@ public class VPaintableMap {
* @return
*/
@Deprecated
- public FloatSize getRelativeSize(VPaintableWidget paintable) {
- return getComponentDetail(paintable).getRelativeSize();
- }
-
- /**
- * FIXME: Should not be here
- *
- * @param paintable
- * @return
- */
- @Deprecated
public void setOffsetSize(VPaintableWidget paintable, Size newSize) {
getComponentDetail(paintable).setOffsetSize(newSize);
}
- /**
- * FIXME: Should not be here
- *
- * @param paintable
- * @return
- */
- @Deprecated
- public void setRelativeSize(VPaintableWidget paintable,
- FloatSize relativeSize) {
- getComponentDetail(paintable).setRelativeSize(relativeSize);
-
- }
-
private ComponentDetail getComponentDetail(VPaintableWidget paintable) {
return idToComponentDetail.get(getPid(paintable));
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java
index 787be254f6..40b6acd28a 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java
@@ -520,8 +520,6 @@ public class VCustomLayout extends ComplexPanel implements VPaintableWidget,
}-*/;
public boolean requestLayout(Set<Widget> children) {
- updateRelativeSizedComponents(true, true);
-
if (width.equals("") || height.equals("")) {
/* Automatically propagated upwards if the size can change */
return false;
@@ -549,78 +547,6 @@ public class VCustomLayout extends ComplexPanel implements VPaintableWidget,
}
}
- @Override
- public void setHeight(String height) {
- if (this.height.equals(height)) {
- return;
- }
-
- boolean shrinking = true;
- if (isLarger(height, this.height)) {
- shrinking = false;
- }
-
- this.height = height;
- super.setHeight(height);
-
- /*
- * If the height shrinks we must remove all components with relative
- * height from the DOM, update their height when they do not affect the
- * available space and finally restore them to the original state
- */
- if (shrinking) {
- updateRelativeSizedComponents(false, true);
- }
- }
-
- @Override
- public void setWidth(String width) {
- if (this.width.equals(width)) {
- return;
- }
-
- boolean shrinking = true;
- if (isLarger(width, this.width)) {
- shrinking = false;
- }
-
- super.setWidth(width);
- this.width = width;
-
- /*
- * If the width shrinks we must remove all components with relative
- * width from the DOM, update their width when they do not affect the
- * available space and finally restore them to the original state
- */
- if (shrinking) {
- updateRelativeSizedComponents(true, false);
- }
- }
-
- private void updateRelativeSizedComponents(boolean relativeWidth,
- boolean relativeHeight) {
-
- Set<Widget> relativeSizeWidgets = new HashSet<Widget>();
-
- for (Widget widget : locationToWidget.values()) {
- FloatSize relativeSize = client.getRelativeSize(widget);
- if (relativeSize != null) {
- if ((relativeWidth && (relativeSize.getWidth() >= 0.0f))
- || (relativeHeight && (relativeSize.getHeight() >= 0.0f))) {
-
- relativeSizeWidgets.add(widget);
- widget.getElement().getStyle()
- .setProperty("position", "absolute");
- }
- }
- }
-
- for (Widget widget : relativeSizeWidgets) {
- client.handleComponentRelativeSize(widget);
- widget.getElement().getStyle().setProperty("position", "");
- }
- }
-
/**
* Compares newSize with currentSize and returns true if it is clear that
* newSize is larger than currentSize. Returns false if newSize is smaller
diff --git a/src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java b/src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java
index 8828582b57..357711d2f4 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java
@@ -4,6 +4,7 @@
package com.vaadin.terminal.gwt.client.ui.label;
+import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HTML;
import com.vaadin.terminal.gwt.client.BrowserInfo;
@@ -15,9 +16,6 @@ public class VLabel extends HTML {
public static final String CLASSNAME = "v-label";
private static final String CLASSNAME_UNDEFINED_WIDTH = "v-label-undef-w";
- private int verticalPaddingBorder = 0;
- private int horizontalPaddingBorder = 0;
-
public VLabel() {
super();
setStyleName(CLASSNAME);
@@ -41,19 +39,14 @@ public class VLabel extends HTML {
}
@Override
- public void setHeight(String height) {
- verticalPaddingBorder = Util.setHeightExcludingPaddingAndBorder(this,
- height, verticalPaddingBorder);
- }
-
- @Override
public void setWidth(String width) {
- horizontalPaddingBorder = Util.setWidthExcludingPaddingAndBorder(this,
- width, horizontalPaddingBorder);
+ super.setWidth(width);
if (width == null || width.equals("")) {
setStyleName(getElement(), CLASSNAME_UNDEFINED_WIDTH, true);
+ getElement().getStyle().setDisplay(Display.INLINE_BLOCK);
} else {
setStyleName(getElement(), CLASSNAME_UNDEFINED_WIDTH, false);
+ getElement().getStyle().clearDisplay();
}
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java b/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java
index 92464cd459..b263f8b5d4 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java
@@ -9,6 +9,7 @@ import java.util.NoSuchElementException;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
@@ -79,7 +80,6 @@ public class ChildComponentContainer extends Panel {
widgetDIV = Document.get().createDivElement();
- setFloat(widgetDIV, "left");
setElement(containerDIV);
containerDIV.getStyle().setProperty("height", "0");
containerDIV.getStyle().setProperty("width", "0px");
@@ -131,6 +131,7 @@ public class ChildComponentContainer extends Panel {
// Physical attach.
widgetDIV.appendChild(widget.getElement());
adopt(w);
+ w.getElement().getStyle().setDisplay(Display.INLINE_BLOCK);
}
}