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.event.ActionEvent;
018    import ch.uzh.ifi.attempto.acewiki.Wiki;
019    import ch.uzh.ifi.attempto.acewiki.core.ontology.Individual;
020    import ch.uzh.ifi.attempto.acewiki.core.ontology.OntologyElement;
021    import ch.uzh.ifi.attempto.acewiki.core.ontology.Sentence;
022    import ch.uzh.ifi.attempto.acewiki.gui.editor.SentenceEditorHandler;
023    
024    /**
025     * This class stands for an article page showing the article of an individual. Individuals
026     * are represented by proper names.
027     * 
028     * @author Tobias Kuhn
029     */
030    public class IndividualPage extends ArticlePage {
031            
032            private static final long serialVersionUID = 8411734605383577958L;
033    
034            private Individual ind;
035            
036            /**
037             * Creates a new article page for an individual.
038             * 
039             * @param ind The individual.
040             * @param wiki The wiki instance.
041             */
042            public IndividualPage(Individual ind, Wiki wiki) {
043                    super(wiki, ind);
044                    this.ind = ind;
045                    
046                    addTab("Assignments", this);
047            }
048            
049            public OntologyElement getOntologyElement() {
050                    return ind;
051            }
052    
053            public void actionPerformed(ActionEvent e) {
054                    super.actionPerformed(e);
055                    if ("Assignments".equals(e.getActionCommand())) {
056                            getWiki().showPage(new AssignmentsPage(this));
057                    }
058            }
059            
060            protected void doUpdate() {
061                    super.doUpdate();
062                    
063                    getTitle().setText(ind.getHeadword());
064            }
065            
066            public void edit(Sentence sentence) {
067                    if (ind.getSentences().contains(sentence)) {
068                            getWiki().showWindow(SentenceEditorHandler.generatePreditorEditWindow(sentence, this));
069                    }
070            }
071    
072    }