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

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

Introduction

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

Prototype

public LinkElement createLinkElement() 

Source Link

Usage

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   ww  w  .  j a  v a2  s .com

        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");
        }
    }
}

From source file:org.rstudio.studio.client.workbench.prefs.views.AceEditorPreview.java

License:Open Source License

public void setTheme(String themeUrl) {
    themeUrl_ = themeUrl;/*w  ww . j  av  a 2 s  . c  o  m*/
    if (!isFrameLoaded_)
        return;

    if (currentStyleLink_ != null)
        currentStyleLink_.removeFromParent();

    Document doc = getDocument();
    currentStyleLink_ = doc.createLinkElement();
    currentStyleLink_.setRel("stylesheet");
    currentStyleLink_.setType("text/css");
    currentStyleLink_.setHref(themeUrl);
    doc.getBody().appendChild(currentStyleLink_);
}