Author: jflesch
Date: 2008-02-07 01:52:57 +0000 (Thu, 07 Feb 2008)
New Revision: 17640

Added:
   trunk/apps/Thaw/images/min-plugins.png
   trunk/apps/Thaw/src/thaw/fcp/FCPGetConfig.java
   trunk/apps/Thaw/src/thaw/plugins/NodeConfigurator.java
   trunk/apps/Thaw/src/thaw/plugins/nodeConfigurator/
   trunk/apps/Thaw/src/thaw/plugins/nodeConfigurator/NodeConfiguratorTab.java
Modified:
   trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
   trunk/apps/Thaw/src/thaw/core/PluginManager.java
   trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java
   trunk/apps/Thaw/src/thaw/gui/IconBox.java
   trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
Log:
New plugin : NodeConfigurator : allows to browse through the node configuration

Added: trunk/apps/Thaw/images/min-plugins.png
===================================================================
(Binary files differ)


Property changes on: trunk/apps/Thaw/images/min-plugins.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java     2008-02-07 01:19:08 UTC 
(rev 17639)
+++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java     2008-02-07 01:52:57 UTC 
(rev 17640)
@@ -78,7 +78,7 @@
                //tabs.setSize(600, 360);
                //okButton.setSize(100, 40);

-               configWin.setSize(600, 470);
+               configWin.setSize(700, 470);
                //configWin.setResizable(false);

                okButton.addActionListener(this);
@@ -98,8 +98,8 @@
                removeTab( pluginConfigPanel.getPanel() );

                addTab("Thaw", IconBox.blueBunny, thawConfigPanel.getPanel());
-               addTab(I18n.getMessage("thaw.common.node"), 
IconBox.minConnectAction, nodeConfigPanel.getPanel());
-               addTab(I18n.getMessage("thaw.common.plugins"), 
IconBox.minSettings, pluginConfigPanel.getPanel());
+               addTab(I18n.getMessage("thaw.config.nodeConnection"), 
IconBox.minConnectAction, nodeConfigPanel.getPanel());
+               addTab(I18n.getMessage("thaw.common.plugins"), 
IconBox.minPlugins, pluginConfigPanel.getPanel());
        }



Modified: trunk/apps/Thaw/src/thaw/core/PluginManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/PluginManager.java    2008-02-07 01:19:08 UTC 
(rev 17639)
+++ trunk/apps/Thaw/src/thaw/core/PluginManager.java    2008-02-07 01:52:57 UTC 
(rev 17640)
@@ -38,6 +38,7 @@
                "thaw.plugins.MiniFrost",
                "thaw.plugins.Restarter",
                "thaw.plugins.TransferLogs",
+               "thaw.plugins.NodeConfigurator",
                "thaw.plugins.MDns",
                "thaw.plugins.IndexWebGrapher",
                "thaw.plugins.SqlConsole",

Added: trunk/apps/Thaw/src/thaw/fcp/FCPGetConfig.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPGetConfig.java                              
(rev 0)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPGetConfig.java      2008-02-07 01:52:57 UTC 
(rev 17640)
@@ -0,0 +1,157 @@
+package thaw.fcp;
+
+import java.util.Observer;
+import java.util.Observable;
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+public class FCPGetConfig extends Observable implements FCPQuery, Observer {
+       private FCPQueueManager queueManager;
+       
+       private final boolean withCurrent;
+       private final boolean withShortDescription;
+       private final boolean withLongDescription;
+       private final boolean withDefaults;
+       private final boolean withSortOrder;
+       private final boolean withExpertFlag;
+       private final boolean withForceWriteFlag;
+
+       public FCPGetConfig(boolean withCurrent, boolean withShortDescription,
+                                               boolean withLongDescription, 
boolean withDefaults,
+                                               boolean withSortOrder, boolean 
withExpertFlag,
+                                               boolean withForceWriteFlag) {
+               this.withCurrent = withCurrent;
+               this.withShortDescription = withShortDescription;
+               this.withLongDescription = withLongDescription;
+               this.withDefaults = withDefaults;
+               this.withSortOrder = withSortOrder;
+               this.withExpertFlag = withExpertFlag;
+               this.withForceWriteFlag = withForceWriteFlag;
+       }
+
+       public int getQueryType() {
+               return 0;
+       }
+
+       public boolean start(FCPQueueManager queueManager) {
+               this.queueManager = queueManager;
+               
+               queueManager.getQueryManager().addObserver(this);
+               
+               FCPMessage msg = new FCPMessage();
+               msg.setMessageName("GetConfig");
+               
+               msg.setValue("WithCurrent", Boolean.toString(withCurrent));
+               msg.setValue("WithShortDescription", 
Boolean.toString(withShortDescription));
+               msg.setValue("WithLongDescription", 
Boolean.toString(withLongDescription));
+               msg.setValue("WithDefaults", Boolean.toString(withDefaults));
+               msg.setValue("WithSortOrder", Boolean.toString(withSortOrder));
+               msg.setValue("WithExpertFlag", 
Boolean.toString(withExpertFlag));
+               msg.setValue("WithForceWriteFlag", 
Boolean.toString(withForceWriteFlag));
+               
+               queueManager.getQueryManager().writeMessage(msg);
+               
+               return true;
+       }
+
+       public boolean stop(FCPQueueManager queueManager) {
+               queueManager.getQueryManager().deleteObserver(this);
+               
+               return true;
+       }
+       
+       public class ConfigSetting implements Comparable {
+               private final String name;
+               private final String shortName;
+               private String current;
+               private String shortDesc;
+               private String longDesc;
+               private String defaultValue;
+               private int sortOrder;
+               private boolean expertFlag;
+               private boolean forceWriteFlag;
+               
+               public ConfigSetting(String name) {
+                       this.name = name;
+                       
+                       int dotPos = name.indexOf('.');
+                       
+                       shortName = name.substring(dotPos+1);                   
+               }
+               
+               public void setElement(String element, String value) {
+                       element = element.toLowerCase();
+                       
+                       if ("current".equals(element))
+                               current = value;
+                       else if ("shortdescription".equals(element))
+                               shortDesc = value;
+                       else if ("longdescription".equals(element))
+                               longDesc = value;
+                       else if ("default".equals(element))
+                               defaultValue = value;
+                       else if ("sortorder".equals(element))
+                               sortOrder = Integer.parseInt(value);
+                       else if ("expertflag".equals(element))
+                               expertFlag = 
Boolean.valueOf(value).booleanValue();
+                       else if ("forcewriteflag".equals(element))
+                               forceWriteFlag = 
Boolean.valueOf(value).booleanValue();
+                       else
+                               thaw.core.Logger.warning(this, "Unknow element 
'"+element+"' : '"+value+"' !");
+               }
+               
+               public String getName() { return name; }
+               public String getCurrent() { return current; }
+               public String getShortDesc() { return shortDesc; }
+               public String getLongDesc() { return longDesc; }
+               public String getDefault() { return defaultValue; }
+               public int getSortOrder() { return sortOrder; }
+               public boolean getExpertFlag() { return expertFlag; }
+               public boolean getForceWriteFlag() { return forceWriteFlag; }
+
+               public int compareTo(Object o) {
+                       return new Integer(sortOrder).compareTo( new 
Integer(((ConfigSetting)o).getSortOrder()) );
+               }
+               
+               public String toString() { return shortName; }
+       }
+
+       public void update(Observable o, Object param) {
+               if (param == null || !(param instanceof FCPMessage))
+                       return;
+               
+               FCPMessage msg = (FCPMessage)param;
+               
+               if (!"ConfigData".equals(msg.getMessageName()))
+                       return;
+               
+               Hashtable fields = msg.getValues();
+               Hashtable configSettings = new Hashtable();
+               
+               for (Enumeration keysEnum = fields.keys();
+                       keysEnum.hasMoreElements(); ) {
+
+                       String key = (String)keysEnum.nextElement(); 
+                       String value = (String)fields.get(key);
+                       
+                       int firstPointPos = key.indexOf('.');
+                       
+                       String element = key.substring(0, firstPointPos);
+                       String name = key.substring(firstPointPos+1);
+                       
+                       ConfigSetting setting = null;
+                       
+                       if ( (setting = 
(ConfigSetting)configSettings.get(name)) == null) {
+                               setting = new ConfigSetting(name);
+                               configSettings.put(name, setting);
+                       }
+                       
+                       setting.setElement(element, value);
+               }
+
+               setChanged();
+               notifyObservers(configSettings);
+               
+               stop(queueManager);
+       }
+}

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java        2008-02-07 01:19:08 UTC 
(rev 17639)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java        2008-02-07 01:52:57 UTC 
(rev 17640)
@@ -50,15 +50,13 @@
                        /* Line not containing '=' (like "Data" or 
"EndMessage") are ignored */
                        if("".equals( lines[i] ) || !(lines[i].indexOf("=") >= 
0))
                                continue;
+                       
+                       int equalPos = lines[i].indexOf('=');
+                       
+                       String name = lines[i].substring(0, equalPos);
+                       String value = lines[i].substring(equalPos+1);

-                       final String[] affectation = lines[i].split("=");
-
-                       if(affectation.length < 2) {
-                               Logger.warning(this, "Malformed message");
-                               continue;
-                       }
-
-                       setValue(affectation[0], affectation[1]);
+                       setValue(name, value);
                }



Modified: trunk/apps/Thaw/src/thaw/gui/IconBox.java
===================================================================
--- trunk/apps/Thaw/src/thaw/gui/IconBox.java   2008-02-07 01:19:08 UTC (rev 
17639)
+++ trunk/apps/Thaw/src/thaw/gui/IconBox.java   2008-02-07 01:52:57 UTC (rev 
17640)
@@ -178,6 +178,8 @@

        public static ImageIcon trust;
        public static ImageIcon minTrust;
+       
+       public static ImageIcon minPlugins;


        /**
@@ -326,6 +328,7 @@
                IconBox.miniFrostOutlookView = 
IconBox.loadIcon("images/miniFrost-view-outlook.png");
                IconBox.trust               = 
IconBox.loadIcon("images/trust.png");
                IconBox.minTrust            = 
IconBox.loadIcon("images/min-trust.png");
+               IconBox.minPlugins          = 
IconBox.loadIcon("images/min-plugins.png");
        }

 }

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2008-02-07 
01:19:08 UTC (rev 17639)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2008-02-07 
01:52:57 UTC (rev 17640)
@@ -161,7 +161,9 @@

 thaw.config.downloadLocally=T??l??charger les fichiers depuis la node

+thaw.config.nodeConnection=Connexion ?? la node

+
 ## Plugins
 thaw.plugin.queueWatcher=Transferts

@@ -725,4 +727,13 @@
 thaw.plugin.wot.usedIdentity.none=[Ne pas publier la liste de confiance]
 thaw.plugin.wot.numberOfRefresh=Nombre de liste de confiances ?? rafraichir 
simultan??ment

+## node configurator

+thaw.plugin.nodeConfig=Configuration de la node
+thaw.plugin.nodeConfig.categories=Categories
+thaw.plugin.nodeConfig.settings=R??glages
+thaw.plugin.nodeConfig.description=Description
+thaw.plugin.nodeConfig.value=Valeur actuelle
+thaw.plugin.nodeConfig.default=Valeur par d??faut
+thaw.plugin.nodeConfig.reload=Recharger les valeurs
+

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2008-02-07 01:19:08 UTC 
(rev 17639)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2008-02-07 01:52:57 UTC 
(rev 17640)
@@ -158,6 +158,7 @@

 thaw.config.downloadLocally=Download files from the node

+thaw.config.nodeConnection=Connection to the node

 ######## Plugins

@@ -733,4 +734,14 @@
 thaw.plugin.wot.usedIdentity.none=[Don't publish the trust list]
 thaw.plugin.wot.numberOfRefresh=Number of trust list to refresh simultaneously

+##?Node configurator

+thaw.plugin.nodeConfig=Node configuration
+
+thaw.plugin.nodeConfig=Configuration de la node
+thaw.plugin.nodeConfig.categories=Categories
+thaw.plugin.nodeConfig.settings=Settings
+thaw.plugin.nodeConfig.description=Description
+thaw.plugin.nodeConfig.value=Current Value
+thaw.plugin.nodeConfig.default=Value by default
+thaw.plugin.nodeConfig.reload=Reload values

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2008-02-07 01:19:08 UTC 
(rev 17639)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2008-02-07 01:52:57 UTC 
(rev 17640)
@@ -86,7 +86,9 @@

 thaw.common.autodetect=Auto-detecter

+thaw.common.close=Fermer
 thaw.common.closeTab=Fermer cette tabulation
+thaw.common.closeWin=Fermer cette fen\u00eatre

 thaw.common.apply=Appliquer

@@ -159,7 +161,9 @@

 thaw.config.downloadLocally=T\u00e9l\u00e9charger les fichiers depuis la node

+thaw.config.nodeConnection=Connexion \u00e0 la node

+
 ## Plugins
 thaw.plugin.queueWatcher=Transferts

@@ -723,4 +727,13 @@
 thaw.plugin.wot.usedIdentity.none=[Ne pas publier la liste de confiance]
 thaw.plugin.wot.numberOfRefresh=Nombre de liste de confiances \u00e0 
rafraichir simultan\u00e9ment

+## node configurator

+thaw.plugin.nodeConfig=Configuration de la node
+thaw.plugin.nodeConfig.categories=Categories
+thaw.plugin.nodeConfig.settings=R\u00e9glages
+thaw.plugin.nodeConfig.description=Description
+thaw.plugin.nodeConfig.value=Valeur actuelle
+thaw.plugin.nodeConfig.default=Valeur par d\u00e9faut
+thaw.plugin.nodeConfig.reload=Recharger les valeurs
+

Added: trunk/apps/Thaw/src/thaw/plugins/NodeConfigurator.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/NodeConfigurator.java                      
        (rev 0)
+++ trunk/apps/Thaw/src/thaw/plugins/NodeConfigurator.java      2008-02-07 
01:52:57 UTC (rev 17640)
@@ -0,0 +1,50 @@
+package thaw.plugins;
+
+import javax.swing.ImageIcon;
+
+import thaw.core.Core;
+import thaw.core.I18n;
+import thaw.core.Plugin;
+
+import thaw.plugins.nodeConfigurator.*;
+
+public class NodeConfigurator implements Plugin {
+       private Core core;
+       private NodeConfiguratorTab configTab;
+       
+       public NodeConfigurator() { }
+
+       public ImageIcon getIcon() {
+               return thaw.gui.IconBox.settings;
+       }
+
+       public String getNameForUser() {
+               return thaw.core.I18n.getMessage("thaw.plugin.nodeConfig");
+       }
+
+       public boolean run(Core core) {
+               this.core = core;
+               
+               core.getConfig().addListener("advancedMode", this);
+               
+               boolean advanced = 
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
+               
+               configTab = new NodeConfiguratorTab(advanced, 
core.getQueueManager());
+               
+               
core.getConfigWindow().addTab(I18n.getMessage("thaw.plugin.nodeConfig"),
+                             thaw.gui.IconBox.minSettings,
+                             configTab.getPanel());
+               
+               configTab.refresh();
+               
+               return true;
+       }
+
+       public void stop() {
+               if (configTab != null) {
+                       core.getConfigWindow().removeTab(configTab.getPanel());
+                       configTab = null;
+               }
+       }
+
+}

Added: 
trunk/apps/Thaw/src/thaw/plugins/nodeConfigurator/NodeConfiguratorTab.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/nodeConfigurator/NodeConfiguratorTab.java  
                        (rev 0)
+++ trunk/apps/Thaw/src/thaw/plugins/nodeConfigurator/NodeConfiguratorTab.java  
2008-02-07 01:52:57 UTC (rev 17640)
@@ -0,0 +1,249 @@
+package thaw.plugins.nodeConfigurator;
+
+import javax.swing.JPanel;
+import javax.swing.JList;
+import javax.swing.JTextField;
+import javax.swing.JTextArea;
+import javax.swing.JScrollPane;
+import javax.swing.JLabel;
+import javax.swing.JButton;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.ListSelectionModel;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import java.util.Observer;
+import java.util.Observable;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.util.Vector;
+import java.util.Iterator;
+
+import thaw.core.Config;
+import thaw.core.I18n;
+import thaw.fcp.FCPGetConfig;
+import thaw.fcp.FCPQueueManager;
+
+public class NodeConfiguratorTab implements Observer, ActionListener, 
ListSelectionListener {
+       private FCPQueueManager queueManager;
+       private boolean advanced;
+       
+       private JPanel panel;
+       
+       private JButton reload;
+       
+       private JList categoryChoice;
+       private JList settingChoice;
+       private JTextArea descriptionArea;
+       private JTextField valueField;
+       private JTextField defaultField;
+       
+       private JButton applyButton;
+       
+       public final static int COLUMNS_WIDTH = 125;
+       public final static int GRAY = 240;
+       
+       private Hashtable categories = null;
+       private Vector categoryNames = null;
+
+       public NodeConfiguratorTab(boolean advanced, FCPQueueManager 
queueManager) {
+               this.advanced = advanced;
+               this.queueManager = queueManager;
+               
+               JScrollPane sc;
+               
+               panel = new JPanel(new BorderLayout(5, 5));
+               
+               /* reload */
+               JPanel reloadPanel = new JPanel(new BorderLayout());
+               reload = new 
JButton(I18n.getMessage("thaw.plugin.nodeConfig.reload"));
+               reload.addActionListener(this);
+               reloadPanel.add(reload, BorderLayout.WEST);
+               reloadPanel.add(new JLabel(""), BorderLayout.EAST);
+               
+               panel.add(reloadPanel, BorderLayout.NORTH);
+               
+               /* categories */
+               JPanel categoryPanel = new JPanel(new BorderLayout(0, 0));
+               categoryPanel.add(new 
JLabel(I18n.getMessage("thaw.plugin.nodeConfig.categories")), 
BorderLayout.NORTH);
+               categoryChoice = new JList();
+               
categoryChoice.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+               categoryChoice.addListSelectionListener(this);
+               categoryPanel.add(sc = new JScrollPane(categoryChoice), 
BorderLayout.CENTER);
+               sc.setPreferredSize(new java.awt.Dimension(COLUMNS_WIDTH, 
COLUMNS_WIDTH)); 
+               
+               panel.add(categoryPanel, BorderLayout.WEST);
+               
+               JPanel subPanel = new JPanel(new BorderLayout(5, 5));
+               
+               /* settings */
+               JPanel settingsPanel = new JPanel(new BorderLayout(0, 0));
+               settingsPanel.add(new 
JLabel(I18n.getMessage("thaw.plugin.nodeConfig.settings")), BorderLayout.NORTH);
+               settingChoice = new JList();
+               settingChoice.addListSelectionListener(this);
+               settingsPanel.add(sc = new JScrollPane(settingChoice), 
BorderLayout.CENTER);
+               sc.setPreferredSize(new java.awt.Dimension(COLUMNS_WIDTH*2, 
COLUMNS_WIDTH*2));
+               
+               subPanel.add(settingsPanel, BorderLayout.WEST);
+               
+
+               JPanel descAndValuePanel = new JPanel(new GridLayout(2, 1));
+               
+               /* description */
+               JPanel descPanel = new JPanel(new BorderLayout(0, 0));
+               descPanel.add(new 
JLabel(I18n.getMessage("thaw.plugin.nodeConfig.description")), 
BorderLayout.NORTH);
+               descriptionArea = new JTextArea();
+               descriptionArea.setEditable(false);
+               descriptionArea.setBackground(new java.awt.Color(GRAY, GRAY, 
GRAY));
+               descriptionArea.setLineWrap(true);
+               descriptionArea.setWrapStyleWord(true);
+               descPanel.add(new JScrollPane(descriptionArea), 
BorderLayout.CENTER);
+               descAndValuePanel.add(descPanel);
+               
+               JPanel valueAndButtonsPanel = new JPanel(new BorderLayout(0, 
0));
+               
+               /* value */     
+               JPanel valuePanel = new JPanel(new GridLayout(4, 0));
+               valuePanel.add(new 
JLabel(I18n.getMessage("thaw.plugin.nodeConfig.default")));
+               defaultField = new JTextField();
+               defaultField.setEditable(false);
+               defaultField.setBackground(new java.awt.Color(GRAY, GRAY, 
GRAY));
+               valuePanel.add(defaultField);
+               valuePanel.add(new 
JLabel(I18n.getMessage("thaw.plugin.nodeConfig.value")));
+               valueField = new JTextField();
+               valueField.addActionListener(this);
+               valuePanel.add(valueField);
+               
+               valueAndButtonsPanel.add(valuePanel, BorderLayout.NORTH);
+               
+               /* button(s) */
+               applyButton = new JButton(I18n.getMessage("thaw.common.apply"));
+               applyButton.addActionListener(this);
+               
+               valueAndButtonsPanel.add(new JLabel(""), BorderLayout.CENTER);
+               valueAndButtonsPanel.add(applyButton, BorderLayout.SOUTH);
+               
+               descAndValuePanel.add(valueAndButtonsPanel);
+               
+               subPanel.add(descAndValuePanel, BorderLayout.CENTER);
+               
+               panel.add(subPanel, BorderLayout.CENTER);
+               
+       }
+       
+       public JPanel getPanel() {
+               return panel;
+       }
+       
+       public void refresh() {
+               FCPGetConfig getConfig = new FCPGetConfig(true /* current */, 
false /* with short desc */,
+                                                                               
                  true /* with long desc */, true /* with defaults */,
+                                                                               
                  true /* with sort order */, true /* with expert flag */,
+                                                                               
                  false /* with force write flag */);
+               getConfig.addObserver(this);
+               getConfig.start(queueManager);
+       }
+       
+       private void refreshDisplay() {
+               categoryChoice.removeListSelectionListener(this);
+               categoryChoice.setListData(categoryNames);
+               categoryChoice.addListSelectionListener(this);
+
+               settingChoice.removeListSelectionListener(this);
+               settingChoice.setListData(new Vector());
+               settingChoice.addListSelectionListener(this);
+
+               descriptionArea.setText("");
+               valueField.setText("");
+               defaultField.setText("");
+       }
+
+       public void actionPerformed(ActionEvent e) {
+               if (e.getSource() == applyButton || e.getSource() == 
valueField) {
+                       
+               } else if (e.getSource() == reload) {
+                       refresh();
+               }
+       }
+
+       public void valueChanged(ListSelectionEvent e) {
+               if (e.getSource() == categoryChoice) {
+
+                       synchronized(categories) {
+                       
+                               String catName = 
(String)categoryChoice.getSelectedValue();
+
+                               settingChoice.removeListSelectionListener(this);
+                               
settingChoice.setListData((Vector)categories.get(catName));
+                               settingChoice.addListSelectionListener(this);
+
+                               descriptionArea.setText("");
+                               valueField.setText("");
+                               defaultField.setText("");
+                       
+                       }
+
+               } else if (e.getSource() == settingChoice) {
+                       
+                       FCPGetConfig.ConfigSetting setting = 
(FCPGetConfig.ConfigSetting)settingChoice.getSelectedValue();
+                       descriptionArea.setText(setting.getLongDesc());
+                       valueField.setText(setting.getCurrent());
+                       defaultField.setText(setting.getDefault());
+               }
+       }
+
+       public void update(Observable o, Object param) {
+               if (param == null || !(param instanceof Hashtable))
+                       return;
+               
+               Hashtable configSettings = (Hashtable)param;
+               
+               /* will restructure the data */
+               categories = new Hashtable();
+               categoryNames = new Vector();
+               
+               synchronized(categories) {
+                       
+                       /* first : sort them by category */
+
+                       for (Enumeration keyEnum = configSettings.keys();
+                                keyEnum.hasMoreElements();) {
+
+                               String name = (String)keyEnum.nextElement();
+                               FCPGetConfig.ConfigSetting setting = 
(FCPGetConfig.ConfigSetting)configSettings.get(name);
+                               
+                               if (setting.getExpertFlag() && !advanced)
+                                       continue;
+
+                               int dotPos = name.indexOf('.');
+                               String categoryName = name.substring(0, dotPos);
+
+                               Vector categorySettings = 
(Vector)categories.get(categoryName);
+                               if (categorySettings == null) {
+                                       categoryNames.add(categoryName);
+                                       categorySettings = new Vector();
+                                       categories.put(categoryName, 
categorySettings);
+                               }
+                               
+                               categorySettings.add(setting);
+                       }
+                       
+                       /* second : sort them by sortOrder */
+                       
+                       for (Enumeration keyEnum = categories.keys();
+                                keyEnum.hasMoreElements();) {
+                               String catName = (String)keyEnum.nextElement();
+                               Vector categorySettings = 
(Vector)categories.get(catName);
+                               
+                               java.util.Collections.sort(categorySettings);   
                
+                       }
+
+                       refreshDisplay();
+               }
+       }
+}


Reply via email to