JAL-2360 refactoring for JalviewColourScheme enum,
[jalview.git] / src / jalview / gui / AlignFrame.java
index f31a220..9aed70d 100644 (file)
@@ -75,7 +75,6 @@ import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
 import jalview.io.JnetAnnotationMaker;
 import jalview.io.NewickFile;
-import jalview.io.StructureFile;
 import jalview.io.TCoffeeScoreFile;
 import jalview.jbgui.GAlignFrame;
 import jalview.schemes.Blosum62ColourScheme;
@@ -88,7 +87,9 @@ import jalview.schemes.HydrophobicColourScheme;
 import jalview.schemes.NucleotideColourScheme;
 import jalview.schemes.PIDColourScheme;
 import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.RNAHelicesColour;
 import jalview.schemes.RNAHelicesColourChooser;
+import jalview.schemes.ResidueColourScheme;
 import jalview.schemes.ResidueProperties;
 import jalview.schemes.StrandColourScheme;
 import jalview.schemes.TCoffeeColourScheme;
@@ -126,7 +127,6 @@ import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.awt.event.KeyAdapter;
 import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.print.PageFormat;
 import java.awt.print.PrinterJob;
@@ -147,8 +147,6 @@ import javax.swing.JInternalFrame;
 import javax.swing.JLayeredPane;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JRadioButtonMenuItem;
 import javax.swing.JScrollPane;
 import javax.swing.SwingUtilities;
 
@@ -858,14 +856,40 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     conservationMenuItem.setEnabled(!nucleotide);
     modifyConservation.setEnabled(!nucleotide);
     showGroupConservation.setEnabled(!nucleotide);
+
+    /*
+     * enable / disable colour schemes
+     * - the old, simple way (based on the nucleotide flag), or
+     * - the new, generic way (interrogate the colour scheme)
+     */
+    AlignmentI al = getViewport().getAlignment();
+    clustalColour.setEnabled(!nucleotide);
+    zappoColour.setEnabled(!nucleotide);
+    taylorColour.setEnabled(!nucleotide);
+    hydrophobicityColour.setEnabled(!nucleotide);
+    helixColour.setEnabled(!nucleotide);
+    strandColour.setEnabled(!nucleotide);
+    turnColour.setEnabled(!nucleotide);
+    // buriedColour.setEnabled(!nucleotide);
+    // TODO make isApplicableTo static in ColourSchemeI in Java 8
+    buriedColour.setEnabled(new BuriedColourScheme().isApplicableTo(al));
     rnahelicesColour.setEnabled(nucleotide);
-    purinePyrimidineColour.setEnabled(nucleotide);
+    nucleotideColour.setEnabled(nucleotide);
+    // purinePyrimidineColour.setEnabled(nucleotide);
+    purinePyrimidineColour.setEnabled(new PurinePyrimidineColourScheme()
+            .isApplicableTo(al));
+    tcoffeeColour
+            .setEnabled(new TCoffeeColourScheme(al).isApplicableTo(al));
+    RNAInteractionColour.setEnabled(nucleotide);
     showComplementMenuItem.setText(nucleotide ? MessageManager
             .getString("label.protein") : MessageManager
             .getString("label.nucleotide"));
-    setColourSelected(jalview.bin.Cache.getDefault(
+
+    String selectedColourScheme = Cache.getDefault(
             nucleotide ? Preferences.DEFAULT_COLOUR_NUC
-                    : Preferences.DEFAULT_COLOUR_PROT, "None"));
+                    : Preferences.DEFAULT_COLOUR_PROT,
+            ResidueColourScheme.NONE);
+    setColourSelected(selectedColourScheme);
   }
 
   /**
@@ -928,7 +952,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     autoCalculate.setSelected(av.autoCalculateConsensus);
     sortByTree.setSelected(av.sortByTree);
     listenToViewSelections.setSelected(av.followSelection);
-    rnahelicesColour.setEnabled(av.getAlignment().hasRNAStructure());
+    // rnahelicesColour.setEnabled(av.getAlignment().hasRNAStructure());
+    rnahelicesColour.setEnabled(new RNAHelicesColour(av.getAlignment())
+            .isApplicableTo(av.getAlignment()));
     rnahelicesColour
             .setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
 
@@ -1114,11 +1140,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   public void saveAs_actionPerformed(ActionEvent e)
   {
+    String format = currentFileFormat == null ? null : currentFileFormat
+            .toString();
     JalviewFileChooser chooser = JalviewFileChooser.forWrite(
-            Cache.getProperty("LAST_DIRECTORY"),
-            // AppletFormatAdapter.WRITABLE_EXTENSIONS,
-            // AppletFormatAdapter.WRITABLE_FNAMES,
-            currentFileFormat.toString(), false);
+            Cache.getProperty("LAST_DIRECTORY"), format);
 
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle(MessageManager
@@ -1132,14 +1157,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       currentFileFormat = chooser.getSelectedFormat();
       while (currentFileFormat == null)
       {
-        JOptionPane
+        JvOptionPane
                 .showInternalMessageDialog(
                         Desktop.desktop,
                         MessageManager
                                 .getString("label.select_file_format_before_saving"),
                         MessageManager
                                 .getString("label.file_format_not_specified"),
-                        JOptionPane.WARNING_MESSAGE);
+                        JvOptionPane.WARNING_MESSAGE);
         currentFileFormat = chooser.getSelectedFormat();
         value = chooser.showSaveDialog(this);
         if (value != JalviewFileChooser.APPROVE_OPTION)
@@ -1235,11 +1260,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     if (!success)
     {
-      JOptionPane.showInternalMessageDialog(this, MessageManager
+      JvOptionPane.showInternalMessageDialog(this, MessageManager
               .formatMessage("label.couldnt_save_file",
                       new Object[] { fileName }), MessageManager
               .getString("label.error_saving_file"),
-              JOptionPane.WARNING_MESSAGE);
+              JvOptionPane.WARNING_MESSAGE);
     }
 
     return success;
@@ -1254,8 +1279,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
     else
     {
-      JOptionPane.showInternalMessageDialog(this, warning, title,
-              JOptionPane.WARNING_MESSAGE);
+      JvOptionPane.showInternalMessageDialog(this, warning, title,
+              JvOptionPane.WARNING_MESSAGE);
     }
     return;
   }
@@ -2372,13 +2397,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               .getAlignment().getWidth()) ? true : false;
       if (isEntireAlignWidth)
       {
-        int confirm = JOptionPane.showConfirmDialog(this,
+        int confirm = JvOptionPane.showConfirmDialog(this,
                 MessageManager.getString("warn.delete_all"), // $NON-NLS-1$
                 MessageManager.getString("label.delete_all"), // $NON-NLS-1$
-                JOptionPane.OK_CANCEL_OPTION);
+                JvOptionPane.OK_CANCEL_OPTION);
 
-        if (confirm == JOptionPane.CANCEL_OPTION
-                || confirm == JOptionPane.CLOSED_OPTION)
+        if (confirm == JvOptionPane.CANCEL_OPTION
+                || confirm == JvOptionPane.CLOSED_OPTION)
         {
           return;
         }
@@ -3301,7 +3326,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   @Override
-  public void textColour_actionPerformed(ActionEvent e)
+  public void textColour_actionPerformed()
   {
     new TextColourChooser().chooseColour(alignPanel, null);
   }
@@ -3313,7 +3338,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  protected void noColourmenuItem_actionPerformed(ActionEvent e)
+  protected void noColourmenuItem_actionPerformed()
   {
     changeColour(null);
   }
@@ -3325,7 +3350,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void clustalColour_actionPerformed(ActionEvent e)
+  public void clustalColour_actionPerformed()
   {
     changeColour(new ClustalxColourScheme(viewport.getAlignment(),
             viewport.getHiddenRepSequences()));
@@ -3338,7 +3363,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void zappoColour_actionPerformed(ActionEvent e)
+  public void zappoColour_actionPerformed()
   {
     changeColour(new ZappoColourScheme());
   }
@@ -3350,7 +3375,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void taylorColour_actionPerformed(ActionEvent e)
+  public void taylorColour_actionPerformed()
   {
     changeColour(new TaylorColourScheme());
   }
@@ -3362,7 +3387,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void hydrophobicityColour_actionPerformed(ActionEvent e)
+  public void hydrophobicityColour_actionPerformed()
   {
     changeColour(new HydrophobicColourScheme());
   }
@@ -3374,7 +3399,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void helixColour_actionPerformed(ActionEvent e)
+  public void helixColour_actionPerformed()
   {
     changeColour(new HelixColourScheme());
   }
@@ -3386,7 +3411,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void strandColour_actionPerformed(ActionEvent e)
+  public void strandColour_actionPerformed()
   {
     changeColour(new StrandColourScheme());
   }
@@ -3398,7 +3423,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void turnColour_actionPerformed(ActionEvent e)
+  public void turnColour_actionPerformed()
   {
     changeColour(new TurnColourScheme());
   }
@@ -3410,7 +3435,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void buriedColour_actionPerformed(ActionEvent e)
+  public void buriedColour_actionPerformed()
   {
     changeColour(new BuriedColourScheme());
   }
@@ -3422,25 +3447,25 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void nucleotideColour_actionPerformed(ActionEvent e)
+  public void nucleotideColour_actionPerformed()
   {
     changeColour(new NucleotideColourScheme());
   }
 
   @Override
-  public void purinePyrimidineColour_actionPerformed(ActionEvent e)
+  public void purinePyrimidineColour_actionPerformed()
   {
     changeColour(new PurinePyrimidineColourScheme());
   }
 
   /*
-   * public void covariationColour_actionPerformed(ActionEvent e) {
+   * public void covariationColour_actionPerformed() {
    * changeColour(new
    * CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation
    * ()[0])); }
    */
   @Override
-  public void annotationColour_actionPerformed(ActionEvent e)
+  public void annotationColour_actionPerformed()
   {
     new AnnotationColourChooser(viewport, alignPanel);
   }
@@ -3452,7 +3477,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   @Override
-  public void rnahelicesColour_actionPerformed(ActionEvent e)
+  public void rnahelicesColour_actionPerformed()
   {
     new RNAHelicesColourChooser(viewport, alignPanel);
   }
@@ -3460,11 +3485,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   /**
    * DOCUMENT ME!
    * 
-   * @param e
-   *          DOCUMENT ME!
    */
   @Override
-  protected void applyToAllGroups_actionPerformed(ActionEvent e)
+  protected void applyToAllGroups_actionPerformed()
   {
     viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
   }
@@ -3514,7 +3537,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  protected void modifyPID_actionPerformed(ActionEvent e)
+  protected void modifyPID_actionPerformed()
   {
     if (viewport.getAbovePIDThreshold()
             && viewport.getGlobalColourScheme() != null)
@@ -3532,7 +3555,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  protected void modifyConservation_actionPerformed(ActionEvent e)
+  protected void modifyConservation_actionPerformed()
   {
     if (viewport.getConservationSelected()
             && viewport.getGlobalColourScheme() != null)
@@ -3550,7 +3573,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  protected void conservationMenuItem_actionPerformed(ActionEvent e)
+  protected void conservationMenuItem_actionPerformed()
   {
     viewport.setConservationSelected(conservationMenuItem.isSelected());
 
@@ -3559,7 +3582,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     changeColour(viewport.getGlobalColourScheme());
 
-    modifyConservation_actionPerformed(null);
+    modifyConservation_actionPerformed();
   }
 
   /**
@@ -3569,7 +3592,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void abovePIDThreshold_actionPerformed(ActionEvent e)
+  public void abovePIDThreshold_actionPerformed()
   {
     viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
 
@@ -3578,7 +3601,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     changeColour(viewport.getGlobalColourScheme());
 
-    modifyPID_actionPerformed(null);
+    modifyPID_actionPerformed();
   }
 
   /**
@@ -3597,104 +3620,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
     else
     {
-      UserColourScheme udc = (UserColourScheme) UserDefinedColours
+      UserColourScheme udc = UserDefinedColours
               .getUserColourSchemes().get(e.getActionCommand());
 
       changeColour(udc);
     }
   }
 
-  public void updateUserColourMenu()
-  {
-
-    Component[] menuItems = colourMenu.getMenuComponents();
-    int iSize = menuItems.length;
-    for (int i = 0; i < iSize; i++)
-    {
-      if (menuItems[i].getName() != null
-              && menuItems[i].getName().equals("USER_DEFINED"))
-      {
-        colourMenu.remove(menuItems[i]);
-        iSize--;
-      }
-    }
-    if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
-    {
-      java.util.Enumeration userColours = jalview.gui.UserDefinedColours
-              .getUserColourSchemes().keys();
-
-      while (userColours.hasMoreElements())
-      {
-        final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
-                userColours.nextElement().toString());
-        radioItem.setName("USER_DEFINED");
-        radioItem.addMouseListener(new MouseAdapter()
-        {
-          @Override
-          public void mousePressed(MouseEvent evt)
-          {
-            if (evt.isPopupTrigger()) // Mac
-            {
-              offerRemoval(radioItem);
-            }
-          }
-
-          @Override
-          public void mouseReleased(MouseEvent evt)
-          {
-            if (evt.isPopupTrigger()) // Windows
-            {
-              offerRemoval(radioItem);
-            }
-          }
-
-          /**
-           * @param radioItem
-           */
-          void offerRemoval(final JRadioButtonMenuItem radioItem)
-          {
-            radioItem.removeActionListener(radioItem.getActionListeners()[0]);
-
-            int option = JOptionPane.showInternalConfirmDialog(
-                    jalview.gui.Desktop.desktop, MessageManager
-                            .getString("label.remove_from_default_list"),
-                    MessageManager
-                            .getString("label.remove_user_defined_colour"),
-                    JOptionPane.YES_NO_OPTION);
-            if (option == JOptionPane.YES_OPTION)
-            {
-              jalview.gui.UserDefinedColours
-                      .removeColourFromDefaults(radioItem.getText());
-              colourMenu.remove(radioItem);
-            }
-            else
-            {
-              radioItem.addActionListener(new ActionListener()
-              {
-                @Override
-                public void actionPerformed(ActionEvent evt)
-                {
-                  userDefinedColour_actionPerformed(evt);
-                }
-              });
-            }
-          }
-        });
-        radioItem.addActionListener(new ActionListener()
-        {
-          @Override
-          public void actionPerformed(ActionEvent evt)
-          {
-            userDefinedColour_actionPerformed(evt);
-          }
-        });
-
-        colourMenu.insert(radioItem, 15);
-        colours.add(radioItem);
-      }
-    }
-  }
-
   /**
    * DOCUMENT ME!
    * 
@@ -3702,7 +3634,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void PIDColour_actionPerformed(ActionEvent e)
+  public void PIDColour_actionPerformed()
   {
     changeColour(new PIDColourScheme());
   }
@@ -3714,7 +3646,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    *          DOCUMENT ME!
    */
   @Override
-  public void BLOSUM62Colour_actionPerformed(ActionEvent e)
+  public void BLOSUM62Colour_actionPerformed()
   {
     changeColour(new Blosum62ColourScheme());
   }
@@ -3809,10 +3741,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     if ((viewport.getSelectionGroup() == null)
             || (viewport.getSelectionGroup().getSize() < 2))
     {
-      JOptionPane.showInternalMessageDialog(this, MessageManager
+      JvOptionPane.showInternalMessageDialog(this, MessageManager
               .getString("label.you_must_select_least_two_sequences"),
               MessageManager.getString("label.invalid_selection"),
-              JOptionPane.WARNING_MESSAGE);
+              JvOptionPane.WARNING_MESSAGE);
     }
     else
     {
@@ -3838,14 +3770,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             .getSelectionGroup().getSize() > 0))
             || (viewport.getAlignment().getHeight() < 4))
     {
-      JOptionPane
+      JvOptionPane
               .showInternalMessageDialog(
                       this,
                       MessageManager
                               .getString("label.principal_component_analysis_must_take_least_four_input_sequences"),
                       MessageManager
                               .getString("label.sequence_selection_insufficient"),
-                      JOptionPane.WARNING_MESSAGE);
+                      JvOptionPane.WARNING_MESSAGE);
 
       return;
     }
@@ -3943,14 +3875,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     {
       if (viewport.getSelectionGroup().getSize() < 3)
       {
-        JOptionPane
+        JvOptionPane
                 .showMessageDialog(
                         Desktop.desktop,
                         MessageManager
                                 .getString("label.you_need_more_two_sequences_selected_build_tree"),
                         MessageManager
                                 .getString("label.not_enough_sequences"),
-                        JOptionPane.WARNING_MESSAGE);
+                        JvOptionPane.WARNING_MESSAGE);
         return;
       }
 
@@ -3961,14 +3893,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       {
         if (_s.getLength() < sg.getEndRes())
         {
-          JOptionPane
+          JvOptionPane
                   .showMessageDialog(
                           Desktop.desktop,
                           MessageManager
                                   .getString("label.selected_region_to_tree_may_only_contain_residues_or_gaps"),
                           MessageManager
                                   .getString("label.sequences_selection_not_aligned"),
-                          JOptionPane.WARNING_MESSAGE);
+                          JvOptionPane.WARNING_MESSAGE);
 
           return;
         }
@@ -3982,14 +3914,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       // are the visible sequences aligned?
       if (!viewport.getAlignment().isAligned(false))
       {
-        JOptionPane
+        JvOptionPane
                 .showMessageDialog(
                         Desktop.desktop,
                         MessageManager
                                 .getString("label.sequences_must_be_aligned_before_creating_tree"),
                         MessageManager
                                 .getString("label.sequences_not_aligned"),
-                        JOptionPane.WARNING_MESSAGE);
+                        JvOptionPane.WARNING_MESSAGE);
 
         return;
       }
@@ -4254,11 +4186,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     else if (viewport.getSelectionGroup() != null
             && viewport.getSelectionGroup().getSize() == 1)
     {
-      int option = JOptionPane.showConfirmDialog(this,
+      int option = JvOptionPane.showConfirmDialog(this,
               MessageManager.getString("warn.oneseq_msainput_selection"),
               MessageManager.getString("label.invalid_selection"),
-              JOptionPane.OK_CANCEL_OPTION);
-      if (option == JOptionPane.OK_OPTION)
+              JvOptionPane.OK_CANCEL_OPTION);
+      if (option == JvOptionPane.OK_OPTION)
       {
         msa = viewport.getAlignmentView(false);
       }
@@ -4334,27 +4266,27 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree());
       } catch (Exception ex)
       {
-        JOptionPane
+        JvOptionPane
                 .showMessageDialog(
                         Desktop.desktop,
                         ex.getMessage(),
                         MessageManager
                                 .getString("label.problem_reading_tree_file"),
-                        JOptionPane.WARNING_MESSAGE);
+                        JvOptionPane.WARNING_MESSAGE);
         ex.printStackTrace();
       }
       if (fin != null && fin.hasWarningMessage())
       {
-        JOptionPane.showMessageDialog(Desktop.desktop, fin
+        JvOptionPane.showMessageDialog(Desktop.desktop, fin
                 .getWarningMessage(), MessageManager
                 .getString("label.possible_problem_with_tree_file"),
-                JOptionPane.WARNING_MESSAGE);
+                JvOptionPane.WARNING_MESSAGE);
       }
     }
   }
 
   @Override
-  protected void tcoffeeColorScheme_actionPerformed(ActionEvent e)
+  protected void tcoffeeColorScheme_actionPerformed()
   {
     changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));
   }
@@ -4733,8 +4665,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       final String errorTitle = MessageManager
               .getString("label.implementation_error")
               + MessageManager.getString("label.translation_failed");
-      JOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
-              JOptionPane.ERROR_MESSAGE);
+      JvOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
+              JvOptionPane.ERROR_MESSAGE);
       return;
     }
     if (al == null || al.getHeight() == 0)
@@ -4743,8 +4675,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               .getString("label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation");
       final String errorTitle = MessageManager
               .getString("label.translation_failed");
-      JOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
-              JOptionPane.WARNING_MESSAGE);
+      JvOptionPane.showMessageDialog(Desktop.desktop, msg, errorTitle,
+              JvOptionPane.WARNING_MESSAGE);
     }
     else
     {
@@ -4899,13 +4831,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               {
                 type = null;
               }
-              if (type != null)
+              if (type != null && type.isStructureFile())
               {
-                if (FileFormat.PDB.equals(type) || FileFormat.MMCif.equals(type))
-                {
-                  filesmatched.add(new Object[] { file, protocol, mtch });
-                  continue;
-                }
+                filesmatched.add(new Object[] { file, protocol, mtch });
+                continue;
               }
             }
             // File wasn't named like one of the sequences or wasn't a PDB file.
@@ -4916,7 +4845,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         if (filesmatched.size() > 0)
         {
           if (Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS", false)
-                  || JOptionPane
+                  || JvOptionPane
                           .showConfirmDialog(
                                   this,
                                   MessageManager
@@ -4929,7 +4858,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                                                           .toString() }),
                                   MessageManager
                                           .getString("label.automatically_associate_structure_files_by_name"),
-                                  JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
+                                  JvOptionPane.YES_NO_OPTION) == JvOptionPane.YES_OPTION)
 
           {
             for (Object[] fm : filesmatched)
@@ -4959,7 +4888,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         {
           if (assocfiles > 0
                   && (Cache.getDefault(
-                          "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false) || JOptionPane
+                          "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false) || JvOptionPane
                           .showConfirmDialog(
                                   this,
                                   "<html>"
@@ -4974,7 +4903,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                                           + "</html>",
                                   MessageManager
                                           .getString("label.ignore_unmatched_dropped_files"),
-                                  JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION))
+                                  JvOptionPane.YES_NO_OPTION) == JvOptionPane.YES_OPTION))
           {
             return;
           }
@@ -5039,7 +4968,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             {
               // some problem - if no warning its probable that the ID matching
               // process didn't work
-              JOptionPane
+              JvOptionPane
                       .showMessageDialog(
                               Desktop.desktop,
                               tcf.getWarningMessage() == null ? MessageManager
@@ -5047,7 +4976,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                                       : tcf.getWarningMessage(),
                               MessageManager
                                       .getString("label.problem_reading_tcoffee_score_file"),
-                              JOptionPane.WARNING_MESSAGE);
+                              JvOptionPane.WARNING_MESSAGE);
             }
           }
           else
@@ -5169,8 +5098,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     if (e.isPopupTrigger())
     {
       String msg = MessageManager.getString("label.enter_view_name");
-      String reply = JOptionPane.showInternalInputDialog(this, msg, msg,
-              JOptionPane.QUESTION_MESSAGE);
+      String reply = JvOptionPane.showInternalInputDialog(this, msg, msg,
+              JvOptionPane.QUESTION_MESSAGE);
 
       if (reply != null)
       {
@@ -5842,7 +5771,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
     AlignmentI cdna = new Alignment(cdnaSeqs.toArray(new SequenceI[cdnaSeqs
             .size()]));
-    AlignFrame alignFrame = new AlignFrame(cdna, AlignFrame.DEFAULT_WIDTH,
+    GAlignFrame alignFrame = new AlignFrame(cdna, AlignFrame.DEFAULT_WIDTH,
             AlignFrame.DEFAULT_HEIGHT);
     cdna.alignAs(alignment);
     String newtitle = "cDNA " + MessageManager.getString("label.for") + " "
@@ -5909,12 +5838,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       } catch (Exception ex)
       {
         System.err.println((ex.toString()));
-        JOptionPane
+        JvOptionPane
                 .showInternalMessageDialog(Desktop.desktop, MessageManager
                         .getString("label.couldnt_run_groovy_script"),
                         MessageManager
                                 .getString("label.groovy_support_failed"),
-                        JOptionPane.ERROR_MESSAGE);
+                        JvOptionPane.ERROR_MESSAGE);
       }
     }
     else