ChildComponentContainer componentContainer = getComponentContainer((Widget) p);\r
if (isDynamicWidth()) {\r
componentContainer.setUnlimitedContainerWidth();\r
+ } else {\r
+ componentContainer.setLimitedContainerWidth(activeLayoutSize\r
+ .getWidth());\r
}\r
\r
componentContainer.updateWidgetSize();\r
* is automatically calculated correctly (e.g. for Labels).
*/
if (fixedWidth > 0) {
- containerDIV.getStyle().setProperty("width", fixedWidth + "px");
+ setLimitedContainerWidth(fixedWidth);
} else {
setUnlimitedContainerWidth();
}
}
public void setUnlimitedContainerWidth() {
- containerDIV.getStyle().setProperty("width", "1000000px");
+ setLimitedContainerWidth(1000000);
+ }
+
+ public void setLimitedContainerWidth(int width) {
+ containerDIV.getStyle().setProperty("width", width + "px");
}
public void updateWidgetSize() {
--- /dev/null
+package com.itmill.toolkit.tests.components.label;\r
+\r
+import com.itmill.toolkit.tests.components.TestBase;\r
+import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.HorizontalLayout;\r
+import com.itmill.toolkit.ui.Label;\r
+import com.itmill.toolkit.ui.Button.ClickEvent;\r
+\r
+public class LabelWrapping extends TestBase {\r
+\r
+ @Override\r
+ protected String getDescription() {\r
+ return "A label inside a limited HorizontalLayout should strive to be as wide as possible and only wrap when the size of the layout is reached. The label should look the same if it is rendered initially with the layout or updated later on.";\r
+ }\r
+\r
+ @Override\r
+ protected Integer getTicketNumber() {\r
+ return 2478;\r
+ }\r
+\r
+ @Override\r
+ protected void setup() {\r
+ HorizontalLayout hl = new HorizontalLayout();\r
+ hl.setWidth("250px");\r
+\r
+ final String longString = "this is a somewhat long string.";\r
+ final Label longLabel = new Label(longString);\r
+\r
+ Button changeLength = new Button("Change length");\r
+ changeLength.addListener(new Button.ClickListener() {\r
+ public void buttonClick(ClickEvent event) {\r
+ if (longLabel.getValue().equals(longString)) {\r
+ longLabel.setValue("");\r
+ } else {\r
+ longLabel.setValue(longString);\r
+ }\r
+ }\r
+ });\r
+\r
+ hl.addComponent(longLabel);\r
+ hl.addComponent(changeLength);\r
+\r
+ addComponent(hl);\r
+ }\r
+\r
+}\r