Author: batosai
Date: 2008-08-10 20:01:46 +0000 (Sun, 10 Aug 2008)
New Revision: 21725

Modified:
   trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
Log:
Better form.

Modified: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-10 19:34:41 UTC 
(rev 21724)
+++ trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-10 20:01:46 UTC 
(rev 21725)
@@ -216,17 +216,17 @@
                        listBoxContent.addChild("p", "You know no other 
identites yet, we are fetching the seedfile that contains a first set of 
identities (Freenet developpers).");
                }
                else {
-                       HTMLNode listForm = pr.addFormChild(listBoxContent, 
SELF_URI + "/setTrust", "setTrustForm");
+                       //HTMLNode listForm = pr.addFormChild(listBoxContent, 
SELF_URI + "/setTrust", "setTrustForm");

-                       HTMLNode identitiesTable = listForm.addChild("table", 
"border", "0");
+                       HTMLNode identitiesTable = 
listBoxContent.addChild("table", "border", "0");
                        HTMLNode row=identitiesTable.addChild("tr");
                        row.addChild("th", "NickName");
                        row.addChild("th", "Last update");
                        row.addChild("th", "Publish TrustList ?");
                        if(treeOwner != null) {
                                row.addChild("th", "Score (Rank)");
-                               row.addChild("th", "Trust");
-                               listForm.addChild("input", new String[] { 
"type", "name", "value" }, new String[] { "hidden", "owner", 
treeOwner.getRequestURI().toString() });
+                               row.addChild("th", "Trust/Comment");
+                               //listForm.addChild("input", new String[] { 
"type", "name", "value" }, new String[] { "hidden", "owner", 
treeOwner.getRequestURI().toString() });
                        }

                        ObjectSet<Identity> identities = 
db.queryByExample(Identity.class);
@@ -252,18 +252,25 @@
                                        row.addChild("td", 
String.valueOf(id.getScore((OwnIdentity)treeOwner, db).getScore())+" 
("+id.getScore((OwnIdentity)treeOwner, db).getRank()+")");

                                        // Trust
+                                       int trustValue = 0;
+                                       String trustComment = "";
+                                       ObjectSet<Trust> trusts = 
db.queryByExample(new Trust(treeOwner, id, 0, null));
+                                       if(trusts.hasNext()) {
+                                               Trust trust = trusts.next();
+                                               trustValue = trust.getValue();
+                                               trustComment = 
trust.getComment();
+                                       }
+                                       
                                        HTMLNode cell = row.addChild("td");
-                                       cell.addChild("input", new String[] { 
"type", "name", "value" }, new String[] { "text", 
id.getRequestURI().toString(), "0" });
+                                       HTMLNode trustForm = 
pr.addFormChild(cell, SELF_URI + "/setTrust", "setTrustForm");
+                                       trustForm.addChild("input", new 
String[] { "type", "name", "value" }, new String[] { "hidden", "truster", 
treeOwner.getRequestURI().toString() });
+                                       trustForm.addChild("input", new 
String[] { "type", "name", "value" }, new String[] { "hidden", "trustee", 
id.getRequestURI().toString() });
+                                       trustForm.addChild("input", new 
String[] { "type", "name", "size", "value" }, new String[] { "text", "value", 
"2", String.valueOf(trustValue) });
+                                       trustForm.addChild("input", new 
String[] { "type", "name", "size", "comment" }, new String[] { "text", 
"comment", "20", trustComment });
+                                       trustForm.addChild("input", new 
String[] { "type", "name", "value" }, new String[] { "submit", "update", 
"Update !" });
                                }
                        }
-                       if(treeOwner != null) {
-                               HTMLNode lastRow = 
identitiesTable.addChild("tr");
-                               HTMLNode lastCell = lastRow.addChild("td", new 
String[] { "colspan", "align" }, new String[] { "5", "center" });
-                               lastCell.addChild("input", new String[] { 
"type", "name", "value" }, new String[] { "submit", "updateTrust", "Update 
trust values !" });
-                       }
-               }
-               
-               
+               }               
                contentNode.addChild(addBox);
                contentNode.addChild(listBox);
                return pageNode.generate();
@@ -321,14 +328,17 @@
                        return insertIdentity(request);
                }
                else if (page.equals("/setTrust")) {
-                       // TODO Update all trust values
-                       return null;
+                       return updateTrust(request);
                }
                else {
                        return makeHomePage();
                }
        }

+       private String updateTrust(HTTPRequest request) {
+               return request.getPartAsString("truster", 
1024)+"<br>"+request.getPartAsString("trustee", 
1024)+"<br>"+request.getPartAsString("value", 
1024)+"<br>"+request.getPartAsString("comment", 1024)+"\n";
+       }
+
        private String addIdentity(HTTPRequest request) {

                try {


Reply via email to