]> source.dussan.org Git - vaadin-framework.git/commitdiff
New IOrderedLayout implementation (without sizing abilities).
authorJouni Koivuviita <jouni.koivuviita@itmill.com>
Thu, 13 Dec 2007 13:45:11 +0000 (13:45 +0000)
committerJouni Koivuviita <jouni.koivuviita@itmill.com>
Thu, 13 Dec 2007 13:45:11 +0000 (13:45 +0000)
svn changeset:3232/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/DefaultWidgetSetNoEntry.gwt.xml
src/com/itmill/toolkit/terminal/gwt/client/StyleConstants.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
src/com/itmill/toolkit/terminal/gwt/public/default/common/common.css
src/com/itmill/toolkit/terminal/gwt/public/default/expandlayout/expandlayout.css
src/com/itmill/toolkit/terminal/gwt/public/default/orderedlayout/orderedlayout.css [new file with mode: 0644]
src/com/itmill/toolkit/ui/Button.java

index 38a39f2eb9025e64b3f38f37dda2dbe5bece9702..29c26697706ea9eb015d65262c0a855b5f6a38f5 100644 (file)
@@ -40,5 +40,6 @@
        <stylesheet src="default/select/filterselect.css"/>
        <stylesheet src="default/progressindicator/progressindicator.css"/>
        <stylesheet src="default/expandlayout/expandlayout.css"/>
+       <stylesheet src="default/orderedlayout/orderedlayout.css"/>
 
 </module>
index 35f1b5818ff8cc9ae569c8c2c393ebae48cb4a84..b4d5499172bc7bdd8f3c4e234c5b627562d1c367 100644 (file)
@@ -6,9 +6,12 @@ package com.itmill.toolkit.terminal.gwt.client;
 
 public class StyleConstants {
 
-    public static final String LAYOUT_MARGIN_TOP = "i-layoutmargin-top";
-    public static final String LAYOUT_MARGIN_RIGHT = "i-layoutmargin-right";
-    public static final String LAYOUT_MARGIN_BOTTOM = "i-layoutmargin-bottom";
-    public static final String LAYOUT_MARGIN_LEFT = "i-layoutmargin-left";
+    public static final String MARGIN_TOP = "margin-top";
+    public static final String MARGIN_RIGHT = "margin-right";
+    public static final String MARGIN_BOTTOM = "margin-bottom";
+    public static final String MARGIN_LEFT = "margin-left";
+    
+    public static final String VERTICAL_SPACING = "vspacing";
+    public static final String HORIZONTAL_SPACING = "hspacing";
 
 }
index d50c3cf351f6b568d5c74285eae1a1ac919bfe63..6f9290c7bc3c5cd487c18032ef46d6e714a3f3ee 100644 (file)
@@ -181,7 +181,7 @@ public class IExpandLayout extends ComplexPanel implements
         }
 
         void setSpacingEnabled(boolean b) {
-            setStyleName(getElement(), CLASSNAME + "-vspacing", b);
+            setStyleName(getElement(), CLASSNAME + "-" + StyleConstants.VERTICAL_SPACING, b);
         }
     }
 
@@ -262,7 +262,7 @@ public class IExpandLayout extends ComplexPanel implements
         }
 
         void setSpacingEnabled(boolean b) {
-            setStyleName(getElement(), CLASSNAME + "-hspacing", b);
+            setStyleName(getElement(), CLASSNAME + "-" + StyleConstants.HORIZONTAL_SPACING, b);
         }
     }
 
@@ -319,12 +319,14 @@ public class IExpandLayout extends ComplexPanel implements
     protected void handleMargins(UIDL uidl) {
         final MarginInfo margins = new MarginInfo(uidl
                 .getIntAttribute("margins"));
-        setStyleName(me, CLASSNAME + "-" + StyleConstants.LAYOUT_MARGIN_TOP,
-                margins.hasTop());
-        setStyleName(me, StyleConstants.LAYOUT_MARGIN_RIGHT, margins.hasRight());
-        setStyleName(me, CLASSNAME + "-" + StyleConstants.LAYOUT_MARGIN_BOTTOM,
+        setStyleName(me, CLASSNAME + "-" + StyleConstants.MARGIN_TOP, margins
+                .hasTop());
+        setStyleName(me, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT, margins
+                .hasRight());
+        setStyleName(me, CLASSNAME + "-" + StyleConstants.MARGIN_BOTTOM,
                 margins.hasBottom());
-        setStyleName(me, StyleConstants.LAYOUT_MARGIN_LEFT, margins.hasLeft());
+        setStyleName(me, CLASSNAME + "-" + StyleConstants.MARGIN_LEFT, margins
+                .hasLeft());
     }
 
     public boolean hasChildComponent(Widget component) {
index ec2763fedb8053d169df0bcbe1d341f24c1c1cf0..e491e101b85bf20aa73bd99fa3dd057714b6f52d 100644 (file)
@@ -49,14 +49,9 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
     /*
      * Elements that provides the Layout interface implementation.
      */
-    protected Element size;
+    protected Element root;
     protected Element margin;
 
-    protected Element topMargin = null;
-    protected Element bottomMargin = null;
-
-    private static final String structure = "<div><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tbody></tbody></table></div>";
-
     public IOrderedLayout(int orientation) {
         orientationMode = orientation;
         constructDOM();
@@ -64,17 +59,17 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
     }
 
     protected void constructDOM() {
-        size = DOM.createDiv();
-        DOM.setInnerHTML(size, structure);
-        margin = DOM.getFirstChild(size);
-        final Element tBody = DOM.getFirstChild(DOM.getFirstChild(margin));
+        root = DOM.createDiv();
+        margin = DOM.createDiv();
+        DOM.appendChild(root, margin);
         if (orientationMode == ORIENTATION_HORIZONTAL) {
-            childContainer = DOM.createTR();
-            DOM.appendChild(tBody, childContainer);
+            final String structure = "<table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr></tr></tbody></table>";
+            DOM.setInnerHTML(margin, structure);
+            childContainer = DOM.getFirstChild(DOM.getFirstChild(DOM.getFirstChild(margin)));
         } else {
-            childContainer = tBody;
+            childContainer = margin;
         }
-        setElement(size);
+        setElement(root);
     }
 
     public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
@@ -86,29 +81,6 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
             return;
         }
 
-        // Set size
-        // TODO move these to own methods (override setWidth & setHeight)
-        if (uidl.hasAttribute("width")) {
-            setWidth(uidl.getStringAttribute("width"));
-            DOM.setStyleAttribute(DOM.getFirstChild(margin), "width", "100%");
-            DOM.setStyleAttribute(getElement(), "tableLayout", "fixed");
-        } else {
-            setWidth("");
-            DOM.setStyleAttribute(DOM.getFirstChild(margin), "width", "");
-            DOM.setStyleAttribute(getElement(), "tableLayout", "");
-        }
-        if (uidl.hasAttribute("height")) {
-            setHeight(uidl.getStringAttribute("height"));
-            DOM.setStyleAttribute(margin, "height", "100%");
-            DOM.setStyleAttribute(DOM.getFirstChild(margin), "height", "100%");
-            DOM.setStyleAttribute(getElement(), "tableLayout", "fixed");
-        } else {
-            setHeight("");
-            DOM.setStyleAttribute(margin, "height", "");
-            DOM.setStyleAttribute(DOM.getFirstChild(margin), "height", "");
-            DOM.setStyleAttribute(getElement(), "tableLayout", "");
-        }
-
         // Update contained components
 
         final ArrayList uidlWidgets = new ArrayList();
@@ -253,17 +225,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
         } else {
             final Element wrapper = createWidgetWrappper();
             DOM.insertChild(childContainer, wrapper, beforeIndex);
-            insert(w, getWidgetContainerFromWrapper(wrapper), beforeIndex,
-                    false);
-        }
-    }
-
-    protected Element getWidgetContainerFromWrapper(Element wrapper) {
-        switch (orientationMode) {
-        case ORIENTATION_HORIZONTAL:
-            return wrapper;
-        default:
-            return DOM.getFirstChild(wrapper);
+            insert(w, wrapper, beforeIndex, false);
         }
     }
 
@@ -271,17 +233,13 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
      * creates an Element which will contain child widget
      */
     protected Element createWidgetWrappper() {
-        final Element td = DOM.createTD();
-        // We need this overflow:hidden, because it's the default rendering of
-        // IE (although it can be overridden with overflow:visible).
-        DOM.setStyleAttribute(td, "overflow", "hidden");
         switch (orientationMode) {
         case ORIENTATION_HORIZONTAL:
+            final Element td = DOM.createTD();
             return td;
         default:
-            final Element tr = DOM.createTR();
-            DOM.appendChild(tr, td);
-            return tr;
+            final Element div = DOM.createDiv();
+            return div;
         }
     }
 
@@ -320,8 +278,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
     public void add(Widget w) {
         final Element wrapper = createWidgetWrappper();
         DOM.appendChild(childContainer, wrapper);
-        super.add(w, orientationMode == ORIENTATION_HORIZONTAL ? wrapper : DOM
-                .getFirstChild(wrapper));
+        super.add(w, wrapper);
     }
 
     public boolean remove(int index) {
@@ -333,9 +290,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
         final boolean removed = super.remove(w);
         if (removed) {
             if (!(w instanceof Caption)) {
-                DOM.removeChild(childContainer,
-                        orientationMode == ORIENTATION_HORIZONTAL ? wrapper
-                                : DOM.getParent(wrapper));
+                DOM.removeChild(childContainer, wrapper);
             }
             return true;
         }
@@ -355,72 +310,16 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
     }
 
     protected void handleMargins(UIDL uidl) {
-        // Modify layout margins
-        String marginClasses = "";
         final MarginInfo margins = new MarginInfo(uidl
                 .getIntAttribute("margins"));
-        final Element topBottomMarginContainer = orientationMode == ORIENTATION_HORIZONTAL ? DOM
-                .getParent(childContainer)
-                : childContainer;
-        // Top margin
-        // remove from current position so we can insert it to proper position
-        if (topMargin != null) {
-            DOM.removeChild(topBottomMarginContainer, topMargin);
-        }
-        topMargin = null;
-        if (margins.hasTop()) {
-            marginClasses += " " + StyleConstants.LAYOUT_MARGIN_TOP;
-            if (topMargin == null) {
-                // We need to insert a new row in to the table
-                topMargin = DOM.createTR();
-                DOM.appendChild(topMargin, DOM.createTD());
-                DOM.appendChild(DOM.getFirstChild(topMargin), DOM.createDiv());
-                DOM.setElementProperty(topMargin, "className", CLASSNAME
-                        + "-toppad");
-                if (orientationMode == ORIENTATION_HORIZONTAL) {
-                    DOM.setElementAttribute(DOM.getFirstChild(topMargin),
-                            "colspan", "" + getPaintables().size());
-                }
-                DOM.insertChild(topBottomMarginContainer, topMargin, 0);
-            }
-        }
-
-        // Right margin
-        if (margins.hasRight()) {
-            marginClasses += " " + StyleConstants.LAYOUT_MARGIN_RIGHT;
-        }
-
-        // Bottom margin
-        // remove from current position so we can insert it to proper position
-        if (bottomMargin != null) {
-            DOM.removeChild(topBottomMarginContainer, bottomMargin);
-        }
-        bottomMargin = null;
-        if (margins.hasBottom()) {
-            marginClasses += " " + StyleConstants.LAYOUT_MARGIN_BOTTOM;
-            if (bottomMargin == null) {
-                // We need to insert a new row in to the table
-                bottomMargin = DOM.createTR();
-                DOM.appendChild(bottomMargin, DOM.createTD());
-                DOM.appendChild(DOM.getFirstChild(bottomMargin), DOM
-                        .createDiv());
-                DOM.setElementProperty(bottomMargin, "className", CLASSNAME
-                        + "-bottompad");
-                if (orientationMode == ORIENTATION_HORIZONTAL) {
-                    DOM.setElementAttribute(DOM.getFirstChild(bottomMargin),
-                            "colspan", "" + getPaintables().size());
-                }
-                DOM.appendChild(topBottomMarginContainer, bottomMargin);
-            }
-        }
-
-        // Left margin
-        if (margins.hasLeft()) {
-            marginClasses += " " + StyleConstants.LAYOUT_MARGIN_LEFT;
-        }
-
-        // Add
-        DOM.setElementProperty(margin, "className", marginClasses);
+        setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP, margins
+                .hasTop());
+        setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT, margins
+                .hasRight());
+        setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_BOTTOM,
+                margins.hasBottom());
+        setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_LEFT, margins
+                .hasLeft());
     }
 
     protected void handleAlignments(UIDL uidl) {
index 98d50e1f8fe3889585581926bbfec8524ab1ec03..1581d9060cb27271410e3f40f5d99e2980d27ff3 100644 (file)
 }
 
 
-
-/* TODO move to layout.css */
-/* Layout margin values */
-
-
-.i-layoutmargin-top .i-orderedlayout-toppad div, 
-.i-layoutmargin-bottom .i-orderedlayout-bottompad div,
-.i-layoutmargin-top .i-expandlayout-toppad div,
-.i-layoutmargin-bottom .i-expandlayout-bottompad div,
-.i-layoutmargin-top .i-orderedlayout-toppad td, 
-.i-layoutmargin-bottom .i-orderedlayout-bottompad td,
-.i-layoutmargin-top .i-expandlayout-toppad td,
-.i-layoutmargin-bottom .i-expandlayout-bottompad td {
-       height: 15px;
-       overflow: hidden;
-}
-.i-layoutmargin-left {
-       padding-left: 18px;
-}
-.i-layoutmargin-right {
-       padding-right: 18px;
-}
+/**
+ * Link component styles 
+ * (useless to move into a separate file)
+ */
 
 .i-link span {
        text-decoration: underline;
 
 
 /* Loading indicator states */
+
 .i-loading-indicator,
 .i-loading-indicator-delay,
 .i-loading-indicator-wait {
index 893205fadb26139099cd13947209e0e42c9ac5e3..11729da5c584c6272fa19ea28414dd2a69e8a7c7 100644 (file)
        height:100%;
 }
 
-.i-expandlayout-i-layoutmargin-top {
+.i-expandlayout-margin-top {
        padding-top: 15px;
 }
-.i-expandlayout-i-layoutmargin-bottom {
+.i-expandlayout-margin-right {
+       padding-right: 18px;
+}
+.i-expandlayout-margin-bottom {
        padding-bottom: 15px;
 }
+.i-expandlayout-margin-left {
+       padding-left: 18px;
+}
+
 .i-expandlayout-vspacing {
-       margin-top: 15px;
+       margin-top: 8px;
 }
 .i-expandlayout-hspacing {
-       margin-left: 18px;
+       margin-left: 8px;
 }
diff --git a/src/com/itmill/toolkit/terminal/gwt/public/default/orderedlayout/orderedlayout.css b/src/com/itmill/toolkit/terminal/gwt/public/default/orderedlayout/orderedlayout.css
new file mode 100644 (file)
index 0000000..c945843
--- /dev/null
@@ -0,0 +1,12 @@
+.i-orderedlayout-margin-top {
+       padding-top: 15px;
+}
+.i-orderedlayout-margin-right {
+       padding-right: 18px;
+}
+.i-orderedlayout-margin-bottom {
+       padding-bottom: 15px;
+}
+.i-orderedlayout-margin-left {
+       padding-left: 18px;
+}
\ No newline at end of file
index 4ec0c4c9f43149719c0e30114462d9a38fbdd5d5..5f8a00de8ec380ece5ac99c8d398b01e0338d4c6 100644 (file)
@@ -208,7 +208,7 @@ public class Button extends AbstractField {
      * @see com.itmill.toolkit.ui.AbstractComponent#setImmediate(boolean)
      */
     public void setImmediate(boolean immediate) {
-        // Push buttons are allways immediate
+        // Push buttons are always immediate
         super.setImmediate(!isSwitchMode() || immediate);
     }