com.github.gwtbootstrap.client.ui.config.Configurator Maven / Gradle / Ivy
Show all versions of gwt-bootstrap Show documentation
/*
* Copyright 2012 GWT-Bootstrap
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.gwtbootstrap.client.ui.config;
import com.github.gwtbootstrap.client.ui.base.IsResponsive;
import com.github.gwtbootstrap.client.ui.resources.Resources;
/**
* Using custom CSS/JS resources.
*
*
* GWT-Bootstrap uses embedded copies of bootstrap.css and bootstrap.js by default. If you need to use your own copies
* or include other resources, you'll need to create a custom {@link Configurator} and a custom {@link Resources}.
*
*
* A suggested layout is below. First, create your resource package at the same level as client/server/shared. Next, create
* css and js directories beneath the resources directory, and add your custom css and js files into those. Next, create your custom
* {@link Configurator} and a custom {@link Resources}. Finally, add
* a replace-with
tag and a public
tag to your module xml.
*
*
* Full example below:
*
*
*
* 1. Create your resources package directory and add css and js directories beneath that. Add your custom css and js files to the css and js
* directories, respectively.
*
* src/main/java/com/example
* |-- client
* |-- resources
* | |-- css
* | | `-- bootstrap.min.css < your custom css
* | | `-- bootstrap-responsive.min.css < your custom css
* | |-- js
* | | `-- bootstrap.min.js < your custom js
* | |-- ExampleConfigurator.java < your custom Configurator class
* | `-- ExampleResources.java < your custom Resources interface
* |-- server
* |-- shared
* `-- Example.gwt.xml < your module xml file
*
*
*
* 2. Create a Resources interface (extending {@link Resources}) that overrides the
* getters of the files you want to replace.
*
*
* public interface MyResources extends Resources {
* {@literal @Source("css/bootstrap.min.css")}
* TextResource bootstrapCss();
*
* {@literal @Source("css/bootstrap-responsive.min.css")}
* TextResource bootstrapResponsiveCss();
* }
*
*
*
*
*
* 3. Create a Configurator
that returns your new {@link Resources}.
*
*
* public MyConfigurator implements Configurator {
* public Resources getResources() {
* return GWT.create(MyResources.class);
* }
* }
*
*
*
*
*
* 4. Add a replace-with
tag, a source
tag, and a public
tag to your module xml
* (*.gwt.xml
):
*
*
* {@literal
*
*
*
*
*
*
*
*
*
* }
*
*
*
*
* A more detailed tutorial and a full working example can be found here.
* @since 2.0.4.0
*
* @author Dominik Mayer
* @author ohashi keisuke
* @author Carlos A Becker
*
* @see Resources
* @see DefaultConfigurator
*/
public interface Configurator {
/**
* Get the Bootstrap Resources that should be used for this project.
*
* @return the Bootstrap Resources
*/
Resources getResources();
//@formatter:off
/**
* Determines whether the project uses a responsive design.
*
*
* If the responsive
* design is enabled, the interface can adapt to the screen size and show
* different content on smartphones, tablets and desktop computers.
*
*
* @return true
if the responsive features should be enabled.
* Default: false
*
* @see IsResponsive
*
* @see Bootstrap documentation
*/
boolean hasResponsiveDesign();
}