From 28905890ca861cdfd7defc659faf4bdb823bac0a Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 6 Feb 2015 10:54:31 +0000 Subject: [PATCH] JAL-1640 new menu allowing view settings to be transferred from any other view on the desktop --- src/jalview/gui/AlignFrame.java | 37 ++++++++++++++++++++++++++++++++++++ src/jalview/jbgui/GAlignFrame.java | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index c58c4ac..b9727e7 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -53,6 +53,7 @@ import jalview.datamodel.SeqCigar; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.gui.ViewSelectionMenu.ViewSetProvider; import jalview.io.AlignmentProperties; import jalview.io.AnnotationFile; import jalview.io.BioJsHTMLOutput; @@ -107,6 +108,8 @@ import java.awt.dnd.DropTargetEvent; import java.awt.dnd.DropTargetListener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; @@ -351,6 +354,40 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, addKeyListener(); + final List selviews = new ArrayList(); + final List origview = new ArrayList(); + ViewSelectionMenu vsel = new ViewSelectionMenu("Transfer colours from", + new ViewSetProvider() + { + + @Override + public AlignmentPanel[] getAllAlignmentPanels() + { + origview.clear(); + origview.add(alignPanel); + return Desktop.getAlignmentPanels(null); + } + }, selviews, new ItemListener() + { + + @Override + public void itemStateChanged(ItemEvent e) + { + if (origview.size() > 0) + { + origview.get(0) + .getAlignViewport() + .setViewStyle( + selviews.get(0).getAlignViewport() + .getViewStyle()); + origview.get(0).updateLayout(); + origview.get(0).setSelected(true); + origview.get(0).alignFrame.setMenusForViewport(); + } + } + }); + formatMenu.add(vsel); + } /** diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 4ecedaf..37ec47d 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -340,7 +340,7 @@ public class GAlignFrame extends JInternalFrame JMenuItem textColour = new JMenuItem(); - JMenu formatMenu = new JMenu(); + protected JMenu formatMenu = new JMenu(); JMenu selectMenu = new JMenu(); -- 1.7.10.2