Author: nextgens
Date: 2007-04-15 18:56:12 +0000 (Sun, 15 Apr 2007)
New Revision: 12754

Modified:
   trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
   trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
   trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/node/LoggingConfigHandler.java
   trunk/freenet/src/freenet/node/Node.java
Log:
Implement something wich is likely to be popular: combo boxes on /config... Now 
you have the choice in between different settings and don't have to remember 
them by heart

Modified: trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2007-04-15 18:36:29 UTC (rev 12753)
+++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2007-04-15 18:56:12 UTC (rev 12754)
@@ -9,6 +9,7 @@
 import java.util.LinkedList;

 import freenet.config.InvalidConfigValueException;
+import freenet.config.StringOption;
 import freenet.config.SubConfig;
 import freenet.crypt.RandomSource;
 import freenet.keys.ClientKey;
@@ -155,6 +156,8 @@
                                "RequestStarterGroup.scheduler",
                                "RequestStarterGroup.schedulerLong",
                                new PrioritySchedulerCallback(this));
+               ((StringOption)sc.getOption(name + 
"_priority_policy")).setPossibleValues(new String[]{ 
ClientRequestScheduler.PRIORITY_HARD, ClientRequestScheduler.PRIORITY_SOFT });
+               
                this.choosenPriorityScheduler = 
sc.getString(name+"_priority_policy");
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
        }

Modified: trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ConfigToadlet.java   2007-04-15 
18:36:29 UTC (rev 12753)
+++ trunk/freenet/src/freenet/clients/http/ConfigToadlet.java   2007-04-15 
18:56:12 UTC (rev 12754)
@@ -9,6 +9,7 @@

 import freenet.client.HighLevelSimpleClient;
 import freenet.config.Config;
+import freenet.config.EnumerableOption;
 import freenet.config.Option;
 import freenet.config.SubConfig;
 import freenet.l10n.L10n;
@@ -154,18 +155,11 @@
                                                Logger.error(this, 
sc[i].getPrefix() + configName + "has returned null from config!);");
                                                continue; 
                                        }
-                                       if(o[j].getValueString().equals("true") 
|| o[j].getValueString().equals("false")){
-                                               HTMLNode selectNode = 
configItemValueNode.addChild("select", "name", sc[i].getPrefix() + '.' + 
configName);
-                                               
if(o[j].getValueString().equals("true")){
-                                                       
selectNode.addChild("option", new String[] { "value", "selected" }, new 
String[] { "true", "selected" }, "true");
-                                                       
selectNode.addChild("option", "value", "false", "false");
-                                               }else{
-                                                       
selectNode.addChild("option", "value", "true", "true");
-                                                       
selectNode.addChild("option", new String[] { "value", "selected" }, new 
String[] { "false", "selected" }, "false");
-                                               }
-                                       }else{
+                                       
+                                       if((o[j] instanceof EnumerableOption) 
&& (o[j].isEnumerable()))
+                                               
configItemValueNode.addChild(addComboBox((EnumerableOption)o[j], sc[i], 
configName));
+                                       else
                                                
configItemValueNode.addChild("input", new String[] { "type", "class", "alt", 
"name", "value" }, new String[] { "text", "config", o[j].getShortDesc(), 
sc[i].getPrefix() + '.' + configName, o[j].getValueString() });
-                                       }

                                        configItemNode.addChild("span", 
"class", "configlongdesc").addChild(L10n.getHTMLNode(o[j].getLongDesc()));
                                }
@@ -187,4 +181,17 @@
        public String supportedMethods() {
                return "GET, POST";
        }
+       
+       private HTMLNode addComboBox(EnumerableOption o, SubConfig sc, String 
name) {
+               HTMLNode result = new HTMLNode("select", "name", sc.getPrefix() 
+ '.' + name);
+               String[] possibleValues = o.getPossibleValues();
+               for(int i=0; i<possibleValues.length; i++) {
+                       if(possibleValues[i].equals(o.getValueString()))
+                               result.addChild("option", new String[] { 
"value", "selected" }, new String[] { possibleValues[i], "selected" }, 
possibleValues[i]);
+                       else
+                               result.addChild("option", "value", 
possibleValues[i], possibleValues[i]);
+               }
+               
+               return result;
+       }
 }

Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java     
2007-04-15 18:36:29 UTC (rev 12753)
+++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java     
2007-04-15 18:56:12 UTC (rev 12754)
@@ -23,12 +23,14 @@
 import java.util.jar.JarFile;

 import freenet.config.InvalidConfigValueException;
+import freenet.config.StringOption;
 import freenet.config.SubConfig;
 import freenet.io.AllowedHosts;
 import freenet.io.NetworkInterface;
 import freenet.node.NodeClientCore;
 import freenet.support.Logger;
 import freenet.support.OOMHandler;
+import freenet.support.StringArray;
 import freenet.support.api.BooleanCallback;
 import freenet.support.api.BucketFactory;
 import freenet.support.api.IntCallback;
@@ -304,8 +306,9 @@
                cssName = fproxyConfig.getString("css");
                if((cssName.indexOf(':') != -1) || (cssName.indexOf('/') != -1))
                        throw new InvalidConfigValueException("CSS name must 
not contain slashes or colons!");
-               this.advancedModeEnabled = 
fproxyConfig.getBoolean("advancedModeEnabled");
-               pageMaker = new PageMaker(cssName);
+               pageMaker = new PageMaker(cssName);             
+               // Set possible values
+               ((StringOption) 
fproxyConfig.getOption("css")).setPossibleValues(StringArray.toArray(pageMaker.getThemes().toArray()));

                if(!fproxyConfig.getOption("CSSOverride").isDefault()) {
                        cssOverride = new 
File(fproxyConfig.getString("CSSOverride"));                  
@@ -313,6 +316,7 @@
                } else
                        cssOverride = null;

+               this.advancedModeEnabled = 
fproxyConfig.getBoolean("advancedModeEnabled");              
                toadlets = new LinkedList();
                core.setToadletContainer(this); // even if not enabled, because 
of config


Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2007-04-15 
18:36:29 UTC (rev 12753)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2007-04-15 
18:56:12 UTC (rev 12754)
@@ -149,7 +149,7 @@
 Node.disableHangCheckers=Disable all hang checkers
 Node.disableHangCheckersLong=Disable all hang checkers/watchdog functions. Set 
this if you are profiling Fred.
 Node.l10nLanguage=The language the node will use to display messages
-Node.l10nLanguageLong=This setting will change the language used to display 
messages. Choose from [en|fr|pl]. Keep in mind that some strings won't be 
translated until next node startup though.
+Node.l10nLanguageLong=This setting will change the language used to display 
messages. Keep in mind that some strings won't be translated until next node 
startup though.
 NodeUpdateManager.enabled=Check for, and download new versions
 NodeUpdateManager.enabledLong=Should your node automatically check for new 
versions of Freenet. If yes, new versions will be automatically detected and 
downloaded, but not necessarily installed. This setting resets itself always 
back to false unless the node runs within the wrapper.
 NodeUpdateManager.installNewVersions=Automatically install new versions
@@ -165,7 +165,7 @@
 PluginManager.loadedOnStartup=Plugins to load on startup
 PluginManager.loadedOnStartupLong=Classpath, name and location for plugins to 
load when node starts up
 RequestStarterGroup.scheduler=Priority policy of the scheduler
-RequestStarterGroup.schedulerLong=Set the priority policy scheme used by the 
scheduler. Could be one of [SOFT|HARD]
+RequestStarterGroup.schedulerLong=Set the priority policy scheme used by the 
scheduler.
 SimpleToadletServer.enabled=Enable FProxy?
 SimpleToadletServer.enabledLong=Whether to enable FProxy and related HTTP 
services
 SimpleToadletServer.bindTo=IP address to bind to

Modified: trunk/freenet/src/freenet/node/LoggingConfigHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/LoggingConfigHandler.java    2007-04-15 
18:36:29 UTC (rev 12753)
+++ trunk/freenet/src/freenet/node/LoggingConfigHandler.java    2007-04-15 
18:56:12 UTC (rev 12754)
@@ -8,6 +8,7 @@

 import freenet.config.InvalidConfigValueException;
 import freenet.config.OptionFormatException;
+import freenet.config.StringOption;
 import freenet.config.SubConfig;
 import freenet.support.FileLoggerHook;
 import freenet.support.Logger;
@@ -116,6 +117,7 @@
                                                }
                                        }
        });
+       ((StringOption)config.getOption("priority")).setPossibleValues(new 
String[]{ "ERROR", "NORMAL", "MINOR", "DEBUG" });

        // detailed priority

@@ -138,7 +140,6 @@

        });

-       
        // interval

        config.register("interval", "1HOUR", 5, true, false, 
"LogConfigHandler.rotationInterval", "LogConfigHandler.rotationIntervalLong",

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2007-04-15 18:36:29 UTC (rev 
12753)
+++ trunk/freenet/src/freenet/node/Node.java    2007-04-15 18:56:12 UTC (rev 
12754)
@@ -44,6 +44,7 @@
 import freenet.config.InvalidConfigValueException;
 import freenet.config.LongOption;
 import freenet.config.PersistentConfig;
+import freenet.config.StringOption;
 import freenet.config.SubConfig;
 import freenet.crypt.DSA;
 import freenet.crypt.DSAGroup;
@@ -1320,6 +1321,7 @@
                                }
                        }
                });
+               
((StringOption)nodeConfig.getOption("l10n")).setPossibleValues(L10n.availableLanguages);

                try {
                        L10n.setLanguage(nodeConfig.getString("l10n"));


Reply via email to