Package jreepad.io

Examples of jreepad.io.JreepadWriter


            encoding = getPrefs().getEncoding();
          else
            encoding = document.getEncoding();

          // Write to either HJT or XML
          JreepadWriter writer;
          if(fileType == JreepadPrefs.FILETYPE_XML)
            writer = new XmlWriter();
          else if (fileType == JreepadPrefs.FILETYPE_XML_ENCRYPTED)
          {
              String password = document.getPassword();
              if (password == null || askForFilename)
                  password = PasswordDialog.showPasswordDialog(true);
              if (password == null)
              {
                  successful = false; // "Cancel" was pressed
                  return;
              }
              EncryptedWriter encryptedWriter = new EncryptedWriter(new XmlWriter());
              encryptedWriter.setPassword(password);
              writer = encryptedWriter;
              document.setPassword(password);
          }
          else
            writer = new TreepadWriter(encoding);

          OutputStream fos = new FileOutputStream(saveLocation);
          writer.write(fos, document);
          fos.close();

          if(MAC_OS_X){
            com.apple.eio.FileManager.setFileTypeAndCreator(saveLocation.toString(),
                    appleAppCode, appleAppCode);
View Full Code Here


      case OUTPUT_HJT:
        resultsParent = new JreepadNode("Search results","");
        for(int i=0; i<res.length; i++)
          resultsParent.add(res[i].getNode());
        String outputEncoding = "ISO-8859-1"; // FIXME: What should the encoding be?
        JreepadWriter writer;
        if (outputFormat == OUTPUT_XML)
            writer= new XmlWriter();
        else
            writer= new TreepadWriter(outputEncoding);
        writer.write(System.out, new JreepadTreeModel(resultsParent));
        break;
      case OUTPUT_TITLES:
        for(int i=0; i<res.length; i++)
          System.out.println(res[i].getNode().getTitle());
        break;
View Full Code Here

      {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        getPrefs().backupLocation = fileChooser.getSelectedFile();

        // Write to either HJT
        JreepadWriter writer = new TreepadWriter(getPrefs().getEncoding());
        OutputStream fos = new FileOutputStream(getPrefs().backupLocation);
        writer.write(fos, document);
        fos.close();

        setCursor(Cursor.getDefaultCursor());
        return true;
      }
View Full Code Here

      {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        getPrefs().exportLocation = fileChooser.getSelectedFile();

        String output = null;
        JreepadWriter writer = null;
        switch(exportFormat)
        {
          case FILE_FORMAT_HTML:
            writer = new HtmlWriter(getPrefs().getEncoding(),
                getPrefs().htmlExportArticleType,
                getPrefs().htmlExportUrlsToLinks,
                getPrefs().htmlExportAnchorLinkType);
            break;
          case FILE_FORMAT_XML:
            writer= new XmlWriter();
            break;
          case FILE_FORMAT_HJT:
            writer= new TreepadWriter(getPrefs().getEncoding());
            break;
          case FILE_FORMAT_TEXT:
            output = theJreepad.getCurrentNode().getContent();
            break;
          case FILE_FORMAT_TEXTASLIST:
            output = theJreepad.getCurrentNode().exportTitlesAsList();
            break;
          case FILE_FORMAT_ARTICLESTOTEXT:
            int answer = JOptionPane.showConfirmDialog(this, lang.getString("PROMPT_INCLUDE_TITLES"),
                       lang.getString("TITLE_INCLUDE_TITLES") , JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            boolean titlesToo = (answer == JOptionPane.YES_OPTION);
            output = theJreepad.getCurrentNode().exportArticlesToText(titlesToo);
            break;
          default:
            setCursor(Cursor.getDefaultCursor());
            JOptionPane.showMessageDialog(this,  "Unknown which format to export - coding error! Oops!",lang.getString("TITLE_MISC_ERROR") , JOptionPane.ERROR_MESSAGE);
            return;
        }

        OutputStream fos = new FileOutputStream(getPrefs().exportLocation);
        if (writer != null)
        {
          writer.write(fos, new JreepadTreeModel(theJreepad.getCurrentNode()));
          fos.close();
        }
        else // assume (output != null)
        {
          OutputStreamWriter osw = new OutputStreamWriter(fos, getPrefs().getEncoding());
View Full Code Here

TOP

Related Classes of jreepad.io.JreepadWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.