}
}
- private void updateTotalRows(UIDL uidl) {
+ protected void updateTotalRows(UIDL uidl) {
int newTotalRows = uidl.getIntAttribute("totalrows");
if (newTotalRows != getTotalRows()) {
if (scrollBody != null) {
scrollBody.unlinkRows(
partialRowAdditions.getIntAttribute("firstprowix"),
partialRowAdditions.getIntAttribute("numprows"));
+ scrollBody.ensureCacheFilled();
} else {
- scrollBody.insertRows(partialRowAdditions,
- partialRowAdditions.getIntAttribute("firstprowix"),
- partialRowAdditions.getIntAttribute("numprows"));
+ if (partialRowAdditions.hasAttribute("delbelow")) {
+ scrollBody.insertRowsDeleteBelow(partialRowAdditions,
+ partialRowAdditions.getIntAttribute("firstprowix"),
+ partialRowAdditions.getIntAttribute("numprows"));
+ } else {
+ scrollBody.insertRows(partialRowAdditions,
+ partialRowAdditions.getIntAttribute("firstprowix"),
+ partialRowAdditions.getIntAttribute("numprows"));
+ }
}
updateCache();
// this may be a new set of rows due content change,
// ensure we have proper cache rows
+ ensureCacheFilled();
+ }
+
+ protected void ensureCacheFilled() {
int reactFirstRow = (int) (firstRowInViewPort - pageLength
* cache_react_rate);
int reactLastRow = (int) (firstRowInViewPort + pageLength + pageLength
}
}
+ protected void insertRowsDeleteBelow(UIDL rowData, int firstIndex,
+ int rows) {
+ unlinkAllRowsStartingAt(firstIndex);
+ insertRows(rowData, firstIndex, rows);
+ }
+
/**
* This method is used to instantiate new rows for this table. It
* automatically sets correct widths to rows cells and assigns correct
fixSpacers();
}
- protected void unlinkAllRowsAfter(int index) {
+ protected void unlinkAllRowsStartingAt(int index) {
if (firstRendered > index) {
index = firstRendered;
}
- for (int ix = renderedRows.size() - 1; ix > index; ix--) {
+ for (int ix = renderedRows.size() - 1; ix >= index; ix--) {
unlinkRowAtIndex(ix);
lastRendered--;
}
final int lastRendered = scrollBody.getLastRendered();
final int firstRendered = scrollBody.getFirstRendered();
+ VConsole.log("firstRendered=" + firstRendered + " preLimit=" + preLimit
+ + " lastRendered=" + lastRendered + " postLimit=" + postLimit);
+
if (postLimit <= lastRendered && preLimit >= firstRendered) {
// remember which firstvisible we requested, in case the server has
// a differing opinion
super.setStyleName(style + " v-treetable");
}
+ @Override
+ protected void updateTotalRows(UIDL uidl) {
+ // Make sure that initializedAndAttached & al are not reset when the
+ // totalrows are updated on expand/collapse requests.
+ int newTotalRows = uidl.getIntAttribute("totalrows");
+ if (collapseRequest) {
+ setTotalRows(newTotalRows);
+ } else {
+ super.setTotalRows(newTotalRows);
+ }
+ }
}
int count = getAddedRowCount();
target.startTag("prows");
+
+ int maxRows = (int) (getPageLength() * getCacheRate());
+ if (!shouldHideAddedRows() && count > maxRows) {
+ count = maxRows + 1;
+ // delete the rows below, since they will fall beyond the cache
+ // page.
+ target.addAttribute("delbelow", true);
+ }
+
target.addAttribute("firstprowix", firstIx);
target.addAttribute("numprows", count);
--- /dev/null
+<?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.TreeTablePartialUpdates?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdates::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>12,6</td>
+</tr>
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdates::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]</td>
+ <td>1692</td>
+</tr>
+<tr>
+ <td>pause</td>
+ <td>300</td>
+ <td></td>
+</tr>
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdates::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]</td>
+ <td>3889</td>
+</tr>
+<tr>
+ <td>pause</td>
+ <td>300</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>treetable-long-scroll</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
--- /dev/null
+package com.vaadin.tests.components.treetable;
+
+import com.vaadin.data.Container.Hierarchical;
+import com.vaadin.data.util.HierarchicalContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.TreeTable;
+
+public class TreeTablePartialUpdates extends TestBase {
+
+ @Override
+ protected void setup() {
+ TreeTable tt = new TreeTable();
+ tt.setContainerDataSource(makeHierarchicalContainer());
+ tt.setWidth("300px");
+ addComponent(tt);
+ }
+
+ private Hierarchical makeHierarchicalContainer() {
+ HierarchicalContainer hc = new HierarchicalContainer();
+ hc.addContainerProperty("p1", String.class, "");
+ hc.addContainerProperty("p2", String.class, "");
+
+ Object r1 = hc.addItem();
+ hc.getItem(r1).getItemProperty("p1").setValue("root1");
+ hc.getItem(r1).getItemProperty("p2").setValue("root1");
+
+ Object r2 = hc.addItem();
+ hc.getItem(r2).getItemProperty("p1").setValue("root2");
+ hc.getItem(r2).getItemProperty("p2").setValue("root2");
+
+ Object r3 = hc.addItem();
+ hc.getItem(r3).getItemProperty("p1").setValue("root3");
+ hc.getItem(r3).getItemProperty("p2").setValue("root3");
+
+ Object r4 = hc.addItem();
+ hc.getItem(r4).getItemProperty("p1").setValue("END");
+ hc.setChildrenAllowed(r4, false);
+
+ addNodesToRoot(hc, r1, 200);
+ addNodesToRoot(hc, r2, 200);
+ addNodesToRoot(hc, r3, 200);
+ return hc;
+ }
+
+ private void addNodesToRoot(HierarchicalContainer hc, Object root, int count) {
+ for (int ix = 0; ix < count; ix++) {
+ Object id = hc.addItem();
+ hc.getItem(id).getItemProperty("p1").setValue(String.valueOf(ix));
+ hc.setParent(id, root);
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6722;
+ }
+
+}