JAL-2838 JAL-2872 added sorting from the Aptx frame (still misbehaving
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Wed, 20 Dec 2017 18:04:25 +0000 (18:04 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Wed, 20 Dec 2017 18:09:26 +0000 (18:09 +0000)
with
multiple alignment views)

src/jalview/ext/archaeopteryx/AptxFrame.java
src/jalview/ext/archaeopteryx/JalviewBinding.java
src/jalview/gui/AlignFrame.java

index 6cecd28..79798d3 100644 (file)
@@ -147,13 +147,26 @@ public class AptxFrame implements TreeFrameI
                 "Filter alignment to show only currently visible sequences");
 
         refreshJalview.setFont(menu.getFont());
+        refreshJalview.addActionListener(
+                TreeViewerUtils.getActiveTreeViews().get(this));
+        sortByTree.addActionListener(new ActionListener()
+        {
+
+          @Override
+          public void actionPerformed(ActionEvent e)
+          {
+            TreeViewerUtils.getActiveTreeViews().get(AptxFrame.this)
+                    .sortByTree_actionPerformed();
+
+          }
+
+        });
 
         menu.add(sortByTree);
         menu.add(refreshJalview);
 
         sortByTree.setFont(menu.getFont());
-        refreshJalview
-                .addActionListener(TreeViewerUtils.getActiveTreeViews().get(this));
+
 
 
       }
index 2ba5a88..9296583 100644 (file)
@@ -5,6 +5,7 @@ import jalview.analysis.Conservation;
 import jalview.api.AlignViewportI;
 import jalview.commands.CommandI;
 import jalview.commands.OrderCommand;
+import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.SequenceGroup;
@@ -64,8 +65,6 @@ public final class JalviewBinding
 
   private final StructureSelectionManager ssm;
 
-  private AlignmentPanel[] associatedPanels;
-
   private Map<SequenceI, TreeNodeI> sequencesBoundToNodes;
 
   private Map<TreeNodeI, SequenceI> nodesBoundToSequences;
@@ -121,8 +120,6 @@ public final class JalviewBinding
     treeView.addMouseListener(this);
     treeView.registerWithPaintRefresher(
             parentAvport.getSequenceSetId());
-    associatedPanels = PaintRefresher
-            .getAssociatedPanels(parentAvport.getSequenceSetId());
 
     aptxFrame.addFrameListener(new InternalFrameAdapter()
     {
@@ -442,8 +439,8 @@ public final class JalviewBinding
       }
     }
 
-
-        for (AlignmentPanel associatedPanel : associatedPanels) {
+    for (AlignmentPanel associatedPanel : getAssociatedPanels())
+    {
 
         associatedPanel.updateAnnotation();
 
@@ -493,7 +490,7 @@ public final class JalviewBinding
     treeGroup.setName("Tree Group " + nrTreeGroups);
     treeGroup.setIdColour(groupColour);
 
-    for (AlignmentPanel associatedPanel : associatedPanels)
+    for (AlignmentPanel associatedPanel : getAssociatedPanels())
     {
       AlignViewportI altViewport = associatedPanel
               .getAlignViewport();
@@ -625,65 +622,60 @@ public final class JalviewBinding
   }
 
   @Override
-  public void sortByTree_actionPerformed()// modify for Aptx
+  public void sortByTree_actionPerformed()
   {
 
-    // if (treeCanvas.applyToAllViews)
-    // {
-    // final ArrayList<CommandI> commands = new ArrayList<>();
-    // for (AlignmentPanel ap : PaintRefresher
-    // .getAssociatedPanels(parentAvport.getSequenceSetId()))
-    // {
-    // commands.add(sortAlignmentIn(ap.av.getAlignPanel()));
-    // }
-    // parentAvport.getAlignPanel().alignFrame.addHistoryItem(new CommandI()
-    // {
-    //
-    // @Override
-    // public void undoCommand(AlignmentI[] views)
-    // {
-    // for (CommandI tsort : commands)
-    // {
-    // tsort.undoCommand(views);
-    // }
-    // }
-    //
-    // @Override
-    // public int getSize()
-    // {
-    // return commands.size();
-    // }
-    //
-    // @Override
-    // public String getDescription()
-    // {
-    // return "Tree Sort (many views)";
-    // }
-    //
-    // @Override
-    // public void doCommand(AlignmentI[] views)
-    // {
-    //
-    // for (CommandI tsort : commands)
-    // {
-    // tsort.doCommand(views);
-    // }
-    // }
-    // });
-    // for (AlignmentPanel ap : PaintRefresher
-    // .getAssociatedPanels(av.getSequenceSetId()))
-    // {
-    // // ensure all the alignFrames refresh their GI after adding an undo item
-    // ap.alignFrame.updateEditMenuBar();
-    // }
-    // }
-    // else
-    // {
-    // treeCanvas.ap.alignFrame
-    // .addHistoryItem(sortAlignmentIn(treeCanvas.ap));
-    // }
+    // if (applyToAllViews)
+
+      final ArrayList<CommandI> commands = new ArrayList<>();
+      for (AlignmentPanel ap : PaintRefresher
+              .getAssociatedPanels(parentAvport.getSequenceSetId()))
+      {
+        commands.add(sortAlignmentIn(ap.av.getAlignPanel()));
+        ap.alignFrame.addHistoryItem(new CommandI()
+        {
+
+          @Override
+          public void undoCommand(AlignmentI[] views)
+          {
+            for (CommandI tsort : commands)
+            {
+              tsort.undoCommand(views);
+            }
+          }
+
+          @Override
+          public int getSize()
+          {
+            return commands.size();
+          }
+
+          @Override
+          public String getDescription()
+          {
+            return "Tree Sort (many views)";
+          }
+
+          @Override
+          public void doCommand(AlignmentI[] views)
+          {
+
+            for (CommandI tsort : commands)
+            {
+              tsort.doCommand(views);
+            }
+          }
+        });
+
+        ap.alignFrame.updateEditMenuBar();
+      }
+    }
+  // else
+  // {
+  // alignPanel.alignFrame.addHistoryItem(sortAlignmentIn(alignPanel));
+  // }
+
 
-  }
 
   @Override
   public CommandI sortAlignmentIn(AlignmentPanel ap)
@@ -745,13 +737,11 @@ public final class JalviewBinding
 
   public AlignmentPanel[] getAssociatedPanels()
   {
-    return associatedPanels;
+    return PaintRefresher
+            .getAssociatedPanels(parentAvport.getSequenceSetId());
   }
 
-  public void setAssociatedPanels(AlignmentPanel[] associatedPanels)
-  {
-    this.associatedPanels = associatedPanels;
-  }
+
 
 }
 
index cb5c14f..0ebf8e8 100644 (file)
@@ -1520,7 +1520,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   /**
    * DOCUMENT ME!
    */
-  void updateEditMenuBar()
+  public void updateEditMenuBar()
   {
 
     if (viewport.getHistoryList().size() > 0)
@@ -3805,7 +3805,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             @Override
             public void actionPerformed(ActionEvent e)
             {
-            binding.sortByTree_actionPerformed();
+            binding.sortByTree_actionPerformed(); // redundant here??
             addHistoryItem(binding.sortAlignmentIn(alignPanel));
             }