Author: saces
Date: 2008-09-14 12:34:01 +0000 (Sun, 14 Sep 2008)
New Revision: 22652

Removed:
   trunk/plugins/FMSPlugin/ui/Service.java
Modified:
   trunk/plugins/FMSPlugin/FMS.java
   trunk/plugins/FMSPlugin/FMSPlugin.java
   trunk/plugins/FMSPlugin/ui/Welcome.java
Log:
ui fixes

Modified: trunk/plugins/FMSPlugin/FMS.java
===================================================================
--- trunk/plugins/FMSPlugin/FMS.java    2008-09-14 11:43:55 UTC (rev 22651)
+++ trunk/plugins/FMSPlugin/FMS.java    2008-09-14 12:34:01 UTC (rev 22652)
@@ -4,8 +4,10 @@
 package plugins.FMSPlugin;

 import com.db4o.ObjectContainer;
+import com.db4o.ObjectSet;

 import freenet.clients.http.PageMaker;
+import freenet.pluginmanager.FredPluginFCP;
 import freenet.pluginmanager.PluginRespirator;
 import freenet.support.HTMLNode;
 import freenet.support.io.TempBucketFactory;
@@ -33,4 +35,18 @@
        final public HTMLNode getPageNode() {
                return pm.getPageNode(FMSPlugin.SELF_TITLE, null);
        }
+
+       /* ----- utils ----- */
+       public boolean isWoTpresent() {
+               FredPluginFCP plug = 
pr.getNode().pluginManager.getFCPPlugin(FMSPlugin.WOT_NAME);
+               return (plug != null);
+       }
+
+       public long countIdentities() {
+               return db_config.queryByExample(FMSIdentity.class).size() - 
countOwnIdentities();
+       }
+
+       public long countOwnIdentities() {
+               return db_config.queryByExample(FMSOwnIdentity.class).size();
+       }
 }

Modified: trunk/plugins/FMSPlugin/FMSPlugin.java
===================================================================
--- trunk/plugins/FMSPlugin/FMSPlugin.java      2008-09-14 11:43:55 UTC (rev 
22651)
+++ trunk/plugins/FMSPlugin/FMSPlugin.java      2008-09-14 12:34:01 UTC (rev 
22652)
@@ -11,7 +11,6 @@
 import plugins.FMSPlugin.ui.Errors;
 import plugins.FMSPlugin.ui.IdentityEditor;
 import plugins.FMSPlugin.ui.Messages;
-import plugins.FMSPlugin.ui.Service;
 import plugins.FMSPlugin.ui.Status;
 import plugins.FMSPlugin.ui.Welcome;

@@ -52,7 +51,7 @@

        public static String SELF_URI = "/plugins/plugins.FMSPlugin.FMSPlugin";
        public static String SELF_TITLE = "FMS clone";
-       //private static String WOT_NAME = "plugins.WoT.WoTplugin";
+       public static String WOT_NAME = "plugins.WoT.WoT";

        public final String MESSAGEBASE = "fms";

@@ -133,10 +132,6 @@
                        return Status.makeStatusPage(fms);
                }

-               if ("/service".equals(page)) {
-                       return Service.makeServicePage(fms);
-               }
-
                if ("/ownidentities".equals(page))
                        return IdentityEditor.makeOwnIdentitiesPage(fms, 
request);


Deleted: trunk/plugins/FMSPlugin/ui/Service.java
===================================================================
--- trunk/plugins/FMSPlugin/ui/Service.java     2008-09-14 11:43:55 UTC (rev 
22651)
+++ trunk/plugins/FMSPlugin/ui/Service.java     2008-09-14 12:34:01 UTC (rev 
22652)
@@ -1,43 +0,0 @@
-/* This code is part of 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 further details of the GPL. */
-package plugins.FMSPlugin.ui;
-
-import plugins.FMSPlugin.FMS;
-import plugins.FMSPlugin.FMSPlugin;
-import freenet.support.HTMLNode;
-
-public class Service {
-       
-       public static String makeServicePage(FMS fms) {
-               HTMLNode pageNode = fms.getPageNode();
-               HTMLNode contentNode = fms.pm.getContentNode(pageNode);
-               contentNode.addChild(createExportBox(fms));
-               contentNode.addChild(createImportBox(fms));
-               return pageNode.generate();
-       }
-       
-       private static HTMLNode createExportBox(FMS fms) {
-               HTMLNode exportBox = fms.pm.getInfobox("Export");
-               HTMLNode exportContent = fms.pm.getContentNode(exportBox);
-               HTMLNode exportForm = fms.pr.addFormChild(exportContent, 
FMSPlugin.SELF_URI + "/exportDB", "exportForm");
-               exportForm.addChild("#", "Export the database (Identities etc 
pp) to xml file. \u00a0 ");
-               exportForm.addChild("input", new String[] { "type", "name", 
"value" }, new String[] { "submit", "export", "Export" });
-               exportForm.addChild("br");
-               exportForm.addChild("#", "Store the backup at a safe place. You 
can reimport it at any node and continue flaming...");
-               return exportBox;
-       }
-       
-       private static HTMLNode createImportBox(FMS fms) {
-               HTMLNode importBox = fms.pm.getInfobox("Import");
-               HTMLNode importContent = fms.pm.getContentNode(importBox);
-               HTMLNode importForm = fms.pr.addFormChild(importContent, 
FMSPlugin.SELF_URI + "/importDB", "importForm");
-               importForm.addChild("#", "Choose xml file to import.\u00a0");
-               importForm.addChild("input", new String[] { "type", "name", 
"value" }, new String[] { "file", "filename", "" });
-               importForm.addChild("#", "\u00a0");
-               importForm.addChild("input", new String[] { "type", "name", 
"value" }, new String[] { "submit", "import", "Import" });
-               importForm.addChild("br");
-               importForm.addChild("#", "You should only try to import files 
that was exported with the function above.");
-               return importBox;
-       }
-}

Modified: trunk/plugins/FMSPlugin/ui/Welcome.java
===================================================================
--- trunk/plugins/FMSPlugin/ui/Welcome.java     2008-09-14 11:43:55 UTC (rev 
22651)
+++ trunk/plugins/FMSPlugin/ui/Welcome.java     2008-09-14 12:34:01 UTC (rev 
22652)
@@ -13,6 +13,7 @@
                HTMLNode pageNode = fms.getPageNode();
                HTMLNode contentNode = fms.pm.getContentNode(pageNode);
                contentNode.addChild(createWelcomeBox(fms));
+               contentNode.addChild(createOverviewBox(fms));
                contentNode.addChild(createBackupHintBox(fms));
                return pageNode.generate();
        }
@@ -24,13 +25,48 @@
                welcomeContent.addChild("P", "Things happens you didn't expect? 
Call 0800-GordonFreeman for rescue");
                return welcomeBox;
        }
-       
+
+       private static HTMLNode createOverviewBox(FMS fms) {
+               HTMLNode overviewBox = fms.pm.getInfobox("Overview");
+               HTMLNode overviewContent = fms.pm.getContentNode(overviewBox);
+               HTMLNode list = overviewContent.addChild("ul");
+               list.addChild(new HTMLNode("li", "Own Identities: " + 
fms.countOwnIdentities()));
+               list.addChild(new HTMLNode("li", "Known Identities: " + 
fms.countIdentities()));
+               list.addChild(new HTMLNode("li", "WoT plugin: " + 
fms.isWoTpresent()));
+               return overviewBox;
+       }
+
        private static HTMLNode createBackupHintBox(FMS fms) {
                HTMLNode bhBox = fms.pm.getInfobox("The boring backup 
reminder");
                HTMLNode bhContent = fms.pm.getContentNode(bhBox);
                bhContent.addChild("P", "You can not turn me off, because I'm 
boring. :P");
-               bhContent.addChild("P", "Don't forget to backup your data. You 
find the buttons at the service page.");
-               bhContent.addChild(new HTMLNode("a", "href", FMSPlugin.SELF_URI 
+ "/service", "Service Page"));
+               bhContent.addChild("P", "Don't forget to backup your data. You 
find the buttons below.");
+               bhContent.addChild(createExportBox(fms));
+               bhContent.addChild(createImportBox(fms));
                return bhBox;
        }
+       
+       private static HTMLNode createExportBox(FMS fms) {
+               HTMLNode exportBox = fms.pm.getInfobox("Export");
+               HTMLNode exportContent = fms.pm.getContentNode(exportBox);
+               HTMLNode exportForm = fms.pr.addFormChild(exportContent, 
FMSPlugin.SELF_URI + "/exportDB", "exportForm");
+               exportForm.addChild("#", "Export the database (Identities etc 
pp) to xml file. \u00a0 ");
+               exportForm.addChild("input", new String[] { "type", "name", 
"value" }, new String[] { "submit", "export", "Export" });
+               exportForm.addChild("br");
+               exportForm.addChild("#", "Store the backup at a safe place. You 
can reimport it at any node and continue flaming...");
+               return exportBox;
+       }
+       
+       private static HTMLNode createImportBox(FMS fms) {
+               HTMLNode importBox = fms.pm.getInfobox("Import");
+               HTMLNode importContent = fms.pm.getContentNode(importBox);
+               HTMLNode importForm = fms.pr.addFormChild(importContent, 
FMSPlugin.SELF_URI + "/importDB", "importForm");
+               importForm.addChild("#", "Choose xml file to import.\u00a0");
+               importForm.addChild("input", new String[] { "type", "name", 
"value" }, new String[] { "file", "filename", "" });
+               importForm.addChild("#", "\u00a0");
+               importForm.addChild("input", new String[] { "type", "name", 
"value" }, new String[] { "submit", "import", "Import" });
+               importForm.addChild("br");
+               importForm.addChild("#", "You should only try to import files 
that was exported with the function above. Otherwise call the rescue number.");
+               return importBox;
+       }
 }


Reply via email to