diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2013-02-05 13:08:33 +0200 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2013-02-15 11:13:46 +0200 |
commit | f2ec1fa217fa0fe7f98b6a2b95ed075a2e874769 (patch) | |
tree | c48e1480b3571dc0824fd2bcdea67b438fe03088 | |
parent | 655a44cadffb2fc0f4d94327582c6611126be8ad (diff) | |
download | vaadin-framework-f2ec1fa217fa0fe7f98b6a2b95ed075a2e874769.tar.gz vaadin-framework-f2ec1fa217fa0fe7f98b6a2b95ed075a2e874769.zip |
Merge of first part of (#10513) to Vaadin 7.
Recalculate column widths if vertical scrollbar has been added/removed.
Change-Id: I093059b8eaad8ff9f9d87db213dec806993459d5
3 files changed, 151 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 75f5550790..75d67b82d6 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -500,7 +500,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, /** * Read from the "recalcWidths" -attribute. When it is true, the table will * recalculate the widths for columns - desirable in some cases. For #1983, - * marked experimental. + * marked experimental. See also variable <code>refreshContentWidths</code> + * in method {@link TableHead#updateCellsFromUIDL(UIDL)}. * <p> * For internal use only. May be removed or replaced in the future. */ @@ -570,6 +571,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, /** For internal use only. May be removed or replaced in the future. */ public ContextMenuDetails contextMenu = null; + private boolean hadScrollBars = false; + public VScrollTable() { setMultiSelectMode(MULTISELECT_MODE_DEFAULT); @@ -2038,6 +2041,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, Util.runWebkitOverflowAutoFix(scrollBodyPanel.getElement()); } }); + + hadScrollBars = willHaveScrollbarz; } /** @@ -2984,7 +2989,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, public void updateCellsFromUIDL(UIDL uidl) { Iterator<?> it = uidl.getChildIterator(); HashSet<String> updated = new HashSet<String>(); - boolean refreshContentWidths = false; + boolean refreshContentWidths = initializedAndAttached + && hadScrollBars != willHaveScrollbars(); while (it.hasNext()) { final UIDL col = (UIDL) it.next(); final String cid = col.getStringAttribute("cid"); diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.html b/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.html new file mode 100644 index 0000000000..c499747232 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.html @@ -0,0 +1,31 @@ +<?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="" /> +<title>TreeTableExtraScrollbar</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">TreeTableExtraScrollbar</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.treetable.TreeTableExtraScrollbar?restartApplication</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>button</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.java new file mode 100644 index 0000000000..4af0da158d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.java @@ -0,0 +1,112 @@ +package com.vaadin.tests.components.treetable; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.TreeTable; + +public class TreeTableExtraScrollbar extends TestBase { + + @Override + protected String getDescription() { + return "Vertical scrollbar should not cause a horizontal scrollbar" + + " if there is more excess space than vertical scrollbar needs."; + } + + @Override + protected Integer getTicketNumber() { + return 10513; + } + + @Override + protected void setup() { + HorizontalLayout layout = new HorizontalLayout(); + layout.setWidth("310px"); + layout.setHeight("300px"); + + final Table table = new TreeTable(); + table.setSizeFull(); + + table.addGeneratedColumn("parameterId", new EmptyColumnGenerator()); + table.addGeneratedColumn("wordingTextId", new TypeColumnGenerator()); + table.addGeneratedColumn("parameterTypeId", new TypeColumnGenerator()); + + table.setColumnWidth("parameterId", 26); + + table.addItem(new TestObject("name 1", "value 1")); + table.addItem(new TestObject("name 2", "value 2")); + table.addItem(new TestObject("name 3", "value 3")); + table.addItem(new TestObject("name 4", "value 4")); + table.addItem(new TestObject("name 5", "value 5")); + + layout.addComponent(table); + + Button button = new Button("Add"); + button.setId("button"); + button.addClickListener(new ClickListener() { + + public void buttonClick(ClickEvent event) { + table.addItem(new TestObject("name 6-1", "value 6-1")); + table.addItem(new TestObject("name 6-2", "value 6-2")); + table.addItem(new TestObject("name 6-3", "value 6-3")); + table.addItem(new TestObject("name 6-4", "value 6-4")); + table.addItem(new TestObject("name 6-5", "value 6-5")); + table.addItem(new TestObject("name 6-6", "value 6-6")); + table.addItem(new TestObject("name 6-7", "value 6-7")); + table.addItem(new TestObject("name 6-8", "value 6-8")); + table.addItem(new TestObject("name 6-9", "value 6-9")); + table.addItem(new TestObject("name 6-9", "value 6-10")); + } + }); + + addComponent(layout); + addComponent(button); + } + + private class EmptyColumnGenerator implements Table.ColumnGenerator { + public Object generateCell(Table table, Object itemId, Object columnId) { + return null; + } + } + + private class TypeColumnGenerator implements Table.ColumnGenerator { + public Object generateCell(Table table, Object itemId, Object columnId) { + if (itemId instanceof TestObject) { + return new Label(((TestObject) itemId).getValue()); + } + return null; + } + } + +} + +class TestObject { + + private String name; + private String value; + + public TestObject(String name, String value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} |