/** * Constructor. */ public BootswatchThemeProvider() { super(); add(BootswatchTheme.AMELIA, BootswatchTheme.CERULEAN, BootswatchTheme.CYBORG, BootswatchTheme.JOURNAL, BootswatchTheme.READABLE, BootswatchTheme.SIMPLEX, BootswatchTheme.SLATE, BootswatchTheme.SPACELAB, BootswatchTheme.SPRUCE, BootswatchTheme.SUPERHERO, BootswatchTheme.UNITED, BootswatchTheme.COSMO); }
/** * {@inheritDoc} */ @Override public void setActiveTheme(String themeName) { setActiveTheme(themeProvider().byName(themeName)); }
/** * sets the default theme. * * @param theme The new default theme * @return This instance */ public DefaultThemeProvider defaultTheme(ITheme theme) { return defaultTheme(theme.name()); }
/** * Render the current active {@link ITheme} which includes all {@link org.apache.wicket.request.resource.ResourceReference} objects * and the {@link de.agilecoders.wicket.markup.html.themes.bootstrap.BootstrapResponsiveCssReference} * if enabled to the response. Also it allows all subclasses to get the {@link IBootstrapSettings} by overriding this method. * * @param settings the bound {@link IBootstrapSettings} * @param headerResponse the current {@link IHeaderResponse} */ public void renderHead(IBootstrapSettings settings, IHeaderResponse headerResponse) { ITheme theme = settings.getActiveThemeProvider().getActiveTheme(); theme.renderHead(headerResponse); if (settings.useResponsiveCss()) { headerResponse.render(CssHeaderItem.forReference(settings.getResponsiveCssResourceReference())); } } }
@Override protected IBootstrapSettings createBootstrapSettings() { IBootstrapSettings settings = super.createBootstrapSettings(); settings.getBootstrapLessCompilerSettings() .setUseLessCompiler(true) .setCacheStrategy(IBootstrapLessCompilerSettings.CacheStrategy.Never); return settings; }
@Override protected void onConfigure() { super.onConfigure(); if (Bootstrap.getSettings(getApplication()).useModernizr()) { add(new CssClassNameAppender("no-js")); } if (locale != null) { add(new AttributeModifier("lang", toAttributeValue(locale()))); } add(new CssClassNameAppender(createBrowserShortcut(clientProperties))); add(new CssClassNameAppender("theme-" + Bootstrap.getSettings().getActiveThemeProvider().getActiveTheme().name())); }
/** * use fixed variation value to trigger {@link LessResourceStreamLocator} * * @return static string {@link LessResourceReference#VARIATION} if less is active */ @Override public final String getVariation() { return Bootstrap.getSettings().getBootstrapLessCompilerSettings().useLessCompiler() ? VARIATION : null; } }
/** * {@inheritDoc} */ @Override public ITheme getActiveTheme() { String style = Session.get().getStyle(); if (Strings.isNullOrEmpty(style)) { return themeProvider().defaultTheme(); } else { return themeProvider().byName(style); } }
/** * @return charset setting */ protected final Charset getCharset() { if (Application.exists()) { return Bootstrap.getSettings().getBootstrapLessCompilerSettings().getCharset(); } else { LOG.warn("no application assigned to current thread, return default charset: {}", Charsets.UTF_8); return Charsets.UTF_8; } } }
/** * Gets the {@link LessJsLessCompiler} to be used. By default returns the configured compiler on * application level, but can be overridden by the user application to provide compiler * specific to the resource. * * @return the configured application level less compiler. May be {@code null}. */ private static IBootstrapLessCompiler getCompiler() { if (Application.exists()) { return Bootstrap.getSettings().getBootstrapLessCompilerSettings().getLessCompiler(); } throw new IllegalStateException("there is no application assigned to current thread."); }
protected IBootstrapSettings createBootstrapSettings() { return new BootstrapSettings(); }
/** * adds a new theme and sets it as default theme. * * @param theme The new default theme * @return This instance */ public DefaultThemeProvider addDefaultTheme(ITheme theme) { add(theme); return defaultTheme(theme); }
/** * Construct. */ public DefaultThemeProvider() { addDefaultTheme(new BootstrapTheme()); add(new WicketTheme()); }
/** * {@inheritDoc} */ @Override public void setActiveTheme(ITheme theme) { assertBoundSession(); if (theme != null) { Session.get().setStyle(theme.name()); } else { Session.get().setStyle(null); } }
/** * sets the default theme. * * @param themeName The new default theme * @return This instance */ public DefaultThemeProvider defaultTheme(String themeName) { ITheme newDefaultTheme = byName(themeName); if (defaultTheme != newDefaultTheme) { defaultTheme = newDefaultTheme; } return this; }
/** * adds an array of new themes. * * @param themes The new themes * @return This instance */ public DefaultThemeProvider add(ITheme... themes) { assertNoDuplicateNames(themes); this.themes.addAll(Lists.newArrayList(themes)); return this; }
/** * Construct. Sets some configuration mode specific settings. * * @param application The current application instance */ public BootstrapSettings(final Application application) { this(); final boolean usesDeploymentConfig = application.usesDeploymentConfig(); minify(usesDeploymentConfig); }
/** * Construct. Uses {@link de.agilecoders.wicket.settings.IBootstrapSettings#getJsResourceFilterName()} * as filter name. */ public RenderJavaScriptToFooterHeaderResponseDecorator() { this(Bootstrap.getSettings().getJsResourceFilterName()); }
/** * @return true if less compiler should be used. */ private static boolean useLessCompiler() { return Bootstrap.getSettings().getBootstrapLessCompilerSettings().useLessCompiler(); }
protected IBootstrapSettings createBootstrapSettings() { return new BootstrapSettings(); }