/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
import jalview.datamodel.SequenceI;
import jalview.jbgui.GFinder;
import jalview.util.MessageManager;
+import jalview.viewmodel.AlignmentViewport;
import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
import java.util.Vector;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+import javax.swing.AbstractAction;
+import javax.swing.JComponent;
import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
/**
* Performs the menu option for searching the alignment, for the next or all
private static final int WIDTH = 340;
- AlignViewport av;
+ AlignmentViewport av;
AlignmentPanel ap;
* @param viewport
* @param alignPanel
*/
- public Finder(AlignViewport viewport, AlignmentPanel alignPanel)
+ public Finder(AlignmentViewport viewport, AlignmentPanel alignPanel)
{
av = viewport;
ap = alignPanel;
frame = new JInternalFrame();
frame.setContentPane(this);
frame.setLayer(JLayeredPane.PALETTE_LAYER);
+ addEscapeHandler();
Desktop.addInternalFrame(frame, MessageManager.getString("label.find"),
WIDTH, HEIGHT);
}
/**
+ * Add a handler for the Escape key when the window has focus
+ */
+ private void addEscapeHandler()
+ {
+ getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+ KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Cancel");
+ getRootPane().getActionMap().put("Cancel", new AbstractAction()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ escapeActionPerformed();
+ }
+ });
+ }
+
+ /**
+ * Close the panel on Escape key press
+ */
+ protected void escapeActionPerformed()
+ {
+ setVisible(false);
+ frame.dispose();
+ }
+
+ /**
* Performs the 'Find Next' action.
*
* @param e
searchResults.getResultEnd(i), "Search Results");
}
- if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
+ if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(seqs,
features, true, ap))
{
ap.alignFrame.showSeqFeatures.setSelected(true);
if ((idMatch.size() > 0))
{
haveResults = true;
- ap.idPanel.highlightSearchResults(idMatch);
+ ap.getIdPanel().highlightSearchResults(idMatch);
}
else
{
- ap.idPanel.highlightSearchResults(null);
+ ap.getIdPanel().highlightSearchResults(null);
}
if (searchResults.getSize() > 0)