List of usage examples for com.google.gwt.dom.client Element getId
@Override
public String getId()
From source file:asquare.gwt.debug.client.DebugUtil.java
License:Apache License
/** * Get a short description of the element. * //from ww w . j ava 2 s. c o m * @param element a DOM element or <code>null</code> * @return a String or <code>null</code> if <code>element</code> is null */ public static String prettyPrintElement(Element element) { if (element == null) { return String.valueOf(element); } String tagName = element.getTagName(); String id = element.getId(); String classNames = element.getClassName(); String description = null; if ("div".equalsIgnoreCase(tagName) || "span".equalsIgnoreCase(tagName)) { if (id != null && !"".equals(id)) { description = id; } else if (classNames != null && !"".equals(classNames)) { description = classNames; } } else if (tagName.equalsIgnoreCase("button")) { description = ButtonElement.as(element).getValue(); } return (description == null) ? tagName : tagName + '[' + description + ']'; }
From source file:ca.nanometrics.gflot.client.options.LegendOptions.java
License:Open Source License
/** * Set a custom container to put the legend table into. The "position" and "margin" etc. options will then be * ignored. Note that Flot will overwrite the contents of the container. *//*from w ww. j a va 2 s .co m*/ public LegendOptions setContainer(Element container) { assert null != container : "container can't be null"; String id = container.getId(); if (id == null || id.length() == 0) { id = Document.get().createUniqueId(); container.setId(id); } put(CONTAINER_KEY, "#" + id); return this; }
From source file:ch.bergturbenthal.hs485.frontend.gwtfrontend.client.svg.SVGProcessor.java
License:Open Source License
public static int normalizeIds(final OMSVGElement srcSvg) { docId++;//from w ww . j ava 2 s . co m // Collect all the original element ids and replace them with a // normalized id int idIndex = 0; final Map<String, Element> idToElement = new HashMap<String, Element>(); final Map<String, String> idToNormalizedId = new HashMap<String, String>(); final List<Element> queue = new ArrayList<Element>(); queue.add(srcSvg.getElement()); while (queue.size() > 0) { final Element element = queue.remove(0); final String id = element.getId(); if (id != null) { idToElement.put(id, element); final String normalizedId = "d" + docId + "_" + idIndex++; idToNormalizedId.put(id, normalizedId); element.setId(normalizedId); } final NodeList<Node> childNodes = element.getChildNodes(); for (int i = 0, length = childNodes.getLength(); i < length; i++) { final Node childNode = childNodes.getItem(i); if (childNode.getNodeType() == Node.ELEMENT_NODE) queue.add((Element) childNode.cast()); } } // Change all the attributes which are URI references final Set<String> attNames = new HashSet<String>(Arrays.asList(new String[] { "clip-path", "mask", "marker-start", "marker-mid", "marker-end", "fill", "stroke", "filter", "cursor", "style" })); queue.add(srcSvg.getElement()); final IdRefTokenizer tokenizer = GWT.create(IdRefTokenizer.class); while (queue.size() > 0) { final Element element = queue.remove(0); if (DOMHelper.hasAttributeNS(element, SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE)) { final String idRef = DOMHelper.getAttributeNS(element, SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE).substring(1); final String normalizeIdRef = idToNormalizedId.get(idRef); DOMHelper.setAttributeNS(element, SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE, "#" + normalizeIdRef); } final NamedNodeMap<Attr> attrs = DOMHelper.getAttributes(element); for (int i = 0, length = attrs.getLength(); i < length; i++) { final Attr attr = attrs.item(i); if (attNames.contains(attr.getName())) { final StringBuilder builder = new StringBuilder(); tokenizer.tokenize(attr.getValue()); IdRefTokenizer.IdRefToken token; while ((token = tokenizer.nextToken()) != null) { String value = token.getValue(); if (token.getKind() == IdRefTokenizer.IdRefToken.DATA) builder.append(value); else { value = idToNormalizedId.get(value); builder.append(value == null ? token.getValue() : value); } } attr.setValue(builder.toString()); } } final NodeList<Node> childNodes = element.getChildNodes(); for (int i = 0, length = childNodes.getLength(); i < length; i++) { final Node childNode = childNodes.getItem(i); if (childNode.getNodeType() == Node.ELEMENT_NODE) queue.add((Element) childNode.cast()); } } return docId; }
From source file:com.ait.toolkit.badge.client.Badge.java
License:Open Source License
public Badge(Element target) { this(target.getId()); }
From source file:com.ait.toolkit.core.client.IdGenerator.java
License:Open Source License
public static String getOrCreateId(Element element) { String id = element.getId(); if (id == null || id.isEmpty()) { id = generateId();// w w w .j a v a 2 s . co m element.setId(id); } return id; }
From source file:com.ait.toolkit.hopscotch.client.TourStep.java
License:Open Source License
protected String getOrCreateId(Element element) { String id = element.getId(); if (id == null || id.isEmpty()) { id = HopScotch.generateId();// w w w .j a v a 2s. c o m element.setId(id); } return id; }
From source file:com.alkacon.acacia.client.widgets.TinyMCEWidget.java
License:Open Source License
/** * Gives an element an id if it doesn't already have an id, and then returns the element's id.<p> * //from w w w .j av a 2 s . c om * @param element the element for which we want to add the id * * @return the id */ protected String ensureId(Element element) { String id = element.getId(); if ((id == null) || "".equals(id)) { id = Document.get().createUniqueId(); element.setId(id); } return id; }
From source file:com.brazoft.foundation.gwt.client.component.ElementResolver.java
License:Apache License
public static Element getChildById(Element parent, String id) { NodeIterable<Node> elements = new NodeIterable<Node>(parent.getChildNodes()); for (Node node : elements) { Element child = (Element) node; if (child.getId().equals(id)) { return child; }//from ww w . ja va 2 s.c o m } return null; }
From source file:com.brazoft.foundation.gwt.client.component.ElementResolver.java
License:Apache License
public static Element getChildByIdRec(Element parent, String id) { NodeIterable<Node> elements = new NodeIterable<Node>(parent.getChildNodes()); for (Node node : elements) { Element child = (Element) node; if (child != null && child.getId() != null) { if (child.getId().equals(id)) { return child; }/*from w ww . ja v a 2s .c om*/ NodeList<Node> childNodes = child.getChildNodes(); for (int cii = 0; cii < childNodes.getLength(); cii++) { Element child2 = (Element) childNodes.getItem(cii); Element childByIdRec = getChildByIdRec(child2, id); if (childByIdRec != null) { return childByIdRec; } } } } return null; }
From source file:com.calclab.emite.widgets.client.AutoDeploy.java
License:Open Source License
public void install(final Element element, final EmiteWidget widget) { final String elementID = element.getId(); if (elementID == null) { Log.error("Trying to install a widget in a element without a id:" + element); }//from w w w . jav a2s. c o m Log.debug("Installing on element id: " + elementID); setParams(element, widget); domAssist.clearElement(element); RootPanel.get(elementID).add((Widget) widget); }