List of usage examples for com.google.gwt.dom.client NodeList getItem
public T getItem(int index)
From source file:org.pentaho.mantle.client.ui.tabs.MantleTabPanel.java
License:Open Source License
public boolean existingTabMatchesName(String name) { // TODO: remove once a more elegant tab solution is in place // Must escape name before attempting to match it in HTML name = name.replaceAll("&", "&") //$NON-NLS-1$ //$NON-NLS-2$ .replaceAll(">", ">") //$NON-NLS-1$ //$NON-NLS-2$ .replaceAll("<", "<") //$NON-NLS-1$ //$NON-NLS-2$ .replaceAll("\"", """); //$NON-NLS-1$ //$NON-NLS-2$ String key = ">" + 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; }//from w w w. j a va 2 s . c o m } return false; }
From source file:org.pentaho.ui.xul.gwt.util.FrameCover.java
License:Open Source License
private void setFrameSize() { if (frameLid == null) { return;/* w w w . j a v a 2 s. c om*/ } // get all iFrames on the document NodeList<Element> iframes = Document.get().getElementsByTagName("iframe"); int top = Integer.MAX_VALUE; int left = Integer.MAX_VALUE; int width = 0; int height = 0; // determine the MAX bounds they encompass for (int i = 0; i < iframes.getLength(); i++) { Element iframe = iframes.getItem(i); if (iframe.getOffsetWidth() > 0 && iframe.getOffsetHeight() > 0) { top = Math.min(top, iframe.getAbsoluteTop()); left = Math.min(left, iframe.getAbsoluteLeft()); width = Math.max(width, iframe.getAbsoluteRight()); height = Math.max(height, iframe.getAbsoluteBottom()); } } // set the size/position of the frame cover to that max frameLid.getElement().getStyle().setLeft(left, Style.Unit.PX); frameLid.getElement().getStyle().setTop(top, Style.Unit.PX); frameLid.getElement().getStyle().setWidth(width, Style.Unit.PX); frameLid.getElement().getStyle().setHeight(height, Style.Unit.PX); }
From source file:org.roda.wui.client.main.Main.java
@Override public void onModuleLoad() { // Set uncaught exception handler ClientLogger.setUncaughtExceptionHandler(); // Remove loading image RootPanel.getBodyElement().removeChild(DOM.getElementById("loading")); NodeList<Element> bodyChilds = RootPanel.getBodyElement().getElementsByTagName("iframe"); for (int i = 0; i < bodyChilds.getLength(); i++) { Element bodyChild = bodyChilds.getItem(i); if (!bodyChild.hasAttribute("title")) { bodyChild.setAttribute("title", "iframe_title"); }//from w w w. j ava2 s. c om } // Add main widget to root panel RootPanel.get().add(this); RootPanel.get().add(footer); RootPanel.get().addStyleName("roda"); // deferred call to init Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { DescriptionLevelUtils.load(new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { logger.error("Failed loading initial data", caught); } @Override public void onSuccess(Void result) { init(); } }); } }); BrowserService.Util.getInstance().isCookiesMessageActive(new AsyncCallback<Boolean>() { @Override public void onSuccess(Boolean result) { if (result) { JavascriptUtils.setCookieOptions(messages.cookiesMessage(), messages.cookiesDismisse(), messages.cookiesLearnMore(), "#" + Theme.RESOLVER.getHistoryToken() + "/CookiesPolicy.html"); } } @Override public void onFailure(Throwable caught) { logger.error("Error checking if cookies message is active!!", caught); } }); }
From source file:org.rstudio.core.client.dom.DomUtils.java
License:Open Source License
private static int trimLines(NodeList<Node> nodes, final int linesToTrim) { if (nodes == null || nodes.getLength() == 0 || linesToTrim == 0) return 0; int linesLeft = linesToTrim; Node node = nodes.getItem(0); while (node != null && linesLeft > 0) { switch (node.getNodeType()) { case Node.ELEMENT_NODE: if (((Element) node).getTagName().equalsIgnoreCase("br")) { linesLeft--;//from w w w. j a v a 2 s . c o m node = removeAndGetNext(node); continue; } else { int trimmed = trimLines(node.getChildNodes(), linesLeft); linesLeft -= trimmed; if (!node.hasChildNodes()) node = removeAndGetNext(node); continue; } case Node.TEXT_NODE: String text = ((Text) node).getData(); Match lastMatch = null; Match match = NEWLINE.match(text, 0); while (match != null && linesLeft > 0) { lastMatch = match; linesLeft--; match = match.nextMatch(); } if (linesLeft > 0 || lastMatch == null) { node = removeAndGetNext(node); continue; } else { int index = lastMatch.getIndex() + 1; if (text.length() == index) node.removeFromParent(); else ((Text) node).deleteData(0, index); break; } } } return linesToTrim - linesLeft; }
From source file:org.rstudio.core.client.dom.DomUtils.java
License:Open Source License
private static int countLinesInternal(Element elementNode, boolean pre) { if (elementNode.getTagName().equalsIgnoreCase("br")) return 1; int result = 0; NodeList<Node> children = elementNode.getChildNodes(); for (int i = 0; i < children.getLength(); i++) result += countLines(children.getItem(i), pre); return result; }
From source file:org.rstudio.core.client.dom.impl.NodeRelativePosition.java
License:Open Source License
private static boolean toOffsetHelper(Node here, NodeRelativePosition target, int[] counter) { if (target.node.equals(here)) { switch (here.getNodeType()) { case Node.TEXT_NODE: counter[0] += target.offset; return true; case Node.ELEMENT_NODE: NodeList<Node> children = here.getChildNodes(); for (int i = 0; i < target.offset; i++) toOffsetHelper(children.getItem(i), target, counter); return true; default:/*from w ww . ja v a 2 s .c o m*/ Debug.log("Unexpected node type for selection offset: " + here.getNodeType()); return false; } } else { if (here.getNodeType() == Node.TEXT_NODE) { counter[0] += ((Text) here).getLength(); return false; } else if (here.getNodeType() == Node.ELEMENT_NODE) { Element el = (Element) here; String tag = el.getTagName().toLowerCase(); if (tag.equals("br")) { counter[0] += 1; return false; } if (tag.equals("script") || tag.equals("style")) return false; // Otherwise continue to iteration code below } NodeList<Node> children = here.getChildNodes(); for (int i = 0; i < children.getLength(); i++) if (toOffsetHelper(children.getItem(i), target, counter)) return true; return false; } }
From source file:org.rstudio.core.client.dom.impl.NodeRelativePosition.java
License:Open Source License
private static NodeRelativePosition toPositionHelper(Node here, int[] counter) { switch (here.getNodeType()) { case Node.TEXT_NODE: Text text = (Text) here; if (counter[0] <= text.getLength()) return new NodeRelativePosition(here, counter[0]); counter[0] -= text.getLength();/*w w w .j a va 2 s. c om*/ return null; case Node.ELEMENT_NODE: Element el = (Element) here; String tagName = el.getTagName().toLowerCase(); if (tagName.equals("br")) { if (counter[0] <= 0) return new NodeRelativePosition(here, 0); counter[0] -= 1; return null; } else if (tagName.equals("script") || tagName.equals("style")) return null; break; } NodeList<Node> children = here.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { NodeRelativePosition result = toPositionHelper(children.getItem(i), counter); if (result != null) return result; } return null; }
From source file:org.rstudio.core.client.widget.FastSelectTable.java
License:Open Source License
public void removeTopRows(int rowCount) { if (rowCount <= 0) return;//w ww . java 2 s . c om NodeList<TableSectionElement> tBodies = table_.getTBodies(); for (int i = 0; i < tBodies.getLength(); i++) { rowCount = removeTopRows(tBodies.getItem(i), rowCount); if (rowCount == 0) return; } }
From source file:org.rstudio.core.client.widget.FastSelectTable.java
License:Open Source License
public boolean moveSelectionUp() { if (selectedRows_.size() == 0) return false; sortSelectedRows();//from w ww . jav a2 s . com int top = selectedRows_.get(0).getRowIndex(); NodeList<TableRowElement> rows = table_.getRows(); TableRowElement rowToSelect = null; while (--top >= 0) { TableRowElement row = rows.getItem(top); if (codec_.isValueRow(row)) { rowToSelect = row; break; } } if (rowToSelect == null) return false; clearSelection(); setSelected(rowToSelect, true); return true; }
From source file:org.rstudio.core.client.widget.FastSelectTable.java
License:Open Source License
public boolean moveSelectionDown() { if (selectedRows_.size() == 0) return false; sortSelectedRows();//w ww .j a v a 2 s. c o m int bottom = selectedRows_.get(selectedRows_.size() - 1).getRowIndex(); NodeList<TableRowElement> rows = table_.getRows(); TableRowElement rowToSelect = null; while (++bottom < rows.getLength()) { TableRowElement row = rows.getItem(bottom); if (codec_.isValueRow(row)) { rowToSelect = row; break; } } if (rowToSelect == null) return false; clearSelection(); setSelected(rowToSelect, true); return true; }