Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CustomTable.java #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 46 additions & 15 deletions src/com/vaadin/ui/CustomTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -3297,8 +3297,13 @@ private void doPaintContent(PaintTarget target) throws PaintException {
* sync. Otherwise we _might_ have the situation where the client side
* discards too few or too many rows, causing out of sync issues.
*/
int pageBufferLastIndex = pageBufferFirstIndex
+ pageBuffer[CELL_ITEMID].length - 1;
int pageBufferLastIndex;
if (pageBuffer != null && pageBuffer.length > 0)
{
pageBufferLastIndex = pageBufferFirstIndex + pageBuffer[CELL_ITEMID].length - 1;
}
else
pageBufferLastIndex = 0;
target.addAttribute(TableConstants.ATTRIBUTE_PAGEBUFFER_FIRST,
pageBufferFirstIndex);
target.addAttribute(TableConstants.ATTRIBUTE_PAGEBUFFER_LAST,
Expand Down Expand Up @@ -3677,19 +3682,34 @@ private void paintRows(PaintTarget target, final Object[][] cells,
if (reqFirstRowToPaint != -1 && firstToBeRenderedInClient != -1) {
start = reqFirstRowToPaint - firstToBeRenderedInClient;
}
int end = cells[0].length;
int end;
if (cells != null && cells.length > 0)
{
end = cells[0].length;
}
else
{
end = 0;
}
if (reqRowsToPaint != -1) {
end = start + reqRowsToPaint;
}
// sanity check
if (lastToBeRenderedInClient != -1 && lastToBeRenderedInClient < end) {
end = lastToBeRenderedInClient + 1;
}
if (start > cells[CELL_ITEMID].length || start < 0) {
start = 0;
if (cells != null && cells.length > 0)
{
if (start > cells[CELL_ITEMID].length || start < 0) {
start = 0;
}
}
if (end > cells[CELL_ITEMID].length) {
end = cells[CELL_ITEMID].length;
if (cells != null && cells.length > 0)
{

if (end > cells[CELL_ITEMID].length) {
end = cells[CELL_ITEMID].length;
}
}

for (int indexInRowbuffer = start; indexInRowbuffer < end; indexInRowbuffer++) {
Expand Down Expand Up @@ -3763,14 +3783,22 @@ private int findNumRowsToPaint(PaintTarget target, final Object[][] cells)
if (reqRowsToPaint >= 0) {
rows = reqRowsToPaint;
} else {
rows = cells[0].length;
if (alwaysRecalculateColumnWidths) {
// TODO experimental feature for now: tell the client to
// recalculate column widths.
// We'll only do this for paints that do not originate from
// table scroll/cache requests (i.e when reqRowsToPaint<0)
target.addAttribute("recalcWidths", true);
}
if (cells != null && cells.length > 0)
{
rows = cells[0].length;
if (alwaysRecalculateColumnWidths) {
// TODO experimental feature for now: tell the client to
// recalculate column widths.
// We'll only do this for paints that do not originate from
// table scroll/cache requests (i.e when reqRowsToPaint<0)
target.addAttribute("recalcWidths", true);
}

}
else
{
rows = 0;
}
}
return rows;
}
Expand Down Expand Up @@ -4024,6 +4052,9 @@ private Object[][] getVisibleCells() {
if (pageBuffer == null) {
refreshRenderedCells();
}
if (pageBuffer == null) {
pageBuffer = new Object[][] { };
}
return pageBuffer;
}

Expand Down