Example usage for com.google.gwt.dom.client NodeList getItem

List of usage examples for com.google.gwt.dom.client NodeList getItem

Introduction

In this page you can find the example usage for com.google.gwt.dom.client NodeList getItem.

Prototype

public T getItem(int index) 

Source Link

Usage

From source file:org.overlord.commons.gwt.client.local.widgets.TemplatedWidgetTable.java

License:Apache License

/**
 * Removes all child nodes from the given element.
 *//*from  w  w w  .j a  v a2s. c om*/
protected void removeAllChildNodes(Node elem) {
    NodeList<Node> childNodes = elem.getChildNodes();
    for (int i = childNodes.getLength() - 1; i >= 0; i--) {
        elem.removeChild(childNodes.getItem(i));
    }
}

From source file:org.overlord.commons.gwt.client.local.widgets.WidgetTable.java

License:Apache License

/**
 * Remove a single row and all its widgets from the table
 *
 * @param rowIndex which row to add to (0 based, excluding thead)
 *//*from   www  .  j  av  a  2 s  .com*/
public void deleteRow(int rowIndex) {
    Element rowElem = rowElements.get(rowIndex);
    NodeList<Node> tds = rowElem.getChildNodes();
    for (int i = 0; i < tds.getLength(); i++) {
        Element td = tds.getItem(i).cast();
        for (Widget widget : wrapperMap.keySet()) {
            if (wrapperMap.get(widget).equals(td)) {
                remove(widget);
                break;
            }
        }
    }
    this.tbody.removeChild(rowElem);
    rowElements.remove(rowIndex);
}

From source file:org.overlord.commons.gwt.client.local.widgets.WidgetTable.java

License:Apache License

/**
 * Ensures that a row at the given index exists.
 * @param rowIndex//from  ww  w  .ja va 2  s.c  om
 */
private Element ensureRow(int rowIndex) {
    NodeList<Node> childNodes = this.tbody.getChildNodes();
    int numTRs = childNodes.getLength();
    if (rowIndex < numTRs) {
        return childNodes.getItem(rowIndex).cast();
    }
    Element tr = null;
    for (int r = numTRs; r <= rowIndex; r++) {
        tr = Document.get().createTRElement().cast();
        DOM.appendChild(this.tbody, tr);
        this.rowElements.add(tr);
    }
    return tr;
}

From source file:org.overlord.commons.gwt.client.local.widgets.WidgetTable.java

License:Apache License

/**
 * Ensure that a td cell exists for the row at the given column
 * index.//from   ww  w  .  ja va2s . c  o  m
 * @param tr the row
 * @param colIndex the column index (0 based)
 * @return the new or already existing td
 */
private Element ensureCell(Element tr, int colIndex) {
    NodeList<Node> tds = tr.getChildNodes();
    int numTDs = tds.getLength();
    if (colIndex < numTDs) {
        return tds.getItem(colIndex).cast();
    }
    Element td = null;
    for (int c = numTDs; c <= colIndex; c++) {
        td = Document.get().createTDElement().cast();
        if (this.columnClasses.containsKey(colIndex)) {
            td.setAttribute("class", this.columnClasses.get(colIndex)); //$NON-NLS-1$
        }
        DOM.appendChild(tr, td);
    }
    return td;
}

From source file:org.overlord.dtgov.ui.client.local.util.DOMUtil.java

License:Apache License

/**
 * Gets an element from the given parent element by ID.
 * @param context//from   w w w  .j  a v a2  s.co m
 * @param id
 */
public static Element findElementById(Element context, String id) {
    NodeList<Node> nodes = context.getChildNodes();
    for (int i = 0; i < nodes.getLength(); i++) {
        Node node = nodes.getItem(i);
        if (((node.getNodeType() == Node.ELEMENT_NODE))) {
            if (id.equals(((Element) node).getAttribute("id"))) { //$NON-NLS-1$
                return (Element) node;
            } else {
                Element elem = findElementById((Element) node, id);
                if (elem != null) {
                    return elem;
                }
            }
        }
    }
    return null;
}

From source file:org.ow2.proactive_grid_cloud_portal.scheduler.client.VisualizationViewHtml.java

License:Open Source License

@Override
public void htmlUpdated(String jobId, String html) {
    showHtml();/*w w  w  .j a v a2s .  c  om*/
    htmlPanel.setHTML(html);

    String width = extractCss(html, "width");
    String height = extractCss(html, "height");
    wrapper.setSize(width, height);

    task2Dom = new HashMap<String, Element>();
    NodeList<Element> elements = htmlPanel.getElement().getElementsByTagName("div");
    if (elements != null) {
        for (int i = 0; i < elements.getLength(); i++) {
            Element elem = elements.getItem(i);
            if (elem.getClassName().contains("task")) {
                // task div - finding it's name
                String taskName = elem.getInnerText();
                taskName = taskName.replaceAll("&nbsp", " ");
                taskName = taskName.replaceAll(String.valueOf((char) 160), " ");
                taskName = taskName.trim();
                task2Dom.put(taskName, elem);
            }
        }
    }

    tasksUpdated(currentTasks, currentTasks.size());
}

From source file:org.pentaho.gwt.widgets.client.utils.ElementUtils.java

License:Open Source License

public static void killAutoScrolling(Element ele) {
    ele.getStyle().setProperty("overflow", "visible"); //$NON-NLS-1$ //$NON-NLS-2$
    if (ele.hasChildNodes()) {

        NodeList<Node> nodes = ele.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            Node n = nodes.getItem(i);
            if (n instanceof Element) {
                killAutoScrolling((Element) n);
            }//from w w  w  .j  av a2  s .  co  m
        }
    }
}

From source file:org.pentaho.gwt.widgets.client.utils.ElementUtils.java

License:Open Source License

public static void killAllTextSelection(com.google.gwt.dom.client.Element item) {
    ElementUtils.preventTextSelection(item);
    com.google.gwt.dom.client.NodeList<Node> children = item.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        killAllTextSelection((com.google.gwt.dom.client.Element) children.getItem(i));
    }//from  w  w w .jav a  2s.c o m
}

From source file:org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPerspective.java

License:Open Source License

private void buildUI() {
    FlowPanel topPanel = new FlowPanel();
    SimplePanel toolbarWrapper = new SimplePanel();
    toolbarWrapper.setWidget(new BrowserToolbar());
    toolbarWrapper.setStyleName("files-toolbar"); //$NON-NLS-1$
    topPanel.add(toolbarWrapper);//from ww w .j  av a 2s  .c o m
    topPanel.add(new SolutionTreeWrapper(solutionTree));

    solutionNavigatorPanel.setStyleName("puc-vertical-split-panel");
    solutionNavigatorPanel.setHeight("100%"); //$NON-NLS-1$
    solutionNavigatorPanel.setTopWidget(topPanel);
    solutionNavigatorPanel.setBottomWidget(filesListPanel);

    /* BISERVER-6181 - - add padding to bottom of file list panel.
       add a css class to allow us to override inline styles to add the padding
    */
    filesListPanel.getElement().getParentElement().addClassName("filter-list-panel-container");

    solutionNavigatorPanel.setSplitPosition("60%"); //$NON-NLS-1$
    solutionNavigatorAndContentPanel.setStyleName("puc-horizontal-split-panel");
    solutionNavigatorAndContentPanel.setLeftWidget(solutionNavigatorPanel);
    solutionNavigatorAndContentPanel.setRightWidget(contentPanel);
    solutionNavigatorAndContentPanel.getElement().setAttribute("id", "solutionNavigatorAndContentPanel");

    @SuppressWarnings("rawtypes")
    NodeList possibleChildren = solutionNavigatorAndContentPanel.getElement().getElementsByTagName("table");
    for (int i = 0; i < possibleChildren.getLength(); i++) {
        Node child = possibleChildren.getItem(i);
        if (child instanceof Element) {
            Element elementChild = (Element) child;
            if (elementChild.getClassName().equalsIgnoreCase("hsplitter")) {
                elementChild.setAttribute("id", "pucHorizontalSplitter");
                elementChild.addClassName("pentaho-rounded-panel-top-right");
                elementChild.addClassName("pentaho-shadow-right-side");
                break;
            }
        }
    }

    possibleChildren = solutionNavigatorPanel.getElement().getElementsByTagName("div");
    for (int i = 0; i < possibleChildren.getLength(); i++) {
        Node child = possibleChildren.getItem(i);
        if (child instanceof Element) {
            Element elementChild = (Element) child;
            if (elementChild.getClassName().equalsIgnoreCase("vsplitter")) {
                elementChild.setAttribute("id", "pucVerticalSplitter");
                pucVerticalSplitterImg = ((Element) elementChild.getChild(0)).getStyle().getBackgroundImage();
                break;
            }
        }
    }

    solutionNavigatorPanel.getElement().getParentElement().addClassName("puc-navigator-panel");
    solutionNavigatorPanel.getElement().getParentElement().removeAttribute("style");

    workspacePanel = new WorkspacePanel(isAdministrator);
    contentPanel.setAnimationEnabled(false);
    contentPanel.add(workspacePanel);
    contentPanel.add(launchPanel);
    contentPanel.add(contentTabPanel);
    if (showSolutionBrowser) {
        solutionNavigatorAndContentPanel.setSplitPosition(defaultSplitPosition);
    } else {
        solutionNavigatorAndContentPanel.setSplitPosition("0px"); //$NON-NLS-1$
        solutionNavigatorPanel.setVisible(false);
    }
    contentPanel.setHeight("100%"); //$NON-NLS-1$
    contentPanel.setWidth("100%"); //$NON-NLS-1$
    contentPanel.getElement().setId("contentDeck");
    contentPanel.getElement().getParentElement().setClassName("pucContentDeck");
    contentPanel.getElement().getParentElement().getStyle().clearBorderWidth();
    contentPanel.getElement().getParentElement().getStyle().clearBorderStyle();
    contentPanel.getElement().getParentElement().getStyle().clearBorderColor();
    contentPanel.getElement().getParentElement().getStyle().clearMargin();

    setStyleName("panelWithTitledToolbar"); //$NON-NLS-1$  
    setHeight("100%"); //$NON-NLS-1$
    setWidth("100%"); //$NON-NLS-1$
    add(solutionNavigatorAndContentPanel);

    sinkEvents(Event.MOUSEEVENTS);

    showContent();
    ElementUtils.removeScrollingFromSplitPane(solutionNavigatorPanel);
    ElementUtils.removeScrollingFromUpTo(solutionNavigatorAndContentPanel.getLeftWidget().getElement(),
            solutionNavigatorAndContentPanel.getElement());

    // BISERVER-6208 Files List panel behaves badly in Safari
    if (Window.Navigator.getUserAgent().toLowerCase().indexOf("webkit") != -1) {
        Timer t = new Timer() {
            public void run() {
                String left = DOM.getElementById("pucHorizontalSplitter").getParentElement().getStyle()
                        .getLeft();
                if (left.indexOf("px") != -1) {
                    left = left.substring(0, left.indexOf("px"));
                }
                int leftInt = Integer.parseInt(left);
                if (leftInt <= 0) {
                    setNavigatorShowing(false);
                }
            }
        };
        t.scheduleRepeating(1000);
    }
}

From source file:org.pentaho.mantle.client.solutionbrowser.tabs.MantleTabPanel.java

License:Open Source License

public boolean existingTabMatchesName(String name) {
    String key = "title=\"" + name + "\""; //$NON-NLS-1$ //$NON-NLS-2$

    NodeList<com.google.gwt.dom.client.Element> divs = getTabBar().getElement().getElementsByTagName("div"); //$NON-NLS-1$

    for (int i = 0; i < divs.getLength(); i++) {
        String tabHtml = divs.getItem(i).getInnerHTML();
        // TODO: remove once a more elegant tab solution is in place
        if (tabHtml.indexOf(key) > -1) {
            return true;
        }/*w  w w  .  j ava  2  s . c o m*/
    }
    return false;
}