|
|
@@ -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; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -2074,17 +1900,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. |
|
|
|
* |