    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.DRSPP;
    018    import nextapp.echo2.app.Column;
    019    import nextapp.echo2.app.Insets;
    020    import nextapp.echo2.app.event.ActionEvent;
    021    import nextapp.echo2.app.event.ActionListener;
    022    import ch.uzh.ifi.attempto.acewiki.Wiki;
    023    import ch.uzh.ifi.attempto.acewiki.core.ontology.Sentence;
    024    import ch.uzh.ifi.attempto.acewiki.gui.Title;
    025    import ch.uzh.ifi.attempto.echocomp.VSpace;
    026    import echopointng.DirectHtml;
    027    import echopointng.util.HtmlKit;
    028
    029    /**
    030     * This class represents a page that shows the logical representation of an ACE sentence.
    031     *
    032     * @author Tobias Kuhn
    033     */
    034    public class LogicPage extends WikiPage implements ActionListener {
    035
    036            private static final long serialVersionUID = 61958212885537L;
    037
    038            private Sentence sentence;
    039
    040            /**
    041             * Creates a new logic page.
    042             *
    043             * @param wiki The wiki instance.
    044             * @param sentence The sentence whose logical representation should be shown in the page.
    045             */
    046            public LogicPage(Wiki wiki, Sentence sentence) {
    047                    super(wiki, new Title(sentence.toString(), "- Logic"));
    048                    this.sentence = sentence;
    049
    050                    addTab("Sentence", this);
    051                    addSelectedTab("Logic");
    052
    053                    add(new VSpace(15));
    054
    055                    addHeadline("Logical representation");
    056
    057                    Column drsColumn = new Column();
    058                    drsColumn.setInsets(new Insets(10, 0, 5, 15));
    059                    drsColumn.add(new DirectHtml("<i><pre>" + sentence.getParserResult().get(DRSPP) + "</pre></i>"));
    060                    add(drsColumn);
    061
    062                    if (sentence.isOWLSWRL()) {
    063
    064                            if (sentence.isOWL()) {
    065                                    addHeadline("OWL (XML syntax)");
    066                            } else {
    067                                    addHeadline("OWL+SWRL (RDF/XML syntax)");
    068                            }
    069
    070                            Column owlrdfColumn = new Column();
    071                            owlrdfColumn.setInsets(new Insets(10, 0, 5, 25));
    072                            owlrdfColumn.add(new DirectHtml("<i><pre>" + HtmlKit.encode(sentence.getOWLXML()) + "</pre></i>"));
    073                            add(owlrdfColumn);
    074                    }
    075            }
    076
    077            public void actionPerformed(ActionEvent e) {
    078                    if ("Sentence".equals(e.getActionCommand())) {
    079                            getWiki().showPage(new SentencePage(getWiki(), sentence));
    080                    }
    081            }
    082
    083            public boolean equals(Object obj) {
    084                    if (obj instanceof LogicPage) {
    085                            return sentence == ((LogicPage) obj).sentence;
    086                    }
    087                    return false;
    088            }
    089
    090            public String toString() {
    091                    return "Logic: " + sentence.getText();
    092            }
    093
    094    }