    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.acewiki.gui.page;
    016
    017    import static ch.uzh.ifi.attempto.ape.OutputType.PARAPHRASE1;
    018    import static ch.uzh.ifi.attempto.ape.OutputType.SYNTAX;
    019    import static ch.uzh.ifi.attempto.ape.OutputType.SYNTAXPP;
    020    import nextapp.echo2.app.Column;
    021    import nextapp.echo2.app.Insets;
    022    import nextapp.echo2.app.event.ActionEvent;
    023    import nextapp.echo2.app.event.ActionListener;
    024    import ch.uzh.ifi.attempto.acewiki.Wiki;
    025    import ch.uzh.ifi.attempto.acewiki.core.ontology.Sentence;
    026    import ch.uzh.ifi.attempto.acewiki.gui.Title;
    027    import ch.uzh.ifi.attempto.echocomp.Label;
    028    import ch.uzh.ifi.attempto.echocomp.VSpace;
    029    import echopointng.DirectHtml;
    030
    031    /**
    032     * This class represents a page that shows the details of an ACE sentence.
    033     *
    034     * @author Tobias Kuhn
    035     */
    036    public class SentencePage extends WikiPage implements ActionListener {
    037
    038            private static final long serialVersionUID = -1550505465878272821L;
    039
    040            private Sentence sentence;
    041
    042            /**
    043             * Creates a new sentence page.
    044             *
    045             * @param wiki The wiki instance.
    046             * @param sentence The sentence to be shown in the page.
    047             */
    048            public SentencePage(Wiki wiki, Sentence sentence) {
    049                    super(wiki, new Title(sentence.toString(), false));
    050                    this.sentence = sentence;
    051
    052                    addSelectedTab("Sentence");
    053                    addTab("Logic", this);
    054
    055                    add(new VSpace(15));
    056
    057                    addHeadline("Paraphrase");
    058
    059                    Column paraphraseColumn = new Column();
    060                    paraphraseColumn.setInsets(new Insets(10, 5, 5, 15));
    061                    paraphraseColumn.add(new Label(sentence.getParserResult().get(PARAPHRASE1)));
    062                    add(paraphraseColumn);
    063
    064                    addHeadline("Syntax Boxes");
    065
    066                    Column boxesColumn = new Column();
    067                    boxesColumn.setInsets(new Insets(10, 5, 5, 15));
    068                    String syntaxList = sentence.getParserResult().get(SYNTAX);
    069                    boxesColumn.add(new DirectHtml(SyntaxBoxes.getBoxesHtml(syntaxList, true, true, true)));
    070                    add(boxesColumn);
    071
    072                    addHeadline("Syntax Tree");
    073
    074                    Column syntaxColumn = new Column();
    075                    syntaxColumn.setInsets(new Insets(10, 0, 5, 15));
    076                    syntaxColumn.add(new DirectHtml("<pre>" + sentence.getParserResult().get(SYNTAXPP) + "</pre>"));
    077                    add(syntaxColumn);
    078            }
    079
    080            public void actionPerformed(ActionEvent e) {
    081                    if ("Logic".equals(e.getActionCommand())) {
    082                            getWiki().showPage(new LogicPage(getWiki(), sentence));
    083                    }
    084            }
    085
    086            public boolean equals(Object obj) {
    087                    if (obj instanceof SentencePage) {
    088                            return sentence == ((SentencePage) obj).sentence;
    089                    }
    090                    return false;
    091            }
    092
    093            public String toString() {
    094                    return sentence.getText();
    095            }
    096
    097    }