summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java31
-rwxr-xr-xtests/testbench/com/vaadin/tests/components/treetable/AddItemToEmptyTreeTable.html72
3 files changed, 103 insertions, 6 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
index 43e07376f4..fa2a7c4849 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
@@ -4334,8 +4334,10 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
row.addStyleName("v-selected");
}
tBodyElement.appendChild(row.getElement());
- adopt(row);
+ // Add to renderedRows before adopt so iterator() will return also
+ // this row if called in an attach handler (#9264)
renderedRows.add(row);
+ adopt(row);
}
private void insertRowAt(VScrollTableRow row, int index) {
@@ -6098,7 +6100,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
availW -= totalExtraWidth;
int forceScrollBodyWidth = -1;
-
+
int extraSpace = availW - usedMinimumWidth;
if (extraSpace < 0) {
if (getTotalRows() == 0) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java b/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java
index 4b1448cdfb..ee6a082adc 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java
@@ -252,8 +252,7 @@ public class VTreeTable extends VScrollTable {
if (isTreeCellAdded) {
return false;
}
- return curColIndex == colIndexOfHierarchy
- + (showRowHeaders ? 1 : 0);
+ return curColIndex == getHierarchyColumnIndex();
}
@Override
@@ -291,6 +290,23 @@ public class VTreeTable extends VScrollTable {
super.onAttach();
if (getIndentWidth() < 0) {
detectIndent(this);
+ // If we detect indent here then the size of the hierarchy
+ // column is still wrong as it has been set when the indent
+ // was not known.
+ int w = getCellWidthFromDom(getHierarchyColumnIndex());
+ if (w >= 0) {
+ setColWidth(getHierarchyColumnIndex(), w);
+ }
+ }
+ }
+
+ private int getCellWidthFromDom(int cellIndex) {
+ final Element cell = DOM.getChild(getElement(), cellIndex);
+ String w = cell.getStyle().getProperty("width");
+ if (w == null || "".equals(w) || !w.endsWith("px")) {
+ return -1;
+ } else {
+ return Integer.parseInt(w.substring(0, w.length() - 2));
}
}
@@ -329,14 +345,21 @@ public class VTreeTable extends VScrollTable {
@Override
protected void setCellWidth(int cellIx, int width) {
- if (cellIx == colIndexOfHierarchy + (showRowHeaders ? 1 : 0)) {
+ if (cellIx == getHierarchyColumnIndex()) {
// take indentation padding into account if this is the
// hierarchy column
- width = Math.max(width - getIndent(), 0);
+ int indent = getIndent();
+ if (indent != -1) {
+ width = Math.max(width - getIndent(), 0);
+ }
}
super.setCellWidth(cellIx, width);
}
+ private int getHierarchyColumnIndex() {
+ return colIndexOfHierarchy + (showRowHeaders ? 1 : 0);
+ }
+
private int getIndent() {
return (depth + 1) * getIndentWidth();
}
diff --git a/tests/testbench/com/vaadin/tests/components/treetable/AddItemToEmptyTreeTable.html b/tests/testbench/com/vaadin/tests/components/treetable/AddItemToEmptyTreeTable.html
new file mode 100755
index 0000000000..15dc0e074d
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/treetable/AddItemToEmptyTreeTable.html
@@ -0,0 +1,72 @@
+<?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>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.treetable.TreeTableTest?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::PID_Smenu#item0</td>
+ <td>38,10</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[0]/VMenuBar[0]#item5</td>
+ <td>52,6</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[1]/VMenuBar[0]#item1</td>
+ <td>68,8</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[2]/VMenuBar[0]#item0</td>
+ <td>12,4</td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.treetable.TreeTableTest</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::PID_Smenu#item0</td>
+ <td>33,7</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[0]/VMenuBar[0]#item5</td>
+ <td>52,9</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[1]/VMenuBar[0]#item1</td>
+ <td>39,5</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[2]/VMenuBar[0]#item1</td>
+ <td>23,3</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>item-added-to-empty-treetable</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>