List of usage examples for com.google.gwt.user.client Element getAttribute
@Override
public String getAttribute(String name)
From source file:ch.unifr.pai.twice.widgets.mpproxy.client.MPProxyBody.java
License:Apache License
/** * Replace all textboxes with multi focus text boxes * //w w w . j av a 2s .c o m * @param mainElement */ private void replaceAllTextBoxes(Element mainElement) { NodeList<com.google.gwt.dom.client.Element> inputFields = mainElement.getElementsByTagName("input"); for (int i = 0; i < inputFields.getLength(); i++) { final com.google.gwt.dom.client.Element el = inputFields.getItem(i); String type = el.getAttribute("type"); if (type == null || type.isEmpty() || type.equalsIgnoreCase("text")) { MultiFocusTextBox box = new MultiFocusTextBox(); box.replaceTextInput(InputElement.as(el)); replacements.add(box); // Scheduler.get().scheduleDeferred(new ScheduledCommand() { // // @Override // public void execute() { // el.getStyle().setDisplay(Display.NONE); // } // }); } } }
From source file:ch.unifr.pai.twice.widgets.mpproxy.client.MPProxyBody.java
License:Apache License
/** * @param e/*from w w w. j av a2 s . co m*/ * @return a textbox or textarea widget if the element is one of those, otherwise null */ private TextBoxBase getTextBoxBase(Element e) { if (e.getTagName().equalsIgnoreCase("input") && (e.getAttribute("type") == null || e.getAttribute("type").isEmpty() || e.getAttribute("type").equalsIgnoreCase("text"))) return TextBox.wrap(e); else if (e.getTagName().equalsIgnoreCase("textarea")) return TextArea.wrap(e); return null; }
From source file:ch.unifr.pai.twice.widgets.mpproxy.client.ProxyBody.java
License:Apache License
/** * Client side logic to rewrite a given URL * //from www .j a v a 2 s .c om * @param element * @param servletPath * @param proxyPath */ public static void rewriteUrl(com.google.gwt.dom.client.Element element, String servletPath, String proxyPath) { NodeList<Node> nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node n = nodes.getItem(i); if (com.google.gwt.dom.client.Element.is(n)) { com.google.gwt.dom.client.Element e = com.google.gwt.dom.client.Element.as(n); if (e != null && e.getTagName() != null && e.getTagName().equalsIgnoreCase("a")) { AnchorElement anchor = AnchorElement.as(e); if (anchor.getHref() != null && !anchor.getHref().isEmpty()) anchor.removeAttribute("onmousedown"); } for (String att : attributesToManipulate) { String value = e.getAttribute(att); if (value != null && !value.startsWith(servletPath) && value.matches("((http)|/).*")) { String transformed = Rewriter.translateCleanUrl(value, servletPath, proxyPath); if (!transformed.equals(value)) e.setAttribute(att, transformed); } } rewriteUrl(e, servletPath, proxyPath); } } }
From source file:ch.unifr.pai.twice.widgets.mptransparentproxy.client.MPProxyBody.java
License:Apache License
/** * Replace all textboxes with multi focus text boxes * /*ww w. ja va 2 s.c o m*/ * @param mainElement */ private void replaceAllTextBoxes(Element mainElement) { NodeList<com.google.gwt.dom.client.Element> inputFields = mainElement.getElementsByTagName("input"); for (int i = 0; i < inputFields.getLength(); i++) { final com.google.gwt.dom.client.Element el = inputFields.getItem(i); String type = el.getAttribute("type"); if (type == null || type.isEmpty() || type.equalsIgnoreCase("text") || type.equalsIgnoreCase("search")) { MultiFocusTextBox box = new MultiFocusTextBox(); box.replaceTextInput(InputElement.as(el)); replacements.add(box); } } }
From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java
License:Apache License
/** @Returns a list of IDs that get put into the template */ public static Vector<String> inject(String elementName, String token, Widget w, boolean inFront) { boolean incrementIDCounter = false; Vector<String> convertedIDs = new Vector<String>(); Vector<Element> nodeTree = new Vector<Element>(); String elementID;/*from w w w .j a va 2 s . co m*/ Element e; int indexOfToken = -1; nodeTree.add(w.getElement()); while (nodeTree.size() > 0) { e = nodeTree.remove(0); for (int x = 0; x < e.getChildCount(); x++) { if (e.getChild(x).getNodeType() == Node.ELEMENT_NODE) nodeTree.add((Element) e.getChild(x)); } elementID = e.getId(); if (elementID != null) indexOfToken = elementID.indexOf(token); if (indexOfToken != -1) { incrementIDCounter = true; e.setId(elementID.substring(0, indexOfToken) + iDCounter + elementID.substring(indexOfToken + token.length())); convertedIDs.add(e.getId()); } else if (e.getId() != "") convertedIDs.add(e.getId()); // Also update the "for" attribute so that checkbox and radio button labels will behave correctly elementID = e.getAttribute("for"); if (elementID != null) indexOfToken = elementID.indexOf(token); if (indexOfToken != -1) { e.setAttribute("for", elementID.substring(0, indexOfToken) + iDCounter + elementID.substring(indexOfToken + token.length())); } } if (incrementIDCounter) iDCounter++; RootPanel.get(elementName).remove(w); if (inFront) RootPanel.get(elementName).insert(w, 0); else RootPanel.get(elementName).add(w); return convertedIDs; }
From source file:com.emitrom.gwt4.touch2.demo.client.core.CSS.java
License:Open Source License
/** * Adds a stylesheet to the document. /*from w ww . ja v a 2 s. c om*/ * * @param id the id * @param url the stylesheet url */ public static void addStyleSheet(String id, String url) { Element link = DOM.createElement("link"); link.setPropertyString("rel", "stylesheet"); link.setPropertyString("type", "text/css"); link.setPropertyString("id", id); link.setPropertyString("href", url); link.setPropertyString("disabled", ""); Element elem = getHeadElement(); Element all = null; for (int i = 0; i < elem.getChildNodes().getLength(); i++) { Node node = elem.getChildNodes().getItem(i).cast(); if (node instanceof Element) { Element child = (Element) node; String tag = child.getTagName(); if (tag != null && child.getTagName().equalsIgnoreCase("link")) { String href = child.getAttribute("href"); if (href.length() != 0 && href.indexOf("gxt-all.css") != -1) { all = child; break; } } } } if (all != null) { int idx = DOM.getChildIndex(elem, all); DOM.insertChild(elem, link, idx + 1); } else { DOM.appendChild(elem, link); } }
From source file:com.extjs.gxt.ui.client.util.CSS.java
License:sencha.com license
/** * Adds a stylesheet to the document./*ww w. j a va 2s . c o m*/ * * @param id the id * @param url the stylesheet url */ public static void addStyleSheet(String id, String url) { Element link = DOM.createElement("link"); link.setPropertyString("rel", "stylesheet"); link.setPropertyString("type", "text/css"); link.setPropertyString("id", id); link.setPropertyString("href", url); link.setPropertyString("disabled", ""); Element elem = XDOM.getHead(); Element all = null; for (int i = 0; i < elem.getChildNodes().getLength(); i++) { Node node = elem.getChildNodes().getItem(i).cast(); if (node instanceof Element) { Element child = (Element) node; String tag = child.getTagName(); if (tag != null && child.getTagName().equalsIgnoreCase("link")) { String href = child.getAttribute("href"); if (href.length() != 0 && href.indexOf("gxt-all.css") != -1) { all = child; break; } } } } if (all != null) { int idx = DOM.getChildIndex(elem, all); DOM.insertChild(elem, link, idx + 1); } else { DOM.appendChild(elem, link); } }
From source file:com.extjs.gxt.ui.client.widget.ColorPalette.java
License:sencha.com license
protected void onKeyDown(ComponentEvent ce) { if (value != null) { Element a = el().child("a.color-" + getValue()).dom; int row = Integer.valueOf(a.getAttribute("row")); if (row < (rowCount - 1)) { int idx = indexOf(elements, a); idx = idx + columnCount;/*from w w w. j av a 2 s . co m*/ if (idx >= 0 && idx < elements.getLength()) { a = elements.getItem(idx); String color = getColorFromElement(a); select(color, true); } } } else { select(getColorFromElement(elements.getItem(0)), true); } }
From source file:com.extjs.gxt.ui.client.widget.ColorPalette.java
License:sencha.com license
protected void onKeyLeft(ComponentEvent ce) { if (value != null) { Element a = el().child("a.color-" + getValue()).dom; int col = Integer.valueOf(a.getAttribute("col")); if (col == 0) { return; }// w ww. ja v a 2 s.c o m int idx = indexOf(elements, a); if (idx > 0 && idx < elements.getLength()) { a = elements.getItem(idx - 1); String color = getColorFromElement(a); select(color, true); } } }
From source file:com.extjs.gxt.ui.client.widget.ColorPalette.java
License:sencha.com license
protected void onKeyRight(ComponentEvent ce) { if (value != null) { Element a = el().child("a.color-" + getValue()).dom; int col = Integer.valueOf(a.getAttribute("col")); if (col == 7) { return; }/* w w w .j a v a 2 s. c o m*/ int idx = indexOf(elements, a); if (idx < elements.getLength() - 1) { a = elements.getItem(idx + 1); String color = getColorFromElement(a); select(color, true); } } else { select(getColorFromElement(elements.getItem(0)), true); } }