Merge branch 'test_paolo_JAL-1065' into Tcoffee_JAL-1065
[jalview.git] / src / jalview / gui / Preferences.java
index 27c455e..789799e 100755 (executable)
@@ -201,7 +201,11 @@ public class Preferences extends GPreferences
     epsRendering.addItem("Text");
     epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
             "Prompt each time"));
-
+    autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
+    userIdWidth.setEnabled(autoIdWidth.isSelected());
+    userIdWidthlabel.setEnabled(autoIdWidth.isSelected());
+    Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
+    userIdWidth.setText(wi == null ? "" : wi.toString());
     blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
     clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true));
     fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true));
@@ -450,6 +454,12 @@ public class Preferences extends GPreferences
             Boolean.toString(modellerOutput.isSelected()));
     jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
 
+    Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
+            Boolean.toString(autoIdWidth.isSelected()));
+    userIdWidth_actionPerformed();
+    Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
+                userIdWidth.getText());
+
     Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
             Boolean.toString(autoCalculateConsCheck.isSelected()));
     Cache.applicationProperties.setProperty("SORT_BY_TREE",
@@ -675,4 +685,38 @@ public class Preferences extends GPreferences
     maxColour.repaint();
   }
 
+  @Override
+  protected void userIdWidth_actionPerformed()
+  {
+    try
+    {
+      String val = userIdWidth.getText().trim();
+      if (val.length() > 0)
+      {
+        Integer iw = Integer.parseInt(val);
+        if (iw.intValue() < 12)
+        {
+          throw new NumberFormatException();
+        }
+        userIdWidth.setText(iw.toString());
+      }
+    } catch (NumberFormatException x)
+    {
+      JOptionPane
+              .showInternalMessageDialog(
+                      Desktop.desktop,
+                      "The user defined width for the\nannotation and sequence ID columns\nin exported figures must be\nat least 12 pixels wide.",
+                      "Invalid ID Column width",
+                      JOptionPane.WARNING_MESSAGE);
+      userIdWidth.setText("");
+    }
+  }
+
+  @Override
+  protected void autoIdWidth_actionPerformed()
+  {
+    userIdWidth.setEnabled(!autoIdWidth.isSelected());
+    userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
+  }
+
 }