001/*
002 *  Copyright 2012 GWT-Bootstrap
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package com.github.gwtbootstrap.datetimepicker.client.ui.resources;
017
018import com.github.gwtbootstrap.client.ui.resources.JavaScriptInjector;
019import com.github.gwtbootstrap.client.ui.resources.ResourceInjector;
020import com.github.gwtbootstrap.datetimepicker.client.ui.util.LocaleUtil;
021import com.google.gwt.resources.client.TextResource;
022
023/**
024 * Utility class to inject our resources into modules page. Use it to inject
025 * JavaScript and CSS files.
026 *
027 * @author Carlos Alexandro Becker
028 * @author Alain Penders
029 * @since 2.1.1.0
030 */
031public class DatetimepickerResourceInjector
032{
033
034    /**
035     * Injects the required CSS styles and JavaScript files into the document header.
036     * <pre>
037     * It's for NoStyle Module.
038     * </pre>
039     */
040    public static void configureWithCssFile() {
041        
042        ResourceInjector.injectResourceCssAsFile("datetimepicker.css");
043        configure();
044    }
045
046
047    /**
048     * Injects the required CSS styles and JavaScript files into the document
049     * header.
050     */
051    public static void configure() {
052        Resources r = Resources.RESOURCES;
053        injectJs(r.datetimepickerJs());
054
055        TextResource locale = LocaleUtil.getLocaleJsResource();
056        if (locale != null) {
057            JavaScriptInjector.inject(locale.getText());
058        }
059    }
060
061    private static void injectJs(TextResource r) {
062        JavaScriptInjector.inject(r.getText());
063    }
064}