JAL-2405 set initial selection group alignment context
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index e5c7b4c..8fa14ae 100644 (file)
@@ -1073,7 +1073,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
   }
 
   /**
-   * Set the selection group for this window.
+   * Set the selection group for this window. Also sets the current alignment as
+   * the context for the group, if it does not already have one.
    * 
    * @param sg
    *          - group holding references to sequences in this alignment view
@@ -1083,7 +1084,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
   public void setSelectionGroup(SequenceGroup sg)
   {
     selectionGroup = sg;
-    if (sg != null)
+    if (sg != null && sg.getContext() == null)
     {
       sg.setContext(alignment);
     }