JAL-3878 Fetch sequences for alignment on menu action, not creation.
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Thu, 30 Sep 2021 14:38:04 +0000 (16:38 +0200)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Thu, 30 Sep 2021 14:38:04 +0000 (16:38 +0200)
src/jalview/ws2/operations/AlignmentOperation.java

index 32a5abc..14564d6 100644 (file)
@@ -156,9 +156,6 @@ public class AlignmentOperation implements Operation
     final String action = submitGaps ? "Align" : "Realign";
     final var calcName = service.getName();
 
-    final AlignmentView msa = frame.gatherSequencesForAlignment();
-    final AlignViewport viewport = frame.getViewport();
-    final AlignmentI alignment = frame.getViewport().getAlignment();
     String title = frame.getTitle();
     WebServiceExecutor executor = frame.getViewport().getWSExecutor();
     {
@@ -167,11 +164,14 @@ public class AlignmentOperation implements Operation
       item.setToolTipText(MessageManager
               .formatMessage("label.action_with_default_settings", action));
       item.addActionListener((event) -> {
+        final AlignmentView msa = frame.gatherSequencesForAlignment();
+        final AlignViewport viewport = frame.getViewport();
+        final AlignmentI alignment = frame.getViewport().getAlignment();
         if (msa != null)
         {
           WebServiceWorkerI worker = new AlignmentWorker(msa,
-                  Collections.emptyList(), title, submitGaps, true,
-                  alignment, viewport);
+              Collections.emptyList(), title, submitGaps, true,
+              alignment, viewport);
           executor.submit(worker);
         }
       });
@@ -185,18 +185,21 @@ public class AlignmentOperation implements Operation
       item.setToolTipText(MessageManager.getString(
               "label.view_and_change_parameters_before_alignment"));
       item.addActionListener((event) -> {
+        final AlignmentView msa = frame.gatherSequencesForAlignment();
+        final AlignViewport viewport = frame.getViewport();
+        final AlignmentI alignment = frame.getViewport().getAlignment();
         if (msa != null)
         {
           openEditParamsDialog(service, null, null)
-                  .thenAcceptAsync((arguments) -> {
-                    if (arguments != null)
-                    {
-                      WebServiceWorkerI worker = new AlignmentWorker(msa,
-                              arguments, title, submitGaps, true, alignment,
-                              viewport);
-                      executor.submit(worker);
-                    }
-                  });
+              .thenAcceptAsync((arguments) -> {
+                if (arguments != null)
+                {
+                  WebServiceWorkerI worker = new AlignmentWorker(msa,
+                      arguments, title, submitGaps, true, alignment,
+                      viewport);
+                  executor.submit(worker);
+                }
+              });
         }
       });
       parent.add(item);
@@ -235,11 +238,14 @@ public class AlignmentOperation implements Operation
                         preset.getDescription()));
         item.setToolTipText(tooltip);
         item.addActionListener((event) -> {
+          final AlignmentView msa = frame.gatherSequencesForAlignment();
+          final AlignViewport viewport = frame.getViewport();
+          final AlignmentI alignment = frame.getViewport().getAlignment();
           if (msa != null)
           {
             WebServiceWorkerI worker = new AlignmentWorker(msa,
-                    preset.getArguments(), title, submitGaps, true,
-                    alignment, viewport);
+                preset.getArguments(), title, submitGaps, true,
+                alignment, viewport);
             executor.submit(worker);
           }
         });