JAL-3068 LineartOptions for EPS/HTML/SVG, new preferences, i18n
[jalview.git] / src / jalview / gui / Preferences.java
index 92854ad..31842e4 100755 (executable)
@@ -54,6 +54,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import javax.help.HelpSetException;
+import javax.swing.JComboBox;
 import javax.swing.JFileChooser;
 import javax.swing.JInternalFrame;
 import javax.swing.JPanel;
@@ -501,23 +502,9 @@ public class Preferences extends GPreferences
     /*
      * Set Output tab defaults
      */
-    epsRendering.addItem(promptEachTimeOpt);
-    epsRendering.addItem(lineArtOpt);
-    epsRendering.addItem(textOpt);
-    String defaultEPS = Cache.getDefault("EPS_RENDERING",
-            "Prompt each time");
-    if (defaultEPS.equalsIgnoreCase("Text"))
-    {
-      epsRendering.setSelectedItem(textOpt);
-    }
-    else if (defaultEPS.equalsIgnoreCase("Lineart"))
-    {
-      epsRendering.setSelectedItem(lineArtOpt);
-    }
-    else
-    {
-      epsRendering.setSelectedItem(promptEachTimeOpt);
-    }
+    setupOutputCombo(epsRendering, "EPS_RENDERING");
+    setupOutputCombo(htmlRendering, "HTML_RENDERING");
+    setupOutputCombo(svgRendering, "SVG_RENDERING");
     autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
     userIdWidth.setEnabled(!autoIdWidth.isSelected());
     userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
@@ -549,6 +536,35 @@ public class Preferences extends GPreferences
   }
 
   /**
+   * A helper method that sets the items and initial selection in a character
+   * rendering option list (Prompt each time/Lineart/Text)
+   * 
+   * @param comboBox
+   * @param propertyKey
+   */
+  protected void setupOutputCombo(JComboBox<Object> comboBox,
+          String propertyKey)
+  {
+    comboBox.addItem(promptEachTimeOpt);
+    comboBox.addItem(lineArtOpt);
+    comboBox.addItem(textOpt);
+    String defaultOption = Cache.getDefault(propertyKey,
+            "Prompt each time");
+    if (defaultOption.equalsIgnoreCase("Text"))
+    {
+      comboBox.setSelectedItem(textOpt);
+    }
+    else if (defaultOption.equalsIgnoreCase("Lineart"))
+    {
+      comboBox.setSelectedItem(lineArtOpt);
+    }
+    else
+    {
+      comboBox.setSelectedItem(promptEachTimeOpt);
+    }
+  }
+
+  /**
    * Save user selections on the Preferences tabs to the Cache and write out to
    * file.
    * 
@@ -684,6 +700,10 @@ public class Preferences extends GPreferences
      */
     Cache.applicationProperties.setProperty("EPS_RENDERING",
             ((OptionsParam) epsRendering.getSelectedItem()).getCode());
+    Cache.applicationProperties.setProperty("HTML_RENDERING",
+            ((OptionsParam) htmlRendering.getSelectedItem()).getCode());
+    Cache.applicationProperties.setProperty("SVG_RENDERING",
+            ((OptionsParam) svgRendering.getSelectedItem()).getCode());
 
     /*
      * Save Connections settings