************************"
+ "
Layouts analyzed on server, total top level problems: "
+ size + "
"));
if (size > 0) {
Tree tree = new Tree();
TreeItem root = new TreeItem("Root problems");
for (int i = 0; i < size; i++) {
JSONObject error = array.get(i).isObject();
printLayoutError(error, root, ac);
}
panel.add(tree);
tree.addItem(root);
}
if (zeroHeightComponents.size() > 0 || zeroWidthComponents.size() > 0) {
panel.add(new HTML("
Client side notifications
"
+ "
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."));
if (zeroHeightComponents.size() > 0) {
panel.add(new HTML(
"
Vertically zero size:
"));
printClientSideDetectedIssues(zeroHeightComponents, ac);
}
if (zeroWidthComponents.size() > 0) {
panel.add(new HTML(
"
Horizontally zero size:
"));
printClientSideDetectedIssues(zeroWidthComponents, ac);
}
}
log("************************");
}
private void printClientSideDetectedIssues(
Set 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 is 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();
final Paintable paintable = ac.getPaintable(pid);
TreeItem errorNode = new TreeItem();
VerticalPanel errorDetails = new VerticalPanel();
errorDetails.add(new Label(Util.getSimpleName(paintable) + " id: "
+ pid));
if (error.containsKey("heightMsg")) {
errorDetails.add(new Label("Height problem: "
+ error.get("heightMsg")));
}
if (error.containsKey("widthMsg")) {
errorDetails.add(new Label("Width problem: "
+ error.get("widthMsg")));
}
final CheckBox emphasisInUi = new CheckBox("Emphasis component in UI");
emphasisInUi.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
if (paintable != null) {
Element element2 = ((Widget) paintable).getElement();
Widget.setStyleName(element2, "invalidlayout", emphasisInUi
.isChecked());
}
}
});
errorDetails.add(emphasisInUi);
errorNode.setWidget(errorDetails);
if (error.containsKey("subErrors")) {
HTML l = new HTML(
"Expand this node to show problems that may be dependent on this problem.");
errorDetails.add(l);
JSONArray array = error.get("subErrors").isArray();
for (int i = 0; i < array.size(); i++) {
JSONValue value = array.get(i);
if (value != null && value.isObject() != null) {
printLayoutError(value.isObject(), errorNode, ac);
} else {
System.out.print(value);
}
}
}
parent.addItem(errorNode);
}
}