/** Creates new form GuiTest */
  public GuiTest() {
    try {
      InputStream inputStream = new FileInputStream("default.xml");
      clearString = Common.streamToString(inputStream);
      clearString = clearString.replace("    ", "\t");
      inputStream.close();
    } catch (Exception e) {
      e.printStackTrace(System.out);
    }

    initComponents();
    //        txtXml.setTabsEmulated( true );
    setXmlString(clearString);
  }
  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
 private String readClauseFile() {
   Language l = this.jellyfishBase.getTripleStore().getLanguage(language);
   InputStream inputStream = null;
   try {
     inputStream = new BufferedInputStream(new FileInputStream(l.getClausesFile()));
     return Common.streamToString(inputStream);
   } catch (Exception ex) {
     throw new RuntimeException(
         "Exception while reading from clause file: " + l.getClausesFile(), ex);
   } finally {
     if (inputStream != null) {
       try {
         inputStream.close();
       } catch (IOException ex) {
       }
     }
   }
 }