<commit_before>package org.basex.gui.view.xquery;

import static org.basex.core.Text.*;
import static org.basex.gui.GUIConstants.*;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import javax.swing.Box;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import org.basex.data.Nodes;
import org.basex.gui.GUICommands;
import org.basex.gui.GUIConstants;
import org.basex.gui.GUIProp;
import org.basex.gui.GUIConstants.Fill;
import org.basex.gui.dialog.Dialog;
import org.basex.gui.layout.BaseXBack;
import org.basex.gui.layout.BaseXButton;
import org.basex.gui.layout.BaseXLabel;
import org.basex.gui.layout.BaseXLayout;
import org.basex.gui.layout.BaseXTextField;
import org.basex.gui.layout.TableLayout;
import org.basex.gui.view.View;
import org.basex.gui.view.ViewNotifier;
import org.basex.io.IO;
import org.basex.util.Util;

/**
 * This view allows the input and evaluation of XQuery queries.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-10, ISC License
 * @author <NAME>
 */
public final class XQueryView extends View {
  /** Execute Button. */
  final BaseXButton stop;
  /** Info label. */
  final BaseXLabel info;
  /** Text Area. */
  final XQueryText text;
  /** Modified flag. */
  boolean modified;

  /** Header string. */
  final BaseXLabel header;
  /** Scroll Pane. */
  private final BaseXBack south;
  /** Execute button. */
  private final BaseXButton go;
  /** Filter button. */
  private final BaseXButton filter;

  /**
   * Default constructor.
   * @param man view manager
   */
  public XQueryView(final ViewNotifier man) {
    super(XQUERYVIEW, HELPXQUERYY, man);

    setLayout(new BorderLayout());
    setBorder(6, 8, 8, 8);
    setFocusable(false);

    header = new BaseXLabel(XQUERYTIT, true, false);

    final BaseXBack b = new BaseXBack(Fill.NONE);
    b.setLayout(new BorderLayout());
    b.add(header, BorderLayout.CENTER);

    final BaseXButton open = BaseXButton.command(GUICommands.XQOPEN, gui);
    // hidden buttons for actions
    final BaseXButton hsave = BaseXButton.command(GUICommands.XQSAVE, gui);
    final BaseXButton hsaveAs = BaseXButton.command(GUICommands.XQSAVEAS, gui);
    
    final BaseXButton save = new BaseXButton(gui, "xqsaveas", HELPSAVE);
    save.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(final ActionEvent e) {
        final JPopupMenu popup = new JPopupMenu(GUISAVE);
        final ActionListener al = new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent ac) {
            if(ac.getActionCommand().equals(GUISAVE)) {
              hsave.doClick();
            } else {
             hsaveAs.doClick(); 
            } 
          }
        };
        final JMenuItem saving = new JMenuItem(GUISAVE);
        final JMenuItem saveAs = new JMenuItem(GUISAVEAS);
        saving.addActionListener(al);
        saveAs.addActionListener(al);
        popup.add(saving);
        popup.add(saveAs);
        popup.show(save, 0, save.getHeight());
      }
    });
    final BaseXTextField find = new BaseXTextField(gui);
    BaseXLayout.setHeight(find, (int) open.getPreferredSize().getHeight());

    final BaseXButton hist = new BaseXButton(gui, "hist", HELPRECENT);
    hist.addActionListener(new ActionListener() {
      @Override<commit_msg>minor<commit_after>package org.basex.gui.view.xquery;

import static org.basex.core.Text.*;
import static org.basex.gui.GUIConstants.*;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import javax.swing.Box;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import org.basex.data.Nodes;
import org.basex.gui.GUICommands;
import org.basex.gui.GUIConstants;
import org.basex.gui.GUIProp;
import org.basex.gui.GUIConstants.Fill;
import org.basex.gui.dialog.Dialog;
import org.basex.gui.layout.BaseXBack;
import org.basex.gui.layout.BaseXButton;
import org.basex.gui.layout.BaseXLabel;
import org.basex.gui.layout.BaseXLayout;
import org.basex.gui.layout.BaseXTextField;
import org.basex.gui.layout.TableLayout;
import org.basex.gui.view.View;
import org.basex.gui.view.ViewNotifier;
import org.basex.io.IO;
import org.basex.util.Util;

/**
 * This view allows the input and evaluation of XQuery queries.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-10, ISC License
 * @author <NAME>
 */
public final class XQueryView extends View {
  /** Execute Button. */
  final BaseXButton stop;
  /** Info label. */
  final BaseXLabel info;
  /** Text Area. */
  final XQueryText text;
  /** Modified flag. */
  boolean modified;

  /** Header string. */
  final BaseXLabel header;
  /** Scroll Pane. */
  private final BaseXBack south;
  /** Execute button. */
  private final BaseXButton go;
  /** Filter button. */
  private final BaseXButton filter;

  /**
   * Default constructor.
   * @param man view manager
   */
  public XQueryView(final ViewNotifier man) {
    super(XQUERYVIEW, HELPXQUERYY, man);

    setLayout(new BorderLayout());
    setBorder(6, 8, 8, 8);
    setFocusable(false);

    header = new BaseXLabel(XQUERYTIT, true, false);

    final BaseXBack b = new BaseXBack(Fill.NONE);
    b.setLayout(new BorderLayout());
    b.add(header, BorderLayout.CENTER);

    final BaseXButton open = BaseXButton.command(GUICommands.XQOPEN, gui);
    // hidden buttons for actions
    final BaseXButton hsave = BaseXButton.command(GUICommands.XQSAVE, gui);
    final BaseXButton hsaveAs = BaseXButton.command(GUICommands.XQSAVEAS, gui);
    
    final BaseXButton save = new BaseXButton(gui, "xqsaveas", HELPSAVE);
    save.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(final ActionEvent e) {
        final JPopupMenu popup = new JPopupMenu(GUISAVE);
        final ActionListener al = new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent ac) {
            if(ac.getActionCommand().equals(GUISAVE)) {
              hsave.doClick();
            } else {
             hsaveAs.doClick(); 
            } 
          }
        };
        final JMenuItem saving = new JMenuItem(GUISAVE);
        final JMenuItem saveAs = new JMenuItem(GUISAVEAS + DOTS);
        saving.addActionListener(al);
        saveAs.addActionListener(al);
        popup.add(saving);
        popup.add(saveAs);
        popup.show(save, 0, save.getHeight());
      }
    });
    final BaseXTextField find = new BaseXTextField(gui);
    BaseXLayout.setHeight(find, (int) open.getPreferredSize().getHeight());

    final BaseXButton hist = new BaseXButton(gui, "hist", HELPRECENT);
    hist.addActionListener(new ActionListener() {
      @Override
{'fraction_non_alphanumeric': 0.11424866733900015, 'fraction_numerical': 0.003169572107765452, 'mean_word_length': 3.3742911153119093, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '3830701', 'n_tokens_mistral': 2240, 'n_tokens_neox': 2197, 'n_words': 500}