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