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

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

Introduction

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

Prototype

public static void inject(String css, boolean immediate) 

Source Link

Document

Add a stylesheet to the document.

Usage

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

License:Open Source License

/**
 * Load the specified style file./*from  w ww.  j a va2  s. c o  m*/
 *
 * @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.arcbees.chosen.client.ChosenImpl.java

License:Apache License

private void setDefaultValues() {
    clickTestAction = new Function() {
        @Override/*  w w  w. j av  a  2s.  c  om*/
        public boolean f(Event e) {
            return testActiveClick(e);
        }
    };

    activeField = false;
    mouseOnContainer = false;
    resultsShowing = false;

    choices = 0;

    if (options.getResources() != null) {
        css = options.getResources().css();
    } else {
        css = GWT.<Resources>create(Resources.class).css();
    }

    Class<?> resourceClass = options.getResources() != null ? options.getResources().getClass()
            : Resources.class;

    if (!INJECTED_RESOURCES.contains(resourceClass)) {
        StyleInjector.inject(css.getText(), true);
        INJECTED_RESOURCES.add(resourceClass);
    }

    resultsFilter = options.getResultFilter();

    customFilter = resultsFilter != null;

    if (!customFilter) {
        resultsFilter = new ClientResultsFilter();
    }
}

From source file:com.duggankimani.app.client.style.ExampleStyles.java

License:sencha.com license

public static Styles get() {
    if (!injected) {
        StyleInjector.inject(instance.styles().getText(), true);
        injected = true;/*from  w  w  w.j a  v a  2s.com*/
    }
    return instance.styles();
}

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

License:Apache License

/**
 * Inject CSS resource./*from   ww  w  .ja v  a2  s  .c o  m*/
 *
 * @param resource  CSS Resource
 * @param immediate true to update DOM immediately, false before returning to the event loop
 * @return Reference for chaining
 */
public StyleInjectorUtils inject(CssResource resource, boolean immediate) {
    StyleInjector.inject(getCss(resource), immediate);
    return this;
}

From source file:com.google.speedtracer.client.Monitor.java

License:Apache License

public void onModuleLoad() {
    if (ClientConfig.isMockMode()) {
        MockUtils.createMockBackgroundPage();
    }//from   w  ww  .  java2  s . co m

    if (ClientConfig.isDebugMode() && GWT.isScript()) {
        GWT.setUncaughtExceptionHandler(new DebugUeh());
    }

    browserId = getIdParameter("browserId");
    tabId = getIdParameter("tabId");

    MonitorResources.init();
    final Resources resources = MonitorResources.getResources();
    // Inject styles. Compiler should concat all these into a big style String.
    StyleInjector.inject(resources.overViewGraphCss().getText() + resources.mainTimeLineCss().getText()
            + resources.transientGraphSelectionCss().getText() + resources.commonCss().getText()
            + resources.overViewTimeLineCss().getText() + resources.domainRegionSelectionCss().getText()
            + resources.hoveringPopupCss().getText() + resources.controllerCss().getText()
            + resources.monitorVisualizationsPanelCss().getText() + resources.fastTooltipCss().getText()
            + resources.timeScaleCss().getText() + resources.currentSelectionMarkerCss().getText()
            + resources.pageTransitionMarkerCss().getText() + resources.detailViewsCss().getText()
            + resources.networkTimeLineDetailViewCss().getText() + resources.resourceRowCss().getText()
            + resources.networkPillBoxCss().getText() + resources.requestDetailsCss().getText()
            + resources.sluggishnessDetailViewCss().getText() + resources.hintletIndicatorCss().getText()
            + resources.filteringScrollTableCss().getText() + resources.pieChartCss().getText()
            + resources.hintletReportCss().getText() + resources.hintletReportDialogCss().getText()
            + resources.sortableTableHeaderCss().getText() + resources.scopeBarCss().getText()
            + resources.colorListCss().getText() + resources.treeCss().getText()
            + resources.eventTraceBreakdownCss().getText() + resources.mainGraphCss().getText()
            + resources.overViewGraphCss().getText() + resources.monitorCss().getText()
            + resources.sourceViewerCss().getText() + resources.stackFrameRendererCss().getText()
            + resources.javaScriptProfileRendererCss().getText() + resources.eventWaterfallRowCss().getText()
            + resources.eventWaterfallRowDetailsCss().getText()
            + resources.sluggishnessFiletPanelCss().getText() + resources.timelineMarksCss().getText(), true);

    final WindowExt window = getBackgroundView();
    channel = Client.connect(window, CHANNEL_NAME, this);
    requestInitialization();
}

From source file:com.google.speedtracer.client.view.ZippyLogger.java

License:Apache License

public static ZippyLogger get() {
    if (INSTANCE == null) {
        ZippyLogger.Resources resources = GWT.create(ZippyLogger.Resources.class);
        StyleInjector.inject(resources.zippyLoggerCss().getText(), true);
        INSTANCE = new ZippyLogger(resources.zippyLoggerCss(), MonitorResources.getResources().commonCss());
    }/* ww w . jav  a  2s .c  o m*/
    return INSTANCE;
}

From source file:com.sencha.gxt.core.client.resources.StyleInjectorHelper.java

License:sencha.com license

/**
 * Ensures that the given CssResource is injected into the document. If the given CssResource has already been
 * injected into the document, this method does nothing.
 *
 * @param style       The CssResource to be injected
 * @param immediately Whether to inject the the CssResource immediately. See {@link StyleInjector#inject(boolean)}.
 * @return {@code true} if the CssResource has been injected successfully, {@code false} otherwise. If the style
 *         resource has already been injected, this method returns {@code false}.
 *//*from  www. j a  v a 2s  . c o m*/
public static boolean ensureInjected(CssResource style, boolean immediately) {
    if (!injected.contains(style.getClass())) {
        injected.add(style.getClass());
        StyleInjector.inject(style.getText(), immediately);
        return true;
    }
    return false;
}

From source file:com.watopi.chosen.client.ChosenImpl.java

License:Open Source License

private void setDefaultValues() {
    clickTestAction = new Function() {
        @Override//from   w  ww .j  av  a  2 s  .com
        public boolean f(Event e) {
            return testActiveClick(e);
        }
    };

    activateAction = new Function() {
        @Override
        public boolean f(Event e) {
            return activateField(e);
        }
    };

    activeField = false;
    mouseOnContainer = false;
    resultsShowing = false;

    NodeList<OptionElement> optionsList = selectElement.getOptions();
    allowSingleDeselect = options.isAllowSingleDeselect() && optionsList.getLength() > 0
            && "".equals(optionsList.getItem(0).getText());

    choices = 0;

    if (options.getResources() != null) {
        css = options.getResources().css();
    } else {
        css = GWT.<Resources>create(Resources.class).css();
    }

    // Force the injection the first time only 
    // If you want to use different css file for different GwtChosen component
    // please register your css files (css.ensureInject()) before the first call of the plugin
    if (!cssInjected) {
        StyleInjector.inject(css.getText(), true);
        cssInjected = true;
    }

}

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

License:Apache License

private static void ensureIndentInjected() {
    if (ourIndentInjected)
        return;//from   w  ww.  ja  v  a2 s .c om

    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:org.otalo.ao.client.widget.chlist.client.ChosenImpl.java

License:Apache License

private void setDefaultValues() {
    clickTestAction = new Function() {
        @Override//from   w  ww .  ja  v  a  2 s .c  o m
        public boolean f(Event e) {
            return testActiveClick(e);
        }
    };

    activateAction = new Function() {
        @Override
        public boolean f(Event e) {
            return activateField(e);
        }
    };

    activeField = false;
    mouseOnContainer = false;
    resultsShowing = false;

    NodeList<OptionElement> optionsList = selectElement.getOptions();
    allowSingleDeselect = options.isAllowSingleDeselect() && optionsList.getLength() > 0
            && "".equals(optionsList.getItem(0).getText());

    choices = 0;

    if (options.getResources() != null) {
        css = options.getResources().css();
    } else {
        css = GWT.<Resources>create(Resources.class).css();
    }

    // Force the injection the first time only
    // If you want to use different css file for different GwtChosen component
    // please register your css files (css.ensureInject()) before the first call of the plugin
    if (!cssInjected) {
        StyleInjector.inject(css.getText(), true);
        cssInjected = true;
    }

}