List of usage examples for com.google.gwt.user.client Element getNodeName
@Override
public String getNodeName()
From source file:asquare.gwt.tk.client.util.DomUtil.java
License:Apache License
/** * Get the DOM nodeName of the specified element. * //from w w w . j a va 2s .c om * @param element * @return the node name upper case, e.g. "TD" */ public static String getElementName(Element element) { return element.getNodeName(); }
From source file:org.adamtacy.client.ui.effects.impl.Resize.java
License:Apache License
private void createInternalEffectsPerElement(Element currEl) { NodeList<Node> nodes = currEl.getChildNodes(); if (nodes != null) { for (int i = 0; i < nodes.getLength(); i++) { Node n = nodes.getItem(i); if (n.getNodeType() == Node.ELEMENT_NODE) { createInternalEffectsPerElement((Element) nodes.getItem(i)); }/*from w w w. j a v a 2s.c om*/ } } Vector<ChangeInterface> temp = new Vector<ChangeInterface>(); String name = currEl.getNodeName(); if (triggerDOM.contains(name)) { GWT.log("Resize Effect is Processing: " + name, null); int startVal; int endVal; // Deal with Widths startVal = getStartWidth(currEl); endVal = getEndWidth(currEl); if (startVal != endVal) { NChangeScalarAction theWidthChange = new NChangeScalarAction(startVal + "px", endVal + "px"); temp.add(theWidthChange); theWidthChange.setUp(currEl, "width", 0); } // Deal with Heights startVal = getStartHeight(currEl); endVal = getEndHeight(currEl); if (startVal != endVal) { NChangeScalarAction theHeightChange = new NChangeScalarAction(startVal + "px", endVal + "px"); temp.add(theHeightChange); theHeightChange.setUp(currEl, "height", 0); } // Deal with Fonts String res = StyleImplementation.getComputedStyle(currEl, "fontSize"); if (res != null) { // We have a font to play with String unit = StyleImplementation.getUnits(res); double value = -1; if (unit == null || unit.equals("")) { // Assume we're dealing with a named font-size, as there are no units // so, find where this name is in our vector of font size names int scale = fontSizes.indexOf(res); // If we found it, calculate the font size if (scale > -1) { value = (double) Math .round(Math.pow(fontSizeScalingFactor, (scale - standardIndex)) * standardFontSize); unit = standardFontUnit; } } else { // Not a named font-size, so get the value value = (new Double(StyleImplementation.getValue(res, unit))).doubleValue(); } if (value > -1) { NChangeScalarAction theFontChange = new NChangeScalarAction((int) (value * startXRatio) + unit, (int) (value * endXRatio) + unit); theFontChange.setUp(currEl, "fontSize", 0); temp.add(theFontChange); } else { GWT.log("Don't know what to do with this font-size definition: " + res, null); } } // Do we need to manage bounding box aspects, e.g. margin etc? if (managesMargin) temp.addAll(getBoxChanges("margin", currEl)); if (managesBorder) temp.addAll(getBoxChanges("border", currEl)); if (managesPadding) temp.addAll(getBoxChanges("padding", currEl)); // Put all ChangeInterfaces together into the determinedEffects object for future management determinedEffects.put(currEl, temp); } else { GWT.log("Resize Effect is Not Processing: " + name, null); } temp = null; }
From source file:org.bonitasoft.forms.client.view.common.DOMUtils.java
License:Open Source License
protected Element getHeadElement() { Element headElement = null;//from w w w. j a v a 2 s. com final Element documentElement = DOM.getParent(RootPanel.getBodyElement()); final int documentChildrenCount = DOM.getChildCount(documentElement); for (int i = 0; i < documentChildrenCount; i++) { final Element documentChildElement = DOM.getChild(documentElement, i); if ("head".equalsIgnoreCase(documentChildElement.getNodeName())) { headElement = documentChildElement; break; } } return headElement; }
From source file:org.geomajas.gwt.client.util.impl.DomImpl.java
License:Open Source License
/** * Clone a single SVG element./*ww w. ja va 2s. c o m*/ * * @param source The source SVG element. * @return Returns the clone. */ public Element cloneSvgElement(Element source) { if (source == null || source.getNodeName() == null) { return null; } if ("#text".equals(source.getNodeName())) { return Document.get().createTextNode(source.getNodeValue()).cast(); } Element clone = createElementNS(Dom.NS_SVG, source.getNodeName(), Dom.createUniqueId()); cloneAttributes(source, clone); for (int i = 0; i < source.getChildCount(); i++) { Element child = source.getChild(i).cast(); clone.appendChild(cloneSvgElement(child)); } return clone; }
From source file:org.geomajas.gwt2.client.gfx.VectorTileObject.java
License:Open Source License
/** * Clone a single SVG element.// w ww . j a v a 2s .co m * * @param source * The source SVG element. * @return Returns the clone. */ private static Element clone(Element source) { if (source == null || source.getNodeName() == null) { return null; } if ("#text".equals(source.getNodeName())) { return Document.get().createTextNode(source.getNodeValue()).cast(); } Element clone = createElementNS(Dom.NS_SVG, source.getNodeName()); cloneAttributes(source, clone); for (int i = 0; i < source.getChildCount(); i++) { Element child = source.getChild(i).cast(); clone.appendChild(clone(child)); } return clone; }
From source file:org.jahia.ajax.gwt.client.widget.edit.mainarea.ModuleHelper.java
License:Open Source License
public static List<Element> getAllLinks(Element parent) { List<Element> list = new ArrayList<Element>(); int nb = DOM.getChildCount(parent); if (parent.getNodeName().toUpperCase().equals("A")) { try {/* w ww.j av a2 s.com*/ String link = DOM.getElementAttribute(parent, "href"); if (link != null && link.length() > 0) { list.add(parent); } } catch (Exception e) { if (e != null) { Log.error(e.getMessage(), e); } } } for (int i = 0; i < nb; i++) { list.addAll(getAllLinks(DOM.getChild(parent, i))); } return list; }
From source file:sf.wicklet.gwt.site.home.client.WickletGwtSiteHome.java
License:Apache License
void wikiCommentPanel(final String href, final String html) { new GwtBuilder() { void build() { final IGwtComplexPanel top = templatepanel(html); final ComplexPanel rightpanel = rightPanel.asPanel(); rightpanel.add(top);/*from w w w. j av a 2s. co m*/ final DomCache cache = new DomCache(top.asPanel().getElement(), "id", "name"); final Element form = cache.byId(WID.commentForm); final UrlParts formaction = UrlParts.parse(form.getAttribute("action")); final IGwtTextBox subject = textbox(cache.by("name", WID.commentSubject).get(0)); final IGwtTextArea comment = textarea(cache.by("name", WID.commentText).get(0)); final IGwtTextBox captcha = textbox(cache.by("name", WID.commentCaptchaText).get(0)); final FocusHandler clearmsg = new FocusHandler() { @Override public void onFocus(final FocusEvent event) { GwtDomUtil.clear(DOM.getElementById(WID.commentFeedback.toString())); } }; top.istyle("margin: 10px").c(form(form).onsubmit(new SubmitHandler() { @Override public void onSubmit(final SubmitEvent event) { event.cancel(); WickletAjax.ajax(WickletGwtSiteUtil.getContextUrl("/wicket/page?" + formaction.getQuery()), encode(subject.getText(), comment.getText(), captcha.getText()), new XmlWickletAjaxCallback() { @Override public void onResponseReceived(final Request request, final Response response) { if (!GwtHttp.Status.isOK(response.getStatusCode())) { showError("ERROR: Invalid response: " + response.getText()); return; } final String res = response.getText(); final Document doc = XMLParser.parse(res); final com.google.gwt.xml.client.Element e = doc.getDocumentElement(); final String tag = e.getNodeName(); if ("success".equals(tag)) { rightpanel.remove(top); rightpanel.asWidget().getElement() .setInnerHTML(GwtXmlUtil.unescXml(GwtXmlUtil.getTextUnder(e))); } else if ("feedback".equals(tag)) { final Element o = DOM.getElementById(WID.commentFeedback.toString()); final String text = GwtXmlUtil.unescTextUnder(e); o.setInnerHTML(text); } else { showError("ERROR: Invalid response: " + tag); } } @Override public void onError(final Request request, final Throwable e) { CConf.debug("ERROR: Wiki comment failed: " + request, e); showError("ERROR: Wiki comment failed"); } }); } }), subject.onfocus(clearmsg), comment.onfocus(clearmsg), image(cache.byId(WID.commentCaptchaImage)), captcha.onfocus(clearmsg), button(cache.byId(WID.commentSubmit))); } String encode(final String subject, final String comment, final String captcha) { return "" + (WID.commentSubject + "=" + URL.encodeQueryString(subject)) + ("&" + WID.commentText + "=" + URL.encodeQueryString(comment)) + ("&" + WID.commentCaptchaText + "=" + URL.encodeQueryString(captcha)); } }.build(); }