001 // This file is part of the Attempto Java Packages. 002 // Copyright 2008-2009, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch). 003 // 004 // The Attempto Java Packages is free software: you can redistribute it and/or modify it under the 005 // terms of the GNU Lesser General Public License as published by the Free Software Foundation, 006 // either version 3 of the License, or (at your option) any later version. 007 // 008 // The Attempto Java Packages is distributed in the hope that it will be useful, but WITHOUT ANY 009 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 010 // PURPOSE. See the GNU Lesser General Public License for more details. 011 // 012 // You should have received a copy of the GNU Lesser General Public License along with the Attempto 013 // Java Packages. If not, see http://www.gnu.org/licenses/. 014 015 package ch.uzh.ifi.attempto.aceeditor; 016 017 import nextapp.echo2.app.ApplicationInstance; 018 import nextapp.echo2.app.Window; 019 import nextapp.echo2.webcontainer.ContainerContext; 020 import nextapp.echo2.webcontainer.WebContainerServlet; 021 import ch.uzh.ifi.attempto.ape.APELocal; 022 import ch.uzh.ifi.attempto.echocomp.ServerDelayMessage; 023 import ch.uzh.ifi.attempto.echocomp.Style; 024 025 /** 026 * This servlet class is used by the web server to start the ACE Editor. 027 * 028 * @author Tobias Kuhn 029 */ 030 public class ACEEditorServlet extends WebContainerServlet { 031 032 private static final long serialVersionUID = -2533205689651186115L; 033 034 /** 035 * Creates a new ACE Editor servlet. 036 */ 037 public ACEEditorServlet() { 038 } 039 040 public ApplicationInstance newApplicationInstance() { 041 042 return new ApplicationInstance() { 043 044 private static final long serialVersionUID = 2982410120358060245L; 045 046 public Window init() { 047 setStyleSheet(Style.styleSheet); 048 049 if (!APELocal.isInitialized()) { 050 String apeCommand = getServletContext().getInitParameter("apecommand"); 051 if (apeCommand == null) apeCommand = "ape.exe"; 052 APELocal.init(apeCommand); 053 } 054 055 ContainerContext cc = (ContainerContext) ApplicationInstance.getActive().getContextProperty(ContainerContext.CONTEXT_PROPERTY_NAME); 056 cc.setServerDelayMessage(new ServerDelayMessage("Please wait...", "../wait.gif")); 057 // (The wait icon should be copied at the right place on the server.) 058 059 String lexiconFile = getInitParameter("lexicon"); 060 if (lexiconFile == null) lexiconFile = "lexicon.pl"; 061 boolean parseWithClexEnabled = !"off".equals(getInitParameter("parse_with_clex")); 062 return new ACEEditor(lexiconFile, parseWithClexEnabled); 063 } 064 065 }; 066 067 } 068 069 }