Example usage for com.google.gwt.dom.client StyleInjector flush

List of usage examples for com.google.gwt.dom.client StyleInjector flush

Introduction

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

Prototype

public static void flush() 

Source Link

Document

Flushes any pending stylesheets to the document.

Usage

From source file:client.ui.components.utils.Style.java

License:Open Source License

/**
 * Load the specified style file.//from  w  w w .j a v a 2s.c  om
 *
 * @param css Path to style file.
 */
public static void load(String css) {
    if (loadedCss.contains(css)) {
        return;
    }

    StyleInjector.inject(css, true);
    StyleInjector.flush();

    loadedCss.add(css);
}

From source file:com.floatzcss.gwt.client.util.StyleInjectorUtils.java

License:Apache License

/**
 * Flushes any pending stylesheets to the document.
 *
 * @see com.google.gwt.dom.client.StyleInjector#flush()
 */
public void flush() {
    StyleInjector.flush();
}

From source file:com.vaadin.client.ui.ui.UIConnector.java

License:Apache License

/**
 * Reads CSS strings and resources injected by {@link Styles#inject} from
 * the UIDL stream./*from  www  .j  a  va  2 s  .c  o  m*/
 * 
 * @param uidl
 *            The uidl which contains "css-resource" and "css-string" tags
 */
private void injectCSS(UIDL uidl) {

    /*
     * Search the UIDL stream for CSS resources and strings to be injected.
     */
    for (Iterator<?> it = uidl.getChildIterator(); it.hasNext();) {
        UIDL cssInjectionsUidl = (UIDL) it.next();

        // Check if we have resources to inject
        if (cssInjectionsUidl.getTag().equals("css-resource")) {
            String url = getWidget().connection.translateVaadinUri(cssInjectionsUidl.getStringAttribute("url"));
            LinkElement link = LinkElement.as(DOM.createElement(LinkElement.TAG));
            link.setRel("stylesheet");
            link.setHref(url);
            link.setType("text/css");
            getHead().appendChild(link);
            // Check if we have CSS string to inject
        } else if (cssInjectionsUidl.getTag().equals("css-string")) {
            for (Iterator<?> it2 = cssInjectionsUidl.getChildIterator(); it2.hasNext();) {
                StyleInjector.injectAtEnd((String) it2.next());
                StyleInjector.flush();
            }
        }
    }
}

From source file:jetbrains.jetpad.cell.toDom.CellContainerToDomMapper.java

License:Apache License

private static void ensureIndentInjected() {
    if (ourIndentInjected)
        return;/*  w  w  w . java 2  s  .  co  m*/

    StyleInjector.flush();

    double width = TextMetricsCalculator.calculate(TextCell.DEFAULT_FONT, "xx").dimension().x;
    StyleInjector.inject("." + CSS.indented() + "{ padding-left: " + width + "px }", true);
    ourIndentInjected = true;
}

From source file:jetbrains.jetpad.cell.toDom.Tooltip.java

License:Apache License

private static Registration injectCornerStyle(String id, Cell cell) {
    Color borderColor = cell.get(Cell.BORDER_COLOR);
    String border = borderColor == null ? "none" : "1px solid " + borderColor.toCssColor();
    Color backgroundColor = cell.get(Cell.BACKGROUND);
    String background = backgroundColor == null ? Color.WHITE.toCssColor() : backgroundColor.toCssColor();
    final StyleElement styleElement = StyleInjector.injectStylesheet("." + id + "::before { border-top: "
            + border + "; border-left: " + border + "; " + "background: linear-gradient(135deg, " + background
            + " 0%, " + background + " 70%, rgba(0,0,0,0) 71%, rgba(0,0,0,0) 100%) }");
    StyleInjector.flush();
    return new Registration() {
        @Override/*  ww w.jav  a 2 s  . c  o m*/
        protected void doRemove() {
            styleElement.removeFromParent();
        }
    };
}