summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2012-08-13 10:10:19 +0000
committerArtur Signell <artur.signell@itmill.com>2012-08-13 10:10:19 +0000
commit131c3db7abb86c7518e5826f74bdd31b729de94e (patch)
tree17e1101c9024a511de530c8de877c2269e5f7b1f /src
parent1e81c23ea378facf0d3ef9fd3fa24c4d813fce5e (diff)
downloadvaadin-framework-131c3db7abb86c7518e5826f74bdd31b729de94e.tar.gz
vaadin-framework-131c3db7abb86c7518e5826f74bdd31b729de94e.zip
Correctly measure indent when adding to an empty TreeTable (#9264)
svn changeset:24155/svn branch:6.8
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java31
2 files changed, 31 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();
}