]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #2370 : added additional client side checks for 0px size components
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 18 Dec 2008 13:19:28 +0000 (13:19 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 18 Dec 2008 13:19:28 +0000 (13:19 +0000)
svn changeset:6276/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
src/com/itmill/toolkit/terminal/gwt/client/Console.java
src/com/itmill/toolkit/terminal/gwt/client/IDebugConsole.java
src/com/itmill/toolkit/terminal/gwt/client/NullConsole.java

index e3092aa6b5a0a8f91088001814e95352c003b94a..b2572e8ad08cab3ba10f99d107cfdc2b5fed30b2 100755 (executable)
@@ -127,7 +127,13 @@ public class ApplicationConnection {
     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) {
@@ -576,6 +582,11 @@ public class ApplicationConnection {
                 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")
@@ -686,9 +697,14 @@ public class ApplicationConnection {
                 }
                 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;
+
             }
         }
 
@@ -1223,6 +1239,10 @@ public class ApplicationConnection {
                 if (horizontalScrollBar) {
                     height -= renderSpace.getScrollbarSize();
                 }
+                if (validatingLayouts && height <= 0) {
+                    zeroHeightComponents.add((Paintable) child);
+                }
+
                 height = (int) (height * relativeSize.getHeight() / 100.0);
 
                 if (height < 0) {
@@ -1278,6 +1298,10 @@ public class ApplicationConnection {
                 if (verticalScrollBar) {
                     width -= renderSpace.getScrollbarSize();
                 }
+                if (validatingLayouts && width <= 0) {
+                    zeroWidthComponents.add((Paintable) child);
+                }
+
                 width = (int) (width * relativeSize.getWidth() / 100.0);
 
                 if (width < 0) {
index 28d4b38843b27d174ec98b85ba75140a498ebfb8..b040ea2074335642c78477c4a2aa48874438f042 100644 (file)
@@ -4,6 +4,8 @@
 
 package com.itmill.toolkit.terminal.gwt.client;
 
+import java.util.Set;
+
 import com.google.gwt.json.client.JSONArray;
 
 public interface Console {
@@ -17,6 +19,8 @@ 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
index 9dbc96df6d29ab0d904d222677b4b4d4f3f9b061..b3070bef74a2b457a0f1b27fb732ebc96473c35a 100755 (executable)
@@ -5,6 +5,7 @@
 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;
@@ -348,10 +349,13 @@ public final class IDebugConsole extends IToolkitOverlay implements Console {
          }
      }-*/;
 
-    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");
@@ -361,10 +365,53 @@ public final class IDebugConsole extends IToolkitOverlay implements Console {
             }
             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();
index ab22b422168a4900acf8be27de2c2a7eb7666a8f..4813c7116a6e3e52ad544862c3f915c9fc4a22de 100644 (file)
@@ -4,6 +4,8 @@
 
 package com.itmill.toolkit.terminal.gwt.client;
 
+import java.util.Set;
+
 import com.google.gwt.json.client.JSONArray;
 
 /**
@@ -25,7 +27,10 @@ public class NullConsole implements Console {
     public void printObject(Object msg) {
     }
 
-    public void printLayoutProblems(JSONArray array, ApplicationConnection ac) {
+    public void printLayoutProblems(JSONArray array,
+            ApplicationConnection applicationConnection,
+            Set<Paintable> zeroHeightComponents,
+            Set<Paintable> zeroWidthComponents) {
     }
 
 }