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