On 10/04/2013 12:10 PM, Michael T. Pope wrote:
On Fri, 04 Oct 2013 11:50:53 +0200
Michael Vehrs <[email protected]> wrote:
At the moment, I am experiencing the following option-related glitch: If
I view the immigration section of the difficulty settings, the unit type
of the immigrant is displayed only once. On every repaint, it is blank.
If I change the section and return to the immigration section, the whole
list option is no longer displayed. There are no errors in the log file.
Yes, I saw that too the other day.  It predates my working on dialogs, but
IIRC it was working correctly when we were hacking at Roles.
Coincidentally I have just reached ClientOptionsDialog et al, but AFAICT
the problem is somewhere in the UI code which I do not understand and do
not need to touch for the FreeColDialog cutover.

[Rolling back one message]
I'm afraid I don't understand your question about the String or
SelectOption values, though.
Options like model.option.buildOnNativeLand (with choices in custom mode)
correctly have .name and .shortDescription forms, and can thus display a 
tooltip.
However the *values* of buildOnNativeLand (e.g.
model.option.buildOnNativeLand.always) do not have .name/.shortDescription.  I
think they should, but do not see how to make this happen cleanly.

Cheers,
Mike Pope

I understand now. Try the attached patch for size. It might be possible to ignore the case localize == false entirely. I'm not sure.


Regards

Michael





diff --git a/src/net/sf/freecol/client/gui/plaf/FreeColComboBoxRenderer.java b/src/net/sf/freecol/client/gui/plaf/FreeColComboBoxRenderer.java
index a976a10..e16ab95 100644
--- a/src/net/sf/freecol/client/gui/plaf/FreeColComboBoxRenderer.java
+++ b/src/net/sf/freecol/client/gui/plaf/FreeColComboBoxRenderer.java
@@ -48,7 +48,7 @@ public class FreeColComboBoxRenderer implements ListCellRenderer, UIResource {
     private final NormalComponent NORMAL_COMPONENT = new NormalComponent();
 
     private final String prefix;
-
+    private boolean localize = true;
 
     /**
      * Creates a new <code>FreeColComboBoxRenderer</code> instance
@@ -66,7 +66,20 @@ public class FreeColComboBoxRenderer implements ListCellRenderer, UIResource {
      * @param prefix a <code>String</code> value
      */
     public FreeColComboBoxRenderer(String prefix) {
+        this(prefix, true);
+    }
+
+
+    /**
+     * Creates a new <code>FreeColComboBoxRenderer</code> instance
+     * with a given prefix.
+     *
+     * @param prefix a <code>String</code> value
+     * @param localize a <code>boolean</code> value
+     */
+    public FreeColComboBoxRenderer(String prefix, boolean localize) {
         this.prefix = prefix;
+        this.localize = localize;
     }
 
 
@@ -94,7 +107,13 @@ public class FreeColComboBoxRenderer implements ListCellRenderer, UIResource {
         if (value == null) {
             c.setText(null);
         } else if (value instanceof String) {
-            c.setText((String)value);
+            String string = (String) value;
+            if (localize) {
+                c.setText(Messages.message(string));
+                c.setToolTipText(Messages.getBestDescription(string));
+            } else {
+                c.setText(string);
+            }
         } else if (value instanceof ObjectWithId) {
             String id = prefix + ((ObjectWithId)value).getId();
             if (id == null) {
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Freecol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freecol-developers

Reply via email to