List of usage examples for com.google.gwt.dom.client NodeList getLength
public int getLength()
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 . com * @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();/*from ww w . java 2 s . c o m*/ 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(" ", " "); 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 a v a 2 s . com } } }
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 ww w . j ava2 s . c om }
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 w w w . j a v a2s .c om 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; }//from w ww . j av a2 s . c om } return false; }
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; }/* w w w . j a va 2 s .com*/ } return false; }
From source file:org.pentaho.ui.xul.gwt.util.FrameCover.java
License:Open Source License
private void setFrameSize() { if (frameLid == null) { return;/*from ww w . ja v a 2 s. c o m*/ } // 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"); }/* ww w .j a v a2 s .com*/ } // 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 www . j a va2s.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; }