aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Koivuviita <jouni.koivuviita@itmill.com>2007-12-13 13:45:11 +0000
committerJouni Koivuviita <jouni.koivuviita@itmill.com>2007-12-13 13:45:11 +0000
commitb3bb571b1ecb6a40ae063c7cbd15642e7e333f5d (patch)
treefb3f9e1866d096862837ca89be7a891e6994c138 /src
parent89497d8012c8b31080c2a47cde5a6a313b339f6a (diff)
downloadvaadin-framework-b3bb571b1ecb6a40ae063c7cbd15642e7e333f5d.tar.gz
vaadin-framework-b3bb571b1ecb6a40ae063c7cbd15642e7e333f5d.zip
New IOrderedLayout implementation (without sizing abilities).
svn changeset:3232/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/DefaultWidgetSetNoEntry.gwt.xml1
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/StyleConstants.java11
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java16
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java147
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/public/default/common/common.css27
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/public/default/expandlayout/expandlayout.css15
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/public/default/orderedlayout/orderedlayout.css12
-rw-r--r--src/com/itmill/toolkit/ui/Button.java2
8 files changed, 69 insertions, 162 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/DefaultWidgetSetNoEntry.gwt.xml b/src/com/itmill/toolkit/terminal/gwt/DefaultWidgetSetNoEntry.gwt.xml
index 38a39f2eb9..29c2669770 100644
--- a/src/com/itmill/toolkit/terminal/gwt/DefaultWidgetSetNoEntry.gwt.xml
+++ b/src/com/itmill/toolkit/terminal/gwt/DefaultWidgetSetNoEntry.gwt.xml
@@ -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>
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/StyleConstants.java b/src/com/itmill/toolkit/terminal/gwt/client/StyleConstants.java
index 35f1b5818f..b4d5499172 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/StyleConstants.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/StyleConstants.java
@@ -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";
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
index d50c3cf351..6f9290c7bc 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
@@ -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) {
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
index ec2763fedb..e491e101b8 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
@@ -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) {
diff --git a/src/com/itmill/toolkit/terminal/gwt/public/default/common/common.css b/src/com/itmill/toolkit/terminal/gwt/public/default/common/common.css
index 98d50e1f8f..1581d9060c 100644
--- a/src/com/itmill/toolkit/terminal/gwt/public/default/common/common.css
+++ b/src/com/itmill/toolkit/terminal/gwt/public/default/common/common.css
@@ -95,28 +95,10 @@
}
-
-/* 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;
@@ -126,6 +108,7 @@
/* Loading indicator states */
+
.i-loading-indicator,
.i-loading-indicator-delay,
.i-loading-indicator-wait {
diff --git a/src/com/itmill/toolkit/terminal/gwt/public/default/expandlayout/expandlayout.css b/src/com/itmill/toolkit/terminal/gwt/public/default/expandlayout/expandlayout.css
index 893205fadb..11729da5c5 100644
--- a/src/com/itmill/toolkit/terminal/gwt/public/default/expandlayout/expandlayout.css
+++ b/src/com/itmill/toolkit/terminal/gwt/public/default/expandlayout/expandlayout.css
@@ -21,15 +21,22 @@
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
index 0000000000..c94584332d
--- /dev/null
+++ b/src/com/itmill/toolkit/terminal/gwt/public/default/orderedlayout/orderedlayout.css
@@ -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
diff --git a/src/com/itmill/toolkit/ui/Button.java b/src/com/itmill/toolkit/ui/Button.java
index 4ec0c4c9f4..5f8a00de8e 100644
--- a/src/com/itmill/toolkit/ui/Button.java
+++ b/src/com/itmill/toolkit/ui/Button.java
@@ -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);
}