Author: bombe
Date: 2008-11-17 02:15:54 +0000 (Mon, 17 Nov 2008)
New Revision: 23676

Added:
   trunk/plugins/WoT/ui/web/IdentityPage.java
Removed:
   trunk/plugins/WoT/ui/web/TrusteesPage.java
   trunk/plugins/WoT/ui/web/TrustersPage.java
Modified:
   trunk/plugins/WoT/WoT.java
   trunk/plugins/WoT/ui/web/KnownIdentitiesPage.java
Log:
Merge Trusters and Trustees web page into Identity page.
Link to Identity page from Known Identities.

Modified: trunk/plugins/WoT/WoT.java
===================================================================
--- trunk/plugins/WoT/WoT.java  2008-11-17 01:51:52 UTC (rev 23675)
+++ trunk/plugins/WoT/WoT.java  2008-11-17 02:15:54 UTC (rev 23676)
@@ -33,13 +33,12 @@
 import plugins.WoT.introduction.IntroductionPuzzle;
 import plugins.WoT.introduction.IntroductionServer;
 import plugins.WoT.ui.web.HomePage;
+import plugins.WoT.ui.web.IdentityPage;
 import plugins.WoT.ui.web.IntroduceIdentityPage;
 import plugins.WoT.ui.web.KnownIdentitiesPage;
 import plugins.WoT.ui.web.OwnIdentitiesPage;
 import plugins.WoT.ui.web.WebPage;
 import plugins.WoT.ui.web.ConfigurationPage;
-import plugins.WoT.ui.web.TrustersPage;
-import plugins.WoT.ui.web.TrusteesPage;
 import plugins.WoT.ui.web.CreateIdentityPage;
 import plugins.WoT.ui.web.WebPageImpl;
 
@@ -193,29 +192,22 @@
                else if(request.isParameterSet("knownidentities")) page = new 
KnownIdentitiesPage(this, request);
                else if(request.isParameterSet("configuration")) page = new 
ConfigurationPage(this, request);
                // TODO Handle these two in KnownIdentitiesPage
-               else if (request.isParameterSet("getTrusters")) {
+               else if (request.isParameterSet("showIdentity")) {
                        try {
                                Identity identity = Identity.getById(db, 
request.getParam("id"));
-                               Set<Trust> trusters = new HashSet<Trust>();
-                               ObjectSet<Trust> trusts = 
identity.getReceivedTrusts(db);
+                               Set<Trust> trusteesTrusts = new 
HashSet<Trust>();
+                               ObjectSet<Trust> trusts = 
identity.getGivenTrusts(db);
                                while (trusts.hasNext()) {
                                        Trust trust = trusts.next();
-                                       trusters.add(trust);
+                                       trusteesTrusts.add(trust);
                                }
-                               page = new TrustersPage(this, request, 
identity, trusters);
-                       } catch (UnknownIdentityException uie1) {
-                               Logger.error(this, "Could not load identity " + 
request.getParam("id"), uie1);
-                       }
-               } else if (request.isParameterSet("getTrustees")) {
-                       try {
-                               Identity identity = Identity.getById(db, 
request.getParam("id"));
-                               Set<Trust> trusters = new HashSet<Trust>();
-                               ObjectSet<Trust> trusts = 
identity.getGivenTrusts(db);
+                               Set<Trust> trustersTrusts = new 
HashSet<Trust>();
+                               trusts = identity.getReceivedTrusts(db);
                                while (trusts.hasNext()) {
                                        Trust trust = trusts.next();
-                                       trusters.add(trust);
+                                       trustersTrusts.add(trust);
                                }
-                               page = new TrusteesPage(this, request, 
identity, trusters);
+                               page = new IdentityPage(this, request, 
identity, trustersTrusts, trusteesTrusts);
                        } catch (UnknownIdentityException uie1) {
                                Logger.error(this, "Could not load identity " + 
request.getParam("id"), uie1);
                        }

Added: trunk/plugins/WoT/ui/web/IdentityPage.java
===================================================================
--- trunk/plugins/WoT/ui/web/IdentityPage.java                          (rev 0)
+++ trunk/plugins/WoT/ui/web/IdentityPage.java  2008-11-17 02:15:54 UTC (rev 
23676)
@@ -0,0 +1,109 @@
+/*
+ * freenet - IdentityPage.java
+ * Copyright © 2008 David Roden
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+package plugins.WoT.ui.web;
+
+import java.util.Set;
+
+import plugins.WoT.Identity;
+import plugins.WoT.Trust;
+import plugins.WoT.WoT;
+import freenet.support.HTMLNode;
+import freenet.support.api.HTTPRequest;
+
+/**
+ * @author David &lsquo;Bombe&rsquo; Roden &lt;[EMAIL PROTECTED]&gt;
+ * @version $Id$
+ */
+public class IdentityPage extends WebPageImpl {
+
+       /** The identity to show trust relationships of. */
+       private final Identity identity;
+
+       /** All trusts that trust the identity. */
+       private final Set<Trust> trustersTrusts;
+
+       /** All trusts that the identity trusts. */
+       private final Set<Trust> trusteesTrusts;
+
+       /**
+        * Creates a new trust-relationship web page.
+        * 
+        * @param webOfTrust
+        *            The web of trust
+        * @param httpRequest
+        *            The HTTP request
+        * @param identity
+        *            The identity
+        * @param trustersTrusts
+        *            The trusts having the given identity as truster
+        * @param trusteesTrusts
+        *            The trusts having the given identity as trustee
+        */
+       public IdentityPage(WoT webOfTrust, HTTPRequest httpRequest, Identity 
identity, Set<Trust> trustersTrusts, Set<Trust> trusteesTrusts) {
+               super(webOfTrust, httpRequest);
+               this.identity = identity;
+               this.trustersTrusts = trustersTrusts;
+               this.trusteesTrusts = trusteesTrusts;
+       }
+
+       /**
+        * [EMAIL PROTECTED]
+        * 
+        * @see WebPage#make()
+        */
+       public void make() {
+               HTMLNode trusteeTrustsNode = getContentBox("Identities that “" 
+ identity.getNickName() + "” trusts");
+
+               HTMLNode trustersTable = trusteeTrustsNode.addChild("table");
+               HTMLNode trustersTableHeader = trustersTable.addChild("tr");
+               trustersTableHeader.addChild("th", "NickName");
+               trustersTableHeader.addChild("th", "Identity");
+               trustersTableHeader.addChild("th", "Trust Value");
+               trustersTableHeader.addChild("th", "Comment");
+
+               for (Trust trust : trusteesTrusts) {
+                       HTMLNode trustRow = trustersTable.addChild("tr");
+                       Identity trustee = trust.getTrustee();
+                       trustRow.addChild("td").addChild("a", "href", 
"?showIdentity&id=" + trustee.getId(), trustee.getNickName());
+                       trustRow.addChild("td", trustee.getId());
+                       trustRow.addChild("td", "align", "right", 
String.valueOf(trust.getValue()));
+                       trustRow.addChild("td", trust.getComment());
+               }
+
+               HTMLNode trusterTrustsNode = getContentBox("Identities that 
trust “" + identity.getNickName() + "”");
+
+               HTMLNode trusteesTable = trusterTrustsNode.addChild("table");
+               HTMLNode trusteesTableHeader = trusteesTable.addChild("tr");
+               trusteesTableHeader.addChild("th", "NickName");
+               trusteesTableHeader.addChild("th", "Identity");
+               trusteesTableHeader.addChild("th", "Trust Value");
+               trusteesTableHeader.addChild("th", "Comment");
+
+               for (Trust trust : trustersTrusts) {
+                       HTMLNode trustRow = trusteesTable.addChild("tr");
+                       Identity truster = trust.getTruster();
+                       trustRow.addChild("td").addChild("a", "href", 
"?showIdentity&id=" + truster.getId(), truster.getNickName());
+                       trustRow.addChild("td", truster.getId());
+                       trustRow.addChild("td", "align", "right", 
String.valueOf(trust.getValue()));
+                       trustRow.addChild("td", trust.getComment());
+               }
+       }
+
+}

Modified: trunk/plugins/WoT/ui/web/KnownIdentitiesPage.java
===================================================================
--- trunk/plugins/WoT/ui/web/KnownIdentitiesPage.java   2008-11-17 01:51:52 UTC 
(rev 23675)
+++ trunk/plugins/WoT/ui/web/KnownIdentitiesPage.java   2008-11-17 02:15:54 UTC 
(rev 23676)
@@ -150,7 +150,7 @@
                        row=identitiesTable.addChild("tr");
                        
                        // NickName
-                       row.addChild("td", new String[] {"title", "style"}, new 
String[] {id.getRequestURI().toString(), "cursor: help;"}, id.getNickName());
+                       row.addChild("td", new String[] {"title", "style"}, new 
String[] {id.getRequestURI().toString(), "cursor: help;"}).addChild("a", 
"href", "?showIdentity&id=" + id.getId(), id.getNickName());
                        
                        // Last Change
                        row.addChild("td", id.getReadableLastChange());
@@ -173,11 +173,11 @@
                        
                        // Nb Trusters
                        HTMLNode trustersCell = row.addChild("td", new String[] 
{ "align" }, new String[] { "center" });
-                       trustersCell.addChild(new HTMLNode("a", "href", 
SELF_URI + "?getTrusters&id="+id.getId(), 
Long.toString(id.getNbReceivedTrusts(db))));
+                       trustersCell.addChild(new HTMLNode("a", "href", 
SELF_URI + "?showIdentity&id="+id.getId(), 
Long.toString(id.getNbReceivedTrusts(db))));
                        
                        // Nb Trustees
                        HTMLNode trusteesCell = row.addChild("td", new String[] 
{ "align" }, new String[] { "center" });
-                       trusteesCell.addChild(new HTMLNode("a", "href", 
SELF_URI + "?getTrustees&id="+id.getId(), 
Long.toString(id.getNbGivenTrusts(db))));
+                       trusteesCell.addChild(new HTMLNode("a", "href", 
SELF_URI + "?showIdentity&id="+id.getId(), 
Long.toString(id.getNbGivenTrusts(db))));
                }
        }
        

Deleted: trunk/plugins/WoT/ui/web/TrusteesPage.java
===================================================================
--- trunk/plugins/WoT/ui/web/TrusteesPage.java  2008-11-17 01:51:52 UTC (rev 
23675)
+++ trunk/plugins/WoT/ui/web/TrusteesPage.java  2008-11-17 02:15:54 UTC (rev 
23676)
@@ -1,71 +0,0 @@
-/*
- * This code is part of WoT, a plugin for Freenet. It is distributed 
- * under the GNU General Public License, version 2 (or at your option
- * any later version). See http://www.gnu.org/ for details of the GPL.
- */
-package plugins.WoT.ui.web;
-
-import java.util.Set;
-
-import plugins.WoT.Identity;
-import plugins.WoT.Trust;
-import plugins.WoT.WoT;
-import freenet.support.HTMLNode;
-import freenet.support.api.HTTPRequest;
-
-/**
- * Web page that shows all identities that receive trust from a given identity.
- * 
- * @author David ‘Bombe’ Roden <[EMAIL PROTECTED]>
- */
-public class TrusteesPage extends WebPageImpl {
-
-       /** The identity to show the trustees of. */
-       private final Identity identity;
-
-       /** Set of trusts that have the identity as truster. */
-       private final Set<Trust> trusts;
-
-       /**
-        * Creates a new trustee web page.
-        * 
-        * @param wot
-        *            a reference to the WoT, used to get resources the page 
needs.
-        * @param request
-        *            the request sent by the user.
-        * @param identity
-        *            The identity to show the trustees of
-        * @param trusts
-        *            The trusts that have the given identity as truster
-        */
-       public TrusteesPage(WoT wot, HTTPRequest request, Identity identity, 
Set<Trust> trusts) {
-               super(wot, request);
-               this.identity = identity;
-               this.trusts = trusts;
-       }
-
-       /**
-        * [EMAIL PROTECTED]
-        * 
-        * @see plugins.WoT.ui.web.WebPage#make()
-        */
-       public void make() {
-               HTMLNode contentNode = getContentBox("Identities that “" + 
identity.getNickName() + "” trusts");
-
-               HTMLNode trustersTable = contentNode.addChild("table");
-               HTMLNode trustersTableHeader = trustersTable.addChild("tr");
-               trustersTableHeader.addChild("th", "NickName");
-               trustersTableHeader.addChild("th", "Identity");
-               trustersTableHeader.addChild("th", "Trust Value");
-               trustersTableHeader.addChild("th", "Comment");
-
-               for (Trust trust : trusts) {
-                       HTMLNode trustRow = trustersTable.addChild("tr");
-                       trustRow.addChild("td", 
trust.getTrustee().getNickName());
-                       trustRow.addChild("td", trust.getTrustee().getId());
-                       trustRow.addChild("td", "align", "right", 
String.valueOf(trust.getValue()));
-                       trustRow.addChild("td", trust.getComment());
-               }
-       }
-
-}

Deleted: trunk/plugins/WoT/ui/web/TrustersPage.java
===================================================================
--- trunk/plugins/WoT/ui/web/TrustersPage.java  2008-11-17 01:51:52 UTC (rev 
23675)
+++ trunk/plugins/WoT/ui/web/TrustersPage.java  2008-11-17 02:15:54 UTC (rev 
23676)
@@ -1,71 +0,0 @@
-/*
- * This code is part of WoT, a plugin for Freenet. It is distributed 
- * under the GNU General Public License, version 2 (or at your option
- * any later version). See http://www.gnu.org/ for details of the GPL.
- */
-package plugins.WoT.ui.web;
-
-import java.util.Set;
-
-import plugins.WoT.Identity;
-import plugins.WoT.Trust;
-import plugins.WoT.WoT;
-import freenet.support.HTMLNode;
-import freenet.support.api.HTTPRequest;
-
-/**
- * Web page that shows all identities that give trust to a given identity.
- * 
- * @author David ‘Bombe’ Roden <[EMAIL PROTECTED]>
- */
-public class TrustersPage extends WebPageImpl {
-
-       /** The identity to show the trusters of. */
-       private final Identity identity;
-
-       /** Set of trusts that have the given identity as trustee. */
-       private final Set<Trust> trusts;
-
-       /**
-        * Creates a new truster web page.
-        * 
-        * @param wot
-        *            a reference to the WoT, used to get resources the page 
needs.
-        * @param request
-        *            the request sent by the user.
-        * @param identity
-        *            The identity to show the trusters of
-        * @param trusters
-        *            The trusts that have the given identity as trustee
-        */
-       public TrustersPage(WoT wot, HTTPRequest request, Identity identity, 
Set<Trust> trusters) {
-               super(wot, request);
-               this.identity = identity;
-               this.trusts = trusters;
-       }
-
-       /**
-        * [EMAIL PROTECTED]
-        * 
-        * @see plugins.WoT.ui.web.WebPage#make()
-        */
-       public void make() {
-               HTMLNode contentNode = getContentBox("Identities that trust “" 
+ identity.getNickName() + "”");
-
-               HTMLNode trustersTable = contentNode.addChild("table");
-               HTMLNode trustersTableHeader = trustersTable.addChild("tr");
-               trustersTableHeader.addChild("th", "NickName");
-               trustersTableHeader.addChild("th", "Identity");
-               trustersTableHeader.addChild("th", "Trust Value");
-               trustersTableHeader.addChild("th", "Comment");
-
-               for (Trust trust : trusts) {
-                       HTMLNode trustRow = trustersTable.addChild("tr");
-                       trustRow.addChild("td", 
trust.getTruster().getNickName());
-                       trustRow.addChild("td", trust.getTruster().getId());
-                       trustRow.addChild("td", "align", "right", 
String.valueOf(trust.getValue()));
-                       trustRow.addChild("td", trust.getComment());
-               }
-       }
-
-}

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to