/** redirectTimer scheduling interval in seconds */
private int sessionExpirationInterval;
- private ArrayList<Widget> relativeSizeChanges = new ArrayList<Widget>();;
- private ArrayList<Widget> captionSizeChanges = new ArrayList<Widget>();
+ private ArrayList<Paintable> relativeSizeChanges = new ArrayList<Paintable>();;
+ private ArrayList<Paintable> componentCaptionSizeChanges = new ArrayList<Paintable>();;
private Date requestStartTime;;
final JSONArray changes = (JSONArray) ((JSONObject) json)
.get("changes");
- Vector<Widget> updatedWidgets = new Vector<Widget>();
+ Vector<Paintable> updatedWidgets = new Vector<Paintable>();
relativeSizeChanges.clear();
- captionSizeChanges.clear();
+ componentCaptionSizeChanges.clear();
for (int i = 0; i < changes.size(); i++) {
try {
paintable.updateFromUIDL(uidl, this);
// paintable may have changed during render to another
// implementation, use the new one for updated widgets map
- updatedWidgets
- .add((Widget) idToPaintable.get(uidl.getId()));
+ updatedWidgets.add(idToPaintable.get(uidl.getId()));
} else {
if (!uidl.getTag().equals("window")) {
ClientExceptionHandler
}
// Check which widgets' size has been updated
- Set<Widget> sizeUpdatedWidgets = new HashSet<Widget>();
+ Set<Paintable> sizeUpdatedWidgets = new HashSet<Paintable>();
updatedWidgets.addAll(relativeSizeChanges);
- sizeUpdatedWidgets.addAll(captionSizeChanges);
+ sizeUpdatedWidgets.addAll(componentCaptionSizeChanges);
- for (Widget widget : updatedWidgets) {
+ for (Paintable paintable : updatedWidgets) {
+ Widget widget = (Widget) paintable;
Size oldSize = componentOffsetSizes.get(widget);
Size newSize = new Size(widget.getOffsetWidth(), widget
.getOffsetHeight());
if (oldSize == null || !oldSize.equals(newSize)) {
- sizeUpdatedWidgets.add(widget);
+ sizeUpdatedWidgets.add(paintable);
componentOffsetSizes.put(widget, newSize);
}
if (componentRelativeSizes.put(component, relativeSize) == null
&& componentOffsetSizes.containsKey(component)) {
// The component has changed from absolute size to relative size
- relativeSizeChanges.add(component);
+ relativeSizeChanges.add((Paintable) component);
}
} else if (relativeHeight < 0.0 && relativeWidth < 0.0) {
if (componentRelativeSizes.remove(component) != null) {
// The component has changed from relative size to absolute size
- relativeSizeChanges.add(component);
+ relativeSizeChanges.add((Paintable) component);
}
}
* development. Published to JavaScript.
*/
public void forceLayout() {
- Util.componentSizeUpdated((Set) paintableToId.keySet());
+ Util.componentSizeUpdated(paintableToId.keySet());
}
private void internalRunDescendentsLayout(HasWidgets container) {
* @return true if the child has a relative size
*/
public boolean handleComponentRelativeSize(Widget child) {
+ final boolean debugSizes = false;
+
Widget widget = child;
FloatSize relativeSize = getRelativeSize(child);
if (relativeSize == null) {
} else {
renderSpace = parent.getAllocatedSpace(widget);
}
+
if (relativeSize.getHeight() >= 0) {
if (renderSpace != null) {
height = 0;
}
- // getConsole().log(
- // "Widget " + Util.getSimpleName(widget) + "/"
- // + widget.hashCode() + " relative height "
- // + relativeSize.getHeight() + "% of "
- // + renderSpace.getHeight() + "px (reported by "
- //
- // + Util.getSimpleName(parent) + "/"
- // + parent.hashCode() + ") : " + height + "px");
+ if (debugSizes) {
+ getConsole()
+ .log(
+ "Widget "
+ + Util.getSimpleName(widget)
+ + "/"
+ + widget.hashCode()
+ + " relative height "
+ + relativeSize.getHeight()
+ + "% of "
+ + renderSpace.getHeight()
+ + "px (reported by "
+
+ + Util.getSimpleName(parent)
+ + "/"
+ + (parent == null ? "?" : parent
+ .hashCode()) + ") : "
+ + height + "px");
+ }
widget.setHeight(height + "px");
} else {
widget.setHeight(relativeSize.getHeight() + "%");
width = 0;
}
- // getConsole().log(
- // "Widget " + Util.getSimpleName(widget) + "/"
- // + widget.hashCode() + " relative width "
- // + relativeSize.getWidth() + "% of "
- // + renderSpace.getWidth() + "px (reported by "
- // + Util.getSimpleName(parent) + "/"
- // + parent.hashCode() + ") : " + width + "px");
+ if (debugSizes) {
+ getConsole()
+ .log(
+ "Widget "
+ + Util.getSimpleName(widget)
+ + "/"
+ + widget.hashCode()
+ + " relative width "
+ + relativeSize.getWidth()
+ + "% of "
+ + renderSpace.getWidth()
+ + "px (reported by "
+ + Util.getSimpleName(parent)
+ + "/"
+ + (parent == null ? "?" : parent
+ .hashCode()) + ") : "
+ + width + "px");
+ }
widget.setWidth(width + "px");
} else {
widget.setWidth(relativeSize.getWidth() + "%");
windowName = newName;
}
- public void captionSizeUpdated(Widget component) {
- captionSizeChanges.add(component);
+ public void captionSizeUpdated(Paintable component) {
+ componentCaptionSizeChanges.add(component);
}
public void analyzeLayouts() {
}-*/;
private static final int LAZY_SIZE_CHANGE_TIMEOUT = 400;
- private static Set<Widget> latelyChangedWidgets = new HashSet<Widget>();
+ private static Set<Paintable> latelyChangedWidgets = new HashSet<Paintable>();
private static Timer lazySizeChangeTimer = new Timer() {
private boolean lazySizeChangeTimerScheduled = false;
* @param lazy
* run componentSizeUpdated lazyly
*/
- public static void notifyParentOfSizeChange(Widget widget, boolean lazy) {
+ public static void notifyParentOfSizeChange(Paintable widget, boolean lazy) {
if (!(widget instanceof Paintable)) {
ApplicationConnection.getConsole().log(
"Notified widget must be paintable not "
latelyChangedWidgets.add(widget);
lazySizeChangeTimer.schedule(LAZY_SIZE_CHANGE_TIMEOUT);
} else {
- Set<Widget> widgets = new HashSet<Widget>();
+ Set<Paintable> widgets = new HashSet<Paintable>();
widgets.add(widget);
Util.componentSizeUpdated(widgets);
}
*
* @param widgets
*/
- public static void componentSizeUpdated(Set<Widget> widgets) {
+ public static void componentSizeUpdated(Set<Paintable> widgets) {
if (widgets.isEmpty()) {
return;
}
Map<Container, Set<Paintable>> childWidgets = new HashMap<Container, Set<Paintable>>();
- for (Widget widget : widgets) {
+ for (Paintable widget : widgets) {
ApplicationConnection.getConsole().log(
"Widget " + Util.getSimpleName(widget) + " size updated");
-
- Widget parent = widget.getParent();
+ Widget parent = ((Widget) widget).getParent();
while (parent != null && !(parent instanceof Container)) {
parent = parent.getParent();
}
set = new HashSet<Paintable>();
childWidgets.put((Container) parent, set);
}
- set.add((Paintable) widget);
+ set.add(widget);
}
}
- Set<Widget> parentChanges = new HashSet<Widget>();
+ Set<Paintable> parentChanges = new HashSet<Paintable>();
for (Container parent : childWidgets.keySet()) {
if (!parent.requestLayout(childWidgets.get(parent))) {
- parentChanges.add((Widget) parent);
+ parentChanges.add(parent);
}
}
public static void updateRelativeChildrenAndSendSizeUpdateEvent(
ApplicationConnection client, HasWidgets container) {
updateRelativeChildrenAndSendSizeUpdateEvent(client, container,
- (Widget) container);
+ (Paintable) container);
}
public static void updateRelativeChildrenAndSendSizeUpdateEvent(
- ApplicationConnection client, HasWidgets container, Widget widget) {
+ ApplicationConnection client, HasWidgets container, Paintable widget) {
/*
* Relative sized children must be updated first so the component has
* the correct outer dimensions when signaling a size change to the
client.handleComponentRelativeSize(w);
}
- HashSet<Widget> widgets = new HashSet<Widget>();
+ HashSet<Paintable> widgets = new HashSet<Paintable>();
widgets.add(widget);
Util.componentSizeUpdated(widgets);
}