001 // This file is part of AceWiki.
002 // Copyright 2008-2012, AceWiki developers.
003 //
004 // AceWiki is free software: you can redistribute it and/or modify it under the terms of the GNU
005 // Lesser General Public License as published by the Free Software Foundation, either version 3 of
006 // the License, or (at your option) any later version.
007 //
008 // AceWiki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
010 // Lesser General Public License for more details.
011 //
012 // You should have received a copy of the GNU Lesser General Public License along with AceWiki. If
013 // not, see http://www.gnu.org/licenses/.
014
015 package ch.uzh.ifi.attempto.acewiki.gui;
016
017 import java.util.List;
018
019 import nextapp.echo.app.Column;
020 import nextapp.echo.app.Font;
021 import nextapp.echo.app.Insets;
022 import ch.uzh.ifi.attempto.acewiki.Wiki;
023 import ch.uzh.ifi.attempto.acewiki.core.LanguageUtils;
024 import ch.uzh.ifi.attempto.acewiki.core.Sentence;
025 import ch.uzh.ifi.attempto.acewiki.core.SentenceDetail;
026 import ch.uzh.ifi.attempto.echocomp.SolidLabel;
027 import ch.uzh.ifi.attempto.echocomp.VSpace;
028 import echopoint.DirectHtml;
029
030 /**
031 * This class represents a page that shows the details of an ACE sentence.
032 *
033 * @author Tobias Kuhn
034 */
035 public class SentencePage extends WikiPage {
036
037 private static final long serialVersionUID = -1550505465878272821L;
038
039 private Sentence sentence;
040
041 /**
042 * Creates a new sentence page.
043 *
044 * @param wiki The wiki instance.
045 * @param sentence The sentence to be shown in the page.
046 */
047 public SentencePage(Wiki wiki, Sentence sentence) {
048 super(wiki);
049 this.sentence = sentence;
050
051 addSelectedTab("Sentence");
052
053 String t = LanguageUtils.getPrettyPrinted(sentence.getText(wiki.getLanguage()));
054 add(new Title(t, false));
055 addHorizontalLine();
056 add(new VSpace(15));
057
058 List<SentenceDetail> l = sentence.getDetails(wiki.getLanguage());
059
060 if (l == null || l.isEmpty()) {
061 Column col = new Column();
062 col.setInsets(new Insets(10, 5, 5, 15));
063 col.add(new SolidLabel("(no detail information available)", Font.ITALIC, 10));
064 add(col);
065 } else {
066 for (SentenceDetail si : l) {
067 addHeadline(si.getName());
068 Column infoColumn = new Column();
069 infoColumn.setInsets(new Insets(10, 5, 5, 15));
070 infoColumn.add(new DirectHtml(si.getRichText()));
071 add(infoColumn);
072 }
073 }
074
075 }
076
077 public boolean equals(Object obj) {
078 if (obj instanceof SentencePage) {
079 return sentence == ((SentencePage) obj).sentence;
080 }
081 return false;
082 }
083
084 public String toString() {
085 return sentence.getText(getWiki().getEngine().getLanguages()[0]);
086 }
087
088 }