(JAL-985,JAL-986) preference widgets for settings
authorjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 9 Nov 2011 14:22:29 +0000 (14:22 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 9 Nov 2011 14:22:29 +0000 (14:22 +0000)
src/jalview/gui/Preferences.java
src/jalview/jbgui/GPreferences.java

index 27c455e..1e9cd46 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());
+  }
+
 }
index 6cad0b5..8e2acc2 100755 (executable)
@@ -160,6 +160,11 @@ public class GPreferences extends JPanel
   JLabel epsLabel = new JLabel();
 
   protected JComboBox epsRendering = new JComboBox();
+  
+  protected JLabel userIdWidthlabel = new JLabel();
+  protected JCheckBox autoIdWidth = new JCheckBox();
+  protected JTextField userIdWidth = new JTextField();
+
 
   JLabel jLabel1 = new JLabel();
 
@@ -635,9 +640,38 @@ public class GPreferences extends JPanel
     sortByTree.setText("Sort With New Tree");
     sortByTree.setToolTipText("When selected, any trees calculated or loaded onto the alignment will automatically sort the alignment.");
     sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
+    
+    autoIdWidth.setFont(JvSwingUtils.getLabelFont());
+    autoIdWidth.setText("Autofit Figure ID width");
+    autoIdWidth.setBounds(new Rectangle(228, 96,188,23));
+    autoIdWidth.addActionListener(new ActionListener()
+    {
+      
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        autoIdWidth_actionPerformed();
+      }
+    });
+    userIdWidthlabel.setFont(JvSwingUtils.getLabelFont());
+    userIdWidthlabel.setText("Figure ID column width");
+    userIdWidthlabel.setBounds(new Rectangle(236, 120,168,23));
+    userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
+    userIdWidth.setText("");
+    userIdWidth.setBounds(new Rectangle(232,144,84,23));
+    userIdWidth.addActionListener(new ActionListener()
+    {
+      
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        userIdWidth_actionPerformed();
+      }
+    });
     modellerOutput.setFont(JvSwingUtils.getLabelFont());
     modellerOutput.setText("Use Modeller Output");
     modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
+
     dasPanel.setLayout(borderLayout4);
     wsPanel.setLayout(borderLayout5);
     wrap.setFont(JvSwingUtils.getLabelFont());
@@ -793,6 +827,9 @@ public class GPreferences extends JPanel
     jPanel11.add(pfamjv);
     jPanel11.add(pileupjv);
     jPanel11.add(pirjv);
+    exportTab.add(autoIdWidth);
+    exportTab.add(userIdWidth);
+    exportTab.add(userIdWidthlabel);
     exportTab.add(modellerOutput);
     tabbedPane.add(calcTab, "Editing");
     calcTab.add(autoCalculateConsCheck);
@@ -807,6 +844,18 @@ public class GPreferences extends JPanel
     exportTab.add(jPanel11);
   }
 
+  protected void autoIdWidth_actionPerformed()
+  {
+    // TODO Auto-generated method stub
+    
+  }
+
+  protected void userIdWidth_actionPerformed()
+  {
+    // TODO Auto-generated method stub
+    
+  }
+
   protected void maxColour_actionPerformed()
   {
     // TODO Auto-generated method stub