Author: nextgens
Date: 2006-08-18 16:33:57 +0000 (Fri, 18 Aug 2006)
New Revision: 10195

Modified:
   trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
   trunk/freenet/src/freenet/config/SubConfig.java
Log:
fproxy:
        * Sort the categories on the /config/ page
Here the page processing is quite long ... maybe we can make it faster.

Modified: trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ConfigToadlet.java   2006-08-18 
15:46:58 UTC (rev 10194)
+++ trunk/freenet/src/freenet/clients/http/ConfigToadlet.java   2006-08-18 
16:33:57 UTC (rev 10195)
@@ -3,6 +3,7 @@
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Arrays;

 import freenet.client.HighLevelSimpleClient;
 import freenet.config.Config;
@@ -109,10 +110,19 @@

        public void handleGet(URI uri, ToadletContext ctx) throws 
ToadletContextClosedException, IOException {
                SubConfig[] sc = config.getConfigs();
+               Arrays.sort(sc);
                boolean advancedEnabled = core.isAdvancedDarknetEnabled();

                HTMLNode pageNode = ctx.getPageMaker().getPageNode("Freenet 
Node Configuration of " + node.getMyName());
                HTMLNode contentNode = 
ctx.getPageMaker().getContentNode(pageNode);
+               
+               HTMLNode navigationBar = 
ctx.getPageMaker().getInfobox("navbar", "Configuration Navigation");
+               HTMLNode navigationContent = 
ctx.getPageMaker().getContentNode(navigationBar).addChild("ul");
+               for(int i=0; i<sc.length;i++){
+                       navigationContent.addChild("li").addChild("a", "href", 
"#"+sc[i].getPrefix(), sc[i].getPrefix());
+               }
+               contentNode.addChild(core.alerts.createSummary());
+               contentNode.addChild(navigationBar);

                HTMLNode infobox = contentNode.addChild("div", "class", 
"infobox infobox-normal");
                infobox.addChild("div", "class", "infobox-header", "Freenet 
node configuration");
@@ -153,6 +163,7 @@

                        if(displayedConfigElements>0) {
                                formNode.addChild("div", "class", 
"configprefix", sc[i].getPrefix());
+                               formNode.addChild("a", "name", 
sc[i].getPrefix());
                                formNode.addChild(configGroupUlNode);
                        }
                }

Modified: trunk/freenet/src/freenet/config/SubConfig.java
===================================================================
--- trunk/freenet/src/freenet/config/SubConfig.java     2006-08-18 15:46:58 UTC 
(rev 10194)
+++ trunk/freenet/src/freenet/config/SubConfig.java     2006-08-18 16:33:57 UTC 
(rev 10195)
@@ -11,7 +11,7 @@
 /**
  * A specific configuration block.
  */
-public class SubConfig {
+public class SubConfig implements Comparable {

        private final HashMap map;
        public final Config config;
@@ -207,5 +207,15 @@
        public String getPrefix(){
                return prefix;
        }
-
+       
+       public int compareTo(Object o){
+               if((o == null) || !(o instanceof SubConfig)) return 0;
+               else{
+                       SubConfig second = (SubConfig) o;
+                       if(this.getPrefix().compareTo(second.getPrefix())>0)
+                               return 1;
+                       else
+                               return -1;
+               }
+       }
 }


Reply via email to