org.jgrapes.webconsole.provider.fontawesome.FontAwesomeProvider Maven / Gradle / Ivy
/*
* JGrapes Event Driven Framework
* Copyright (C) 2017-2018 Michael N. Lipp
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
* for more details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program; if not, see .
*/
package org.jgrapes.webconsole.provider.fontawesome;
import freemarker.core.ParseException;
import freemarker.template.MalformedTemplateNameException;
import freemarker.template.TemplateNotFoundException;
import java.io.IOException;
import org.jgrapes.core.Channel;
import org.jgrapes.core.Event;
import org.jgrapes.core.Manager;
import org.jgrapes.core.annotation.Handler;
import org.jgrapes.webconsole.base.ConsoleSession;
import org.jgrapes.webconsole.base.PageResourceProvider;
import org.jgrapes.webconsole.base.events.AddPageResources;
import org.jgrapes.webconsole.base.events.ConsoleReady;
/**
* Provider for the [Font Awesome](http://fontawesome.com/).
*/
public class FontAwesomeProvider extends PageResourceProvider {
/**
* Creates a new component with its channel set to the given
* channel.
*
* @param componentChannel the channel that the component's
* handlers listen on by default and that
* {@link Manager#fire(Event, Channel...)} sends the event to
*/
public FontAwesomeProvider(Channel componentChannel) {
super(componentChannel);
}
/**
* On {@link ConsoleReady}, fire the appropriate {@link AddPageResources}.
*
* @param event the event
* @param consoleSession the web console session
* @throws TemplateNotFoundException the template not found exception
* @throws MalformedTemplateNameException the malformed template name exception
* @throws ParseException the parse exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@Handler(priority = 100)
public void onConsoleReady(ConsoleReady event,
ConsoleSession consoleSession)
throws TemplateNotFoundException, MalformedTemplateNameException,
ParseException, IOException {
String minExt = event.renderSupport()
.useMinifiedResources() ? ".min" : "";
consoleSession.respond(new AddPageResources()
.addCss(event.renderSupport().pageResource(
"fontawesome-free/css/all" + minExt + ".css")));
}
}