JAL-1911 improvement to bugfix - do not save i18n text in preference file
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Thu, 26 May 2016 17:18:59 +0000 (18:18 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Thu, 26 May 2016 17:18:59 +0000 (18:18 +0100)
resources/lang/Messages_es.properties
src/jalview/gui/Preferences.java
src/jalview/gui/TreePanel.java
src/jalview/jbgui/GPreferences.java

index 8943860..b3da568 100644 (file)
@@ -321,7 +321,7 @@ action.save_vamsas_session = Guardar Sesi
 label.select_vamsas_session_opened_as_new_vamsas_session= Selecciones una sesión vamsas para abrirla como una nueva sesión.
 label.open_saved_vamsas_session = Abrir una sesión VAMSAS guardada
 label.groovy_console = Consola Groovy 
-label.lineart = lineart
+label.lineart = Lineart
 label.dont_ask_me_again = No volver a preguntar
 label.select_eps_character_rendering_style = Seleccionar el carácter EPS como estilo de visualización 
 label.invert_selection = Invertir selección
index ea090a3..84baa1c 100755 (executable)
@@ -359,12 +359,29 @@ public class Preferences extends GPreferences
     /*
      * Set Output tab defaults
      */
-    epsRendering
-.addItem("Prompt each time");
-    epsRendering.addItem(MessageManager.getString("label.lineart"));
-    epsRendering.addItem(MessageManager.getString("action.text"));
-    epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
-            "Prompt each time"));
+    epsRendering.addItem(new OptionsParam(MessageManager
+            .getString("label.prompt_each_time"), "Prompt each time"));
+    epsRendering.addItem(new OptionsParam(MessageManager
+            .getString("label.lineart"), "Lineart"));
+    epsRendering.addItem(new OptionsParam(MessageManager
+            .getString("action.text"), "Text"));
+    String defaultEPS = Cache.getDefault("EPS_RENDERING",
+            "Prompt each time");
+    if (defaultEPS.equalsIgnoreCase("Text"))
+    {
+      epsRendering.setSelectedItem(new OptionsParam(MessageManager
+              .getString("action.text"), "Text"));
+    }
+    else if (defaultEPS.equalsIgnoreCase("Lineart"))
+    {
+      epsRendering.setSelectedItem(new OptionsParam(MessageManager
+              .getString("label.lineart"), "Lineart"));
+    }
+    else
+    {
+      epsRendering.setSelectedItem(new OptionsParam(MessageManager
+              .getString("label.prompt_each_time"), "Prompt each time"));
+    }
     autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
     userIdWidth.setEnabled(!autoIdWidth.isSelected());
     userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
@@ -521,8 +538,8 @@ public class Preferences extends GPreferences
     }
     else
     {
-      Cache.applicationProperties.setProperty("EPS_RENDERING", epsRendering
-              .getSelectedItem().toString());
+      Cache.applicationProperties.setProperty("EPS_RENDERING",
+              ((OptionsParam) epsRendering.getSelectedItem()).getCode());
     }
 
     /*
@@ -983,4 +1000,57 @@ public class Preferences extends GPreferences
     }
   }
 
+  public class OptionsParam
+  {
+    private String name;
+
+    private String code;
+
+    public OptionsParam(String name, String code)
+    {
+      this.name = name;
+      this.code = code;
+    }
+
+    public String getName()
+    {
+      return name;
+    }
+
+    public void setName(String name)
+    {
+      this.name = name;
+    }
+
+    public String getCode()
+    {
+      return code;
+    }
+
+    public void setCode(String code)
+    {
+      this.code = code;
+    }
+
+    @Override
+    public String toString()
+    {
+      return name;
+    }
+
+    @Override
+    public boolean equals(Object that)
+    {
+      if (!(that instanceof OptionsParam))
+      {
+        return false;
+      }
+      return this.code.equalsIgnoreCase(((OptionsParam) that).code);
+    }
+
+    @Override
+    public int hashCode(){
+      return name.hashCode() + code.hashCode();
+    }
+  }
 }
index ae73baa..d78350d 100755 (executable)
@@ -723,8 +723,7 @@ public class TreePanel extends GTreePanel
 
     // If we need to prompt, and if the GUI is visible then
     // Prompt for EPS rendering style
-    if (renderStyle.equalsIgnoreCase(MessageManager
-            .getString("label.prompt_each_time"))
+    if (renderStyle.equalsIgnoreCase("Prompt each time")
             && !(System.getProperty("java.awt.headless") != null && System
                     .getProperty("java.awt.headless").equals("true")))
     {
index c4c737c..25727d0 100755 (executable)
@@ -201,7 +201,7 @@ public class GPreferences extends JPanel
   /*
    * Output tab components
    */
-  protected JComboBox<String> epsRendering = new JComboBox<String>();
+  protected JComboBox<Object> epsRendering = new JComboBox<Object>();
 
   protected JLabel userIdWidthlabel = new JLabel();