Minor updates
[jalview.git] / src / jalview / gui / AlignFrame.java
index 2371be3..6d5a0eb 100644 (file)
@@ -35,6 +35,7 @@ import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 //from JalviewLite imports import jalview.api.FeatureRenderer;
 import jalview.api.FeatureSettingsControllerI;
+import jalview.api.FeatureSettingsModelI;
 import jalview.api.SplitContainerI;
 import jalview.api.ViewStyleI;
 import jalview.api.analysis.SimilarityParamsI;
@@ -131,7 +132,6 @@ import java.awt.event.MouseEvent;
 import java.awt.print.PageFormat;
 import java.awt.print.PrinterJob;
 import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.PrintWriter;
@@ -167,8 +167,8 @@ import ext.vamsas.ServiceHandle;
  */
 @SuppressWarnings("serial")
 public class AlignFrame extends GAlignFrame
-        implements AlignFrameI, DropTargetListener,
-        IProgressIndicator, AlignViewControllerGuiI, ColourChangeListener
+        implements AlignFrameI, DropTargetListener, IProgressIndicator,
+        AlignViewControllerGuiI, ColourChangeListener
 {
 
   public static final int DEFAULT_WIDTH = 700;
@@ -194,9 +194,9 @@ public class AlignFrame extends GAlignFrame
   /**
    * Current filename for this alignment
    */
-  private String fileName = null;
+  String fileName = null;
 
-  private File fileObject;
+  File fileObject;
 
   /**
    * Creates a new AlignFrame object with specific width and height.
@@ -366,10 +366,11 @@ public class AlignFrame extends GAlignFrame
     addAlignmentPanel(alignPanel, newPanel);
 
     // setBackground(Color.white); // BH 2019
-                 
+
     if (!Jalview.isHeadlessMode())
     {
       progressBar = new ProgressBar(this.statusPanel, this.statusBar);
+      // JalviewJS options
       statusPanel.setVisible(Jalview.getInstance().getShowStatus());
       alignFrameMenuBar.setVisible(Jalview.getInstance().getAllowMenuBar());
     }
@@ -403,6 +404,7 @@ public class AlignFrame extends GAlignFrame
     calculateTree.addActionListener(new ActionListener()
     {
 
+      
       @Override
       public void actionPerformed(ActionEvent e)
       {
@@ -414,24 +416,10 @@ public class AlignFrame extends GAlignFrame
     if (Desktop.getDesktopPane() != null)
     {
       this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
-      PropertyChangeListener serviceListener = (Platform.isJS() ? null
-              : addServiceListeners());
-      addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+      if (!Platform.isJS())
       {
-        @Override
-        public void internalFrameClosed(
-                javax.swing.event.InternalFrameEvent evt)
-        {
-          // System.out.println("deregistering discoverer listener");
-          if (serviceListener != null)
-          {
-            Desktop.getInstance().removeJalviewPropertyChangeListener(
-                    "services", serviceListener);
-          }
-          closeMenuItem_actionPerformed(true);
-        }
-      });
-
+        addServiceListeners();
+      }
       setGUINucleotide();
     }
 
@@ -455,6 +443,7 @@ public class AlignFrame extends GAlignFrame
             new ViewSetProvider()
             {
 
+              
               @Override
               public AlignmentPanel[] getAllAlignmentPanels()
               {
@@ -469,6 +458,7 @@ public class AlignFrame extends GAlignFrame
             }, selviews, new ItemListener()
             {
 
+              
               @Override
               public void itemStateChanged(ItemEvent e)
               {
@@ -524,6 +514,7 @@ public class AlignFrame extends GAlignFrame
     }
     addFocusListener(new FocusAdapter()
     {
+      
       @Override
       public void focusGained(FocusEvent e)
       {
@@ -568,6 +559,7 @@ public class AlignFrame extends GAlignFrame
   {
     addKeyListener(new KeyAdapter()
     {
+      
       @Override
       public void keyPressed(KeyEvent evt)
       {
@@ -585,8 +577,8 @@ public class AlignFrame extends GAlignFrame
         {
 
         case KeyEvent.VK_ESCAPE: // escape key
-          deselectAllSequenceMenuItem_actionPerformed(null);
-
+                                 // alignPanel.deselectAllSequences();
+          alignPanel.deselectAllSequences();
           break;
 
         case KeyEvent.VK_DOWN:
@@ -760,6 +752,7 @@ public class AlignFrame extends GAlignFrame
         }
       }
 
+      
       @Override
       public void keyReleased(KeyEvent evt)
       {
@@ -848,40 +841,58 @@ public class AlignFrame extends GAlignFrame
   }
 
   /* Set up intrinsic listeners for dynamically generated GUI bits. */
-  private PropertyChangeListener addServiceListeners()
+  private void addServiceListeners()
   {
-    PropertyChangeListener serviceListener = new PropertyChangeListener()
+    final java.beans.PropertyChangeListener thisListener;
+    Desktop.getInstance().addJalviewPropertyChangeListener("services",
+            thisListener = new java.beans.PropertyChangeListener()
+            {
+              
+              @Override
+              public void propertyChange(PropertyChangeEvent evt)
+              {
+                // // System.out.println("Discoverer property change.");
+                // if (evt.getPropertyName().equals("services"))
+                {
+                  SwingUtilities.invokeLater(new Runnable()
+                  {
+
+                    
+                    @Override
+                    public void run()
+                    {
+                      System.err.println(
+                              "Rebuild WS Menu for service change");
+                      BuildWebServiceMenu();
+                    }
+
+                  });
+                }
+              }
+            });
+    addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
     {
+      
       @Override
-      public void propertyChange(PropertyChangeEvent evt)
+      public void internalFrameClosed(
+              javax.swing.event.InternalFrameEvent evt)
       {
-        {
-          SwingUtilities.invokeLater(new Runnable()
-          {
-
-            @Override
-            public void run()
-            {
-              System.err.println("Rebuild WS Menu for service change");
-              BuildWebServiceMenu();
-            }
-          });
-        }
+        // System.out.println("deregistering discoverer listener");
+        Desktop.getInstance().removeJalviewPropertyChangeListener(
+                "services", thisListener);
+        closeMenuItem_actionPerformed(true);
       }
-    };
-
-    Desktop.getInstance().addJalviewPropertyChangeListener("services",
-            serviceListener);
+    });
     // Finally, build the menu once to get current service state
     new Thread(new Runnable()
     {
+      
       @Override
       public void run()
       {
         BuildWebServiceMenu();
       }
     }).start();
-    return serviceListener;
   }
 
   /**
@@ -912,6 +923,7 @@ public class AlignFrame extends GAlignFrame
    * operation that affects the data in the current view (selection changed,
    * etc) to update the menus to reflect the new state.
    */
+  
   @Override
   public void setMenusForViewport()
   {
@@ -942,11 +954,8 @@ public class AlignFrame extends GAlignFrame
     scaleLeft.setVisible(av.getWrapAlignment());
     scaleRight.setVisible(av.getWrapAlignment());
     annotationPanelMenuItem.setState(av.isShowAnnotation());
-    /*
-     * Show/hide annotations only enabled if annotation panel is shown
-     */
-    syncAnnotationMenuItems();
-
+    // Show/hide annotations only enabled if annotation panel is shown
+    syncAnnotationMenuItems(av.isShowAnnotation());
     viewBoxesMenuItem.setSelected(av.getShowBoxes());
     viewTextMenuItem.setSelected(av.getShowText());
     showNonconservedMenuItem.setSelected(av.getShowUnconserved());
@@ -964,7 +973,8 @@ public class AlignFrame extends GAlignFrame
     applyToAllGroups.setState(av.getColourAppliesToAllGroups());
     showNpFeatsMenuitem.setSelected(av.isShowNPFeats());
     showDbRefsMenuitem.setSelected(av.isShowDBRefs());
-    autoCalculate.setSelected(av.getAutoCalculateConsensusAndConservation());
+    autoCalculate
+            .setSelected(av.getAutoCalculateConsensusAndConservation());
     sortByTree.setSelected(av.sortByTree);
     listenToViewSelections.setSelected(av.followSelection);
 
@@ -991,12 +1001,14 @@ public class AlignFrame extends GAlignFrame
    * 
    * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
    */
+  
   @Override
   public void setProgressBar(String message, long id)
   {
     progressBar.setProgressBar(message, id);
   }
 
+  
   @Override
   public void registerHandler(final long id,
           final IProgressIndicatorHandler handler)
@@ -1008,6 +1020,7 @@ public class AlignFrame extends GAlignFrame
    * 
    * @return true if any progress bars are still active
    */
+  
   @Override
   public boolean operationInProgress()
   {
@@ -1019,6 +1032,7 @@ public class AlignFrame extends GAlignFrame
    * will cause the status bar to be hidden, with possibly undesirable flicker
    * of the screen layout.
    */
+  
   @Override
   public void setStatus(String text)
   {
@@ -1038,18 +1052,21 @@ public class AlignFrame extends GAlignFrame
     return alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer();
   }
 
+  
   @Override
   public void fetchSequence_actionPerformed()
   {
     new SequenceFetcher(this);
   }
 
+  
   @Override
   public void addFromFile_actionPerformed(ActionEvent e)
   {
     Desktop.getInstance().inputLocalFileMenuItem_actionPerformed(viewport);
   }
 
+  
   @Override
   public void reload_actionPerformed(ActionEvent e)
   {
@@ -1123,6 +1140,7 @@ public class AlignFrame extends GAlignFrame
         final FeatureSettings nfs = newframe.featureSettings;
         SwingUtilities.invokeLater(new Runnable()
         {
+          
           @Override
           public void run()
           {
@@ -1136,6 +1154,7 @@ public class AlignFrame extends GAlignFrame
     }
   }
 
+  
   @Override
   public void addFromText_actionPerformed(ActionEvent e)
   {
@@ -1143,12 +1162,14 @@ public class AlignFrame extends GAlignFrame
             .inputTextboxMenuItem_actionPerformed(viewport.getAlignPanel());
   }
 
+  
   @Override
   public void addFromURL_actionPerformed(ActionEvent e)
   {
     Desktop.getInstance().inputURLMenuItem_actionPerformed(viewport);
   }
 
+  
   @Override
   public void save_actionPerformed(ActionEvent e)
   {
@@ -1167,6 +1188,7 @@ public class AlignFrame extends GAlignFrame
    * Saves the alignment to a file with a name chosen by the user, if necessary
    * warning if a file would be overwritten
    */
+  
   @Override
   public void saveAs_actionPerformed()
   {
@@ -1264,21 +1286,23 @@ public class AlignFrame extends GAlignFrame
       String shortName = title;
       if (shortName.indexOf(File.separatorChar) > -1)
       {
-        shortName = shortName.substring(
-                shortName.lastIndexOf(File.separatorChar) + 1);
+        shortName = shortName
+                .substring(shortName.lastIndexOf(File.separatorChar) + 1);
       }
-      lastSaveSuccessful = new Jalview2XML().saveAlignment(this, file, shortName);
-      
+      lastSaveSuccessful = new Jalview2XML().saveAlignment(this, file,
+              shortName);
+
       statusBar.setText(MessageManager.formatMessage(
               "label.successfully_saved_to_file_in_format", new Object[]
               { fileName, format }));
-      
+
       return;
     }
 
     AlignExportSettingsI options = new AlignExportSettingsAdapter(false);
     Runnable cancelAction = new Runnable()
     {
+      
       @Override
       public void run()
       {
@@ -1287,6 +1311,7 @@ public class AlignFrame extends GAlignFrame
     };
     Runnable outputAction = new Runnable()
     {
+      
       @Override
       public void run()
       {
@@ -1309,16 +1334,17 @@ public class AlignFrame extends GAlignFrame
           BackupFiles backupfiles = doBackup ? new BackupFiles(file) : null;
           try
           {
-            String tempFilePath = doBackup ? backupfiles.getTempFilePath() : file;
-                       PrintWriter out = new PrintWriter(
-                    new FileWriter(tempFilePath));
+            String tempFilePath = doBackup ? backupfiles.getTempFilePath()
+                    : file;
+            PrintWriter out = new PrintWriter(new FileWriter(tempFilePath));
 
             out.print(output);
             out.close();
             AlignFrame.this.setTitle(file);
             statusBar.setText(MessageManager.formatMessage(
-                  "label.successfully_saved_to_file_in_format", new Object[]
-                  { fileName, format.getName() }));
+                    "label.successfully_saved_to_file_in_format",
+                    new Object[]
+                    { fileName, format.getName() }));
             lastSaveSuccessful = true;
           } catch (Exception ex)
           {
@@ -1360,6 +1386,7 @@ public class AlignFrame extends GAlignFrame
    * 
    * @param fileFormatName
    */
+  
   @Override
   protected void outputText_actionPerformed(String fileFormatName)
   {
@@ -1368,6 +1395,7 @@ public class AlignFrame extends GAlignFrame
     AlignExportSettingsI options = new AlignExportSettingsAdapter(false);
     Runnable outputAction = new Runnable()
     {
+      
       @Override
       public void run()
       {
@@ -1418,6 +1446,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void htmlMenuItem_actionPerformed(ActionEvent e)
   {
@@ -1425,6 +1454,7 @@ public class AlignFrame extends GAlignFrame
     htmlSVG.exportHTML(null);
   }
 
+  
   @Override
   public void bioJSMenuItem_actionPerformed(ActionEvent e)
   {
@@ -1443,6 +1473,7 @@ public class AlignFrame extends GAlignFrame
    * 
    * @param f
    */
+  
   @Override
   public void createPNG(File f)
   {
@@ -1455,6 +1486,7 @@ public class AlignFrame extends GAlignFrame
    * 
    * @param f
    */
+  
   @Override
   public void createEPS(File f)
   {
@@ -1467,12 +1499,14 @@ public class AlignFrame extends GAlignFrame
    * 
    * @param f
    */
+  
   @Override
   public void createSVG(File f)
   {
     alignPanel.makeAlignmentImage(TYPE.SVG, f);
   }
 
+  
   @Override
   public void pageSetup_actionPerformed(ActionEvent e)
   {
@@ -1486,6 +1520,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void printMenuItem_actionPerformed(ActionEvent e)
   {
@@ -1494,30 +1529,34 @@ public class AlignFrame extends GAlignFrame
     thread.start();
   }
 
+  
   @Override
   public void exportFeatures_actionPerformed(ActionEvent e)
   {
     new AnnotationExporter(alignPanel).exportFeatures();
   }
 
+  
   @Override
   public void exportAnnotations_actionPerformed(ActionEvent e)
   {
     new AnnotationExporter(alignPanel).exportAnnotations();
   }
 
+  
   @Override
   public void associatedData_actionPerformed(ActionEvent e)
   {
     final JalviewFileChooser chooser = new JalviewFileChooser(
             jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
     chooser.setFileView(new JalviewFileView());
-    chooser.setDialogTitle(
-            MessageManager.getString("label.load_jalview_annotations"));
-    chooser.setToolTipText(
-            MessageManager.getString("label.load_jalview_annotations"));
+    String tooltip = MessageManager
+            .getString("label.load_jalview_annotations");
+    chooser.setDialogTitle(tooltip);
+    chooser.setToolTipText(tooltip);
     chooser.setResponseHandler(0, new Runnable()
     {
+      
       @Override
       public void run()
       {
@@ -1536,6 +1575,7 @@ public class AlignFrame extends GAlignFrame
    * 
    * @param closeAllTabs
    */
+  
   @Override
   public void closeMenuItem_actionPerformed(boolean closeAllTabs)
   {
@@ -1569,6 +1609,13 @@ public class AlignFrame extends GAlignFrame
 
       if (closeAllTabs)
       {
+        // JalviewJS-develop only
+        //
+        // if (featureSettings != null && featureSettings.isOpen())
+        // {
+        // featureSettings.close();
+        // featureSettings = null;
+        // }
         /*
          * this will raise an INTERNAL_FRAME_CLOSED event and this method will
          * be called recursively, with the frame now in 'closed' state
@@ -1642,6 +1689,7 @@ public class AlignFrame extends GAlignFrame
     }
   }
 
+  
   @Override
   public void addHistoryItem(CommandI command)
   {
@@ -1687,6 +1735,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void undoMenuItem_actionPerformed(ActionEvent e)
   {
@@ -1725,6 +1774,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void redoMenuItem_actionPerformed(ActionEvent e)
   {
@@ -1931,6 +1981,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void copy_actionPerformed()
   {
@@ -1996,6 +2047,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void pasteNew_actionPerformed(ActionEvent e)
   {
@@ -2008,6 +2060,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void pasteThis_actionPerformed(ActionEvent e)
   {
@@ -2184,7 +2237,7 @@ public class AlignFrame extends GAlignFrame
                     newGraphGroups.add(q, null);
                   }
                   newGraphGroups.set(newann.graphGroup,
-                          new Integer(++fgroup));
+                          Integer.valueOf(++fgroup));
                 }
                 newann.graphGroup = newGraphGroups.get(newann.graphGroup)
                         .intValue();
@@ -2231,7 +2284,7 @@ public class AlignFrame extends GAlignFrame
                     newGraphGroups.add(q, null);
                   }
                   newGraphGroups.set(newann.graphGroup,
-                          new Integer(++fgroup));
+                          Integer.valueOf(++fgroup));
                 }
                 newann.graphGroup = newGraphGroups.get(newann.graphGroup)
                         .intValue();
@@ -2353,6 +2406,7 @@ public class AlignFrame extends GAlignFrame
 
   }
 
+  
   @Override
   protected void expand_newalign(ActionEvent e)
   {
@@ -2407,6 +2461,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Action Cut (delete and copy) the selected region
    */
+  
   @Override
   protected void cut_actionPerformed()
   {
@@ -2417,6 +2472,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Performs menu option to Delete the currently selected region
    */
+  
   @Override
   protected void delete_actionPerformed()
   {
@@ -2427,56 +2483,63 @@ public class AlignFrame extends GAlignFrame
       return;
     }
 
-    Runnable okAction = new Runnable() 
-    {
-               @Override
-               public void run() 
-               {
-                   SequenceI[] cut = sg.getSequences()
-                           .toArray(new SequenceI[sg.getSize()]);
-
-                   addHistoryItem(new EditCommand(
-                           MessageManager.getString("label.cut_sequences"), Action.CUT,
-                           cut, sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
-                           viewport.getAlignment()));
-
-                   viewport.setSelectionGroup(null);
-                   viewport.sendSelection();
-                   viewport.getAlignment().deleteGroup(sg);
-
-                   viewport.firePropertyChange("alignment", null,
-                           viewport.getAlignment().getSequences());
-                   if (viewport.getAlignment().getHeight() < 1)
-                   {
-                     try
-                     {
-                       AlignFrame.this.setClosed(true);
-                     } catch (Exception ex)
-                     {
-                     }
-                   }
-               }};
+    Runnable okAction = new Runnable()
+    {
+      
+      @Override
+      public void run()
+      {
+        SequenceI[] cut = sg.getSequences()
+                .toArray(new SequenceI[sg.getSize()]);
+
+        addHistoryItem(new EditCommand(
+                MessageManager.getString("label.cut_sequences"), Action.CUT,
+                cut, sg.getStartRes(),
+                sg.getEndRes() - sg.getStartRes() + 1,
+                viewport.getAlignment()));
+
+        viewport.setSelectionGroup(null);
+        viewport.sendSelection();
+        viewport.getAlignment().deleteGroup(sg);
+
+        viewport.firePropertyChange("alignment", null,
+                viewport.getAlignment().getSequences());
+        if (viewport.getAlignment().getHeight() < 1)
+        {
+          try
+          {
+            AlignFrame.this.setClosed(true);
+          } catch (Exception ex)
+          {
+          }
+        }
+      }
+    };
 
     /*
      * If the cut affects all sequences, prompt for confirmation
      */
-    boolean wholeHeight = sg.getSize() == viewport.getAlignment().getHeight();
+    boolean wholeHeight = sg.getSize() == viewport.getAlignment()
+            .getHeight();
     boolean wholeWidth = (((sg.getEndRes() - sg.getStartRes())
             + 1) == viewport.getAlignment().getWidth()) ? true : false;
-       if (wholeHeight && wholeWidth)
-       {
-           JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.getDesktopPane());
-               dialog.setResponseHandler(0, okAction); // 0 = OK_OPTION
-           Object[] options = new Object[] { MessageManager.getString("action.ok"),
-                   MessageManager.getString("action.cancel") };
-               dialog.showDialog(MessageManager.getString("warn.delete_all"),
-                   MessageManager.getString("label.delete_all"),
-                   JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
-                   options, options[0]);
-       } else 
-       {
-               okAction.run();
-       }
+    if (wholeHeight && wholeWidth)
+    {
+      JvOptionPane dialog = JvOptionPane
+              .newOptionDialog(Desktop.getDesktopPane());
+      dialog.setResponseHandler(0, okAction); // 0 = OK_OPTION
+      Object[] options = new Object[] {
+          MessageManager.getString("action.ok"),
+          MessageManager.getString("action.cancel") };
+      dialog.showDialog(MessageManager.getString("warn.delete_all"),
+              MessageManager.getString("label.delete_all"),
+              JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
+              options, options[0]);
+    }
+    else
+    {
+      okAction.run();
+    }
   }
 
   /**
@@ -2485,6 +2548,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void deleteGroups_actionPerformed(ActionEvent e)
   {
@@ -2502,21 +2566,23 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
   {
-    SequenceGroup sg = new SequenceGroup(
-            viewport.getAlignment().getSequences());
-
-    sg.setEndRes(viewport.getAlignment().getWidth() - 1);
-    viewport.setSelectionGroup(sg);
-    viewport.isSelectionGroupChanged(true);
-    viewport.sendSelection();
-    // JAL-2034 - should delegate to
-    // alignPanel to decide if overview needs
-    // updating.
-    alignPanel.paintAlignment(false, false);
-    PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+    // SequenceGroup sg = new SequenceGroup(
+    // viewport.getAlignment().getSequences());
+    //
+    // sg.setEndRes(viewport.getAlignment().getWidth() - 1);
+    // viewport.setSelectionGroup(sg);
+    // viewport.isSelectionGroupChanged(true);
+    // viewport.sendSelection();
+    // // JAL-2034 - should delegate to
+    // // alignPanel to decide if overview needs
+    // // updating.
+    // alignPanel.paintAlignment(false, false);
+    // PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+    alignPanel.selectAllSequences();
   }
 
   /**
@@ -2525,24 +2591,26 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
   {
-    if (viewport.cursorMode)
-    {
-      alignPanel.getSeqPanel().keyboardNo1 = null;
-      alignPanel.getSeqPanel().keyboardNo2 = null;
-    }
-    viewport.setSelectionGroup(null);
-    viewport.getColumnSelection().clear();
-    viewport.setSelectionGroup(null);
-    alignPanel.getIdPanel().getIdCanvas().searchResults = null;
-    // JAL-2034 - should delegate to
-    // alignPanel to decide if overview needs
-    // updating.
-    alignPanel.paintAlignment(false, false);
-    PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
-    viewport.sendSelection();
+    alignPanel.deselectAllSequences();
+    // if (viewport.cursorMode)
+    // {
+    // alignPanel.getSeqPanel().keyboardNo1 = null;
+    // alignPanel.getSeqPanel().keyboardNo2 = null;
+    // }
+    // viewport.setSelectionGroup(null);
+    // viewport.getColumnSelection().clear();
+    // viewport.setSelectionGroup(null);
+    // alignPanel.getIdPanel().getIdCanvas().searchResults = null;
+    // // JAL-2034 - should delegate to
+    // // alignPanel to decide if overview needs
+    // // updating.
+    // alignPanel.paintAlignment(false, false);
+    // PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+    // viewport.sendSelection();
   }
 
   /**
@@ -2551,6 +2619,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
   {
@@ -2558,7 +2627,7 @@ public class AlignFrame extends GAlignFrame
 
     if (sg == null)
     {
-      selectAllSequenceMenuItem_actionPerformed(null);
+      alignPanel.selectAllSequences();
 
       return;
     }
@@ -2576,6 +2645,7 @@ public class AlignFrame extends GAlignFrame
     viewport.sendSelection();
   }
 
+  
   @Override
   public void invertColSel_actionPerformed(ActionEvent e)
   {
@@ -2590,6 +2660,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
   {
@@ -2602,6 +2673,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void remove2RightMenuItem_actionPerformed(ActionEvent e)
   {
@@ -2648,8 +2720,8 @@ public class AlignFrame extends GAlignFrame
                 column, viewport.getAlignment());
       }
 
-      setStatus(MessageManager
-              .formatMessage("label.removed_columns", new String[]
+      setStatus(MessageManager.formatMessage("label.removed_columns",
+              new String[]
               { Integer.valueOf(trimRegion.getSize()).toString() }));
 
       addHistoryItem(trimRegion);
@@ -2674,6 +2746,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
   {
@@ -2698,8 +2771,8 @@ public class AlignFrame extends GAlignFrame
 
     addHistoryItem(removeGapCols);
 
-    setStatus(MessageManager
-            .formatMessage("label.removed_empty_columns", new Object[]
+    setStatus(MessageManager.formatMessage("label.removed_empty_columns",
+            new Object[]
             { Integer.valueOf(removeGapCols.getSize()).toString() }));
 
     // This is to maintain viewport position on first residue
@@ -2724,6 +2797,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
   {
@@ -2763,6 +2837,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void padGapsMenuitem_actionPerformed(ActionEvent e)
   {
@@ -2777,6 +2852,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void findMenuItem_actionPerformed(ActionEvent e)
   {
@@ -2786,6 +2862,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Create a new view of the current alignment.
    */
+  
   @Override
   public void newView_actionPerformed(ActionEvent e)
   {
@@ -2821,8 +2898,8 @@ public class AlignFrame extends GAlignFrame
 
     if (viewport.getViewName() == null)
     {
-      viewport.setViewName(MessageManager
-              .getString("label.view_name_original"));
+      viewport.setViewName(
+              MessageManager.getString("label.view_name_original"));
     }
 
     /*
@@ -2927,6 +3004,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Explode tabbed views into separate windows.
    */
+  
   @Override
   public void expandViews_actionPerformed(ActionEvent e)
   {
@@ -2936,6 +3014,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Gather views in separate windows back into a tabbed presentation.
    */
+  
   @Override
   public void gatherViews_actionPerformed(ActionEvent e)
   {
@@ -2948,6 +3027,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void font_actionPerformed(ActionEvent e)
   {
@@ -2960,6 +3040,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void seqLimit_actionPerformed(ActionEvent e)
   {
@@ -2970,6 +3051,7 @@ public class AlignFrame extends GAlignFrame
     alignPanel.paintAlignment(true, false);
   }
 
+  
   @Override
   public void idRightAlign_actionPerformed(ActionEvent e)
   {
@@ -2977,6 +3059,7 @@ public class AlignFrame extends GAlignFrame
     alignPanel.paintAlignment(false, false);
   }
 
+  
   @Override
   public void centreColumnLabels_actionPerformed(ActionEvent e)
   {
@@ -2989,6 +3072,7 @@ public class AlignFrame extends GAlignFrame
    * 
    * @see jalview.jbgui.GAlignFrame#followHighlight_actionPerformed()
    */
+  
   @Override
   protected void followHighlight_actionPerformed()
   {
@@ -3010,6 +3094,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void colourTextMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3023,6 +3108,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void wrapMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3033,12 +3119,14 @@ public class AlignFrame extends GAlignFrame
     alignPanel.updateLayout();
   }
 
+  
   @Override
   public void showAllSeqs_actionPerformed(ActionEvent e)
   {
     viewport.showAllHiddenSeqs();
   }
 
+  
   @Override
   public void showAllColumns_actionPerformed(ActionEvent e)
   {
@@ -3047,6 +3135,7 @@ public class AlignFrame extends GAlignFrame
     viewport.sendSelection();
   }
 
+  
   @Override
   public void hideSelSequences_actionPerformed(ActionEvent e)
   {
@@ -3126,6 +3215,7 @@ public class AlignFrame extends GAlignFrame
    * jalview.jbgui.GAlignFrame#hideAllButSelection_actionPerformed(java.awt.
    * event.ActionEvent)
    */
+  
   @Override
   public void hideAllButSelection_actionPerformed(ActionEvent e)
   {
@@ -3140,6 +3230,7 @@ public class AlignFrame extends GAlignFrame
    * jalview.jbgui.GAlignFrame#hideAllSelection_actionPerformed(java.awt.event
    * .ActionEvent)
    */
+  
   @Override
   public void hideAllSelection_actionPerformed(ActionEvent e)
   {
@@ -3159,6 +3250,7 @@ public class AlignFrame extends GAlignFrame
    * jalview.jbgui.GAlignFrame#showAllhidden_actionPerformed(java.awt.event.
    * ActionEvent)
    */
+  
   @Override
   public void showAllhidden_actionPerformed(ActionEvent e)
   {
@@ -3168,6 +3260,7 @@ public class AlignFrame extends GAlignFrame
     viewport.sendSelection();
   }
 
+  
   @Override
   public void hideSelColumns_actionPerformed(ActionEvent e)
   {
@@ -3177,6 +3270,7 @@ public class AlignFrame extends GAlignFrame
     viewport.sendSelection();
   }
 
+  
   @Override
   public void hiddenMarkers_actionPerformed(ActionEvent e)
   {
@@ -3190,6 +3284,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void scaleAbove_actionPerformed(ActionEvent e)
   {
@@ -3204,6 +3299,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void scaleLeft_actionPerformed(ActionEvent e)
   {
@@ -3218,6 +3314,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void scaleRight_actionPerformed(ActionEvent e)
   {
@@ -3232,6 +3329,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3245,6 +3343,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void viewTextMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3258,6 +3357,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3267,18 +3367,26 @@ public class AlignFrame extends GAlignFrame
 
   public FeatureSettings featureSettings;
 
+  
   @Override
   public FeatureSettingsControllerI getFeatureSettingsUI()
   {
     return featureSettings;
   }
 
+  
   @Override
   public void featureSettings_actionPerformed(ActionEvent e)
   {
+    showFeatureSettingsUI();
+  }
+
+  
+  public FeatureSettingsControllerI showFeatureSettingsUI()
+  {
     if (featureSettings != null)
     {
-      featureSettings.close();
+      // featureSettings.closeOldSettings();
       featureSettings = null;
     }
     if (!showSeqFeatures.isSelected())
@@ -3288,6 +3396,7 @@ public class AlignFrame extends GAlignFrame
       showSeqFeatures_actionPerformed(null);
     }
     featureSettings = new FeatureSettings(this);
+    return featureSettings;
   }
 
   /**
@@ -3296,6 +3405,7 @@ public class AlignFrame extends GAlignFrame
    * @param evt
    *          DOCUMENT ME!
    */
+  
   @Override
   public void showSeqFeatures_actionPerformed(ActionEvent evt)
   {
@@ -3312,25 +3422,25 @@ public class AlignFrame extends GAlignFrame
    * 
    * @param e
    */
+  
   @Override
   public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
   {
     final boolean setVisible = annotationPanelMenuItem.isSelected();
     viewport.setShowAnnotation(setVisible);
-    syncAnnotationMenuItems();
+    syncAnnotationMenuItems(setVisible);
     alignPanel.updateLayout();
   }
 
-  private void syncAnnotationMenuItems()
+  private void syncAnnotationMenuItems(boolean setVisible)
   {
-    final boolean setVisible = annotationPanelMenuItem.isSelected();
     showAllSeqAnnotations.setEnabled(setVisible);
     hideAllSeqAnnotations.setEnabled(setVisible);
     showAllAlAnnotations.setEnabled(setVisible);
     hideAllAlAnnotations.setEnabled(setVisible);
   }
 
-
+  
   @Override
   public void alignmentProperties()
   {
@@ -3348,7 +3458,7 @@ public class AlignFrame extends GAlignFrame
       JLabel textLabel = new JLabel();
       textLabel.setText(content);
       textLabel.setBackground(Color.WHITE);
-      
+
       pane = new JPanel(new BorderLayout());
       ((JPanel) pane).setOpaque(true);
       pane.setBackground(Color.WHITE);
@@ -3382,6 +3492,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void overviewMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3426,6 +3537,7 @@ public class AlignFrame extends GAlignFrame
     frame.addInternalFrameListener(
             new javax.swing.event.InternalFrameAdapter()
             {
+              
               @Override
               public void internalFrameClosed(
                       javax.swing.event.InternalFrameEvent evt)
@@ -3442,6 +3554,7 @@ public class AlignFrame extends GAlignFrame
     alignPanel.setOverviewPanel(overview);
   }
 
+  
   @Override
   public void textColour_actionPerformed()
   {
@@ -3454,12 +3567,14 @@ public class AlignFrame extends GAlignFrame
    * CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation
    * ()[0])); }
    */
+  
   @Override
   public void annotationColour_actionPerformed()
   {
     new AnnotationColourChooser(viewport, alignPanel);
   }
 
+  
   @Override
   public void annotationColumn_actionPerformed(ActionEvent e)
   {
@@ -3473,6 +3588,7 @@ public class AlignFrame extends GAlignFrame
    * 
    * @param selected
    */
+  
   @Override
   public void applyToAllGroups_actionPerformed(boolean selected)
   {
@@ -3485,6 +3601,7 @@ public class AlignFrame extends GAlignFrame
    * @param name
    *          the name (not the menu item label!) of the colour scheme
    */
+  
   @Override
   public void changeColour_actionPerformed(String name)
   {
@@ -3502,8 +3619,8 @@ public class AlignFrame extends GAlignFrame
      * otherwise set the chosen colour scheme (or null for 'None')
      */
     ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme(name,
-            viewport,
-            viewport.getAlignment(), viewport.getHiddenRepSequences());
+            viewport, viewport.getAlignment(),
+            viewport.getHiddenRepSequences());
     changeColour(cs);
   }
 
@@ -3512,6 +3629,7 @@ public class AlignFrame extends GAlignFrame
    * 
    * @param cs
    */
+  
   @Override
   public void changeColour(ColourSchemeI cs)
   {
@@ -3526,6 +3644,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Show the PID threshold slider panel
    */
+  
   @Override
   protected void modifyPID_actionPerformed()
   {
@@ -3537,6 +3656,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Show the Conservation slider panel
    */
+  
   @Override
   protected void modifyConservation_actionPerformed()
   {
@@ -3548,6 +3668,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Action on selecting or deselecting (Colour) By Conservation
    */
+  
   @Override
   public void conservationMenuItem_actionPerformed(boolean selected)
   {
@@ -3569,6 +3690,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Action on selecting or deselecting (Colour) Above PID Threshold
    */
+  
   @Override
   public void abovePIDThreshold_actionPerformed(boolean selected)
   {
@@ -3597,6 +3719,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3614,6 +3737,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void sortIDMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3630,6 +3754,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void sortLengthMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3646,6 +3771,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void sortGroupMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3663,6 +3789,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3675,6 +3802,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
   {
@@ -3697,10 +3825,12 @@ public class AlignFrame extends GAlignFrame
     }
   }
 
+  
   @Override
   public void autoCalculate_actionPerformed(ActionEvent e)
   {
-    viewport.setAutoCalculateConsensusAndConservation(autoCalculate.isSelected());
+    viewport.setAutoCalculateConsensusAndConservation(
+            autoCalculate.isSelected());
     if (viewport.getAutoCalculateConsensusAndConservation())
     {
       viewport.firePropertyChange("alignment", null,
@@ -3708,12 +3838,14 @@ public class AlignFrame extends GAlignFrame
     }
   }
 
+  
   @Override
   public void sortByTreeOption_actionPerformed(ActionEvent e)
   {
     viewport.sortByTree = sortByTree.isSelected();
   }
 
+  
   @Override
   protected void listenToViewSelections_actionPerformed(ActionEvent e)
   {
@@ -3800,6 +3932,7 @@ public class AlignFrame extends GAlignFrame
     sort.add(item);
     item.addActionListener(new java.awt.event.ActionListener()
     {
+      
       @Override
       public void actionPerformed(ActionEvent e)
       {
@@ -3833,6 +3966,7 @@ public class AlignFrame extends GAlignFrame
     sort.add(item);
     item.addActionListener(new java.awt.event.ActionListener()
     {
+      
       @Override
       public void actionPerformed(ActionEvent e)
       {
@@ -3858,6 +3992,7 @@ public class AlignFrame extends GAlignFrame
    * rebuilding in subsequence calls.
    * 
    */
+  
   @Override
   public void buildSortByAnnotationScoresMenu()
   {
@@ -3887,8 +4022,7 @@ public class AlignFrame extends GAlignFrame
       Enumeration<String> labels = scoreSorts.keys();
       while (labels.hasMoreElements())
       {
-        addSortByAnnotScoreMenuItem(sortByAnnotScore,
-                labels.nextElement());
+        addSortByAnnotScoreMenuItem(sortByAnnotScore, labels.nextElement());
       }
       sortByAnnotScore.setVisible(scoreSorts.size() > 0);
       scoreSorts.clear();
@@ -3905,6 +4039,7 @@ public class AlignFrame extends GAlignFrame
    * closed, and adjust the tree leaf to sequence mapping when the alignment is
    * modified.
    */
+  
   @Override
   public void buildTreeSortMenu()
   {
@@ -3934,6 +4069,7 @@ public class AlignFrame extends GAlignFrame
       final JMenuItem item = new JMenuItem(tp.getTitle());
       item.addActionListener(new java.awt.event.ActionListener()
       {
+        
         @Override
         public void actionPerformed(ActionEvent e)
         {
@@ -4043,6 +4179,7 @@ public class AlignFrame extends GAlignFrame
    * @param e
    *          DOCUMENT ME!
    */
+  
   @Override
   protected void loadTreeMenuItem_actionPerformed(ActionEvent e)
   {
@@ -4055,8 +4192,9 @@ public class AlignFrame extends GAlignFrame
     chooser.setToolTipText(
             MessageManager.getString("label.load_tree_file"));
 
-    chooser.setResponseHandler(0,new Runnable()
+    chooser.setResponseHandler(0, new Runnable()
     {
+      
       @Override
       public void run()
       {
@@ -4070,7 +4208,8 @@ public class AlignFrame extends GAlignFrame
           viewport.setCurrentTree(showNewickTree(fin, filePath).getTree());
         } catch (Exception ex)
         {
-          JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), ex.getMessage(),
+          JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
+                  ex.getMessage(),
                   MessageManager
                           .getString("label.problem_reading_tree_file"),
                   JvOptionPane.WARNING_MESSAGE);
@@ -4181,6 +4320,7 @@ public class AlignFrame extends GAlignFrame
     buildingMenu = true;
     new Thread(new Runnable()
     {
+      
       @Override
       public void run()
       {
@@ -4215,11 +4355,11 @@ public class AlignFrame extends GAlignFrame
           final JMenu dismenu = new JMenu("Protein Disorder");
           // JAL-940 - only show secondary structure prediction services from
           // the legacy server
-          Hashtable<String, Vector<ServiceHandle>> services = Discoverer
+          Hashtable<String, Vector<ServiceHandle>> ds = Discoverer
                   .getInstance().getServices();
           if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
           // &&
-          services != null && (services.size() > 0))
+          ds != null && (ds.size() > 0))
           {
             // TODO: refactor to allow list of AbstractName/Handler bindings to
             // be
@@ -4227,14 +4367,13 @@ public class AlignFrame extends GAlignFrame
             // No MSAWS used any more:
             // Vector msaws = null; // (Vector)
             // Discoverer.services.get("MsaWS");
-            Vector<ServiceHandle> secstrpr = services.get("SecStrPred");
+            Vector<ServiceHandle> secstrpr = ds.get("SecStrPred");
             if (secstrpr != null)
             {
               // Add any secondary structure prediction services
               for (int i = 0, j = secstrpr.size(); i < j; i++)
               {
-                final ext.vamsas.ServiceHandle sh = secstrpr
-                        .get(i);
+                final ext.vamsas.ServiceHandle sh = secstrpr.get(i);
                 jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
                         .getServiceClient(sh);
                 int p = secstrmenu.getItemCount();
@@ -4259,6 +4398,7 @@ public class AlignFrame extends GAlignFrame
 
           javax.swing.SwingUtilities.invokeLater(new Runnable()
           {
+            
             @Override
             public void run()
             {
@@ -4351,7 +4491,7 @@ public class AlignFrame extends GAlignFrame
      * JMenuItem testAlView = new JMenuItem("Test AlignmentView"); final
      * AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
      * 
-     * @Override public void actionPerformed(ActionEvent e) {
+     *  public void actionPerformed(ActionEvent e) {
      * jalview.datamodel.AlignmentView
      * .testSelectionViews(af.viewport.getAlignment(),
      * af.viewport.getColumnSelection(), af.viewport.selectionGroup); }
@@ -4407,6 +4547,7 @@ public class AlignFrame extends GAlignFrame
         JMenuItem xtype = new JMenuItem(source);
         xtype.addActionListener(new ActionListener()
         {
+          
           @Override
           public void actionPerformed(ActionEvent e)
           {
@@ -4450,6 +4591,7 @@ public class AlignFrame extends GAlignFrame
    * Construct and display a new frame containing the translation of this
    * frame's DNA sequences to their aligned protein (amino acid) equivalents.
    */
+  
   @Override
   public void showTranslation_actionPerformed(GeneticCodeI codeTable)
   {
@@ -4468,8 +4610,8 @@ public class AlignFrame extends GAlignFrame
       final String errorTitle = MessageManager
               .getString("label.implementation_error")
               + MessageManager.getString("label.translation_failed");
-      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), msg, errorTitle,
-              JvOptionPane.ERROR_MESSAGE);
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), msg,
+              errorTitle, JvOptionPane.ERROR_MESSAGE);
       return;
     }
     if (al == null || al.getHeight() == 0)
@@ -4478,8 +4620,8 @@ public class AlignFrame extends GAlignFrame
               "label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation");
       final String errorTitle = MessageManager
               .getString("label.translation_failed");
-      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), msg, errorTitle,
-              JvOptionPane.WARNING_MESSAGE);
+      JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), msg,
+              errorTitle, JvOptionPane.WARNING_MESSAGE);
     }
     else
     {
@@ -4529,6 +4671,7 @@ public class AlignFrame extends GAlignFrame
 
   }
 
+  
   @Override
   public void refreshFeatureUI(boolean enableIfNecessary)
   {
@@ -4543,26 +4686,31 @@ public class AlignFrame extends GAlignFrame
 
   }
 
+  
   @Override
   public void dragEnter(DropTargetDragEvent evt)
   {
   }
 
+  
   @Override
   public void dragExit(DropTargetEvent evt)
   {
   }
 
+  
   @Override
   public void dragOver(DropTargetDragEvent evt)
   {
   }
 
+  
   @Override
   public void dropActionChanged(DropTargetDragEvent evt)
   {
   }
 
+  
   @Override
   public void drop(DropTargetDropEvent evt)
   {
@@ -4571,24 +4719,34 @@ public class AlignFrame extends GAlignFrame
     evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
     Transferable t = evt.getTransferable();
 
-    final AlignFrame thisaf = this;
     final List<Object> files = new ArrayList<>();
     List<DataSourceType> protocols = new ArrayList<>();
 
     try
     {
       Desktop.transferFromDropTarget(files, protocols, evt, t);
-    } catch (Exception e)
-    {
-      e.printStackTrace();
-    }
-    if (files != null)
+      if (files.size() > 0)
     {
       new Thread(new Runnable()
       {
+        
         @Override
         public void run()
         {
+            loadDroppedFiles(files, protocols, evt, t);
+          }
+        }).start();
+      }
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+    }
+  }
+
+  protected void loadDroppedFiles(List<Object> files,
+          List<DataSourceType> protocols, DropTargetDropEvent evt,
+          Transferable t)
+  {
           try
           {
             // check to see if any of these files have names matching sequences
@@ -4613,10 +4771,13 @@ public class AlignFrame extends GAlignFrame
               if (protocol == DataSourceType.FILE)
               {
                 File fl;
-                if (file instanceof File) {
+                if (file instanceof File)
+                {
                   fl = (File) file;
                   Platform.cacheFileData(fl);
-                } else {
+                }
+                else
+                {
                   fl = new File(fileName);
                 }
                 pdbfn = fl.getName();
@@ -4667,8 +4828,8 @@ public class AlignFrame extends GAlignFrame
             int assocfiles = 0;
             if (filesmatched.size() > 0)
             {
-              boolean autoAssociate = Cache
-                      .getDefault(Preferences.AUTOASSOCIATE_PDBANDSEQS, false);
+              boolean autoAssociate = Cache.getDefault(
+                      Preferences.AUTOASSOCIATE_PDBANDSEQS, false);
               if (!autoAssociate)
               {
                 String msg = MessageManager.formatMessage(
@@ -4678,8 +4839,8 @@ public class AlignFrame extends GAlignFrame
                                 .toString() });
                 String ttl = MessageManager.getString(
                         "label.automatically_associate_structure_files_by_name");
-                int choice = JvOptionPane.showConfirmDialog(thisaf, msg,
-                        ttl, JvOptionPane.YES_NO_OPTION);
+          int choice = JvOptionPane.showConfirmDialog(this, msg, ttl,
+                  JvOptionPane.YES_NO_OPTION);
                 autoAssociate = choice == JvOptionPane.YES_OPTION;
               }
               if (autoAssociate)
@@ -4720,9 +4881,9 @@ public class AlignFrame extends GAlignFrame
             }
             if (filesnotmatched.size() > 0)
             {
-              if (assocfiles > 0 && (Cache.getDefault(
-                      "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false)
-                      || JvOptionPane.showConfirmDialog(thisaf,
+        if (assocfiles > 0 && (Cache
+                .getDefault("AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false)
+                || JvOptionPane.showConfirmDialog(this,
                               "<html>" + MessageManager.formatMessage(
                                       "label.ignore_unmatched_dropped_files_info",
                                       new Object[]
@@ -4747,9 +4908,6 @@ public class AlignFrame extends GAlignFrame
             ex.printStackTrace();
           }
         }
-      }).start();
-    }
-  }
 
   /**
    * Attempt to load a "dropped" file or URL string, by testing in turn for
@@ -4858,9 +5016,17 @@ public class AlignFrame extends GAlignFrame
           {
             if (parseFeaturesFile(file, sourceType))
             {
+              SplitFrame splitFrame = (SplitFrame) getSplitViewContainer();
+              if (splitFrame != null)
+              {
+                splitFrame.repaint();
+              }
+              else
+              {
               alignPanel.paintAlignment(true, true);
             }
           }
+          }
           else
           {
             new FileLoader().loadFile(viewport, file, sourceType, format);
@@ -4910,9 +5076,37 @@ public class AlignFrame extends GAlignFrame
   }
 
   /**
+   * Change the display state for the given feature groups -- Added by BH from
+   * JalviewLite
+   * 
+   * @param groups
+   *          list of group strings
+   * @param state
+   *          visible or invisible
+   */
+  
+  public void setFeatureGroupState(String[] groups, boolean state)
+  {
+    jalview.api.FeatureRenderer fr = null;
+    viewport.setShowSequenceFeatures(true);
+    if (alignPanel != null
+            && (fr = alignPanel.getFeatureRenderer()) != null)
+    {
+
+      fr.setGroupVisibility(Arrays.asList(groups), state);
+      alignPanel.getSeqPanel().seqCanvas.repaint();
+      if (alignPanel.overviewPanel != null)
+      {
+        alignPanel.overviewPanel.updateOverviewImage();
+      }
+    }
+  }
+
+  /**
    * Method invoked by the ChangeListener on the tabbed pane, in other words
    * when a different tabbed pane is selected by the user or programmatically.
    */
+  
   @Override
   public void tabSelectionChanged(int index)
   {
@@ -4922,6 +5116,21 @@ public class AlignFrame extends GAlignFrame
       viewport = alignPanel.av;
       avc.setViewportAndAlignmentPanel(viewport, alignPanel);
       setMenusFromViewport(viewport);
+      if (featureSettings != null// && featureSettings.isOpen()
+              && featureSettings.fr.getViewport() != viewport)
+      {
+        if (viewport.isShowSequenceFeatures())
+        {
+          // refresh the featureSettings to reflect UI change
+          showFeatureSettingsUI();
+        }
+        else
+        {
+          // close feature settings for this view.
+          featureSettings.close();
+        }
+      }
+
     }
 
     /*
@@ -4968,6 +5177,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * On right mouse click on view tab, prompt for and set new view name.
    */
+  
   @Override
   public void tabbedPane_mousePressed(MouseEvent e)
   {
@@ -4992,34 +5202,9 @@ public class AlignFrame extends GAlignFrame
   }
 
   /**
-   * Change the display state for the given feature groups -- Added by BH from
-   * JalviewLite
-   * 
-   * @param groups
-   *          list of group strings
-   * @param state
-   *          visible or invisible
-   */
-  public void setFeatureGroupState(String[] groups, boolean state)
-  {
-    jalview.api.FeatureRenderer fr = null;
-    viewport.setShowSequenceFeatures(true);
-    if (alignPanel != null
-            && (fr = alignPanel.getFeatureRenderer()) != null)
-    {
-
-      fr.setGroupVisibility(Arrays.asList(groups), state);
-      alignPanel.getSeqPanel().seqCanvas.repaint();
-      if (alignPanel.overviewPanel != null)
-      {
-        alignPanel.overviewPanel.updateOverviewImage();
-      }
-    }
-  }
-
-  /**
    * Open the dialog for regex description parsing.
    */
+  
   @Override
   protected void extractScores_actionPerformed(ActionEvent e)
   {
@@ -5043,6 +5228,7 @@ public class AlignFrame extends GAlignFrame
    * jalview.jbgui.GAlignFrame#showDbRefs_actionPerformed(java.awt.event.ActionEvent
    * )
    */
+  
   @Override
   protected void showDbRefs_actionPerformed(ActionEvent e)
   {
@@ -5055,6 +5241,7 @@ public class AlignFrame extends GAlignFrame
    * @seejalview.jbgui.GAlignFrame#showNpFeats_actionPerformed(java.awt.event.
    * ActionEvent)
    */
+  
   @Override
   protected void showNpFeats_actionPerformed(ActionEvent e)
   {
@@ -5110,6 +5297,7 @@ public class AlignFrame extends GAlignFrame
             Cache.getDefault(DBRefFetcher.TRIM_RETRIEVED_SEQUENCES, true));
     trimrs.addActionListener(new ActionListener()
     {
+      
       @Override
       public void actionPerformed(ActionEvent e)
       {
@@ -5126,11 +5314,13 @@ public class AlignFrame extends GAlignFrame
     fetchr.addActionListener(new ActionListener()
     {
 
+      
       @Override
       public void actionPerformed(ActionEvent e)
       {
         new Thread(new Runnable()
         {
+          
           @Override
           public void run()
           {
@@ -5142,9 +5332,17 @@ public class AlignFrame extends GAlignFrame
                     alignPanel.alignFrame.featureSettings, isNucleotide);
             dbRefFetcher.addListener(new FetchFinishedListenerI()
             {
+              
               @Override
               public void finished()
               {
+                //
+                // for (FeatureSettingsModelI srcSettings : dbRefFetcher
+                // .getFeatureSettingsModels())
+                // {
+                //
+                // alignPanel.av.mergeFeaturesStyle(srcSettings);
+                // }
                 AlignFrame.this.setMenusForViewport();
               }
             });
@@ -5158,16 +5356,19 @@ public class AlignFrame extends GAlignFrame
     rfetch.add(fetchr);
     new Thread(new Runnable()
     {
+      
       @Override
       public void run()
       {
         javax.swing.SwingUtilities.invokeLater(new Runnable()
         {
+          
           @Override
           public void run()
           {
-            String[] dbclasses = jalview.ws.SequenceFetcher.getInstance()
-                    .getNonAlignmentSources();
+                 jalview.ws.SequenceFetcher
+                 sf = jalview.ws.SequenceFetcher.getInstance();
+            String[] dbclasses = sf.getNonAlignmentSources();
             List<DbSourceProxy> otherdb;
             JMenu dfetch = new JMenu();
             JMenu ifetch = new JMenu();
@@ -5177,8 +5378,7 @@ public class AlignFrame extends GAlignFrame
             int dbi = 0;
             for (String dbclass : dbclasses)
             {
-              otherdb = jalview.ws.SequenceFetcher.getInstance()
-                      .getSourceProxy(dbclass);
+              otherdb = sf.getSourceProxy(dbclass);
               // add a single entry for this class, or submenu allowing 'fetch
               // all' or pick one
               if (otherdb == null || otherdb.size() < 1)
@@ -5192,18 +5392,19 @@ public class AlignFrame extends GAlignFrame
               if (otherdb.size() == 1)
               {
                 DbSourceProxy src = otherdb.get(0);
-                DbSourceProxy[] dassource = new DbSourceProxy[] {
-                    src };
+                DbSourceProxy[] dassource = new DbSourceProxy[] { src };
                 fetchr = new JMenuItem(src.getDbSource());
                 fetchr.addActionListener(new ActionListener()
                 {
 
+                  
                   @Override
                   public void actionPerformed(ActionEvent e)
                   {
                     new Thread(new Runnable()
                     {
 
+                      
                       @Override
                       public void run()
                       {
@@ -5218,9 +5419,14 @@ public class AlignFrame extends GAlignFrame
                         dbRefFetcher
                                 .addListener(new FetchFinishedListenerI()
                                 {
+                                  
                                   @Override
                                   public void finished()
                                   {
+                                    FeatureSettingsModelI srcSettings = dassource[0]
+                                            .getFeatureColourScheme();
+                                    // alignPanel.av.mergeFeaturesStyle(
+                                    // srcSettings);
                                     AlignFrame.this.setMenusForViewport();
                                   }
                                 });
@@ -5248,12 +5454,14 @@ public class AlignFrame extends GAlignFrame
                         { src.getDbSource() }));
                 fetchr.addActionListener(new ActionListener()
                 {
+                  
                   @Override
                   public void actionPerformed(ActionEvent e)
                   {
                     new Thread(new Runnable()
                     {
 
+                      
                       @Override
                       public void run()
                       {
@@ -5268,6 +5476,7 @@ public class AlignFrame extends GAlignFrame
                         dbRefFetcher
                                 .addListener(new FetchFinishedListenerI()
                                 {
+                                  
                                   @Override
                                   public void finished()
                                   {
@@ -5316,12 +5525,14 @@ public class AlignFrame extends GAlignFrame
                   fetchr.addActionListener(new ActionListener()
                   {
 
+                    
                     @Override
                     public void actionPerformed(ActionEvent e)
                     {
                       new Thread(new Runnable()
                       {
 
+                        
                         @Override
                         public void run()
                         {
@@ -5336,6 +5547,7 @@ public class AlignFrame extends GAlignFrame
                           dbRefFetcher
                                   .addListener(new FetchFinishedListenerI()
                                   {
+                                    
                                     @Override
                                     public void finished()
                                     {
@@ -5387,6 +5599,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Left justify the whole alignment.
    */
+  
   @Override
   protected void justifyLeftMenuItem_actionPerformed(ActionEvent e)
   {
@@ -5398,6 +5611,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Right justify the whole alignment.
    */
+  
   @Override
   protected void justifyRightMenuItem_actionPerformed(ActionEvent e)
   {
@@ -5406,6 +5620,7 @@ public class AlignFrame extends GAlignFrame
     viewport.firePropertyChange("alignment", null, al);
   }
 
+  
   @Override
   public void setShowSeqFeatures(boolean b)
   {
@@ -5420,6 +5635,7 @@ public class AlignFrame extends GAlignFrame
    * jalview.jbgui.GAlignFrame#showUnconservedMenuItem_actionPerformed(java.
    * awt.event.ActionEvent)
    */
+  
   @Override
   protected void showUnconservedMenuItem_actionPerformed(ActionEvent e)
   {
@@ -5434,6 +5650,7 @@ public class AlignFrame extends GAlignFrame
    * jalview.jbgui.GAlignFrame#showGroupConsensus_actionPerformed(java.awt.event
    * .ActionEvent)
    */
+  
   @Override
   protected void showGroupConsensus_actionPerformed(ActionEvent e)
   {
@@ -5449,6 +5666,7 @@ public class AlignFrame extends GAlignFrame
    * jalview.jbgui.GAlignFrame#showGroupConservation_actionPerformed(java.awt
    * .event.ActionEvent)
    */
+  
   @Override
   protected void showGroupConservation_actionPerformed(ActionEvent e)
   {
@@ -5463,6 +5681,7 @@ public class AlignFrame extends GAlignFrame
    * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
    * .event.ActionEvent)
    */
+  
   @Override
   protected void showConsensusHistogram_actionPerformed(ActionEvent e)
   {
@@ -5477,6 +5696,7 @@ public class AlignFrame extends GAlignFrame
    * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
    * .event.ActionEvent)
    */
+  
   @Override
   protected void showSequenceLogo_actionPerformed(ActionEvent e)
   {
@@ -5484,6 +5704,7 @@ public class AlignFrame extends GAlignFrame
     alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
   }
 
+  
   @Override
   protected void normaliseSequenceLogo_actionPerformed(ActionEvent e)
   {
@@ -5493,6 +5714,7 @@ public class AlignFrame extends GAlignFrame
     alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
   }
 
+  
   @Override
   protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e)
   {
@@ -5506,6 +5728,7 @@ public class AlignFrame extends GAlignFrame
    * jalview.jbgui.GAlignFrame#makeGrpsFromSelection_actionPerformed(java.awt
    * .event.ActionEvent)
    */
+  
   @Override
   protected void makeGrpsFromSelection_actionPerformed(ActionEvent e)
   {
@@ -5530,6 +5753,7 @@ public class AlignFrame extends GAlignFrame
     }
   }
 
+  
   @Override
   protected void createGroup_actionPerformed(ActionEvent e)
   {
@@ -5543,6 +5767,7 @@ public class AlignFrame extends GAlignFrame
     }
   }
 
+  
   @Override
   protected void unGroup_actionPerformed(ActionEvent e)
   {
@@ -5581,6 +5806,7 @@ public class AlignFrame extends GAlignFrame
    * @param forAlignment
    *          update non-sequence-related annotations
    */
+  
   @Override
   protected void setAnnotationsVisibility(boolean visible,
           boolean forSequences, boolean forAlignment)
@@ -5614,6 +5840,7 @@ public class AlignFrame extends GAlignFrame
   /**
    * Store selected annotation sort order for the view and repaint.
    */
+  
   @Override
   protected void sortAnnotations_actionPerformed()
   {
@@ -5688,6 +5915,7 @@ public class AlignFrame extends GAlignFrame
    * 
    * @param show
    */
+  
   @Override
   protected void showComplement_actionPerformed(boolean show)
   {
@@ -5702,6 +5930,7 @@ public class AlignFrame extends GAlignFrame
    * Generate the reverse (optionally complemented) of the selected sequences,
    * and add them to the alignment
    */
+  
   @Override
   protected void showReverse_actionPerformed(boolean complement)
   {
@@ -5727,6 +5956,7 @@ public class AlignFrame extends GAlignFrame
    * AlignFrame is set as currentAlignFrame in Desktop, to allow the script to
    * be targeted at this alignment.
    */
+  
   @Override
   protected void runGroovy_actionPerformed()
   {
@@ -5777,6 +6007,7 @@ public class AlignFrame extends GAlignFrame
     return false;
   }
 
+  
   @Override
   protected void selectHighlightedColumns_actionPerformed(
           ActionEvent actionEvent)
@@ -5827,6 +6058,7 @@ public class AlignFrame extends GAlignFrame
     }
   }
 
+  
   @Override
   protected void loadVcf_actionPerformed()
   {
@@ -5838,6 +6070,7 @@ public class AlignFrame extends GAlignFrame
     final AlignFrame us = this;
     chooser.setResponseHandler(0, new Runnable()
     {
+      
       @Override
       public void run()
       {
@@ -5851,6 +6084,38 @@ public class AlignFrame extends GAlignFrame
 
   }
 
+  private Rectangle lastFeatureSettingsBounds = null;
+
+  
+  public void setFeatureSettingsGeometry(Rectangle bounds)
+  {
+    lastFeatureSettingsBounds = bounds;
+  }
+
+  
+  public Rectangle getFeatureSettingsGeometry()
+  {
+    return lastFeatureSettingsBounds;
+  }
+
+  
+  public void scrollTo(int row, int column)
+  {
+    alignPanel.getSeqPanel().scrollTo(row, column);
+  }
+
+  
+  public void scrollToRow(int row)
+  {
+    alignPanel.getSeqPanel().scrollToRow(row);
+  }
+
+  
+  public void scrollToColumn(int column)
+  {
+    alignPanel.getSeqPanel().scrollToColumn(column);
+  }
+
   /**
    * BH 2019 from JalviewLite
    * 
@@ -5864,8 +6129,7 @@ public class AlignFrame extends GAlignFrame
   {
     jalview.api.FeatureRenderer fr = null;
     if (alignPanel != null
-            && (fr = alignPanel
-                    .getFeatureRenderer()) != null)
+            && (fr = alignPanel.getFeatureRenderer()) != null)
     {
       List<String> gps = fr.getGroups(visible);
       String[] _gps = gps.toArray(new String[gps.size()]);
@@ -5874,21 +6138,6 @@ public class AlignFrame extends GAlignFrame
     return null;
   }
 
-  public void scrollTo(int row, int column)
-  {
-    alignPanel.getSeqPanel().scrollTo(row, column);
-  }
-
-  public void scrollToRow(int row)
-  {
-    alignPanel.getSeqPanel().scrollToRow(row);
-  }
-
-  public void scrollToColumn(int column)
-  {
-    alignPanel.getSeqPanel().scrollToColumn(column);
-  }
-
   /**
    * 
    * @return list of feature groups on the view