Bläddra i källkod

Implemented reqrows and reqfirstrow attributes

svn changeset:343/svn branch:toolkit
tags/6.7.0.beta1
Joonas Lehtinen 17 år sedan
förälder
incheckning
3388cb06b4
1 ändrade filer med 51 tillägg och 4 borttagningar
  1. 51
    4
      src/com/itmill/toolkit/ui/Table.java

+ 51
- 4
src/com/itmill/toolkit/ui/Table.java Visa fil

* sortable. */ * sortable. */
private boolean sortDisabled = false; private boolean sortDisabled = false;
/** Number of rows explicitly requested by the client to be painted on next paint.
* This is -1 if no request by the client is made. Painting the component will automatically
* reset this to -1.
*/
private int reqRowsToPaint = -1;
/** Index of the first rows explicitly requested by the client to be painted.
* This is -1 if no request by the client is made. Painting the component will automatically
* reset this to -1.
*/
private int reqFirstRowToPaint = -1;
/* Table constructors *************************************************** */ /* Table constructors *************************************************** */


/** Create new empty table */ /** Create new empty table */
setCurrentPageFirstItemIndex(value.intValue() - 1); setCurrentPageFirstItemIndex(value.intValue() - 1);
} }


// Set requested firstrow and rows for the next paint
if (variables.containsKey("reqfirstrow") || variables.containsKey("reqrows")) {
Integer value = (Integer) variables.get("reqfirstrow");
if (value != null)
reqFirstRowToPaint = value.intValue() -1;
value = (Integer) variables.get("reqrows");
if (value != null)
reqRowsToPaint = value.intValue();
pageBuffer = null;
requestRepaint();
}

// Actions // Actions
if (variables.containsKey("action")) { if (variables.containsKey("action")) {
StringTokenizer st = new StringTokenizer((String) variables StringTokenizer st = new StringTokenizer((String) variables
target.addAttribute("selectmode", "none"); target.addAttribute("selectmode", "none");
target.addAttribute("cols", cols); target.addAttribute("cols", cols);
target.addAttribute("rows", cells[0].length); target.addAttribute("rows", cells[0].length);
target.addAttribute("firstrow", (reqFirstRowToPaint >= 0 ? reqFirstRowToPaint : first) + 1);
target.addAttribute("totalrows", total); target.addAttribute("totalrows", total);
if (pagelen != 0) if (pagelen != 0)
target.addAttribute("pagelength", pagelen); target.addAttribute("pagelength", pagelen);
target.addAttribute("colheaders", true); target.addAttribute("colheaders", true);
if (rowheads) if (rowheads)
target.addAttribute("rowheaders", true); target.addAttribute("rowheaders", true);
// Columns // Columns
target.startTag("cols"); target.startTag("cols");
Collection sortables = getSortableContainerPropertyIds(); Collection sortables = getSortableContainerPropertyIds();
target.addVariable(this, "sortascending", this.sortAscending); target.addVariable(this, "sortascending", this.sortAscending);
} }


// Reset and paint "to be painted next" variables. Also reset pageBuffer
reqFirstRowToPaint = -1;
reqRowsToPaint = -1;
pageBuffer = null;
target.addVariable(this, "reqrows", reqRowsToPaint);
target.addVariable(this, "reqfirstrow", reqFirstRowToPaint);

// Actions // Actions
if (!actionSet.isEmpty()) { if (!actionSet.isEmpty()) {
target.startTag("actions"); target.startTag("actions");
int rows = size(); int rows = size();
if (rows > 0 && firstIndex >= 0) if (rows > 0 && firstIndex >= 0)
rows -= firstIndex; rows -= firstIndex;
if (pagelen > 0 && pagelen < rows) if (pagelen > 0 && pagelen < rows)
rows = pagelen; rows = pagelen;
// If "to be painted next" variables are set, use them
if (reqRowsToPaint >= 0) rows = reqRowsToPaint;
Object id;
if (reqFirstRowToPaint >= 0 && reqFirstRowToPaint < size())
firstIndex = reqFirstRowToPaint;
if (rows + firstIndex > size()) rows = size() - firstIndex;

// Get first item id
if (items instanceof Container.Indexed)
id = ((Container.Indexed) items).getIdByIndex(firstIndex);
else {
id = ((Container.Ordered) items).firstItemId();
for (int i=0; i<firstIndex; i++) id = ((Container.Ordered) items).nextItemId(id);
}

Object[][] cells = new Object[cols + CELL_FIRSTCOL][rows]; Object[][] cells = new Object[cols + CELL_FIRSTCOL][rows];
if (rows == 0) if (rows == 0)
return cells; return cells;
Object id = getCurrentPageFirstItemId();
int headmode = getRowHeaderMode(); int headmode = getRowHeaderMode();
boolean[] iscomponent = new boolean[cols]; boolean[] iscomponent = new boolean[cols];
for (int i = 0; i < cols; i++) for (int i = 0; i < cols; i++)
iscomponent[i] = Component.class iscomponent[i] = Component.class
.isAssignableFrom(getType(colids[i])); .isAssignableFrom(getType(colids[i]));

// Create page contents // Create page contents
int filledRows = 0; int filledRows = 0;
for (int i = 0; i < rows && id != null; i++) { for (int i = 0; i < rows && id != null; i++) {
this.width = width; this.width = width;
requestRepaint(); requestRepaint();
} }

} }

Laddar…
Avbryt
Spara