import jalview.datamodel.SequenceI;
import jalview.jbgui.GFinder;
import jalview.util.MessageManager;
-import jalview.viewmodel.AlignmentViewport;
import java.awt.Dimension;
+import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
private static final int MIN_HEIGHT = 120;
- private static final int MY_HEIGHT = 120;
+ private static final int MY_HEIGHT = 150;
private static final int MY_WIDTH = 400;
private SearchResultsI searchResults;
- /*
- * true if we only search a given alignment view
- */
- private boolean focusfixed;
-
- /**
- * Creates a new Finder object with no associated viewport or panel. Each Find
- * or Find Next action will act on whichever viewport has focus at the time.
- */
- public Finder()
- {
- this(null, null);
- }
-
/**
- * Constructor given an associated viewport and alignment panel. Constructs
- * and displays an internal frame where the user can enter a search string.
+ * Constructor given an associated alignment panel. Constructs and displays an
+ * internal frame where the user can enter a search string.
*
- * @param viewport
* @param alignPanel
*/
- public Finder(AlignmentViewport viewport, AlignmentPanel alignPanel)
+ public Finder(AlignmentPanel alignPanel)
{
- av = viewport;
+ av = alignPanel.getAlignViewport();
ap = alignPanel;
finders = new HashMap<>();
- focusfixed = viewport != null;
frame = new JInternalFrame();
frame.setContentPane(this);
frame.setLayer(JLayeredPane.PALETTE_LAYER);
}
});
addEscapeHandler();
+
Desktop.addInternalFrame(frame, MessageManager.getString("label.find"),
MY_WIDTH, MY_HEIGHT);
frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
/**
* if !focusfixed and not in a desktop environment, checks that av and ap are
* valid. Otherwise, gets the topmost alignment window and sets av and ap
- * accordingly
+ * accordingly. Also sets the 'ignore hidden' checkbox disabled if the viewport
+ * has no hidden columns.
*
* @return false if no alignment window was found
*/
boolean getFocusedViewport()
{
- if (focusfixed || Desktop.desktop == null)
+ if (Desktop.desktop == null)
{
if (ap != null && av != null)
{
{
av = ((AlignFrame) alignFrame).viewport;
ap = ((AlignFrame) alignFrame).alignPanel;
+ ignoreHidden.setEnabled(av.hasHiddenColumns());
return true;
}
}
boolean isCaseSensitive = caseSensitive.isSelected();
boolean doSearchDescription = searchDescription.isSelected();
+ boolean skipHidden = ignoreHidden.isSelected();
if (doFindAll)
{
- finder.findAll(searchString, isCaseSensitive, doSearchDescription);
+ finder.findAll(searchString, isCaseSensitive, doSearchDescription,
+ skipHidden);
}
else
{
- finder.findNext(searchString, isCaseSensitive, doSearchDescription);
+ finder.findNext(searchString, isCaseSensitive, doSearchDescription,
+ skipHidden);
}
searchResults = finder.getSearchResults();
ap.alignFrame.requestFocus();
}
}
+
+ @Override
+ protected void paintComponent(Graphics g)
+ {
+ /*
+ * enable 'hidden regions' option only if
+ * 'top' viewport has hidden columns
+ */
+ getFocusedViewport();
+ super.paintComponent(g);
+ }
}