Example usage for com.google.gwt.dom.client Document getHead

List of usage examples for com.google.gwt.dom.client Document getHead

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Document getHead.

Prototype

public HeadElement getHead() 

Source Link

Usage

From source file:fr.putnami.pwt.core.widget.client.DocumentMeta.java

License:Open Source License

/**
 * Return the first meta tag from the head section with name matching. <br>
 * If createIfMissing the tag is created and added at the end of the head section.<br>
 * <p>//from  w w w . ja va 2 s  .  c o  m
 * <strong>Note : </strong> the name is case insensitive
 * </p>
 *
 * @param name the name attribute of the metta tag
 * @param createIfMissing create the tag in the head section if missing
 * @return meta tag element or null
 */
public static MetaElement getDescriptionTag(String name, boolean createIfMissing) {
    Document doc = Document.get();
    HeadElement head = doc.getHead();
    assert head != null : "No head section found in the document";
    assert name != null : "the name must not be null";

    NodeList<Element> tags = head.getElementsByTagName("meta");
    MetaElement metaTag = null;
    for (int i = 0; i < tags.getLength(); i++) {
        metaTag = (MetaElement) tags.getItem(i);
        if (name.equalsIgnoreCase(metaTag.getName())) {
            return metaTag;
        }
    }
    if (createIfMissing) {
        metaTag = doc.createMetaElement();
        metaTag.setName(name);
        head.appendChild(metaTag);
    }
    return metaTag;
}

From source file:org.chromium.distiller.PagingLinksFinder.java

License:Open Source License

public static AnchorElement createAnchorWithBase(String base_url) {
    Document doc = DomUtil.createHTMLDocument(Document.get());

    BaseElement base = doc.createBaseElement();
    base.setHref(base_url);/*from  w w  w . j  a va2  s . co  m*/
    doc.getHead().appendChild(base);

    AnchorElement a = doc.createAnchorElement();
    doc.getBody().appendChild(a);
    return a;
}

From source file:org.rstudio.core.client.widget.RStudioThemedFrame.java

License:Open Source License

private void addThemesStyle(String customStyle, String urlStyle, boolean removeBodyStyle) {
    if (getWindow() != null && getWindow().getDocument() != null) {
        Document document = getWindow().getDocument();

        if (customStyle == null)
            customStyle = "";

        customStyle += "\n"
                + ".rstudio-themes-flat.rstudio-themes-dark.rstudio-themes-scrollbars::-webkit-scrollbar,\n"
                + ".rstudio-themes-flat.rstudio-themes-dark.rstudio-themes-scrollbars ::-webkit-scrollbar {\n"
                + "   background: #FFF;\n" + "}\n" + "\n"
                + ".rstudio-themes-flat.rstudio-themes-dark.rstudio-themes-scrollbars::-webkit-scrollbar-thumb,\n"
                + ".rstudio-themes-flat.rstudio-themes-dark.rstudio-themes-scrollbars ::-webkit-scrollbar-thumb {\n"
                + "   -webkit-border-radius: 10px;\n" + "   background: " + ThemeColors.darkGreyBackground
                + ";\n" + "}\n" + "\n"
                + ".rstudio-themes-flat.rstudio-themes-dark.rstudio-themes-scrollbars::-webkit-scrollbar-track,\n"
                + ".rstudio-themes-flat.rstudio-themes-dark.rstudio-themes-scrollbars ::-webkit-scrollbar-track,\n"
                + ".rstudio-themes-flat.rstudio-themes-dark.rstudio-themes-scrollbars::-webkit-scrollbar-corner,\n"
                + ".rstudio-themes-flat.rstudio-themes-dark.rstudio-themes-scrollbars ::-webkit-scrollbar-corner {\n"
                + "   background: " + ThemeColors.darkGreyMostInactiveBackground + ";\n" + "}\n"
                + ".rstudio-themes-flat.rstudio-themes-dark.rstudio-themes-scrollbars::-webkit-scrollbar-thumb,\n"
                + ".rstudio-themes-flat.rstudio-themes-dark.rstudio-themes-scrollbars ::-webkit-scrollbar-thumb{\n"
                + "   border: solid 3px " + ThemeColors.darkGreyMostInactiveBackground + ";" + "}\n";

        StyleElement style = document.createStyleElement();
        style.setInnerHTML(customStyle);
        document.getHead().appendChild(style);

        if (urlStyle != null) {
            LinkElement styleLink = document.createLinkElement();
            styleLink.setHref(urlStyle);
            styleLink.setRel("stylesheet");
            document.getHead().appendChild(styleLink);
        }/*from  w ww  .j  a  va 2  s.c o m*/

        RStudioGinjector.INSTANCE.getAceThemes().applyTheme(document);

        BodyElement body = document.getBody();
        if (body != null) {
            if (removeBodyStyle)
                body.removeAttribute("style");

            RStudioThemes.initializeThemes(RStudioGinjector.INSTANCE.getUIPrefs(), document,
                    document.getBody());

            body.addClassName("ace_editor_theme");
        }
    }
}