    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 nextapp.echo2.app.Color;
    018    import nextapp.echo2.app.event.ActionEvent;
    019    import ch.uzh.ifi.attempto.acewiki.Wiki;
    020    import ch.uzh.ifi.attempto.acewiki.core.ontology.Concept;
    021    import ch.uzh.ifi.attempto.acewiki.core.ontology.NounConcept;
    022    import ch.uzh.ifi.attempto.acewiki.core.ontology.OntologyElement;
    023    import ch.uzh.ifi.attempto.acewiki.core.ontology.Sentence;
    024    import ch.uzh.ifi.attempto.acewiki.gui.editor.SentenceEditorHandler;
    025
    026    /**
    027     * This class stands for an article page showing the article of a concept. At the
    028     * moment, concepts are represented only by nouns.
    029     *
    030     * @author Tobias Kuhn
    031     */
    032    public class ConceptPage extends ArticlePage {
    033
    034            private static final long serialVersionUID = -505381176379658743L;
    035
    036            private NounConcept concept;
    037
    038            /**
    039             * Creates a new article page for a concept.
    040             *
    041             * @param concept The concept.
    042             * @param wiki The wiki instance.
    043             */
    044            protected ConceptPage(Concept concept, Wiki wiki) {
    045                    super(wiki, concept);
    046                    this.concept = (NounConcept) concept;
    047
    048                    addTab("Individuals", this);
    049                    addTab("Hierarchy", this);
    050
    051                    update();
    052            }
    053
    054            public OntologyElement getOntologyElement() {
    055                    return concept;
    056            }
    057
    058            public void actionPerformed(ActionEvent e) {
    059                    super.actionPerformed(e);
    060                    if ("Individuals".equals(e.getActionCommand())) {
    061                            getWiki().showPage(new IndividualsPage(this));
    062                    } else if ("Hierarchy".equals(e.getActionCommand())) {
    063                            getWiki().showPage(new HierarchyPage(this));
    064                    }
    065            }
    066
    067            protected void doUpdate() {
    068                    super.doUpdate();
    069
    070                    getTitle().setText(concept.getHeadword());
    071
    072                    Thread thread = new Thread() {
    073                            public void run() {
    074                                    getWiki().enqueueTask(new Runnable() {
    075                                            public void run() {
    076                                                    if (concept.getOntology().isSatisfiable(concept)) {
    077                                                            getTitle().setColor(Color.BLACK);
    078                                                    } else {
    079                                                            getTitle().setColor(new Color(193, 0, 0));
    080                                                    }
    081                                            }
    082                                    });
    083                            }
    084                    };
    085                    thread.start();
    086            }
    087
    088            public void edit(Sentence sentence) {
    089                    if (concept.getSentences().contains(sentence)) {
    090                            getWiki().showWindow(SentenceEditorHandler.generatePreditorEditWindow(sentence, this));
    091                    }
    092            }
    093
    094    }