浏览代码

New IOrderedLayout implementation (without sizing abilities).

svn changeset:3232/svn branch:trunk
tags/6.7.0.beta1
Jouni Koivuviita 16 年前
父节点
当前提交
b3bb571b1e

+ 1
- 0
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>

+ 7
- 4
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";

}

+ 9
- 7
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) {

+ 23
- 124
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) {

+ 5
- 22
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 {

+ 11
- 4
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;
}

+ 12
- 0
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;
}

+ 1
- 1
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);
}


正在加载...
取消
保存