summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2011-09-12 14:21:09 +0000
committerLeif Åstrand <leif@vaadin.com>2011-09-12 14:21:09 +0000
commit9778741d2e2af87276639deacc6b61060d344468 (patch)
treeb6f18afb264e7d41528d7a11921e16e67de13b24
parent9caf1e58a7bb167578ae34a775a7ce4a65258b61 (diff)
downloadvaadin-framework-9778741d2e2af87276639deacc6b61060d344468.tar.gz
vaadin-framework-9778741d2e2af87276639deacc6b61060d344468.zip
#7564 Resizing table column from the server only resizes the header
svn changeset:20971/svn branch:6.7
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java30
-rw-r--r--src/com/vaadin/ui/Table.java1
-rw-r--r--tests/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html20
3 files changed, 48 insertions, 3 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
index 61b6fc1c99..49d7c78a87 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
@@ -2803,6 +2803,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
public void updateCellsFromUIDL(UIDL uidl) {
Iterator<?> it = uidl.getChildIterator();
HashSet<String> updated = new HashSet<String>();
+ boolean refreshContentWidths = false;
while (it.hasNext()) {
final UIDL col = (UIDL) it.next();
final String cid = col.getStringAttribute("cid");
@@ -2848,7 +2849,14 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
if (width < c.getMinWidth()) {
width = c.getMinWidth();
}
- c.setWidth(width, true);
+ if (width != c.getWidth() && scrollBody != null) {
+ // Do a more thorough update if a column is resized from
+ // the server
+ setColWidth(getColIndexByKey(c.cid), width, true);
+ refreshContentWidths = true;
+ } else {
+ c.setWidth(width, true);
+ }
} else if (recalcWidths) {
c.setUndefinedWidth();
}
@@ -2865,6 +2873,11 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
}
+ if (refreshContentWidths) {
+ // Recalculate the column sizings if any column has changed
+ triggerLazyColumnAdjustment(true);
+ }
+
// check for orphaned header cells
for (Iterator<String> cit = availableCells.keySet().iterator(); cit
.hasNext();) {
@@ -3635,8 +3648,13 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
if (col.hasAttribute("width")) {
- final String width = col.getStringAttribute("width");
- c.setWidth(Integer.parseInt(width), true);
+ if (scrollBody == null) {
+ // Already updated by setColWidth called from
+ // TableHeads.updateCellsFromUIDL in case of a server
+ // side resize
+ final String width = col.getStringAttribute("width");
+ c.setWidth(Integer.parseInt(width), true);
+ }
} else if (recalcWidths) {
c.setUndefinedWidth();
}
@@ -5604,6 +5622,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
*/
@Override
public void run() {
+ if (scrollBody == null) {
+ // Try again later if we get here before scrollBody has been
+ // initalized
+ triggerLazyColumnAdjustment(false);
+ return;
+ }
Iterator<Widget> headCells = tHead.iterator();
int usedMinimumWidth = 0;
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index ea97654670..f752519fd1 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -750,6 +750,7 @@ public class Table extends AbstractSelect implements Action.Container,
} else {
columnWidths.put(propertyId, Integer.valueOf(width));
}
+ requestRepaint();
}
/**
diff --git a/tests/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html b/tests/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html
index 701adeac34..9c8a12fe15 100644
--- a/tests/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html
+++ b/tests/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html
@@ -36,6 +36,26 @@
<td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]</td>
<td>120</td>
</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementWidth</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]</td>
+ <td>80</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementWidth</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]</td>
+ <td>100</td>
+</tr>
</tbody></table>
</body>
</html>