All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.gwt.test.internal.patchers.dom.TableRowElementPatcher Maven / Gradle / Ivy

There is a newer version: 0.63
Show newest version
package com.googlecode.gwt.test.internal.patchers.dom;

import com.google.gwt.dom.client.*;
import com.googlecode.gwt.test.internal.utils.JsoUtils;
import com.googlecode.gwt.test.patchers.PatchClass;
import com.googlecode.gwt.test.patchers.PatchMethod;

import java.util.List;

@PatchClass(TableRowElement.class)
class TableRowElementPatcher {

    @PatchMethod
    static void deleteCell(TableRowElement element, int index) {

        List innerList = JsoUtils.getChildNodeInnerList(element);

        if (index == -1 || index >= innerList.size()) {
            index = innerList.size() - 1;

        }

        innerList.remove(index);
    }

    @PatchMethod
    static NodeList getCells(TableRowElement element) {
        return element.getChildNodes().>cast();
    }

    @PatchMethod
    static int getSectionRowIndex(TableRowElement element) {
        if (element == null) {
            return -1;
        }
        Element parent = element.getParentElement();
        if (parent == null) {
            return -1;
        }

        for (int i = 0; i < parent.getChildNodes().getLength(); i++) {
            if (element.equals(parent.getChildNodes().getItem(i))) {
                return i;
            }
        }

        return -1;

    }

    @PatchMethod
    static TableCellElement insertCell(TableRowElement element, int index) {

        List innerList = JsoUtils.getChildNodeInnerList(element);
        TableCellElement newCell = Document.get().createTDElement();

        if (index == -1 || index >= element.getCells().getLength()) {
            innerList.add(newCell);
        } else {
            innerList.add(index, newCell);
        }

        return newCell;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy