// server has defined column width explicitly
w = hCell.getWidth();
} else {
- int hw = DOM.getIntAttribute(hCell.getElement(), "offsetWidth");
+ int hw = DOM.getElementPropertyInt(hCell.getElement(), "offsetWidth");
int cw = tBody.getColWidth(i);
w = (hw > cw ? hw : cw) + IScrollTableBody.CELL_EXTRA_WIDTH;
}
tHead.disableBrowserIntelligence();
- if(firstvisible > 0)
+ if(firstvisible > 0) {
bodyContainer.setScrollPosition(firstvisible*tBody.getRowHeight());
+ firstRowInViewPort = firstvisible;
+ }
- DeferredCommand.add(new Command() {
+ DeferredCommand.addCommand(new Command() {
public void execute() {
if(totalRows - 1 > tBody.getLastRendered()) {
// fetch cache rows
client.console.log(""+firstRowInViewPort);
if(scrollPositionElement == null) {
scrollPositionElement = DOM.createDiv();
- DOM.setAttribute(scrollPositionElement, "className", "i-table-scrollposition");
+ DOM.setElementProperty(scrollPositionElement, "className", "i-table-scrollposition");
DOM.appendChild(RootPanel.get().getElement(), scrollPositionElement);
}
DOM.setStyleAttribute(scrollPositionElement, "left",
(
DOM.getAbsoluteLeft(getElement()) +
- DOM.getIntAttribute(getElement(), "offsetWidth")/2
+ DOM.getElementPropertyInt(getElement(), "offsetWidth")/2
- 75
) + "px");
DOM.setStyleAttribute(scrollPositionElement, "top",
public HeaderCell(String colId, String headerText) {
this.cid = colId;
- DOM.setAttribute(colResizeWidget, "className", CLASSNAME+"-resizer");
+ DOM.setElementProperty(colResizeWidget, "className", CLASSNAME+"-resizer");
DOM.setStyleAttribute(colResizeWidget, "width", DRAG_WIDGET_WIDTH +"px");
DOM.sinkEvents(colResizeWidget, Event.MOUSEEVENTS);
DOM.appendChild(td, colResizeWidget);
- DOM.setAttribute(captionContainer, "className", CLASSNAME+"-caption-container");
+ DOM.setElementProperty(captionContainer, "className", CLASSNAME+"-caption-container");
DOM.sinkEvents(captionContainer, Event.MOUSEEVENTS);
DOM.appendChild(td, captionContainer);
floatingCopyOfHeaderCell = DOM.getChild(floatingCopyOfHeaderCell, 1);
// TODO isolate non-standard css attribute (filter)
// TODO move styles to css file
- DOM.setAttribute(floatingCopyOfHeaderCell, "className", CLASSNAME+"-header-drag");
+ DOM.setElementProperty(floatingCopyOfHeaderCell, "className", CLASSNAME+"-header-drag");
updateFloatingCopysPosition(DOM.getAbsoluteLeft(td), DOM.getAbsoluteTop(td));
DOM.appendChild(RootPanel.get().getElement(), floatingCopyOfHeaderCell);
}
private void updateFloatingCopysPosition(int x, int y) {
- x -= DOM.getIntAttribute(floatingCopyOfHeaderCell, "offsetWidth")/2;
+ x -= DOM.getElementPropertyInt(floatingCopyOfHeaderCell, "offsetWidth")/2;
DOM.setStyleAttribute(floatingCopyOfHeaderCell, "left", x + "px");
if(y > 0)
DOM.setStyleAttribute(floatingCopyOfHeaderCell, "top", (y + 7) + "px");
public TableHead() {
DOM.setStyleAttribute(hTableWrapper, "overflow", "hidden");
- DOM.setAttribute(hTableWrapper, "className", CLASSNAME+"-header");
+ DOM.setElementProperty(hTableWrapper, "className", CLASSNAME+"-header");
// TODO move styles to CSS
- DOM.setAttribute(columnSelector, "className", CLASSNAME+"-column-selector");
+ DOM.setElementProperty(columnSelector, "className", CLASSNAME+"-column-selector");
DOM.setStyleAttribute(columnSelector, "display", "none");
DOM.appendChild(table, headerTableBody);
}
public void setHorizontalScrollPosition(int scrollLeft) {
- DOM.setIntAttribute(hTableWrapper, "scrollLeft", scrollLeft);
+ DOM.setElementPropertyInt(hTableWrapper, "scrollLeft", scrollLeft);
}
public void setWidth(int width) {
if(index < visibleCells.size()) {
// insert to right slot
DOM.insertChild(tr, cell.getElement(), index);
- adopt(cell, null);
+ adopt(cell);
visibleCells.insertElementAt(cell, index);
} else if( index == visibleCells.size()) {
//simply append
- adopt(cell, tr);
+ DOM.appendChild(tr, cell.getElement());
+ adopt(cell);
visibleCells.add(cell);
} else {
throw new RuntimeException("Header cells must be appended in order");
}
public boolean remove(Widget w) {
- disown(w);
if(visibleCells.contains(w)) {
visibleCells.remove(w);
return true;
}
+ orphan(w);
+ DOM.removeChild(DOM.getParent(w.getElement()), w.getElement());
return false;
}
private void focusSlot(int index) {
removeSlotFocus();
if(index > 0)
- DOM.setAttribute(
+ DOM.setElementProperty(
DOM.getFirstChild(DOM.getChild(tr, index - 1)),
"className", CLASSNAME+"-resizer "+CLASSNAME+"-focus-slot-right");
else
- DOM.setAttribute(
+ DOM.setElementProperty(
DOM.getFirstChild(DOM.getChild(tr, index)),
"className", CLASSNAME+"-resizer "+CLASSNAME+"-focus-slot-left");
focusedSlot = index;
if(focusedSlot < 0)
return;
if(focusedSlot == 0)
- DOM.setAttribute(
+ DOM.setElementProperty(
DOM.getFirstChild(DOM.getChild(tr, focusedSlot)),
"className", CLASSNAME+"-resizer");
else if( focusedSlot > 0)
- DOM.setAttribute(
+ DOM.setElementProperty(
DOM.getFirstChild(DOM.getChild(tr, focusedSlot - 1)),
"className", CLASSNAME+"-resizer");
focusedSlot = -1;
if(DOM.compare(DOM.eventGetTarget(event), columnSelector)) {
int left = DOM.getAbsoluteLeft(columnSelector);
int top = DOM.getAbsoluteTop(columnSelector) +
- DOM.getIntAttribute(columnSelector, "offsetHeight");
+ DOM.getElementPropertyInt(columnSelector, "offsetHeight");
client.getContextMenu().showAt(this, left, top);
}
}
}
private void constructDOM() {
- DOM.setAttribute(table, "className", CLASSNAME+"-table");
- DOM.setAttribute(preSpacer, "className", CLASSNAME+"-row-spacer");
- DOM.setAttribute(postSpacer, "className", CLASSNAME+"-row-spacer");
+ DOM.setElementProperty(table, "className", CLASSNAME+"-table");
+ DOM.setElementProperty(preSpacer, "className", CLASSNAME+"-row-spacer");
+ DOM.setElementProperty(postSpacer, "className", CLASSNAME+"-row-spacer");
DOM.appendChild(table, tBody);
DOM.appendChild(container, preSpacer);
if(first != null && first.getStyleName().indexOf("i-odd") == -1)
row.addStyleName("i-odd");
DOM.insertChild(tBody, row.getElement(), 0);
- adopt(row, null);
+ adopt(row);
renderedRows.add(0, row);
}
if(last != null && last.getStyleName().indexOf("i-odd") == -1)
row.addStyleName("i-odd");
DOM.appendChild(tBody, row.getElement());
- adopt(row, null);
+ adopt(row);
renderedRows.add(row);
}
lastRendered--;
}
IScrollTableRow toBeRemoved = (IScrollTableRow) renderedRows.get(index);
- this.disown(toBeRemoved);
+ DOM.removeChild(tBody, toBeRemoved.getElement());
+ this.orphan(toBeRemoved);
renderedRows.remove(index);
fixSpacers();
}
return rowHeight;
else {
if(DOM.getChildCount(tBody) > 0) {
- rowHeight = DOM.getIntAttribute(tBody, "offsetHeight")/DOM.getChildCount(tBody);
+ rowHeight = DOM.getElementPropertyInt(tBody, "offsetHeight")/DOM.getChildCount(tBody);
} else {
return DEFAULT_ROW_HEIGHT;
}
public int getColWidth(int i) {
Element e = DOM.getChild(DOM.getChild(tBody, 0), i);
- return DOM.getIntAttribute(e, "offsetWidth");
+ return DOM.getElementPropertyInt(e, "offsetWidth");
}
public void setColWidth(int colIndex, int w) {
// String only content is optimized by not using Label widget
Element td = DOM.createTD();
Element container = DOM.createDiv();
- DOM.setAttribute(container, "className", CLASSNAME+"-cell-content");
+ DOM.setElementProperty(container, "className", CLASSNAME+"-cell-content");
DOM.setInnerHTML(container, text);
if(align != ALIGN_LEFT) {
switch (align) {
public void addCell(Widget w, char align) {
Element td = DOM.createTD();
Element container = DOM.createDiv();
- DOM.setAttribute(container, "className", CLASSNAME+"-cell-content");
+ DOM.setElementProperty(container, "className", CLASSNAME+"-cell-content");
// TODO make widget cells respect align. text-align:center for IE, margin: auto for others
DOM.appendChild(td, container);
DOM.appendChild(getElement(), td);
- adopt(w, container);
+ DOM.appendChild(container, w.getElement());
+ adopt(w);
childWidgets.add(w);
}
* React on click that occur on content cells only
*/
public void onBrowserEvent(Event event) {
- String s = DOM.getAttribute(DOM.eventGetTarget(event), "className");
+ String s = DOM.getElementProperty(DOM.eventGetTarget(event), "className");
switch (DOM.eventGetType(event)) {
case Event.ONCLICK:
if((CLASSNAME+"-cell-content").equals(s)) {