summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Englund <marc@vaadin.com>2012-10-11 13:10:58 +0000
committerVaadin Code Review <review@vaadin.com>2012-10-11 13:10:58 +0000
commite722952c0e571945f1afee9f150c946caaf17f8f (patch)
tree708d2d277209242888051a47caba709d2a2af805
parentf6339220790b932f4488171fd492658f63e80fcd (diff)
parentce11d139f6ef2a71c689897c922a6d9987ee4416 (diff)
downloadvaadin-framework-e722952c0e571945f1afee9f150c946caaf17f8f.tar.gz
vaadin-framework-e722952c0e571945f1afee9f150c946caaf17f8f.zip
Merge "Fixed primary stylename handling in AbsoluteLayout as well as moved layout specific functionality into the layout from the connector #9899"
-rw-r--r--client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java171
-rw-r--r--client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java388
-rw-r--r--uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutPrimaryStylename.html67
-rw-r--r--uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutPrimaryStylename.java45
4 files changed, 549 insertions, 122 deletions
diff --git a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java
index 599f52dc2a..0877b563a0 100644
--- a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java
+++ b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java
@@ -15,13 +15,7 @@
*/
package com.vaadin.client.ui.absolutelayout;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.google.gwt.dom.client.Style;
-import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.DirectionalManagedLayout;
@@ -31,13 +25,16 @@ import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentContainerConnector;
import com.vaadin.client.ui.LayoutClickEventHandler;
-import com.vaadin.client.ui.absolutelayout.VAbsoluteLayout.AbsoluteWrapper;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.LayoutClickRpc;
import com.vaadin.shared.ui.absolutelayout.AbsoluteLayoutServerRpc;
import com.vaadin.shared.ui.absolutelayout.AbsoluteLayoutState;
import com.vaadin.ui.AbsoluteLayout;
+/**
+ * Connects the server side {@link AbsoluteLayout} with the client side
+ * counterpart {@link VAbsoluteLayout}
+ */
@Connect(AbsoluteLayout.class)
public class AbsoluteLayoutConnector extends
AbstractComponentContainerConnector implements DirectionalManagedLayout {
@@ -54,13 +51,15 @@ public class AbsoluteLayoutConnector extends
protected LayoutClickRpc getLayoutClickRPC() {
return rpc;
};
-
};
private AbsoluteLayoutServerRpc rpc;
- private Map<String, AbsoluteWrapper> connectorIdToComponentWrapper = new HashMap<String, AbsoluteWrapper>();
-
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.ui.AbstractComponentConnector#init()
+ */
@Override
protected void init() {
super.init();
@@ -82,41 +81,58 @@ public class AbsoluteLayoutConnector extends
element);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.client.ComponentContainerConnector#updateCaption(com.vaadin
+ * .client.ComponentConnector)
+ */
@Override
public void updateCaption(ComponentConnector component) {
VAbsoluteLayout absoluteLayoutWidget = getWidget();
- AbsoluteWrapper componentWrapper = getWrapper(component);
-
boolean captionIsNeeded = VCaption.isNeeded(component.getState());
- VCaption caption = componentWrapper.getCaption();
-
+ VCaption caption = absoluteLayoutWidget.getWidgetCaption(component
+ .getWidget());
if (captionIsNeeded) {
if (caption == null) {
caption = new VCaption(component, getConnection());
- absoluteLayoutWidget.add(caption);
- componentWrapper.setCaption(caption);
- }
- caption.updateCaption();
- componentWrapper.updateCaptionPosition();
- } else {
- if (caption != null) {
- caption.removeFromParent();
}
+ absoluteLayoutWidget.setWidgetCaption(component.getWidget(),
+ caption);
+ } else if (caption != null) {
+ absoluteLayoutWidget.setWidgetCaption(component.getWidget(), null);
}
-
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.ui.AbstractComponentConnector#getWidget()
+ */
@Override
public VAbsoluteLayout getWidget() {
return (VAbsoluteLayout) super.getWidget();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.ui.AbstractComponentConnector#getState()
+ */
@Override
public AbsoluteLayoutState getState() {
return (AbsoluteLayoutState) super.getState();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.client.ui.AbstractComponentConnector#onStateChanged(com.vaadin
+ * .client.communication.StateChangeEvent)
+ */
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
@@ -125,106 +141,63 @@ public class AbsoluteLayoutConnector extends
// TODO Margin handling
for (ComponentConnector child : getChildComponents()) {
- getWrapper(child).setPosition(
+ getWidget().setWidgetPosition(
+ child.getWidget(),
getState().connectorToCssPosition.get(child
.getConnectorId()));
}
};
- private AbsoluteWrapper getWrapper(ComponentConnector child) {
- String childId = child.getConnectorId();
- AbsoluteWrapper wrapper = connectorIdToComponentWrapper.get(childId);
- if (wrapper != null) {
- return wrapper;
- }
-
- wrapper = new AbsoluteWrapper(child.getWidget());
- connectorIdToComponentWrapper.put(childId, wrapper);
- getWidget().add(wrapper);
- return wrapper;
-
- }
-
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.ui.AbstractComponentContainerConnector#
+ * onConnectorHierarchyChange
+ * (com.vaadin.client.ConnectorHierarchyChangeEvent)
+ */
@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
-
for (ComponentConnector child : getChildComponents()) {
- getWrapper(child);
+ if (!getWidget().contains(child.getWidget())) {
+ getWidget().add(child.getWidget());
+ }
}
-
for (ComponentConnector oldChild : event.getOldChildren()) {
if (oldChild.getParent() != this) {
- String connectorId = oldChild.getConnectorId();
- AbsoluteWrapper absoluteWrapper = connectorIdToComponentWrapper
- .remove(connectorId);
- absoluteWrapper.destroy();
+ getWidget().remove(oldChild.getWidget());
}
}
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.DirectionalManagedLayout#layoutVertically()
+ */
@Override
public void layoutVertically() {
- VAbsoluteLayout layout = getWidget();
- for (ComponentConnector paintable : getChildComponents()) {
- Widget widget = paintable.getWidget();
- AbsoluteWrapper wrapper = (AbsoluteWrapper) widget.getParent();
- Style wrapperStyle = wrapper.getElement().getStyle();
-
- if (paintable.isRelativeHeight()) {
- int h;
- if (wrapper.top != null && wrapper.bottom != null) {
- h = wrapper.getOffsetHeight();
- } else if (wrapper.bottom != null) {
- // top not defined, available space 0... bottom of
- // wrapper
- h = wrapper.getElement().getOffsetTop()
- + wrapper.getOffsetHeight();
- } else {
- // top defined or both undefined, available space ==
- // canvas - top
- h = layout.canvas.getOffsetHeight()
- - wrapper.getElement().getOffsetTop();
- }
- wrapperStyle.setHeight(h, Unit.PX);
- getLayoutManager().reportHeightAssignedToRelative(paintable, h);
- } else {
- wrapperStyle.clearHeight();
+ getWidget().layoutVertically();
+ for (ComponentConnector connector : getChildComponents()) {
+ if (connector.isRelativeHeight()) {
+ getLayoutManager().reportHeightAssignedToRelative(connector,
+ getWidget().getWidgetSlotHeight(connector.getWidget()));
}
-
- wrapper.updateCaptionPosition();
}
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.DirectionalManagedLayout#layoutHorizontally()
+ */
@Override
public void layoutHorizontally() {
- VAbsoluteLayout layout = getWidget();
- for (ComponentConnector paintable : getChildComponents()) {
- AbsoluteWrapper wrapper = getWrapper(paintable);
- Style wrapperStyle = wrapper.getElement().getStyle();
-
- if (paintable.isRelativeWidth()) {
- int w;
- if (wrapper.left != null && wrapper.right != null) {
- w = wrapper.getOffsetWidth();
- } else if (wrapper.right != null) {
- // left == null
- // available width == right edge == offsetleft + width
- w = wrapper.getOffsetWidth()
- + wrapper.getElement().getOffsetLeft();
- } else {
- // left != null && right == null || left == null &&
- // right == null
- // available width == canvas width - offset left
- w = layout.canvas.getOffsetWidth()
- - wrapper.getElement().getOffsetLeft();
- }
- wrapperStyle.setWidth(w, Unit.PX);
- getLayoutManager().reportWidthAssignedToRelative(paintable, w);
- } else {
- wrapperStyle.clearWidth();
+ getWidget().layoutHorizontally();
+ for (ComponentConnector connector : getChildComponents()) {
+ if (connector.isRelativeWidth()) {
+ getLayoutManager().reportWidthAssignedToRelative(connector,
+ getWidget().getWidgetSlotWidth(connector.getWidget()));
}
-
- wrapper.updateCaptionPosition();
}
}
}
diff --git a/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java b/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java
index 1f5b58bef3..6c58933dd3 100644
--- a/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java
+++ b/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java
@@ -18,12 +18,12 @@ package com.vaadin.client.ui.absolutelayout;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Style;
+import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.StyleConstants;
import com.vaadin.client.VCaption;
@@ -39,52 +39,386 @@ public class VAbsoluteLayout extends ComplexPanel {
protected final Element canvas = DOM.createDiv();
- private Object previousStyleName;
-
- protected ApplicationConnection client;
-
+ /**
+ * Default constructor
+ */
public VAbsoluteLayout() {
setElement(Document.get().createDivElement());
- setStyleName(CLASSNAME);
- addStyleName(StyleConstants.UI_LAYOUT);
marginElement = Document.get().createDivElement();
canvas.getStyle().setProperty("position", "relative");
canvas.getStyle().setProperty("overflow", "hidden");
marginElement.appendChild(canvas);
getElement().appendChild(marginElement);
-
- canvas.setClassName(CLASSNAME + "-canvas");
- canvas.setClassName(CLASSNAME + "-margin");
+ setStyleName(CLASSNAME);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.google.gwt.user.client.ui.Panel#add(com.google.gwt.user.client.ui
+ * .Widget)
+ */
@Override
public void add(Widget child) {
- super.add(child, canvas);
+ AbsoluteWrapper wrapper = new AbsoluteWrapper(child);
+ wrapper.setStyleName(getStylePrimaryName() + "-wrapper");
+ super.add(wrapper, canvas);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.google.gwt.user.client.ui.ComplexPanel#remove(com.google.gwt.user
+ * .client.ui.Widget)
+ */
+ @Override
+ public boolean remove(Widget w) {
+ AbsoluteWrapper wrapper = getChildWrapper(w);
+ if (wrapper != null) {
+ wrapper.destroy();
+ return super.remove(wrapper);
+ }
+ return false;
+ }
+
+ /**
+ * Does this layout contain a widget
+ *
+ * @param widget
+ * The widget to check
+ * @return Returns true if the widget is in this layout, false if not
+ */
+ public boolean contains(Widget widget) {
+ return getChildWrapper(widget) != null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.gwt.user.client.ui.ComplexPanel#getWidget(int)
+ */
+ @Override
+ public Widget getWidget(int index) {
+ for (int i = 0, j = 0; i < super.getWidgetCount(); i++) {
+ Widget w = getWidget(i);
+ if (w instanceof AbsoluteWrapper) {
+ if (j == index) {
+ return w;
+ } else {
+ j++;
+ }
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.gwt.user.client.ui.ComplexPanel#getWidgetCount()
+ */
+ @Override
+ public int getWidgetCount() {
+ int counter = 0;
+ for (int i = 0; i < super.getWidgetCount(); i++) {
+ if (getWidget(i) instanceof AbsoluteWrapper) {
+ counter++;
+ }
+ }
+ return counter;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.google.gwt.user.client.ui.ComplexPanel#getWidgetIndex(com.google.
+ * gwt.user.client.ui.Widget)
+ */
+ @Override
+ public int getWidgetIndex(Widget child) {
+ for (int i = 0, j = 0; i < super.getWidgetCount(); i++) {
+ Widget w = getWidget(i);
+ if (w instanceof AbsoluteWrapper) {
+ if (child == w) {
+ return j;
+ } else {
+ j++;
+ }
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Sets a caption for a contained widget
+ *
+ * @param child
+ * The child widget to set the caption for
+ * @param caption
+ * The caption of the widget
+ */
+ public void setWidgetCaption(Widget child, VCaption caption) {
+ AbsoluteWrapper wrapper = getChildWrapper(child);
+ if (wrapper != null) {
+ if (caption != null) {
+ if (!getChildren().contains(caption)) {
+ add(caption);
+ }
+ wrapper.setCaption(caption);
+ caption.updateCaption();
+ wrapper.updateCaptionPosition();
+ } else if (wrapper.getCaption() != null) {
+ wrapper.setCaption(null);
+ }
+ }
+ }
+
+ /**
+ * Set the position of the widget in the layout. The position is a CSS
+ * property string using properties such as top,left,right,top
+ *
+ * @param child
+ * The child widget to set the position for
+ * @param position
+ * The position string
+ */
+ public void setWidgetPosition(Widget child, String position) {
+ AbsoluteWrapper wrapper = getChildWrapper(child);
+ if (wrapper != null) {
+ wrapper.setPosition(position);
+ }
+ }
+
+ /**
+ * Get the caption for a widget
+ *
+ * @param child
+ * The child widget to get the caption of
+ */
+ public VCaption getWidgetCaption(Widget child) {
+ AbsoluteWrapper wrapper = getChildWrapper(child);
+ if (wrapper != null) {
+ return wrapper.getCaption();
+ }
+ return null;
+ }
+
+ /**
+ * Get the pixel width of an slot in the layout
+ *
+ * @param child
+ * The widget in the layout.
+ * @return Returns the size in pixels, or 0 if child is not in the layout
+ */
+ public int getWidgetSlotWidth(Widget child) {
+ AbsoluteWrapper wrapper = getChildWrapper(child);
+ if (wrapper != null) {
+ return wrapper.getOffsetWidth();
+ }
+ return 0;
+ }
+
+ /**
+ * Get the pixel height of an slot in the layout
+ *
+ * @param child
+ * The widget in the layout
+ * @return Returns the size in pixels, or 0 if the child is not in the
+ * layout
+ */
+ public int getWidgetSlotHeight(Widget child) {
+ AbsoluteWrapper wrapper = getChildWrapper(child);
+ if (wrapper != null) {
+ return wrapper.getOffsetHeight();
+ }
+ return 0;
+ }
+
+ /**
+ * Get the wrapper for a widget
+ *
+ * @param child
+ * The child to get the wrapper for
+ * @return
+ */
+ protected AbsoluteWrapper getChildWrapper(Widget child) {
+ for (Widget w : getChildren()) {
+ AbsoluteWrapper wrapper = (AbsoluteWrapper) w;
+ if (wrapper.getWidget() == child) {
+ return wrapper;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.google.gwt.user.client.ui.UIObject#setStylePrimaryName(java.lang.
+ * String)
+ */
+ @Override
+ public void setStylePrimaryName(String style) {
+ updateStylenames(style);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.google.gwt.user.client.ui.UIObject#setStyleName(java.lang.String)
+ */
+ @Override
+ public void setStyleName(String style) {
+ super.setStyleName(style);
+ updateStylenames(style);
+ addStyleName(StyleConstants.UI_LAYOUT);
+ }
+
+ /**
+ * Updates all style names contained in the layout
+ *
+ * @param primaryStyleName
+ * The style name to use as primary
+ */
+ protected void updateStylenames(String primaryStyleName) {
+ super.setStylePrimaryName(primaryStyleName);
+ canvas.setClassName(getStylePrimaryName() + "-canvas");
+ canvas.setClassName(getStylePrimaryName() + "-margin");
+ for (Widget w : getChildren()) {
+ if (w instanceof AbsoluteWrapper) {
+ AbsoluteWrapper wrapper = (AbsoluteWrapper) w;
+ wrapper.setStyleName(getStylePrimaryName() + "-wrapper");
+ }
+ }
}
- public static class AbsoluteWrapper extends SimplePanel {
+ /**
+ * Performs a vertical layout of the layout. Should be called when a widget
+ * is added or removed
+ */
+ public void layoutVertically() {
+ for (Widget widget : getChildren()) {
+ if (widget instanceof AbsoluteWrapper) {
+ AbsoluteWrapper wrapper = (AbsoluteWrapper) widget;
+ Style wrapperStyle = wrapper.getElement().getStyle();
+ Style widgetStyle = wrapper.getWidget().getElement().getStyle();
+ if (widgetStyle.getHeight() != null
+ && widgetStyle.getHeight().endsWith("%")) {
+ int h;
+ if (wrapper.top != null && wrapper.bottom != null) {
+ h = wrapper.getOffsetHeight();
+ } else if (wrapper.bottom != null) {
+ // top not defined, available space 0... bottom of
+ // wrapper
+ h = wrapper.getElement().getOffsetTop()
+ + wrapper.getOffsetHeight();
+ } else {
+ // top defined or both undefined, available space ==
+ // canvas - top
+ h = canvas.getOffsetHeight()
+ - wrapper.getElement().getOffsetTop();
+ }
+ wrapperStyle.setHeight(h, Unit.PX);
+ } else {
+ wrapperStyle.clearHeight();
+ }
+
+ wrapper.updateCaptionPosition();
+ }
+ }
+ }
+
+ /**
+ * Performs an horizontal layout. Should be called when a widget is add or
+ * removed
+ */
+ public void layoutHorizontally() {
+ for (Widget widget : getChildren()) {
+ if (widget instanceof AbsoluteWrapper) {
+ AbsoluteWrapper wrapper = (AbsoluteWrapper) widget;
+ Style wrapperStyle = wrapper.getElement().getStyle();
+ Style widgetStyle = wrapper.getWidget().getElement().getStyle();
+
+ if (widgetStyle.getWidth() != null
+ && widgetStyle.getWidth().endsWith("%")) {
+ int w;
+ if (wrapper.left != null && wrapper.right != null) {
+ w = wrapper.getOffsetWidth();
+ } else if (wrapper.right != null) {
+ // left == null
+ // available width == right edge == offsetleft + width
+ w = wrapper.getOffsetWidth()
+ + wrapper.getElement().getOffsetLeft();
+ } else {
+ // left != null && right == null || left == null &&
+ // right == null
+ // available width == canvas width - offset left
+ w = canvas.getOffsetWidth()
+ - wrapper.getElement().getOffsetLeft();
+ }
+ wrapperStyle.setWidth(w, Unit.PX);
+ } else {
+ wrapperStyle.clearWidth();
+ }
+
+ wrapper.updateCaptionPosition();
+ }
+ }
+ }
+
+ /**
+ * Internal wrapper for wrapping widgets in the Absolute layout
+ */
+ protected class AbsoluteWrapper extends SimplePanel {
private String css;
- String left;
- String top;
- String right;
- String bottom;
+ private String left;
+ private String top;
+ private String right;
+ private String bottom;
private String zIndex;
private VCaption caption;
+ /**
+ * Constructor
+ *
+ * @param child
+ * The child to wrap
+ */
public AbsoluteWrapper(Widget child) {
setWidget(child);
- setStyleName(CLASSNAME + "-wrapper");
}
+ /**
+ * Get the caption of the wrapper
+ */
public VCaption getCaption() {
return caption;
}
+ /**
+ * Set the caption for the wrapper
+ *
+ * @param caption
+ * The caption for the wrapper
+ */
public void setCaption(VCaption caption) {
- this.caption = caption;
+ if (caption != null) {
+ this.caption = caption;
+ } else if (this.caption != null) {
+ this.caption.removeFromParent();
+ this.caption = caption;
+ }
}
+ /**
+ * Removes the wrapper caption and itself from the layout
+ */
public void destroy() {
if (caption != null) {
caption.removeFromParent();
@@ -92,9 +426,15 @@ public class VAbsoluteLayout extends ComplexPanel {
removeFromParent();
}
- public void setPosition(String stringAttribute) {
- if (css == null || !css.equals(stringAttribute)) {
- css = stringAttribute;
+ /**
+ * Set the position for the wrapper in the layout
+ *
+ * @param position
+ * The position string
+ */
+ public void setPosition(String position) {
+ if (css == null || !css.equals(position)) {
+ css = position;
top = right = bottom = left = zIndex = null;
if (!css.equals("")) {
String[] properties = css.split(";");
@@ -134,7 +474,10 @@ public class VAbsoluteLayout extends ComplexPanel {
updateCaptionPosition();
}
- void updateCaptionPosition() {
+ /**
+ * Updates the caption position by using element offset left and top
+ */
+ private void updateCaptionPosition() {
if (caption != null) {
Style style = caption.getElement().getStyle();
style.setProperty("position", "absolute");
@@ -144,5 +487,4 @@ public class VAbsoluteLayout extends ComplexPanel {
}
}
}
-
}
diff --git a/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutPrimaryStylename.html b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutPrimaryStylename.html
new file mode 100644
index 0000000000..fccbb29b8b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutPrimaryStylename.html
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.absolutelayout.AbsoluteLayoutPrimaryStylename?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertNotCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/</td>
+ <td>v-absolute-layout</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/</td>
+ <td>my-absolute-layout</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/domChild[0]/domChild[0]</td>
+ <td>my-absolute-layout-margin</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]/</td>
+ <td>my-absolute-layout-wrapper</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertNotCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/</td>
+ <td>my-absolute-layout</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/</td>
+ <td>my-second-absolute-layout</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/domChild[0]/domChild[0]</td>
+ <td>my-second-absolute-layout-margin</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]/</td>
+ <td>my-second-absolute-layout-wrapper</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutPrimaryStylename.java b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutPrimaryStylename.java
new file mode 100644
index 0000000000..b75d5931b5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutPrimaryStylename.java
@@ -0,0 +1,45 @@
+package com.vaadin.tests.components.absolutelayout;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbsoluteLayout;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.NativeButton;
+
+public class AbsoluteLayoutPrimaryStylename extends TestBase {
+
+ @Override
+ protected void setup() {
+ final AbsoluteLayout layout = new AbsoluteLayout();
+ layout.setWidth("100px");
+ layout.setWidth("200px");
+ layout.setPrimaryStyleName("my-absolute-layout");
+
+ Component comp1 = new NativeButton("Child 1");
+ comp1.setWidth("100%");
+ comp1.setHeight("50px");
+ layout.addComponent(comp1);
+
+ addComponent(layout);
+
+ addComponent(new Button("Change primary stylename",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ layout.setPrimaryStyleName("my-second-absolute-layout");
+ }
+ }));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Absolutelayout should handle setting primary stylename both initially and dynamically";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 9899;
+ }
+
+}