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.Map; 018 019 import nextapp.echo.app.Insets; 020 import nextapp.echo.app.event.ActionEvent; 021 import nextapp.echo.app.event.ActionListener; 022 import ch.uzh.ifi.attempto.acewiki.Wiki; 023 import ch.uzh.ifi.attempto.acewiki.core.AceWikiReasoner; 024 import ch.uzh.ifi.attempto.acewiki.core.Ontology; 025 import ch.uzh.ifi.attempto.echocomp.VSpace; 026 027 /** 028 * This class represents a page with information about the respective wiki. 029 * 030 * @author Tobias Kuhn 031 */ 032 public class AboutPage extends WikiPage implements ActionListener { 033 034 private static final long serialVersionUID = -5184590884798735077L; 035 036 private NameValueTable table1, table2, table3, table4; 037 038 /** 039 * Creates a new about page. 040 * 041 * @param wiki The wiki instance. 042 */ 043 public AboutPage(Wiki wiki) { 044 super(wiki); 045 046 addTab("Main Page", this); 047 addTab("Index", this); 048 addTab("Search", this); 049 addSelectedTab("About"); 050 051 add(new Title("About", true)); 052 addHorizontalLine(); 053 add(new VSpace(10)); 054 055 addHeadline("System"); 056 table1 = new NameValueTable(); 057 table1.setInsets(new Insets(10, 10, 10, 15)); 058 add(table1); 059 060 addHeadline("Ontology"); 061 table2 = new NameValueTable(); 062 table2.setInsets(new Insets(10, 10, 10, 15)); 063 add(table2); 064 065 addHeadline("Reasoner"); 066 table3 = new NameValueTable(); 067 table3.setInsets(new Insets(10, 10, 10, 15)); 068 add(table3); 069 070 addHeadline("Users"); 071 table4 = new NameValueTable(); 072 table4.setInsets(new Insets(10, 10, 10, 15)); 073 add(table4); 074 075 add(new VSpace(20)); 076 } 077 078 protected void doUpdate() { 079 table1.clear(); 080 table2.clear(); 081 table3.clear(); 082 table4.clear(); 083 084 Wiki w = getWiki(); 085 Ontology o = w.getOntology(); 086 087 table1.addEntry("AceWiki version", Wiki.getInfo("acewiki-version")); 088 table1.addEntry("AceWiki release stage", Wiki.getInfo("acewiki-release-stage")); 089 table1.addEntry("AceWiki build date", Wiki.getInfo("acewiki-build-date")); 090 091 table2.addEntry("ontology name", o.getName()); 092 table2.addEntry("number of ontology elements", o.getOntologyElements().size() + ""); 093 table2.addEntry("ontology URI", o.getURI()); 094 095 AceWikiReasoner r = o.getReasoner(); 096 table3.addEntry("reasoner type", r.getReasonerType()); 097 table3.addEntry("reasoner name", r.getReasonerName()); 098 table3.addEntry("reasoner version", r.getReasonerVersion()); 099 Map<String, String> info = r.getInfo(); 100 if (info != null) { 101 for (String s : info.keySet()) { 102 table3.addEntry(s, info.get(s)); 103 } 104 } 105 106 table4.addEntry("number of registered users", w.getUserBase().getUserCount() + ""); 107 table4.addEntry("login enabled", (w.isLoginEnabled() ? "yes" : "no")); 108 table4.addEntry("login required for viewing", (w.isLoginRequiredForViewing() ? "yes" : "no")); 109 table4.addEntry("login required for editing", (w.isLoginRequiredForEditing() ? "yes" : "no")); 110 table4.addEntry("open user registration", (w.isUserRegistrationOpen() ? "yes" : "no")); 111 } 112 113 public void actionPerformed(ActionEvent e) { 114 if ("Main Page".equals(e.getActionCommand())) { 115 getWiki().showStartPage(); 116 } else if ("Index".equals(e.getActionCommand())) { 117 getWiki().showIndexPage(); 118 } else if ("Search".equals(e.getActionCommand())) { 119 getWiki().showSearchPage(); 120 } 121 } 122 123 public boolean equals(Object obj) { 124 return obj instanceof AboutPage; 125 } 126 127 public String toString() { 128 return "-ABOUT-"; 129 } 130 131 }