-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add bootstrap-theme.css as theme, fix issue in GoogleCssReference (re…
…lated to issue #349)
- Loading branch information
1 parent
cb1ff9e
commit e67a05b
Showing
4 changed files
with
106 additions
and
10 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...src/main/java/de/agilecoders/wicket/themes/markup/html/bootstrap/BootstrapThemeTheme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.agilecoders.wicket.themes.markup.html.bootstrap; | ||
|
||
import de.agilecoders.wicket.core.settings.Theme; | ||
|
||
/** | ||
* # Description | ||
* | ||
* java representation of `bootstrap-theme.css` which is an enhanced default bootstrap theme. | ||
* | ||
* # Usage | ||
* | ||
* ``` | ||
* public void init() { | ||
* final IBootstrapSettings settings = new BootstrapSettings(); | ||
* Bootstrap.install(this, settings); | ||
* // theme provider must be set after `install` because it needs webjars. | ||
* settings.setThemeProvider(new SingleThemeProvider(new BootstrapThemeTheme())); | ||
* } | ||
* ``` | ||
* | ||
* @author Michael Haitz <[email protected]> | ||
*/ | ||
public class BootstrapThemeTheme extends Theme { | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param name the theme name | ||
*/ | ||
public BootstrapThemeTheme(String name) { | ||
super(name, BootstrapThemeThemeCssReference.instance()); | ||
} | ||
|
||
/** | ||
* Construct using default theme name: `bootstrap-theme`. | ||
*/ | ||
public BootstrapThemeTheme() { | ||
this("bootstrap-theme"); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...a/de/agilecoders/wicket/themes/markup/html/bootstrap/BootstrapThemeThemeCssReference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package de.agilecoders.wicket.themes.markup.html.bootstrap; | ||
|
||
import de.agilecoders.wicket.core.Bootstrap; | ||
import de.agilecoders.wicket.core.util.Dependencies; | ||
import de.agilecoders.wicket.webjars.request.resource.WebjarsCssResourceReference; | ||
import org.apache.wicket.markup.head.CssHeaderItem; | ||
import org.apache.wicket.markup.head.HeaderItem; | ||
|
||
/** | ||
* # Description | ||
* | ||
* The BootstrapThemeThemeCssReference uses the latest version of bootstrap-theme.css from the `org.webjars.bootstrap` | ||
* dependency which is defined in `pom.xml`. This reference has a dependency to base bootstrap css reference, but there | ||
* will be no version conflicts between this reference and the `bootstrap.css` from `BootstrapCssReference` because both | ||
* will are loaded from same jar file. | ||
* | ||
* # Usage | ||
* | ||
* this css resource reference can be used directly: | ||
* ```java | ||
* response.render(CssHeaderItem.forReference(BootstrapThemeThemeCssReference.instance())); | ||
* ``` | ||
* | ||
* or together with bootstrap theme: | ||
* | ||
* ``` | ||
* settings.setThemeProvider(new SingleThemeProvider(new BootstrapThemeTheme())); | ||
* ``` | ||
* | ||
* @author Michael Haitz <[email protected]> | ||
*/ | ||
public class BootstrapThemeThemeCssReference extends WebjarsCssResourceReference { | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* @return singleton instance of {@link de.agilecoders.wicket.themes.markup.html.bootstrap.BootstrapThemeThemeCssReference} | ||
*/ | ||
public static BootstrapThemeThemeCssReference instance() { | ||
return Holder.INSTANCE; | ||
} | ||
|
||
/** | ||
* Singleton instance of this reference | ||
*/ | ||
private static final class Holder { | ||
private static final BootstrapThemeThemeCssReference INSTANCE = new BootstrapThemeThemeCssReference(); | ||
} | ||
|
||
/** | ||
* Private constructor to prevent instantiation. | ||
*/ | ||
private BootstrapThemeThemeCssReference() { | ||
super("/bootstrap/current/css/bootstrap-theme.css"); | ||
} | ||
|
||
@Override | ||
public Iterable<? extends HeaderItem> getDependencies() { | ||
return Dependencies.combine(super.getDependencies(), | ||
CssHeaderItem.forReference(Bootstrap.getSettings().getCssResourceReference())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters