JAL-1499 patch from Mungo Carstairs
[jalview.git] / src / jalview / gui / Preferences.java
old mode 100755 (executable)
new mode 100644 (file)
index 3a0489a..f7d189b
@@ -6,31 +6,43 @@
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
  *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
- * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.gui;
 
-import java.util.*;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.*;
-
-import jalview.bin.*;
-import jalview.io.*;
-import jalview.jbgui.*;
-import jalview.schemes.*;
+import jalview.bin.Cache;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.jbgui.GPreferences;
+import jalview.jbgui.GSequenceLink;
+import jalview.schemes.ColourSchemeProperty;
 import jalview.util.MessageManager;
 
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.util.Collection;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import javax.swing.JColorChooser;
+import javax.swing.JFileChooser;
+import javax.swing.JInternalFrame;
+import javax.swing.JOptionPane;
+
 /**
  * DOCUMENT ME!
  * 
@@ -88,9 +100,10 @@ public class Preferences extends GPreferences
               .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
       if (srsPos > -1)
       {
-        sequenceURLLinks.setElementAt(
-                "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
-                srsPos);
+        sequenceURLLinks
+                .setElementAt(
+                        "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
+                        srsPos);
       }
     }
 
@@ -108,7 +121,7 @@ public class Preferences extends GPreferences
 
   DasSourceBrowser dasSource;
 
-  private WsPreferences wsPrefs;
+  private final WsPreferences wsPrefs;
 
   /**
    * Creates a new Preferences object.
@@ -129,7 +142,8 @@ public class Preferences extends GPreferences
       height = 460;
     }
 
-    Desktop.addInternalFrame(frame, MessageManager.getString("label.preferences"), width, height);
+    Desktop.addInternalFrame(frame,
+            MessageManager.getString("label.preferences"), width, height);
     frame.setMinimumSize(new Dimension(width, height));
 
     seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true));
@@ -290,6 +304,7 @@ public class Preferences extends GPreferences
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void ok_actionPerformed(ActionEvent e)
   {
 
@@ -457,6 +472,8 @@ public class Preferences extends GPreferences
             Boolean.toString(clustaljv.isSelected()));
     Cache.applicationProperties.setProperty("FASTA_JVSUFFIX",
             Boolean.toString(fastajv.isSelected()));
+    Cache.applicationProperties.setProperty("MEGA_JVSUFFIX",
+            Boolean.toString(megajv.isSelected()));
     Cache.applicationProperties.setProperty("MSF_JVSUFFIX",
             Boolean.toString(msfjv.isSelected()));
     Cache.applicationProperties.setProperty("PFAM_JVSUFFIX",
@@ -496,14 +513,17 @@ public class Preferences extends GPreferences
   /**
    * DOCUMENT ME!
    */
+  @Override
   public void startupFileTextfield_mouseClicked()
   {
     JalviewFileChooser chooser = new JalviewFileChooser(
             jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
             new String[]
-            { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", "jar" },
+            { "fa, fasta, fastq", "aln", "pfam", "meg", "msf", "pir",
+                "blc", "jar" },
             new String[]
-            { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" },
+            { "Fasta", "Clustal", "PFAM", "MEGA", "MSF", "PIR", "BLC",
+                "Jalview" },
             jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle("Select startup file");
@@ -525,6 +545,7 @@ public class Preferences extends GPreferences
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void cancel_actionPerformed(ActionEvent e)
   {
     try
@@ -543,6 +564,7 @@ public class Preferences extends GPreferences
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void annotations_actionPerformed(ActionEvent e)
   {
     conservation.setEnabled(annotations.isSelected());
@@ -556,6 +578,7 @@ public class Preferences extends GPreferences
             && (identity.isSelected() || showGroupConsensus.isSelected()));
   }
 
+  @Override
   public void newLink_actionPerformed(ActionEvent e)
   {
 
@@ -564,8 +587,8 @@ public class Preferences extends GPreferences
     while (!valid)
     {
       if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
-              MessageManager.getString("label.new_sequence_url_link"), JOptionPane.OK_CANCEL_OPTION, -1,
-              null) == JOptionPane.OK_OPTION)
+              MessageManager.getString("label.new_sequence_url_link"),
+              JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
       {
         if (link.checkValid())
         {
@@ -582,6 +605,7 @@ public class Preferences extends GPreferences
     }
   }
 
+  @Override
   public void editLink_actionPerformed(ActionEvent e)
   {
     GSequenceLink link = new GSequenceLink();
@@ -590,7 +614,8 @@ public class Preferences extends GPreferences
     if (index == -1)
     {
       JOptionPane.showInternalMessageDialog(Desktop.desktop,
-              MessageManager.getString("label.no_link_selected"), MessageManager.getString("label.no_link_selected"),
+              MessageManager.getString("label.no_link_selected"),
+              MessageManager.getString("label.no_link_selected"),
               JOptionPane.WARNING_MESSAGE);
       return;
     }
@@ -603,8 +628,8 @@ public class Preferences extends GPreferences
     {
 
       if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
-              MessageManager.getString("label.new_sequence_url_link"), JOptionPane.OK_CANCEL_OPTION, -1,
-              null) == JOptionPane.OK_OPTION)
+              MessageManager.getString("label.new_sequence_url_link"),
+              JOptionPane.OK_CANCEL_OPTION, -1, null) == JOptionPane.OK_OPTION)
       {
         if (link.checkValid())
         {
@@ -622,13 +647,15 @@ public class Preferences extends GPreferences
     }
   }
 
+  @Override
   public void deleteLink_actionPerformed(ActionEvent e)
   {
     int index = linkNameList.getSelectedIndex();
     if (index == -1)
     {
       JOptionPane.showInternalMessageDialog(Desktop.desktop,
-              MessageManager.getString("label.no_link_selected"), MessageManager.getString("label.no_link_selected"),
+              MessageManager.getString("label.no_link_selected"),
+              MessageManager.getString("label.no_link_selected"),
               JOptionPane.WARNING_MESSAGE);
       return;
     }
@@ -643,6 +670,7 @@ public class Preferences extends GPreferences
     linkURLList.setListData(urlLinks);
   }
 
+  @Override
   public void defaultBrowser_mouseClicked(MouseEvent e)
   {
     JFileChooser chooser = new JFileChooser(".");
@@ -664,6 +692,7 @@ public class Preferences extends GPreferences
    * jalview.jbgui.GPreferences#showunconserved_actionPerformed(java.awt.event
    * .ActionEvent)
    */
+  @Override
   protected void showunconserved_actionPerformed(ActionEvent e)
   {
     // TODO Auto-generated method stub
@@ -679,6 +708,7 @@ public class Preferences extends GPreferences
     return groupURLLinks;
   }
 
+  @Override
   public void minColour_actionPerformed()
   {
     Color col = JColorChooser.showDialog(this,
@@ -690,6 +720,7 @@ public class Preferences extends GPreferences
     minColour.repaint();
   }
 
+  @Override
   public void maxColour_actionPerformed()
   {
     Color col = JColorChooser.showDialog(this,