JAL-1640 new menu allowing view settings to be transferred from any other view on...
authorJim Procter <jprocter@dundee.ac.uk>
Fri, 6 Feb 2015 10:54:31 +0000 (10:54 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Fri, 6 Feb 2015 10:54:31 +0000 (10:54 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/jbgui/GAlignFrame.java

index c58c4ac..b9727e7 100644 (file)
@@ -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<AlignmentPanel> selviews = new ArrayList<AlignmentPanel>();
+    final List<AlignmentPanel> origview = new ArrayList<AlignmentPanel>();
+    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);
+
   }
 
   /**
index 4ecedaf..37ec47d 100755 (executable)
@@ -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();