private void btnLoadXmlActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnLoadXmlActionPerformed

    JFileChooser chooser = new JFileChooser();
    chooser.setFileFilter(
        new FileFilter() {
          @Override
          public boolean accept(File f) {
            if (f.isDirectory()) return true;
            return f.getPath().toLowerCase().endsWith(".xml") && f.canRead() && f.canWrite();
          }

          @Override
          public String getDescription() {
            return "XML file";
          }
        });
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    if (currentDir != null) chooser.setCurrentDirectory(currentDir);

    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      currentDir = chooser.getCurrentDirectory();

      FileInputStream fileInputStream = null;
      try {
        fileInputStream = new FileInputStream(chooser.getSelectedFile());
        String contents = Common.streamToString(fileInputStream);
        txtXml.setSyntaxEditingStyle("text/xml");
        txtXml.setText(contents);
        txtXml.setEditable(true);
      } catch (Exception ex) {
        txtXml.setSyntaxEditingStyle("text/text");
        txtXml.setText(Common.traceToString(ex));
        txtXml.setEditable(false);
      } finally {
        if (fileInputStream != null) {
          try {
            fileInputStream.close();
          } catch (Exception ex) {
          }
        }
      }

      //            setXmlTextIsDirty( true );
    }
  } // GEN-LAST:event_btnLoadXmlActionPerformed
    public void run() {

      System.out.println("RELOADING");

      try {
        jellyfishBase.reloadClauseBase(language);

        clauseBase = jellyfishBase.getClauseBase(language);

      } catch (Exception ex) {
        String trace = Common.traceToString(ex);
        dlgWait.setVisible(false);
        JOptionPane.showMessageDialog(
            rootFrame, trace, "Error While Loading", JOptionPane.ERROR_MESSAGE);
        ex.printStackTrace(System.out);
      } finally {
        dlgWait.setVisible(false);
      }
    }
    public void run() {
      String xml = txtXml.getText();
      java.io.ByteArrayInputStream inputStream = new ByteArrayInputStream(xml.getBytes());
      ClauseBase newClauseBase = new ClauseBase(tokenizer);
      try {
        newClauseBase.build(inputStream);
        clauseBase = newClauseBase;
        setXmlTextIsDirty(false);
      } catch (Exception ex) {
        ex.printStackTrace(System.out);
        JOptionPane.showMessageDialog(rootPane, Common.traceToString(ex));
      } finally {
        try {
          inputStream.close();
        } catch (IOException ex) {
        }
      }

      dlgWait.setVisible(false);
    }