JAL-1459 ensure we notify the drop handler that we've dealt with the
[jalview.git] / src / jalview / gui / AlignFrame.java
old mode 100755 (executable)
new mode 100644 (file)
index d984f3c..62fd29d
@@ -1,18 +1,18 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
- *
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ * 
  * This file is part of Jalview.
- *
+ * 
  * Jalview is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
+ * modify it under the terms of the GNU General Public License 
  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * Jalview is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
- *
+ * 
  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  */
 package jalview.gui;
@@ -24,6 +24,7 @@ import jalview.analysis.CrossRef;
 import jalview.analysis.NJTree;
 import jalview.analysis.ParseProperties;
 import jalview.analysis.SequenceIdMatcher;
+import jalview.api.AlignViewControllerI;
 import jalview.bin.Cache;
 import jalview.commands.CommandI;
 import jalview.commands.EditCommand;
@@ -75,8 +76,10 @@ import jalview.schemes.TaylorColourScheme;
 import jalview.schemes.TurnColourScheme;
 import jalview.schemes.UserColourScheme;
 import jalview.schemes.ZappoColourScheme;
+import jalview.util.MessageManager;
 import jalview.ws.jws1.Discoverer;
 import jalview.ws.jws2.Jws2Discoverer;
+import jalview.ws.jws2.jabaws2.Jws2Instance;
 import jalview.ws.seqfetcher.DbSourceProxy;
 
 import java.awt.BorderLayout;
@@ -144,6 +147,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   public AlignmentPanel alignPanel;
 
   AlignViewport viewport;
+  public AlignViewControllerI avc;
 
   Vector alignPanels = new Vector();
 
@@ -287,6 +293,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    */
   void init()
   {
+    avc = new jalview.controller.AlignViewController(viewport, alignPanel);
     if (viewport.getAlignmentConservationAnnotation() == null)
     {
       BLOSUM62Colour.setEnabled(false);
@@ -329,7 +336,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
 
     addKeyListener();
-
+    
   }
 
   /**
@@ -475,8 +482,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
         case KeyEvent.VK_F2:
           viewport.cursorMode = !viewport.cursorMode;
-          statusBar.setText("Keyboard editing mode is "
-                  + (viewport.cursorMode ? "on" : "off"));
+          statusBar.setText(MessageManager.formatMessage("label.keyboard_editing_mode", new String[]{(viewport.cursorMode ? "on" : "off")}));
           if (viewport.cursorMode)
           {
             alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes;
@@ -557,6 +563,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   public void addAlignmentPanel(final AlignmentPanel ap, boolean newPanel)
   {
     ap.alignFrame = this;
+    avc = new jalview.controller.AlignViewController(viewport, alignPanel);
 
     alignPanels.addElement(ap);
 
@@ -734,7 +741,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     rnahelicesColour
             .setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
     setShowProductsEnabled();
-
     updateEditMenuBar();
   }
 
@@ -808,7 +814,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     final JPanel progressPanel = (JPanel) progressBars.get(new Long(id));
     if (handler.canCancel())
     {
-      JButton cancel = new JButton("Cancel");
+      JButton cancel = new JButton(MessageManager.getString("action.cancel"));
       final IProgressIndicator us = this;
       cancel.addActionListener(new ActionListener()
       {
@@ -988,8 +994,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       if (currentFileFormat == null)
       {
         JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                "You must select a file format before saving!",
-                "File format not specified", JOptionPane.WARNING_MESSAGE);
+                MessageManager.getString("label.select_file_format_before_saving"),
+                MessageManager.getString("label.file_format_not_specified"), JOptionPane.WARNING_MESSAGE);
         value = chooser.showSaveDialog(this);
         return;
       }
@@ -1025,8 +1031,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
       success = new Jalview2XML().SaveAlignment(this, file, shortName);
 
-      statusBar.setText("Successfully saved to file: " + fileName + " in "
-              + format + " format.");
+      statusBar.setText(MessageManager.formatMessage("label.successfully_saved_to_file_in_format",new String[]{fileName, format}));
+
 
     }
     else
@@ -1047,9 +1053,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         int reply = JOptionPane
                 .showInternalConfirmDialog(
                         Desktop.desktop,
-                        "The Alignment contains hidden columns."
-                                + "\nDo you want to save only the visible alignment?",
-                        "Save / Omit Hidden Columns",
+                        MessageManager.getString("label.alignment_contains_hidden_columns"),
+                        MessageManager.getString("action.save_omit_hidden_columns"),
                         JOptionPane.YES_NO_OPTION,
                         JOptionPane.QUESTION_MESSAGE);
 
@@ -1079,8 +1084,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           out.print(output);
           out.close();
           this.setTitle(file);
-          statusBar.setText("Successfully saved to file: " + fileName
-                  + " in " + format + " format.");
+          statusBar.setText(MessageManager.formatMessage("label.successfully_saved_to_file_in_format",new String[]{fileName, format}));
         } catch (Exception ex)
         {
           success = false;
@@ -1091,8 +1095,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     if (!success)
     {
-      JOptionPane.showInternalMessageDialog(this, "Couldn't save file: "
-              + fileName, "Error Saving File", JOptionPane.WARNING_MESSAGE);
+      JOptionPane.showInternalMessageDialog(this, MessageManager.formatMessage("label.couldnt_save_file", new String[]{fileName}),
+              MessageManager.getString("label.error_saving_file"), JOptionPane.WARNING_MESSAGE);
     }
 
     return success;
@@ -1129,9 +1133,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       int reply = JOptionPane
               .showInternalConfirmDialog(
                       Desktop.desktop,
-                      "The Alignment contains hidden columns."
-                              + "\nDo you want to output only the visible alignment?",
-                      "Save / Omit Hidden Columns",
+                      MessageManager.getString("label.alignment_contains_hidden_columns"),
+                      MessageManager.getString("action.save_omit_hidden_columns"),
                       JOptionPane.YES_NO_OPTION,
                       JOptionPane.QUESTION_MESSAGE);
 
@@ -1347,12 +1350,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     {
       undoMenuItem.setEnabled(true);
       CommandI command = (CommandI) viewport.historyList.peek();
-      undoMenuItem.setText("Undo " + command.getDescription());
+      undoMenuItem.setText(MessageManager.formatMessage("label.undo_command", new String[]{command.getDescription()}));
     }
     else
     {
       undoMenuItem.setEnabled(false);
-      undoMenuItem.setText("Undo");
+      undoMenuItem.setText(MessageManager.getString("action.undo"));
     }
 
     if (viewport.redoList.size() > 0)
@@ -1360,12 +1363,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       redoMenuItem.setEnabled(true);
 
       CommandI command = (CommandI) viewport.redoList.peek();
-      redoMenuItem.setText("Redo " + command.getDescription());
+      redoMenuItem.setText(MessageManager.formatMessage("label.redo_command", new String[]{command.getDescription()}));
     }
     else
     {
       redoMenuItem.setEnabled(false);
-      redoMenuItem.setText("Redo");
+      redoMenuItem.setText(MessageManager.getString("action.redo"));
     }
   }
 
@@ -1693,7 +1696,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     Desktop.jalviewClipboard = new Object[]
     { seqs, viewport.getAlignment().getDataset(), hiddenColumns };
-    statusBar.setText("Copied " + seqs.length + " sequences to clipboard.");
+    statusBar.setText(MessageManager.formatMessage("label.copied_sequences_to_clipboard", new String[]{Integer.valueOf(seqs.length).toString()}));
   }
 
   /**
@@ -2135,12 +2138,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   protected void deleteGroups_actionPerformed(ActionEvent e)
   {
-    viewport.getAlignment().deleteAllGroups();
-    viewport.sequenceColours = null;
-    viewport.setSelectionGroup(null);
-    PaintRefresher.Refresh(this, viewport.getSequenceSetId());
-    alignPanel.updateAnnotation();
-    alignPanel.paintAlignment(true);
+    if (avc.deleteGroups()) {
+      PaintRefresher.Refresh(this, viewport.getSequenceSetId());
+      alignPanel.updateAnnotation();
+      alignPanel.paintAlignment(true);
+    }
   }
 
   /**
@@ -2294,7 +2296,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                 viewport.getSelectionGroup());
       }
 
-      statusBar.setText("Removed " + trimRegion.getSize() + " columns.");
+      statusBar.setText(MessageManager.formatMessage("label.removed_columns", new String[]{Integer.valueOf(trimRegion.getSize()).toString()}));
 
       addHistoryItem(trimRegion);
 
@@ -2342,8 +2344,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
     addHistoryItem(removeGapCols);
 
-    statusBar.setText("Removed " + removeGapCols.getSize()
-            + " empty columns.");
+    statusBar.setText(MessageManager.formatMessage("label.removed_empty_columns", new String[]{Integer.valueOf(removeGapCols.getSize()).toString()}));
 
     // This is to maintain viewport position on first residue
     // of first sequence
@@ -2537,7 +2538,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     newap.av.viewName = newViewName;
 
     addAlignmentPanel(newap, true);
-
+    newap.alignmentChanged();
+    
     if (alignPanels.size() == 2)
     {
       viewport.gatherViewsHere = true;
@@ -2951,7 +2953,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     editPane.setEditable(false);
     StringBuffer contents = new AlignmentProperties(viewport.getAlignment())
             .formatAsHtml();
-    editPane.setText("<html>" + contents.toString() + "</html>");
+    editPane.setText(MessageManager.formatMessage("label.html_content", new String[]{contents.toString()}));
     JInternalFrame frame = new JInternalFrame();
     frame.getContentPane().add(new JScrollPane(editPane));
 
@@ -3411,8 +3413,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
 
               int option = JOptionPane.showInternalConfirmDialog(
                       jalview.gui.Desktop.desktop,
-                      "Remove from default list?",
-                      "Remove user defined colour",
+                      MessageManager.getString("label.remove_from_default_list"),
+                      MessageManager.getString("label.remove_user_defined_colour"),
                       JOptionPane.YES_NO_OPTION);
               if (option == JOptionPane.YES_OPTION)
               {
@@ -3564,7 +3566,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             || (viewport.getSelectionGroup().getSize() < 2))
     {
       JOptionPane.showInternalMessageDialog(this,
-              "You must select at least 2 sequences.", "Invalid Selection",
+              MessageManager.getString("label.you_must_select_least_two_sequences"), MessageManager.getString("label.invalid_selection"),
               JOptionPane.WARNING_MESSAGE);
     }
     else
@@ -3590,9 +3592,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             || (viewport.getAlignment().getHeight() < 4))
     {
       JOptionPane.showInternalMessageDialog(this,
-              "Principal component analysis must take\n"
-                      + "at least 4 input sequences.",
-              "Sequence selection insufficient",
+              MessageManager.getString("label.principal_component_analysis_must_take_least_four_input_sequences"),
+              MessageManager.getString("label.sequence_selection_insufficient"),
               JOptionPane.WARNING_MESSAGE);
 
       return;
@@ -3694,8 +3695,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         JOptionPane
                 .showMessageDialog(
                         Desktop.desktop,
-                        "You need to have more than two sequences selected to build a tree!",
-                        "Not enough sequences", JOptionPane.WARNING_MESSAGE);
+                        MessageManager.getString("label.you_need_more_two_sequences_selected_build_tree"),
+                        MessageManager.getString("label.not_enough_sequences"), JOptionPane.WARNING_MESSAGE);
         return;
       }
 
@@ -3709,10 +3710,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           JOptionPane
                   .showMessageDialog(
                           Desktop.desktop,
-                          "The selected region to create a tree may\nonly contain residues or gaps.\n"
-                                  + "Try using the Pad function in the edit menu,\n"
-                                  + "or one of the multiple sequence alignment web services.",
-                          "Sequences in selection are not aligned",
+                          MessageManager.getString("label.selected_region_to_tree_may_only_contain_residues_or_gaps"),
+                          MessageManager.getString("label.sequences_selection_not_aligned"),
                           JOptionPane.WARNING_MESSAGE);
 
           return;
@@ -3730,10 +3729,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         JOptionPane
                 .showMessageDialog(
                         Desktop.desktop,
-                        "The sequences must be aligned before creating a tree.\n"
-                                + "Try using the Pad function in the edit menu,\n"
-                                + "or one of the multiple sequence alignment web services.",
-                        "Sequences not aligned",
+                        MessageManager.getString("label.sequences_must_be_aligned_before_creating_tree"),
+                        MessageManager.getString("label.sequences_not_aligned"),
                         JOptionPane.WARNING_MESSAGE);
 
         return;
@@ -4047,13 +4044,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       } catch (Exception ex)
       {
         JOptionPane.showMessageDialog(Desktop.desktop, ex.getMessage(),
-                "Problem reading tree file", JOptionPane.WARNING_MESSAGE);
+                MessageManager.getString("label.problem_reading_tree_file"), JOptionPane.WARNING_MESSAGE);
         ex.printStackTrace();
       }
       if (fin != null && fin.hasWarningMessage())
       {
         JOptionPane.showMessageDialog(Desktop.desktop,
-                fin.getWarningMessage(), "Possible problem with tree file",
+                fin.getWarningMessage(), MessageManager.getString("label.possible_problem_with_tree_file"),
                 JOptionPane.WARNING_MESSAGE);
       }
     }
@@ -4158,6 +4155,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       @Override
       public void run()
       {
+        final List<JMenuItem> legacyItems=new ArrayList<JMenuItem>();
         try
         {
           System.err.println("Building ws menu again "
@@ -4189,28 +4187,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             // TODO: refactor to allow list of AbstractName/Handler bindings to
             // be
             // stored or retrieved from elsewhere
-            Vector msaws = null; // (Vector) Discoverer.services.get("MsaWS");
+            // No MSAWS used any more:
+            // Vector msaws = null; // (Vector) Discoverer.services.get("MsaWS");
             Vector secstrpr = (Vector) Discoverer.services
                     .get("SecStrPred");
-            Vector seqsrch = null; // (Vector)
-                                   // Discoverer.services.get("SeqSearch");
-            // TODO: move GUI generation code onto service implementation - so a
-            // client instance attaches itself to the GUI with method call like
-            // jalview.ws.MsaWSClient.bind(servicehandle, Desktop.instance,
-            // alignframe)
-            if (msaws != null)
-            {
-              // Add any Multiple Sequence Alignment Services
-              for (int i = 0, j = msaws.size(); i < j; i++)
-              {
-                final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) msaws
-                        .get(i);
-                jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
-                        .getServiceClient(sh);
-                impl.attachWSMenuEntry(msawsmenu, me);
-
-              }
-            }
             if (secstrpr != null)
             {
               // Add any secondary structure prediction services
@@ -4220,35 +4200,23 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                         .get(i);
                 jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
                         .getServiceClient(sh);
+                int p=secstrmenu.getItemCount();
                 impl.attachWSMenuEntry(secstrmenu, me);
-              }
-            }
-            if (seqsrch != null)
-            {
-              // Add any sequence search services
-              for (int i = 0, j = seqsrch.size(); i < j; i++)
-              {
-                final ext.vamsas.ServiceHandle sh = (ext.vamsas.ServiceHandle) seqsrch
-                        .elementAt(i);
-                jalview.ws.WSMenuEntryProviderI impl = jalview.ws.jws1.Discoverer
-                        .getServiceClient(sh);
-                impl.attachWSMenuEntry(seqsrchmenu, me);
+                int q=secstrmenu.getItemCount();
+                for (int litm=p;litm<q; litm++)
+                {
+                  legacyItems.add(secstrmenu.getItem(litm));
+                }
               }
             }
           }
-
+          
           // Add all submenus in the order they should appear on the web
           // services menu
           wsmenu.add(msawsmenu);
           wsmenu.add(secstrmenu);
           wsmenu.add(dismenu);
           wsmenu.add(analymenu);
-          // final ArrayList<JMenu> submens=new ArrayList<JMenu>();
-          // submens.add(msawsmenu);
-          // submens.add(secstrmenu);
-          // submens.add(dismenu);
-          // submens.add(analymenu);
-
           // No search services yet
           // wsmenu.add(seqsrchmenu);
 
@@ -4273,6 +4241,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                   webService.add(me.webServiceNoServices);
                 }
                 // TODO: move into separate menu builder class.
+                boolean new_sspred=false;
                 if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
                 {
                   Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
@@ -4281,6 +4250,16 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                     if (jws2servs.hasServices())
                     {
                       jws2servs.attachWSMenuEntry(webService, me);
+                      for (Jws2Instance sv:jws2servs.getServices()) {
+                        if (sv.description.toLowerCase().contains("jpred"))
+                        {
+                          for (JMenuItem jmi:legacyItems)
+                          {
+                            jmi.setVisible(false);
+                          }
+                        }
+                      }
+                      
                     }
                     if (jws2servs.isRunning())
                     {
@@ -4291,7 +4270,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                     }
                   }
                 }
-
                 build_urlServiceMenu(me.webService);
                 build_fetchdbmenu(webService);
                 for (JMenu item : wsmenu)
@@ -4573,8 +4551,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       JOptionPane
               .showMessageDialog(
                       Desktop.desktop,
-                      "Please select at least three bases in at least one sequence in order to perform a cDNA translation.",
-                      "Translation Failed", JOptionPane.WARNING_MESSAGE);
+                      MessageManager.getString("label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation"),
+                      MessageManager.getString("label.translation_failed"), JOptionPane.WARNING_MESSAGE);
     }
     else
     {
@@ -4603,15 +4581,21 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     } catch (Exception ex)
     {
       al = null;
-      jalview.bin.Cache.log.debug("Exception during translation.", ex);
+      jalview.bin.Cache.log.error("Exception during translation. Please report this !", ex);
+      JOptionPane
+      .showMessageDialog(
+              Desktop.desktop,
+              MessageManager.getString("label.error_when_translating_sequences_submit_bug_report"),
+              MessageManager.getString("label.implementation_error") + MessageManager.getString("translation_failed"), JOptionPane.ERROR_MESSAGE);
+      return;
     }
     if (al == null)
     {
       JOptionPane
               .showMessageDialog(
                       Desktop.desktop,
-                      "Please select at least three bases in at least one sequence in order to perform a cDNA translation.",
-                      "Translation Failed", JOptionPane.WARNING_MESSAGE);
+                      MessageManager.getString("label.select_at_least_three_bases_in_at_least_one_sequence_to_cDNA_translation"),
+                      MessageManager.getString("label.translation_failed"), JOptionPane.WARNING_MESSAGE);
     }
     else
     {
@@ -4810,10 +4794,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                   || JOptionPane
                           .showConfirmDialog(
                                   this,
-                                  "Do you want to automatically associate the "
-                                          + filesmatched.size()
-                                          + " PDB files with sequences in the alignment that have the same name ?",
-                                  "Automatically Associate PDB files by name",
+                                  MessageManager.formatMessage("label.automatically_associate_pdb_files_with_sequences_same_name",
+                                                 new String[]{Integer.valueOf(filesmatched.size()).toString()}),
+                                  MessageManager.getString("label.automatically_associate_pdb_files_by_name"),
                                   JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
 
           {
@@ -4846,10 +4829,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                           "AUTOASSOCIATE_PDBANDSEQS_IGNOREOTHERS", false) || JOptionPane
                           .showConfirmDialog(
                                   this,
-                                  "<html>Do you want to <em>ignore</em> the "
-                                          + filesnotmatched.size()
-                                          + " files whose names did not match any sequence IDs ?</html>",
-                                  "Ignore unmatched dropped files ?",
+                                  MessageManager.formatMessage("label.ignore_unmatched_dropped_files_info", new String[]{Integer.valueOf(filesnotmatched.size()).toString()}),
+                                  MessageManager.getString("label.ignore_unmatched_dropped_files"),
                                   JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION))
           {
             return;
@@ -4908,8 +4889,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               tcoffeeColour.setSelected(true);
               changeColour(new TCoffeeColourScheme(viewport.getAlignment()));
               isAnnotation = true;
-              statusBar
-                      .setText("Successfully pasted T-Coffee scores to alignment.");
+              statusBar.setText(MessageManager.getString("label.successfully_pasted_tcoffee_scores_to_alignment"));
             }
             else
             {
@@ -4918,9 +4898,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               JOptionPane
                       .showMessageDialog(
                               Desktop.desktop,
-                              tcf.getWarningMessage() == null ? "Check that the file matches sequence IDs in the alignment."
+                              tcf.getWarningMessage() == null ? MessageManager.getString("label.check_file_matches_sequence_ids_alignment")
                                       : tcf.getWarningMessage(),
-                              "Problem reading T-COFFEE score file",
+                              MessageManager.getString("label.problem_reading_tcoffee_score_file"),
                               JOptionPane.WARNING_MESSAGE);
             }
           }
@@ -5027,6 +5007,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     {
       alignPanel = (AlignmentPanel) alignPanels.elementAt(index);
       viewport = alignPanel.av;
+      avc.setViewportAndAlignmentPanel(viewport, alignPanel);
       setMenusFromViewport(viewport);
     }
   }
@@ -5037,7 +5018,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     if (SwingUtilities.isRightMouseButton(e))
     {
       String reply = JOptionPane.showInternalInputDialog(this,
-              "Enter View Name", "Edit View Name",
+              MessageManager.getString("label.enter_view_name"), MessageManager.getString("label.enter_view_name"),
               JOptionPane.QUESTION_MESSAGE);
 
       if (reply != null)
@@ -5317,7 +5298,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
                   ++i;
                   if (++icomp >= mcomp || i == (otherdb.size()))
                   {
-                    ifetch.setText(imname + " to '" + sname + "'");
+                    ifetch.setText(MessageManager.formatMessage("label.source_to_target",new String[]{imname,sname}));
                     dfetch.add(ifetch);
                     ifetch = new JMenu();
                     imname = null;
@@ -5329,7 +5310,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               ++dbi;
               if (comp >= mcomp || dbi >= (dbclasses.length))
               {
-                dfetch.setText(mname + " to '" + dbclass + "'");
+                dfetch.setText(MessageManager.formatMessage("label.source_to_target",new String[]{mname,dbclass}));
                 rfetch.add(dfetch);
                 dfetch = new JMenu();
                 mname = null;
@@ -5467,34 +5448,31 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   protected void makeGrpsFromSelection_actionPerformed(ActionEvent e)
   {
-    if (viewport.getSelectionGroup() != null)
-    {
-      SequenceGroup[] gps = jalview.analysis.Grouping.makeGroupsFrom(
-              viewport.getSequenceSelection(),
-              viewport.getAlignmentView(true).getSequenceStrings(
-                      viewport.getGapCharacter()), viewport.getAlignment()
-                      .getGroups());
-      viewport.getAlignment().deleteAllGroups();
-      viewport.sequenceColours = null;
-      viewport.setSelectionGroup(null);
-      // set view properties for each group
-      for (int g = 0; g < gps.length; g++)
-      {
-        gps[g].setShowNonconserved(viewport.getShowUnconserved());
-        gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo());
-        viewport.getAlignment().addGroup(gps[g]);
-        Color col = new Color((int) (Math.random() * 255),
-                (int) (Math.random() * 255), (int) (Math.random() * 255));
-        col = col.brighter();
-        for (SequenceI s : gps[g].getSequences())
-          viewport.setSequenceColour(s, col);
-      }
+    if (avc.makeGroupsFromSelection()) {
       PaintRefresher.Refresh(this, viewport.getSequenceSetId());
       alignPanel.updateAnnotation();
       alignPanel.paintAlignment(true);
     }
   }
 
+  @Override
+  protected void createGroup_actionPerformed(ActionEvent e)
+  {
+    if (avc.createGroup())
+    {
+      alignPanel.alignmentChanged();
+    }
+  }
+
+  @Override
+  protected void unGroup_actionPerformed(ActionEvent e)
+  {
+    if (avc.unGroup())
+    {
+      alignPanel.alignmentChanged();
+    }
+  }
+
   /**
    * make the given alignmentPanel the currently selected tab
    *