From: kjvdheide Date: Wed, 20 Dec 2017 18:04:25 +0000 (+0000) Subject: JAL-2838 JAL-2872 added sorting from the Aptx frame (still misbehaving X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=1b3cfcaa6095f0f83c7faefacd75efebbfae8710;p=jalview.git JAL-2838 JAL-2872 added sorting from the Aptx frame (still misbehaving with multiple alignment views) --- diff --git a/src/jalview/ext/archaeopteryx/AptxFrame.java b/src/jalview/ext/archaeopteryx/AptxFrame.java index 6cecd28..79798d3 100644 --- a/src/jalview/ext/archaeopteryx/AptxFrame.java +++ b/src/jalview/ext/archaeopteryx/AptxFrame.java @@ -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)); + } diff --git a/src/jalview/ext/archaeopteryx/JalviewBinding.java b/src/jalview/ext/archaeopteryx/JalviewBinding.java index 2ba5a88..9296583 100644 --- a/src/jalview/ext/archaeopteryx/JalviewBinding.java +++ b/src/jalview/ext/archaeopteryx/JalviewBinding.java @@ -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 sequencesBoundToNodes; private Map 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 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 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; - } + } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index cb5c14f..0ebf8e8 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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)); }