JAL-2089 patch broken merge to master for Release 2.10.0b1
[jalview.git] / src / jalview / gui / SplitFrame.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.gui;
22
23 import jalview.api.SplitContainerI;
24 import jalview.api.ViewStyleI;
25 import jalview.datamodel.AlignmentI;
26 import jalview.jbgui.GAlignFrame;
27 import jalview.jbgui.GSplitFrame;
28 import jalview.structure.StructureSelectionManager;
29 import jalview.util.Platform;
30 import jalview.viewmodel.AlignmentViewport;
31
32 import java.awt.Component;
33 import java.awt.Toolkit;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.KeyAdapter;
37 import java.awt.event.KeyEvent;
38 import java.awt.event.KeyListener;
39 import java.beans.PropertyVetoException;
40 import java.util.Arrays;
41 import java.util.List;
42 import java.util.Map.Entry;
43
44 import javax.swing.AbstractAction;
45 import javax.swing.InputMap;
46 import javax.swing.JComponent;
47 import javax.swing.JMenuItem;
48 import javax.swing.KeyStroke;
49 import javax.swing.event.InternalFrameAdapter;
50 import javax.swing.event.InternalFrameEvent;
51
52 /**
53  * An internal frame on the desktop that hosts a horizontally split view of
54  * linked DNA and Protein alignments. Additional views can be created in linked
55  * pairs, expanded to separate split frames, or regathered into a single frame.
56  * <p>
57  * (Some) operations on each alignment are automatically mirrored on the other.
58  * These include mouseover (highlighting), sequence and column selection,
59  * sequence ordering and sorting, and grouping, colouring and sorting by tree.
60  * 
61  * @author gmcarstairs
62  *
63  */
64 public class SplitFrame extends GSplitFrame implements SplitContainerI
65 {
66   private static final int WINDOWS_INSETS_WIDTH = 28; // tbc
67
68   private static final int MAC_INSETS_WIDTH = 28;
69
70   private static final int WINDOWS_INSETS_HEIGHT = 50; // tbc
71
72   private static final int MAC_INSETS_HEIGHT = 50;
73
74   private static final int DESKTOP_DECORATORS_HEIGHT = 65;
75
76   private static final long serialVersionUID = 1L;
77
78   public SplitFrame(GAlignFrame top, GAlignFrame bottom)
79   {
80     super(top, bottom);
81     init();
82   }
83
84   /**
85    * Initialise this frame.
86    */
87   protected void init()
88   {
89     getTopFrame().setSplitFrame(this);
90     getBottomFrame().setSplitFrame(this);
91     getTopFrame().setVisible(true);
92     getBottomFrame().setVisible(true);
93
94     ((AlignFrame) getTopFrame()).getViewport().setCodingComplement(
95             ((AlignFrame) getBottomFrame()).getViewport());
96
97     /*
98      * estimate width and height of SplitFrame; this.getInsets() doesn't seem to
99      * give the full additional size (a few pixels short)
100      */
101     int widthFudge = Platform.isAMac() ? MAC_INSETS_WIDTH
102             : WINDOWS_INSETS_WIDTH;
103     int heightFudge = Platform.isAMac() ? MAC_INSETS_HEIGHT
104             : WINDOWS_INSETS_HEIGHT;
105     int width = ((AlignFrame) getTopFrame()).getWidth() + widthFudge;
106     int height = ((AlignFrame) getTopFrame()).getHeight()
107             + ((AlignFrame) getBottomFrame()).getHeight() + DIVIDER_SIZE
108             + heightFudge;
109     height = fitHeightToDesktop(height);
110     setSize(width, height);
111
112     adjustLayout();
113
114     addCloseFrameListener();
115
116     addKeyListener();
117
118     addKeyBindings();
119
120     addCommandListeners();
121   }
122
123   /**
124    * Reduce the height if too large to fit in the Desktop. Also adjust the
125    * divider location in proportion.
126    * 
127    * @param height
128    *          in pixels
129    * @return original or reduced height
130    */
131   public int fitHeightToDesktop(int height)
132   {
133     // allow about 65 pixels for Desktop decorators on Windows
134
135     int newHeight = Math.min(height, Desktop.instance.getHeight()
136             - DESKTOP_DECORATORS_HEIGHT);
137     if (newHeight != height)
138     {
139       int oldDividerLocation = getDividerLocation();
140       setDividerLocation(oldDividerLocation * newHeight / height);
141     }
142     return newHeight;
143   }
144
145   /**
146    * Set the top and bottom frames to listen to each others Commands (e.g. Edit,
147    * Order).
148    */
149   protected void addCommandListeners()
150   {
151     // TODO if CommandListener is only ever 1:1 for complementary views,
152     // may change broadcast pattern to direct messaging (more efficient)
153     final StructureSelectionManager ssm = StructureSelectionManager
154             .getStructureSelectionManager(Desktop.instance);
155     ssm.addCommandListener(((AlignFrame) getTopFrame()).getViewport());
156     ssm.addCommandListener(((AlignFrame) getBottomFrame()).getViewport());
157   }
158
159   /**
160    * Do any tweaking and twerking of the layout wanted.
161    */
162   public void adjustLayout()
163   {
164     /*
165      * Ensure sequence ids are the same width so sequences line up
166      */
167     int w1 = ((AlignFrame) getTopFrame()).getViewport().getIdWidth();
168     int w2 = ((AlignFrame) getBottomFrame()).getViewport().getIdWidth();
169     int w3 = Math.max(w1, w2);
170     if (w1 != w3)
171     {
172       ((AlignFrame) getTopFrame()).getViewport().setIdWidth(w3);
173     }
174     if (w2 != w3)
175     {
176       ((AlignFrame) getBottomFrame()).getViewport().setIdWidth(w3);
177     }
178
179     /*
180      * Scale protein to either 1 or 3 times character width of dna
181      */
182     final AlignViewport topViewport = ((AlignFrame) getTopFrame()).viewport;
183     final AlignViewport bottomViewport = ((AlignFrame) getBottomFrame()).viewport;
184     final AlignmentI topAlignment = topViewport.getAlignment();
185     final AlignmentI bottomAlignment = bottomViewport.getAlignment();
186     AlignmentViewport cdna = topAlignment.isNucleotide() ? topViewport
187             : (bottomAlignment.isNucleotide() ? bottomViewport : null);
188     AlignmentViewport protein = !topAlignment.isNucleotide() ? topViewport
189             : (!bottomAlignment.isNucleotide() ? bottomViewport : null);
190     if (protein != null && cdna != null)
191     {
192       ViewStyleI vs = protein.getViewStyle();
193       int scale = vs.isScaleProteinAsCdna() ? 3 : 1;
194       vs.setCharWidth(scale * cdna.getViewStyle().getCharWidth());
195       protein.setViewStyle(vs);
196     }
197   }
198
199   /**
200    * Adjust the divider for a sensible split of the real estate (for example,
201    * when many transcripts are shown with a single protein). This should only be
202    * called after the split pane has been laid out (made visible) so it has a
203    * height.
204    */
205   protected void adjustDivider()
206   {
207     final AlignViewport topViewport = ((AlignFrame) getTopFrame()).viewport;
208     final AlignViewport bottomViewport = ((AlignFrame) getBottomFrame()).viewport;
209     final AlignmentI topAlignment = topViewport.getAlignment();
210     final AlignmentI bottomAlignment = bottomViewport.getAlignment();
211     boolean topAnnotations = topViewport.isShowAnnotation();
212     boolean bottomAnnotations = bottomViewport.isShowAnnotation();
213     // TODO need number of visible sequences here, not #sequences - how?
214     int topCount = topAlignment.getHeight();
215     int bottomCount = bottomAlignment.getHeight();
216     int topCharHeight = topViewport.getViewStyle().getCharHeight();
217     int bottomCharHeight = bottomViewport.getViewStyle().getCharHeight();
218
219     /*
220      * estimate ratio of (topFrameContent / bottomFrameContent)
221      */
222     int insets = Platform.isAMac() ? MAC_INSETS_HEIGHT
223             : WINDOWS_INSETS_HEIGHT;
224     // allow 3 'rows' for scale, scrollbar, status bar
225     int topHeight = insets + (3 + topCount) * topCharHeight
226             + (topAnnotations ? topViewport.calcPanelHeight() : 0);
227     int bottomHeight = insets + (3 + bottomCount) * bottomCharHeight
228             + (bottomAnnotations ? bottomViewport.calcPanelHeight() : 0);
229     double ratio = ((double) topHeight) / (topHeight + bottomHeight);
230
231     /*
232      * limit to 0.2 <= ratio <= 0.8 to avoid concealing all sequences
233      */
234     ratio = Math.min(ratio, 0.8d);
235     ratio = Math.max(ratio, 0.2d);
236     setRelativeDividerLocation(ratio);
237   }
238
239   /**
240    * Add a listener to tidy up when the frame is closed.
241    */
242   protected void addCloseFrameListener()
243   {
244     addInternalFrameListener(new InternalFrameAdapter()
245     {
246       @Override
247       public void internalFrameClosed(InternalFrameEvent evt)
248       {
249         close();
250       };
251     });
252   }
253
254   /**
255    * Add a key listener that delegates to whichever split component the mouse is
256    * in (or does nothing if neither).
257    */
258   protected void addKeyListener()
259   {
260     addKeyListener(new KeyAdapter()
261     {
262
263       @Override
264       public void keyPressed(KeyEvent e)
265       {
266         AlignFrame af = (AlignFrame) getFrameAtMouse();
267
268         /*
269          * Intercept and override any keys here if wanted.
270          */
271         if (!overrideKey(e, af))
272         {
273           if (af != null)
274           {
275             for (KeyListener kl : af.getKeyListeners())
276             {
277               kl.keyPressed(e);
278             }
279           }
280         }
281       }
282
283       @Override
284       public void keyReleased(KeyEvent e)
285       {
286         Component c = getFrameAtMouse();
287         if (c != null)
288         {
289           for (KeyListener kl : c.getKeyListeners())
290           {
291             kl.keyReleased(e);
292           }
293         }
294       }
295
296     });
297   }
298
299   /**
300    * Returns true if the key event is overriden and actioned (or ignored) here,
301    * else returns false, indicating it should be delegated to the AlignFrame's
302    * usual handler.
303    * <p>
304    * We can't handle Cmd-Key combinations here, instead this is done by
305    * overriding key bindings.
306    * 
307    * @see addKeyOverrides
308    * @param e
309    * @param af
310    * @return
311    */
312   protected boolean overrideKey(KeyEvent e, AlignFrame af)
313   {
314     boolean actioned = false;
315     int keyCode = e.getKeyCode();
316     switch (keyCode)
317     {
318     case KeyEvent.VK_DOWN:
319       if (e.isAltDown() || !af.viewport.cursorMode)
320       {
321         /*
322          * Key down (or Alt-key-down in cursor mode) - move selected sequences
323          */
324         ((AlignFrame) getTopFrame()).moveSelectedSequences(false);
325         ((AlignFrame) getBottomFrame()).moveSelectedSequences(false);
326         actioned = true;
327         e.consume();
328       }
329       break;
330     case KeyEvent.VK_UP:
331       if (e.isAltDown() || !af.viewport.cursorMode)
332       {
333         /*
334          * Key up (or Alt-key-up in cursor mode) - move selected sequences
335          */
336         ((AlignFrame) getTopFrame()).moveSelectedSequences(true);
337         ((AlignFrame) getBottomFrame()).moveSelectedSequences(true);
338         actioned = true;
339         e.consume();
340       }
341       break;
342     default:
343     }
344     return actioned;
345   }
346
347   /**
348    * Set key bindings (recommended for Swing over key accelerators).
349    */
350   private void addKeyBindings()
351   {
352     overrideDelegatedKeyBindings();
353
354     overrideImplementedKeyBindings();
355   }
356
357   /**
358    * Override key bindings with alternative action methods implemented in this
359    * class.
360    */
361   protected void overrideImplementedKeyBindings()
362   {
363     overrideFind();
364     overrideNewView();
365     overrideCloseView();
366     overrideExpandViews();
367     overrideGatherViews();
368   }
369
370   /**
371    * Replace Cmd-W close view action with our version.
372    */
373   protected void overrideCloseView()
374   {
375     AbstractAction action;
376     /*
377      * Ctrl-W / Cmd-W - close view or window
378      */
379     KeyStroke key_cmdW = KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit
380             .getDefaultToolkit().getMenuShortcutKeyMask(), false);
381     action = new AbstractAction()
382     {
383       @Override
384       public void actionPerformed(ActionEvent e)
385       {
386         closeView_actionPerformed();
387       }
388     };
389     overrideKeyBinding(key_cmdW, action);
390   }
391
392   /**
393    * Replace Cmd-T new view action with our version.
394    */
395   protected void overrideNewView()
396   {
397     /*
398      * Ctrl-T / Cmd-T open new view
399      */
400     KeyStroke key_cmdT = KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit
401             .getDefaultToolkit().getMenuShortcutKeyMask(), false);
402     AbstractAction action = new AbstractAction()
403     {
404       @Override
405       public void actionPerformed(ActionEvent e)
406       {
407         newView_actionPerformed();
408       }
409     };
410     overrideKeyBinding(key_cmdT, action);
411   }
412
413   /**
414    * For now, delegates key events to the corresponding key accelerator for the
415    * AlignFrame that the mouse is in. Hopefully can be simplified in future if
416    * AlignFrame is changed to use key bindings rather than accelerators.
417    */
418   protected void overrideDelegatedKeyBindings()
419   {
420     if (getTopFrame() instanceof AlignFrame)
421     {
422       /*
423        * Get all accelerator keys in the top frame (the bottom should be
424        * identical) and override each one.
425        */
426       for (Entry<KeyStroke, JMenuItem> acc : ((AlignFrame) getTopFrame())
427               .getAccelerators().entrySet())
428       {
429         overrideKeyBinding(acc);
430       }
431     }
432   }
433
434   /**
435    * Overrides an AlignFrame key accelerator with our version which delegates to
436    * the action listener in whichever frame has the mouse (and does nothing if
437    * neither has).
438    * 
439    * @param acc
440    */
441   private void overrideKeyBinding(Entry<KeyStroke, JMenuItem> acc)
442   {
443     final KeyStroke ks = acc.getKey();
444     InputMap inputMap = this.getInputMap(JComponent.WHEN_FOCUSED);
445     inputMap.put(ks, ks);
446     this.getActionMap().put(ks, new AbstractAction()
447     {
448       @Override
449       public void actionPerformed(ActionEvent e)
450       {
451         Component c = getFrameAtMouse();
452         if (c != null && c instanceof AlignFrame)
453         {
454           for (ActionListener a : ((AlignFrame) c).getAccelerators()
455                   .get(ks).getActionListeners())
456           {
457             a.actionPerformed(null);
458           }
459         }
460       }
461     });
462   }
463
464   /**
465    * Replace an accelerator key's action with the specified action.
466    * 
467    * @param ks
468    */
469   protected void overrideKeyBinding(KeyStroke ks, AbstractAction action)
470   {
471     this.getActionMap().put(ks, action);
472     overrideMenuItem(ks, action);
473   }
474
475   /**
476    * Create and link new views (with matching names) in both panes.
477    * <p>
478    * Note this is _not_ multiple tabs, each hosting a split pane view, rather it
479    * is a single split pane with each split holding multiple tabs which are
480    * linked in pairs.
481    * <p>
482    * TODO implement instead with a tabbed holder in the SplitView, each tab
483    * holding a single JSplitPane. Would avoid a duplicated tab, at the cost of
484    * some additional coding.
485    */
486   protected void newView_actionPerformed()
487   {
488     AlignFrame topFrame = (AlignFrame) getTopFrame();
489     AlignFrame bottomFrame = (AlignFrame) getBottomFrame();
490     final boolean scaleProteinAsCdna = topFrame.viewport
491             .isScaleProteinAsCdna();
492
493     AlignmentPanel newTopPanel = topFrame.newView(null, true);
494     AlignmentPanel newBottomPanel = bottomFrame.newView(null, true);
495
496     /*
497      * This currently (for the first new view only) leaves the top pane on tab 0
498      * but the bottom on tab 1. This results from 'setInitialTabVisible' echoing
499      * from the bottom back to the first frame. Next line is a fudge to work
500      * around this. TODO find a better way.
501      */
502     if (topFrame.getTabIndex() != bottomFrame.getTabIndex())
503     {
504       topFrame.setDisplayedView(newTopPanel);
505     }
506
507     newBottomPanel.av.viewName = newTopPanel.av.viewName;
508     newTopPanel.av.setCodingComplement(newBottomPanel.av);
509
510     /*
511      * These lines can be removed once scaleProteinAsCdna is added to element
512      * Viewport in jalview.xsd, as Jalview2XML.copyAlignPanel will then take
513      * care of it
514      */
515     newTopPanel.av.setScaleProteinAsCdna(scaleProteinAsCdna);
516     newBottomPanel.av.setScaleProteinAsCdna(scaleProteinAsCdna);
517
518     /*
519      * Line up id labels etc
520      */
521     adjustLayout();
522
523     final StructureSelectionManager ssm = StructureSelectionManager
524             .getStructureSelectionManager(Desktop.instance);
525     ssm.addCommandListener(newTopPanel.av);
526     ssm.addCommandListener(newBottomPanel.av);
527   }
528
529   /**
530    * Close the currently selected view in both panes. If there is only one view,
531    * close this split frame.
532    */
533   protected void closeView_actionPerformed()
534   {
535     int viewCount = ((AlignFrame) getTopFrame()).getAlignPanels().size();
536     if (viewCount < 2)
537     {
538       close();
539       return;
540     }
541
542     AlignmentPanel topPanel = ((AlignFrame) getTopFrame()).alignPanel;
543     AlignmentPanel bottomPanel = ((AlignFrame) getBottomFrame()).alignPanel;
544
545     ((AlignFrame) getTopFrame()).closeView(topPanel);
546     ((AlignFrame) getBottomFrame()).closeView(bottomPanel);
547
548   }
549
550   /**
551    * Close child frames and this split frame.
552    */
553   public void close()
554   {
555     ((AlignFrame) getTopFrame()).closeMenuItem_actionPerformed(true);
556     ((AlignFrame) getBottomFrame()).closeMenuItem_actionPerformed(true);
557     try
558     {
559       this.setClosed(true);
560     } catch (PropertyVetoException e)
561     {
562       // ignore
563     }
564   }
565
566   /**
567    * Replace AlignFrame 'expand views' action with SplitFrame version.
568    */
569   protected void overrideExpandViews()
570   {
571     KeyStroke key_X = KeyStroke.getKeyStroke(KeyEvent.VK_X, 0, false);
572     AbstractAction action = new AbstractAction()
573     {
574       @Override
575       public void actionPerformed(ActionEvent e)
576       {
577         expandViews_actionPerformed();
578       }
579     };
580     overrideMenuItem(key_X, action);
581   }
582
583   /**
584    * Replace AlignFrame 'gather views' action with SplitFrame version.
585    */
586   protected void overrideGatherViews()
587   {
588     KeyStroke key_G = KeyStroke.getKeyStroke(KeyEvent.VK_G, 0, false);
589     AbstractAction action = new AbstractAction()
590     {
591       @Override
592       public void actionPerformed(ActionEvent e)
593       {
594         gatherViews_actionPerformed();
595       }
596     };
597     overrideMenuItem(key_G, action);
598   }
599
600   /**
601    * Override the menu action associated with the keystroke in the child frames,
602    * replacing it with the given action.
603    * 
604    * @param ks
605    * @param action
606    */
607   private void overrideMenuItem(KeyStroke ks, AbstractAction action)
608   {
609     overrideMenuItem(ks, action, getTopFrame());
610     overrideMenuItem(ks, action, getBottomFrame());
611   }
612
613   /**
614    * Override the menu action associated with the keystroke in one child frame,
615    * replacing it with the given action. Mwahahahaha.
616    * 
617    * @param key
618    * @param action
619    * @param comp
620    */
621   private void overrideMenuItem(KeyStroke key, final AbstractAction action,
622           JComponent comp)
623   {
624     if (comp instanceof AlignFrame)
625     {
626       JMenuItem mi = ((AlignFrame) comp).getAccelerators().get(key);
627       if (mi != null)
628       {
629         for (ActionListener al : mi.getActionListeners())
630         {
631           mi.removeActionListener(al);
632         }
633         mi.addActionListener(new ActionListener()
634         {
635           @Override
636           public void actionPerformed(ActionEvent e)
637           {
638             action.actionPerformed(e);
639           }
640         });
641       }
642     }
643   }
644
645   /**
646    * Expand any multiple views (which are always in pairs) into separate split
647    * frames.
648    */
649   protected void expandViews_actionPerformed()
650   {
651     Desktop.instance.explodeViews(this);
652   }
653
654   /**
655    * Gather any other SplitFrame views of this alignment back in as multiple
656    * (pairs of) views in this SplitFrame.
657    */
658   protected void gatherViews_actionPerformed()
659   {
660     Desktop.instance.gatherViews(this);
661   }
662
663   /**
664    * Returns the alignment in the complementary frame to the one given.
665    */
666   @Override
667   public AlignmentI getComplement(Object alignFrame)
668   {
669     if (alignFrame == this.getTopFrame())
670     {
671       return ((AlignFrame) getBottomFrame()).viewport.getAlignment();
672     }
673     else if (alignFrame == this.getBottomFrame())
674     {
675       return ((AlignFrame) getTopFrame()).viewport.getAlignment();
676     }
677     return null;
678   }
679
680   /**
681    * Returns the title of the complementary frame to the one given.
682    */
683   @Override
684   public String getComplementTitle(Object alignFrame)
685   {
686     if (alignFrame == this.getTopFrame())
687     {
688       return ((AlignFrame) getBottomFrame()).getTitle();
689     }
690     else if (alignFrame == this.getBottomFrame())
691     {
692       return ((AlignFrame) getTopFrame()).getTitle();
693     }
694     return null;
695   }
696
697   /**
698    * Set the 'other half' to hidden / revealed.
699    */
700   @Override
701   public void setComplementVisible(Object alignFrame, boolean show)
702   {
703     /*
704      * Hiding the AlignPanel suppresses unnecessary repaints
705      */
706     if (alignFrame == getTopFrame())
707     {
708       ((AlignFrame) getBottomFrame()).alignPanel.setVisible(show);
709     }
710     else if (alignFrame == getBottomFrame())
711     {
712       ((AlignFrame) getTopFrame()).alignPanel.setVisible(show);
713     }
714     super.setComplementVisible(alignFrame, show);
715   }
716
717   /**
718    * return the AlignFrames held by this container
719    * 
720    * @return { Top alignFrame (Usually CDS), Bottom AlignFrame (Usually
721    *         Protein)}
722    */
723   public List<AlignFrame> getAlignFrames()
724   {
725     return Arrays.asList(new AlignFrame[] { (AlignFrame) getTopFrame(),
726         (AlignFrame) getBottomFrame() });
727   }
728
729   /**
730    * Replace Cmd-F Find action with our version. This is necessary because the
731    * 'default' Finder searches in the first AlignFrame it finds. We need it to
732    * search in the half of the SplitFrame that has the mouse.
733    */
734   protected void overrideFind()
735   {
736     /*
737      * Ctrl-F / Cmd-F open Finder dialog, 'focused' on the right alignment
738      */
739     KeyStroke key_cmdF = KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit
740             .getDefaultToolkit().getMenuShortcutKeyMask(), false);
741     AbstractAction action = new AbstractAction()
742     {
743       @Override
744       public void actionPerformed(ActionEvent e)
745       {
746         Component c = getFrameAtMouse();
747         if (c != null && c instanceof AlignFrame)
748         {
749           AlignFrame af = (AlignFrame) c;
750           new Finder(af.viewport, af.alignPanel);
751         }
752       }
753     };
754     overrideKeyBinding(key_cmdF, action);
755   }
756 }