<commit_before>//
// SearchableWindow.java
//

/*
LOCI Plugins for ImageJ: a collection of ImageJ plugins including the
4D Data Browser, Bio-Formats Importer, Bio-Formats Exporter and OME plugins.
Copyright (C) 2006-@year@ <NAME>, <NAME>,
<NAME>, <NAME> and <NAME>.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package loci.plugins;

import com.jgoodies.forms.layout.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import ij.text.*;

/**
 * Text panel with search capabilities.
 *
 * <dl><dt><b>Source code:</b></dt>
 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/loci/plugins/SearchableWindow.java">Trac</a>,
 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/loci/plugins/SearchableWindow.java">SVN</a></dd></dl>
 */
public class SearchableWindow extends TextWindow implements ActionListener {

  protected TextPanel panel;
  protected int index;

  // -- Constructor --

  public SearchableWindow(String title, String headings, String data,
    int w, int h)
  {
    super(title, headings, data, w, h);
    index = -1;
    panel = getTextPanel();

    MenuBar menubar = getMenuBar();
    Menu menu = menubar.getMenu(0);
    MenuItem search = new MenuItem("Search...");
    search.addActionListener(this);
    menu.add(search);
  }

  // -- ActionListener API methods --

  public void actionPerformed(ActionEvent e) {
    new SearchBox(this);
  }

  // -- SearchableWindow API methods --

  public void selectLine(int index) {
    int ys = panel.getFontMetrics(getFont()).getHeight() + 2;
    int y = ys * (index + 1) + 2;  // absolute y coordinate
    int totalHeight = ys * panel.getLineCount();

    Scrollbar ss = null;
    Component[] components = panel.getComponents();
    for (int i=0; i<components.length; i++) {
      if (components[i] instanceof Scrollbar) {
        Scrollbar s = (Scrollbar) components[i];<commit_msg>Can now save metadata.<commit_after>//
// SearchableWindow.java
//

/*
LOCI Plugins for ImageJ: a collection of ImageJ plugins including the
4D Data Browser, Bio-Formats Importer, Bio-Formats Exporter and OME plugins.
Copyright (C) 2006-@year@ <NAME>, <NAME>,
<NAME>, <NAME> and <NAME>.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package loci.plugins;

import com.jgoodies.forms.layout.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import ij.text.*;

/**
 * Text panel with search capabilities.
 *
 * <dl><dt><b>Source code:</b></dt>
 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/loci/plugins/SearchableWindow.java">Trac</a>,
 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/loci/plugins/SearchableWindow.java">SVN</a></dd></dl>
 */
public class SearchableWindow extends TextWindow implements ActionListener {

  protected TextPanel panel;
  protected int index;

  // -- Constructor --

  public SearchableWindow(String title, String headings, String data,
    int w, int h)
  {
    super(title, headings, data, w, h);
    index = -1;
    panel = getTextPanel();

    MenuBar menubar = getMenuBar();
    Menu menu = menubar.getMenu(0);
    MenuItem search = new MenuItem("Search...");
    search.setActionCommand("search");
    search.addActionListener(this);
    menu.add(search);
  }

  // -- ActionListener API methods --

  public void actionPerformed(ActionEvent e) {
    if ("search".equals(e.getActionCommand())) {
      new SearchBox(this);
    }
    else panel.actionPerformed(e);
  }

  // -- SearchableWindow API methods --

  public void selectLine(int index) {
    int ys = panel.getFontMetrics(getFont()).getHeight() + 2;
    int y = ys * (index + 1) + 2;  // absolute y coordinate
    int totalHeight = ys * panel.getLineCount();

    Scrollbar ss = null;
    Component[] components = panel.getComponents();
    for (int i=0; i<components.length; i++) {
      if (components[i] instanceof Scrollbar) {
        Scrollbar s = (Scrollbar) components[i];
{'fraction_non_alphanumeric': 0.11741424802110818, 'fraction_numerical': 0.00980022615906521, 'mean_word_length': 3.729946524064171, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 37, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1538095', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1552, 'n_words': 549}