List of usage examples for com.google.gwt.dom.client LinkElement getHref
public String getHref()
From source file:com.vaadin.client.ResourceLoader.java
License:Apache License
/** * Creates a new resource loader. You should generally not create you own * resource loader, but instead use {@link ResourceLoader#get()} to get an * instance./*from ww w . j av a2 s . c o m*/ */ protected ResourceLoader() { Document document = Document.get(); head = document.getElementsByTagName("head").getItem(0); // detect already loaded scripts and stylesheets NodeList<Element> scripts = document.getElementsByTagName("script"); for (int i = 0; i < scripts.getLength(); i++) { ScriptElement element = ScriptElement.as(scripts.getItem(i)); String src = element.getSrc(); if (src != null && src.length() != 0) { loadedResources.add(src); } } NodeList<Element> links = document.getElementsByTagName("link"); for (int i = 0; i < links.getLength(); i++) { LinkElement linkElement = LinkElement.as(links.getItem(i)); String rel = linkElement.getRel(); String href = linkElement.getHref(); if ("stylesheet".equalsIgnoreCase(rel) && href != null && href.length() != 0) { loadedResources.add(href); } } }
From source file:com.vaadin.client.ui.ui.UIConnector.java
License:Apache License
/** * Internal helper for removing any stylesheet with the given URL * //from ww w . ja v a2 s .c om * @since 7.3 * @param url * the url to match with existing stylesheets */ private void removeStylesheet(String url) { NodeList<Element> linkTags = getHead().getElementsByTagName(LinkElement.TAG); for (int i = 0; i < linkTags.getLength(); i++) { LinkElement link = LinkElement.as(linkTags.getItem(i)); if (!"stylesheet".equals(link.getRel())) { continue; } if (!"text/css".equals(link.getType())) { continue; } if (url.equals(link.getHref())) { getHead().removeChild(link); } } }
From source file:com.vaadin.client.ui.ui.UIConnector.java
License:Apache License
/** * Finds a link tag for a style sheet with the given URL * //from ww w .j av a 2 s . c o m * @since 7.3 * @param url * the URL of the style sheet * @return the link tag or null if no matching link tag was found */ private LinkElement findStylesheetTag(String url) { NodeList<Element> linkTags = getHead().getElementsByTagName(LinkElement.TAG); for (int i = 0; i < linkTags.getLength(); i++) { final LinkElement link = LinkElement.as(linkTags.getItem(i)); if ("stylesheet".equals(link.getRel()) && "text/css".equals(link.getType()) && url.equals(link.getHref())) { return link; } } return null; }
From source file:edu.caltech.ipac.firefly.ui.TitleFlasher.java
private static void findFavIcon() { Document doc = Document.get(); NodeList<Element> eleList = doc.getElementsByTagName("link"); for (int i = 0; (i < eleList.getLength()); i++) { Element e = eleList.getItem(i); LinkElement le = LinkElement.as(e); if ("image/x-icon".equals(le.getType())) { if (!StringUtils.isEmpty(le.getHref())) { favIconElement = le;/* w ww . ja v a 2s. com*/ String favIcon = le.getHref(); break; } } } }