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.preditor.example;
016    
017    import nextapp.echo2.app.ApplicationInstance;
018    import nextapp.echo2.app.Window;
019    import nextapp.echo2.webcontainer.WebContainerServlet;
020    import ch.uzh.ifi.attempto.echocomp.Style;
021    import ch.uzh.ifi.attempto.preditor.PreditorWindow;
022    import ch.uzh.ifi.attempto.preditor.text.EnglishContextChecker;
023    
024    /**
025     * This class is an examplary implementation of a servlet that starts a predictive editor. See the
026     * <a href="{@docRoot}/src-html/ch/uzh/ifi/attempto/preditor/example/ExampleServlet.html#line.1">source code</a>.
027     * 
028     * @author Tobias Kuhn
029     */
030    public class ExampleServlet extends WebContainerServlet {
031            
032            private static final long serialVersionUID = -6998969461055356964L;
033    
034            /**
035             * Creates a new servlet instance.
036             */
037            public ExampleServlet() {
038            }
039    
040            public ApplicationInstance newApplicationInstance() {
041                    
042                    return new ApplicationInstance() {
043                            
044                            private static final long serialVersionUID = -5640636230574254208L;
045    
046                            public Window init() {
047                                    setStyleSheet(Style.styleSheet);
048                                    Window window = new Window();
049                                    window.setTitle("Preditor Example Application");
050                                    
051                                    PreditorWindow preditor = new PreditorWindow("My Predictive Editor", new ExampleGrammar(), new ExampleMenuCreator());
052                                    preditor.setContextChecker(new EnglishContextChecker(true));
053                                    preditor.setClosable(false);
054                                    window.getContent().add(preditor);
055                                    
056                                    return window;
057                            }
058                            
059                    };
060                    
061            }
062    
063    }