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.acewiki.gui.page; 016 017 import static ch.uzh.ifi.attempto.ape.OutputType.PARAPHRASE1; 018 import static ch.uzh.ifi.attempto.ape.OutputType.SYNTAXPP; 019 import nextapp.echo2.app.Column; 020 import nextapp.echo2.app.Insets; 021 import nextapp.echo2.app.event.ActionEvent; 022 import nextapp.echo2.app.event.ActionListener; 023 import ch.uzh.ifi.attempto.acewiki.Wiki; 024 import ch.uzh.ifi.attempto.acewiki.core.ontology.Sentence; 025 import ch.uzh.ifi.attempto.acewiki.gui.Title; 026 import ch.uzh.ifi.attempto.ape.SyntaxBoxes; 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 boxesColumn.add(new DirectHtml(SyntaxBoxes.getBoxesHtml(sentence.getParserResult()))); 069 add(boxesColumn); 070 071 addHeadline("Syntax Tree"); 072 073 Column syntaxColumn = new Column(); 074 syntaxColumn.setInsets(new Insets(10, 0, 5, 15)); 075 syntaxColumn.add(new DirectHtml("<pre>" + sentence.getParserResult().get(SYNTAXPP) + "</pre>")); 076 add(syntaxColumn); 077 } 078 079 public void actionPerformed(ActionEvent e) { 080 if ("Logic".equals(e.getActionCommand())) { 081 getWiki().showPage(new LogicPage(getWiki(), sentence)); 082 } 083 } 084 085 public boolean equals(Object obj) { 086 if (obj instanceof SentencePage) { 087 return sentence == ((SentencePage) obj).sentence; 088 } 089 return false; 090 } 091 092 public String toString() { 093 return sentence.getText(); 094 } 095 096 }