001/* 002 * (C) Copyright 2006-2009 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Jean-Marc Orliaguet, Chalmers 016 * 017 * $Id$ 018 */ 019 020package org.nuxeo.theme.webengine.fm.extensions; 021 022import java.io.IOException; 023import java.io.Writer; 024import java.util.Map; 025 026import org.nuxeo.theme.html.ui.Accesskeys; 027 028import freemarker.core.Environment; 029import freemarker.template.TemplateDirectiveBody; 030import freemarker.template.TemplateDirectiveModel; 031import freemarker.template.TemplateException; 032import freemarker.template.TemplateModel; 033import freemarker.template.TemplateModelException; 034 035/** 036 * @author <a href="mailto:jmo@chalmers.se">Jean-Marc Orliaguet</a> 037 */ 038public class NXThemesAccesskeysDirective implements TemplateDirectiveModel { 039 040 public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) 041 throws TemplateException, IOException { 042 043 if (!params.isEmpty()) { 044 throw new TemplateModelException("This directive doesn't allow parameters."); 045 } 046 if (loopVars.length != 0) { 047 throw new TemplateModelException("This directive doesn't allow loop variables."); 048 } 049 if (body != null) { 050 throw new TemplateModelException("Didn't expect a body"); 051 } 052 053 Writer writer = env.getOut(); 054 writer.write(Accesskeys.render()); 055 } 056}