private ArrayList<Paintable> relativeSizeChanges = new ArrayList<Paintable>();;
private ArrayList<Paintable> componentCaptionSizeChanges = new ArrayList<Paintable>();;
- private Date requestStartTime;;
+ private Date requestStartTime;
+
+ private boolean validatingLayouts = false;
+
+ private Set<Paintable> zeroWidthComponents = null;
+
+ private Set<Paintable> zeroHeightComponents = null;
public ApplicationConnection(WidgetSet widgetSet,
ApplicationConfiguration cnf) {
view.clear();
idToPaintable.clear();
paintableToId.clear();
+ if (meta.containsKey("invalidLayouts")) {
+ validatingLayouts = true;
+ zeroWidthComponents = new HashSet<Paintable>();
+ zeroHeightComponents = new HashSet<Paintable>();
+ }
}
if (meta.containsKey("timedRedirect")) {
final JSONObject timedRedirect = meta.get("timedRedirect")
}
applicationRunning = false;
}
- if (meta.containsKey("invalidLayouts")) {
+ if (validatingLayouts) {
getConsole().printLayoutProblems(
- meta.get("invalidLayouts").isArray(), this);
+ meta.get("invalidLayouts").isArray(), this,
+ zeroHeightComponents, zeroWidthComponents);
+ zeroHeightComponents = null;
+ zeroWidthComponents = null;
+ validatingLayouts = false;
+
}
}
if (horizontalScrollBar) {
height -= renderSpace.getScrollbarSize();
}
+ if (validatingLayouts && height <= 0) {
+ zeroHeightComponents.add((Paintable) child);
+ }
+
height = (int) (height * relativeSize.getHeight() / 100.0);
if (height < 0) {
if (verticalScrollBar) {
width -= renderSpace.getScrollbarSize();
}
+ if (validatingLayouts && width <= 0) {
+ zeroWidthComponents.add((Paintable) child);
+ }
+
width = (int) (width * relativeSize.getWidth() / 100.0);
if (width < 0) {
package com.itmill.toolkit.terminal.gwt.client;
+import java.util.Set;
+
import com.google.gwt.json.client.JSONArray;
public interface Console {
public abstract void dirUIDL(UIDL u);
public abstract void printLayoutProblems(JSONArray array,
- ApplicationConnection applicationConnection);
+ ApplicationConnection applicationConnection,
+ Set<Paintable> zeroHeightComponents,
+ Set<Paintable> zeroWidthComponents);
}
\ No newline at end of file
package com.itmill.toolkit.terminal.gwt.client;
import java.util.List;
+import java.util.Set;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
}
}-*/;
- public void printLayoutProblems(JSONArray array, ApplicationConnection ac) {
- log("************************");
+ public void printLayoutProblems(JSONArray array, ApplicationConnection ac,
+ Set<Paintable> zeroHeightComponents,
+ Set<Paintable> zeroWidthComponents) {
int size = array.size();
- log("Layouts analyzed, total top level errors: " + size);
+ panel.add(new HTML("<div>************************</di>"
+ + "<h4>Layouts analyzed on server, total top level errors: "
+ + size + " </h4>"));
if (size > 0) {
Tree tree = new Tree();
TreeItem root = new TreeItem("Root errors");
}
panel.add(tree);
tree.addItem(root);
+
+ if (zeroHeightComponents.size() > 0
+ || zeroWidthComponents.size() > 0) {
+ panel.add(new HTML("<h4> Client side notifications</h4>"
+ + " <em>Following relative sized components where "
+ + "rendered to zero size container on client side."
+ + " Note that these are not necessary invalid "
+ + "states. Just reported here as they might be.</em>"));
+ if (zeroHeightComponents.size() > 0) {
+ panel.add(new HTML(
+ "<p><strong>Vertically zero size:</strong><p>"));
+ printClientSideDetectedIssues(zeroHeightComponents, ac);
+ }
+ if (zeroWidthComponents.size() > 0) {
+ panel.add(new HTML(
+ "<p><strong>Horizontally zero size:</strong><p>"));
+ printClientSideDetectedIssues(zeroWidthComponents, ac);
+ }
+ }
}
log("************************");
}
+ private void printClientSideDetectedIssues(
+ Set<Paintable> zeroHeightComponents, ApplicationConnection ac) {
+ for (final Paintable paintable : zeroHeightComponents) {
+ final Container layout = Util.getLayout((Widget) paintable);
+
+ VerticalPanel errorDetails = new VerticalPanel();
+ errorDetails.add(new Label("" + Util.getSimpleName(paintable)
+ + " inside " + Util.getSimpleName(layout)));
+ final CheckBox emphasisInUi = new CheckBox(
+ "Emphasis components parent in UI (actual component not visible)");
+ emphasisInUi.addClickListener(new ClickListener() {
+ public void onClick(Widget sender) {
+ if (paintable != null) {
+ Element element2 = ((Widget) layout).getElement();
+ Widget.setStyleName(element2, "invalidlayout",
+ emphasisInUi.isChecked());
+ }
+ }
+ });
+ errorDetails.add(emphasisInUi);
+ panel.add(errorDetails);
+ }
+ }
+
private void printLayoutError(JSONObject error, TreeItem parent,
final ApplicationConnection ac) {
final String pid = error.get("id").isString().stringValue();