[jsword-svn] r1578 - in trunk: bibledesktop/src/main/resources common common/src/main/java/org/crosswire/common/config common-swing/src/main/java/org/crosswire/common/config/swing common-swing/src/main/java/org/crosswire/common/swing

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Sat Jul 28 17:49:36 MST 2007


Author: dmsmith
Date: 2007-07-28 17:49:34 -0700 (Sat, 28 Jul 2007)
New Revision: 1578

Added:
   trunk/common-swing/src/main/java/org/crosswire/common/config/swing/MappedOptionsField.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/MapComboBoxModel.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/MapEntryRenderer.java
   trunk/common/src/main/java/org/crosswire/common/config/MappedChoice.java
   trunk/common/src/main/java/org/crosswire/common/config/MappedOptionsChoice.java
Modified:
   trunk/bibledesktop/src/main/resources/config.properties
   trunk/bibledesktop/src/main/resources/config.xml
   trunk/common-swing/src/main/java/org/crosswire/common/config/swing/Field.properties
   trunk/common-swing/src/main/java/org/crosswire/common/config/swing/OptionsField.java
   trunk/common/JSwordDictionary.txt
   trunk/common/src/main/java/org/crosswire/common/config/Choice.properties
   trunk/common/src/main/java/org/crosswire/common/config/IntOptionsChoice.java
Log:
Integer options are now internationalized.

Modified: trunk/bibledesktop/src/main/resources/config.properties
===================================================================
--- trunk/bibledesktop/src/main/resources/config.properties	2007-07-28 18:27:15 UTC (rev 1577)
+++ trunk/bibledesktop/src/main/resources/config.properties	2007-07-29 00:49:34 UTC (rev 1578)
@@ -85,7 +85,7 @@
 BibleDisplay.Converter.hidden=true
 BibleDisplay.Converter.name=Converter
 BibleDisplay.Converter.help=The engine used to generate the book display
-BibleDisplay.ConfigurableStylesheet.hidden=true
+BibleDisplay.ConfigurableStylesheet.hidden=false
 BibleDisplay.ConfigurableStylesheet.name=Configurable Stylesheet
 BibleDisplay.ConfigurableStylesheet.help=The style applied to displayed Books when using the configurable styler.
 Application.LookAndFeel.hidden=true

Modified: trunk/bibledesktop/src/main/resources/config.xml
===================================================================
--- trunk/bibledesktop/src/main/resources/config.xml	2007-07-28 18:27:15 UTC (rev 1577)
+++ trunk/bibledesktop/src/main/resources/config.xml	2007-07-29 00:49:34 UTC (rev 1578)
@@ -36,7 +36,7 @@
 <!ATTLIST option
   key CDATA #REQUIRED
   static (true|false) 'true'
-  type (string|boolean|int-options|string-options|string-array|file|path|directory|number|font|class|custom|password) #REQUIRED
+  type (string|boolean|int-options|map-options|string-options|string-array|file|path|directory|number|font|class|custom|password) #REQUIRED
   class CDATA #IMPLIED
   separator CDATA #IMPLIED
 >

Modified: trunk/common/JSwordDictionary.txt
===================================================================
--- trunk/common/JSwordDictionary.txt	2007-07-28 18:27:15 UTC (rev 1577)
+++ trunk/common/JSwordDictionary.txt	2007-07-29 00:49:34 UTC (rev 1578)
@@ -9,3 +9,4 @@
 unshaped
 combo
 tabbed
+locale

Modified: trunk/common/src/main/java/org/crosswire/common/config/Choice.properties
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/config/Choice.properties	2007-07-28 18:27:15 UTC (rev 1577)
+++ trunk/common/src/main/java/org/crosswire/common/config/Choice.properties	2007-07-29 00:49:34 UTC (rev 1578)
@@ -1,8 +1,8 @@
-
 string=org.crosswire.common.config.StringChoice
 password=org.crosswire.common.config.StringChoice
 boolean=org.crosswire.common.config.BooleanChoice
 int-options=org.crosswire.common.config.IntOptionsChoice
+map-options=org.crosswire.common.config.MappedOptionsChoice
 string-options=org.crosswire.common.config.StringOptionsChoice
 string-array=org.crosswire.common.config.StringArrayChoice
 file=org.crosswire.common.config.FileChoice

Modified: trunk/common/src/main/java/org/crosswire/common/config/IntOptionsChoice.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/config/IntOptionsChoice.java	2007-07-28 18:27:15 UTC (rev 1577)
+++ trunk/common/src/main/java/org/crosswire/common/config/IntOptionsChoice.java	2007-07-29 00:49:34 UTC (rev 1578)
@@ -21,10 +21,10 @@
  */
 package org.crosswire.common.config;
 
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
+import java.util.Map;
 import java.util.ResourceBundle;
+import java.util.TreeMap;
 
 import org.crosswire.common.util.Reporter;
 import org.jdom.Element;
@@ -35,8 +35,9 @@
  * @see gnu.lgpl.License for license details.<br>
  *      The copyright to this program is held by it's authors.
  * @author Joe Walker [joe at eireneh dot com]
+ * @author DM Smith [dmsmith555 at yahoo dot com]
  */
-public class IntOptionsChoice extends AbstractReflectedChoice implements MultipleChoice
+public class IntOptionsChoice extends AbstractReflectedChoice implements MappedChoice
 {
     /* (non-Javadoc)
      * @see org.crosswire.common.config.Choice#init(org.jdom.Element)
@@ -50,27 +51,23 @@
 
         String prefix = getKey() + ".alternative."; //$NON-NLS-1$
 
-        List list = new ArrayList();
+        options = new TreeMap();
         Iterator iter = option.getChildren("alternative").iterator(); //$NON-NLS-1$
         while (iter.hasNext())
         {
             Element alternative = (Element) iter.next();
             int number = Integer.parseInt(alternative.getAttributeValue("number")); //$NON-NLS-1$
             String name = configResources.getString(prefix + number);
-            list.add(number, name);
+            options.put(new Integer(number), name);
         }
-
-        options = (String[]) list.toArray(new String[list.size()]);
     }
 
     /* (non-Javadoc)
-     * @see org.crosswire.common.config.MultipleChoice#getOptions()
+     * @see org.crosswire.common.config.MappedChoice#getOptions()
      */
-    public String[] getOptions()
+    public Map getOptions()
     {
-        String [] copy = new String[options.length];
-        System.arraycopy(options, 0, copy, 0, options.length);
-        return copy;
+        return new TreeMap(options);
     }
 
     /* (non-Javadoc)
@@ -87,7 +84,6 @@
     /* @Override */
     public String convertToString(Object orig)
     {
-//        return options[((Integer) orig).intValue()];
         return orig.toString();
     }
 
@@ -104,19 +100,19 @@
         }
         catch (NumberFormatException ex)
         {
-            // Then work on the name list
-            for (int i = 0; i < options.length; i++)
+            Iterator iter = options.entrySet().iterator();
+            while (iter.hasNext())
             {
-                if (options[i].equalsIgnoreCase(orig))
+                Map.Entry mapEntry = (Map.Entry) iter.next();
+                if (mapEntry.getValue().equals(orig))
                 {
-                    return new Integer(i);
+                    return mapEntry.getKey();
                 }
             }
-
             Reporter.informUser(this, Msg.IGNORE, new Object[] { orig });
-            return options[0];
+            return null;
         }
     }
 
-    private String[] options;
+    private Map options;
 }

Added: trunk/common/src/main/java/org/crosswire/common/config/MappedChoice.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/config/MappedChoice.java	                        (rev 0)
+++ trunk/common/src/main/java/org/crosswire/common/config/MappedChoice.java	2007-07-29 00:49:34 UTC (rev 1578)
@@ -0,0 +1,42 @@
+/**
+ * Distribution License:
+ * This is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published
+ * by the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/llgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2007
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: MappedChoice.java 1462 2007-07-02 02:32:23Z dmsmith $
+ */
+package org.crosswire.common.config;
+
+import java.util.Map;
+
+/**
+ * MappedChoice is simply a Choice where there are a number of alternative
+ * options where each entry is a Map.Entry.
+ *
+ * @see gnu.lgpl.License for license details.<br>
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public interface MappedChoice extends Choice
+{
+    /**
+     * The available alternative values to be presented as options to the user
+     * where the user interface allows presentation of alternatives.
+     * @return A string array of alternatives.
+     */
+    Map getOptions();
+}

Added: trunk/common/src/main/java/org/crosswire/common/config/MappedOptionsChoice.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/config/MappedOptionsChoice.java	                        (rev 0)
+++ trunk/common/src/main/java/org/crosswire/common/config/MappedOptionsChoice.java	2007-07-29 00:49:34 UTC (rev 1578)
@@ -0,0 +1,114 @@
+/**
+ * Distribution License:
+ * This is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published
+ * by the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/llgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: IntOptionsChoice.java 1575 2007-07-28 16:18:14Z dmsmith $
+ */
+package org.crosswire.common.config;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.TreeMap;
+
+import org.crosswire.common.util.Reporter;
+import org.jdom.Element;
+
+/**
+ * A class to convert between strings and objects of a type.
+ *
+ * @see gnu.lgpl.License for license details.<br>
+ *      The copyright to this program is held by it's authors.
+ * @author Joe Walker [joe at eireneh dot com]
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public class MappedOptionsChoice extends AbstractReflectedChoice implements MappedChoice
+{
+    /* (non-Javadoc)
+     * @see org.crosswire.common.config.Choice#init(org.jdom.Element)
+     */
+    /* @Override */
+    public void init(Element option, ResourceBundle configResources) throws StartupException
+    {
+        assert configResources != null;
+
+        super.init(option, configResources);
+        Element mapElement = option.getChild("map"); //$NON-NLS-1$
+        if (mapElement == null)
+        {
+            throw new StartupException(Msg.CONFIG_NOMAP);
+        }
+
+        String name = mapElement.getAttributeValue("name"); //$NON-NLS-1$
+        Object map = ChoiceFactory.getDataMap().get(name);
+        if (map instanceof Map)
+        {
+            options = (Map) map;
+        }
+        else
+        {
+            options = new TreeMap();
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.crosswire.common.config.MappedChoice#getOptions()
+     */
+    public Map getOptions()
+    {
+        return new TreeMap(options);
+    }
+
+    /* (non-Javadoc)
+     * @see org.crosswire.common.config.Choice#getConvertionClass()
+     */
+    public Class getConversionClass()
+    {
+        return String.class;
+    }
+
+    /* (non-Javadoc)
+     * @see org.crosswire.common.config.AbstractReflectedChoice#convertToString(java.lang.Object)
+     */
+    /* @Override */
+    public String convertToString(Object orig)
+    {
+        return orig.toString();
+    }
+
+    /* (non-Javadoc)
+     * @see org.crosswire.common.config.AbstractReflectedChoice#convertToObject(java.lang.String)
+     */
+    /* @Override */
+    public Object convertToObject(String orig)
+    {
+        Iterator iter = options.entrySet().iterator();
+        while (iter.hasNext())
+        {
+            Map.Entry mapEntry = (Map.Entry) iter.next();
+            if (mapEntry.getValue().equals(orig))
+            {
+                return mapEntry.getKey();
+            }
+        }
+        Reporter.informUser(this, Msg.IGNORE, new Object[] { orig });
+        return ""; //$NON-NLS-1$
+    }
+
+    private Map options;
+}

Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/Field.properties
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/Field.properties	2007-07-28 18:27:15 UTC (rev 1577)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/Field.properties	2007-07-29 00:49:34 UTC (rev 1578)
@@ -1,7 +1,8 @@
 string=org.crosswire.common.config.swing.TextField
 password=org.crosswire.common.config.swing.PasswordField
 boolean=org.crosswire.common.config.swing.BooleanField
-int-options=org.crosswire.common.config.swing.NumberField
+int-options=org.crosswire.common.config.swing.MappedOptionsField
+map-options=org.crosswire.common.config.swing.MappedOptionsField
 string-options=org.crosswire.common.config.swing.StringArrayField
 string-array=org.crosswire.common.config.swing.StringArrayField
 file=org.crosswire.common.config.swing.FileField

Added: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/MappedOptionsField.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/MappedOptionsField.java	                        (rev 0)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/MappedOptionsField.java	2007-07-29 00:49:34 UTC (rev 1578)
@@ -0,0 +1,141 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2007
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: MappedOptionsField.java 1464 2007-07-02 02:34:40Z dmsmith $
+ */
+package org.crosswire.common.config.swing;
+
+import java.awt.Dimension;
+import java.util.Map;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+
+import org.crosswire.common.config.Choice;
+import org.crosswire.common.config.MappedChoice;
+import org.crosswire.common.swing.MapComboBoxModel;
+import org.crosswire.common.swing.MapEntryRenderer;
+import org.crosswire.common.util.Logger;
+
+/**
+ * Allow the user to choose from a combo box.
+ *
+ * @see gnu.lgpl.License for license details.
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public class MappedOptionsField implements Field
+{
+    /**
+     * Create an empty MappedOptionsField
+     */
+    public MappedOptionsField()
+    {
+        combo = new JComboBox(new String[] { Msg.NO_OPTIONS.toString() });
+        // Set the preferred width. Note, the actual combo box will resize to the width of it's container
+        combo.setPreferredSize(new Dimension(100, combo.getPreferredSize().height));
+    }
+
+    /**
+     * Some fields will need some extra info to display properly
+     * like the options in an options field. FieldMap calls this
+     * method with options provided by the choice.
+     * @param param The options provided by the Choice
+     */
+    public void setChoice(Choice param)
+    {
+        if (!(param instanceof MappedChoice))
+        {
+            throw new IllegalArgumentException("Illegal type for Choice. Not a MappedChoice. " + param.getKey()); //$NON-NLS-1$
+        }
+        MappedChoice mc = (MappedChoice) param;
+        Map map = mc.getOptions();
+        if (map == null)
+        {
+            throw new IllegalArgumentException("getOptions() returns null for option: " + param.getKey()); //$NON-NLS-1$
+        }
+        combo.setModel(new MapComboBoxModel(map));
+        combo.setRenderer(new MapEntryRenderer());
+   }
+
+    /**
+     * Return a string for use in the properties file
+     * @return The current value
+     */
+    public String getValue()
+    {
+        Object reply = combo.getSelectedItem();
+
+        if (reply instanceof Map.Entry)
+        {
+            return ((Map.Entry) reply).getKey().toString();
+        }
+        return reply == null ? "" : reply.toString(); //$NON-NLS-1$
+    }
+
+    /**
+     * Set the current value
+     * @param value The new text
+     */
+    public void setValue(String value)
+    {
+        ComboBoxModel model = combo.getModel();
+        int size = model.getSize();
+        for (int i = 0; i < size; i++)
+        {
+            Object match = model.getElementAt(i);
+            if (match instanceof Map.Entry)
+            {
+                Map.Entry mapEntry = (Map.Entry) match;
+                if (mapEntry.getKey().toString().equals(value))
+                {
+                    combo.setSelectedItem(mapEntry);
+                    return;
+                }
+            }
+        }
+
+        // Equate null and empty string
+        Object selected = combo.getSelectedItem();
+        if (value.length() > 0 && selected != null)
+        {
+            log.warn("Checked for options without finding: '" + value + "'. Defaulting to first option: " + selected);  //$NON-NLS-1$//$NON-NLS-2$
+        }
+    }
+
+    /**
+     * Get the actual component that we can add to a Panel.
+     * (This can well be this in an implementation).
+     */
+    public JComponent getComponent()
+    {
+        return combo;
+    }
+
+    /**
+     * The component that we are wrapping in a field
+     */
+    private JComboBox combo;
+
+    /**
+     * The log stream
+     */
+    private static final Logger log = Logger.getLogger(MappedOptionsField.class);
+}

Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/OptionsField.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/OptionsField.java	2007-07-28 18:27:15 UTC (rev 1577)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/OptionsField.java	2007-07-29 00:49:34 UTC (rev 1578)
@@ -22,6 +22,7 @@
 package org.crosswire.common.config.swing;
 
 import java.awt.Dimension;
+import java.util.Map;
 
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.JComboBox;
@@ -33,7 +34,7 @@
 import org.crosswire.common.util.Logger;
 
 /**
- * Allow the user to choose from True/False.
+ * Allow the user to choose from a combo box.
  *
  * @see gnu.lgpl.License for license details.
  *      The copyright to this program is held by it's authors.
@@ -47,7 +48,6 @@
      */
     public OptionsField()
     {
-        list = new String[0];
         combo = new JComboBox(new String[] { Msg.NO_OPTIONS.toString() });
         // Set the preferred width. Note, the actual combo box will resize to the width of it's container
         combo.setPreferredSize(new Dimension(100, combo.getPreferredSize().height));
@@ -70,14 +70,12 @@
             {
                 throw new IllegalArgumentException("getOptions() returns null for option with help text " + mc.getHelpText()); //$NON-NLS-1$
             }
+            combo.setModel(new DefaultComboBoxModel(list));
         }
         else
         {
-            log.warn("Unknown Choice type: " + param.getClass().getName()); //$NON-NLS-1$
             list = new String[] { Msg.ERROR.toString() };
         }
-
-        combo.setModel(new DefaultComboBoxModel(list));
     }
 
     /**
@@ -86,14 +84,13 @@
      */
     public String getValue()
     {
-        String reply = (String) combo.getSelectedItem();
+        Object reply = combo.getSelectedItem();
 
-        if (reply == null)
+        if (reply instanceof Map.Entry)
         {
-            reply = ""; //$NON-NLS-1$
+            return ((Map.Entry) reply).getKey().toString();
         }
-
-        return reply;
+        return reply == null ? "" : reply.toString(); //$NON-NLS-1$
     }
 
     /**

Added: trunk/common-swing/src/main/java/org/crosswire/common/swing/MapComboBoxModel.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/MapComboBoxModel.java	                        (rev 0)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/MapComboBoxModel.java	2007-07-29 00:49:34 UTC (rev 1578)
@@ -0,0 +1,92 @@
+/**
+ * Distribution License:
+ * BibleDesktop is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 2 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/gpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: BibleComboBoxModel.java 1410 2007-06-15 17:59:12 -0400 (Fri, 15 Jun 2007) dmsmith $
+ */
+package org.crosswire.common.swing;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+
+/**
+ * A ComboBoxModel for selecting entries from a map.
+ *
+ * @see gnu.gpl.License for license details.
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public class MapComboBoxModel extends AbstractListModel implements ComboBoxModel
+{
+    /**
+     * Simple ctor for an entry from a map.
+     */
+    public MapComboBoxModel(Map map)
+    {
+        list = new ArrayList(map.entrySet());
+    }
+
+    /* (non-Javadoc)
+     * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+     */
+    public void setSelectedItem(Object newSelection)
+    {
+        selected = newSelection;
+        fireContentsChanged(this, -1, -1);
+    }
+
+    /* (non-Javadoc)
+     * @see javax.swing.ComboBoxModel#getSelectedItem()
+     */
+    public Object getSelectedItem()
+    {
+        return selected;
+    }
+
+    /* (non-Javadoc)
+     * @see javax.swing.ListModel#getSize()
+     */
+    public int getSize()
+    {
+        return list.size();
+    }
+
+    /* (non-Javadoc)
+     * @see javax.swing.ListModel#getElementAt(int)
+     */
+    public Object getElementAt(int index)
+    {
+        return list.get(index);
+    }
+
+    private List list;
+
+    /**
+     * What is currently selected?
+     */
+    private transient Object selected;
+
+    /**
+     * Serialization ID
+     */
+    private static final long serialVersionUID = 4830813224135775043L;
+}

Added: trunk/common-swing/src/main/java/org/crosswire/common/swing/MapEntryRenderer.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/MapEntryRenderer.java	                        (rev 0)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/MapEntryRenderer.java	2007-07-29 00:49:34 UTC (rev 1578)
@@ -0,0 +1,58 @@
+/**
+ * Distribution License:
+ * BibleDesktop is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 2 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/gpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2007
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: BibleNameCellRenderer.java 1471 2007-07-03 21:01:02Z dmsmith $
+ */
+package org.crosswire.common.swing;
+
+import java.awt.Component;
+import java.util.Map;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JList;
+
+/**
+ * Render a Map Entry as it's value.
+ *
+ * @see gnu.gpl.License for license details.
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public class MapEntryRenderer extends DefaultListCellRenderer
+{
+    /* (non-Javadoc)
+     * @see javax.swing.DefaultListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+     */
+    public Component getListCellRendererComponent(JList list, Object value, int index, boolean selected, boolean focus)
+    {
+        Object displayObject = value;
+        if (value instanceof Map.Entry)
+        {
+            Map.Entry mapEntry = (Map.Entry) value;
+            displayObject = mapEntry.getValue();
+        }
+
+        return super.getListCellRendererComponent(list, displayObject, index, selected, focus);
+    }
+
+    /**
+     * Serialization ID
+     */
+    private static final long serialVersionUID = 3978138859576308017L;
+}




More information about the jsword-svn mailing list