Package net.sf.jasperreports.view

Examples of net.sf.jasperreports.view.JRSaveContributor


      FileFilter fileFilter = fileChooser.getFileFilter();
      File file = fileChooser.getSelectedFile();
     
      lastFolder = file.getParentFile();

      JRSaveContributor contributor = null;

      if (fileFilter instanceof JRSaveContributor)
      {
        contributor = (JRSaveContributor)fileFilter;
      }
      else
      {
        int i = 0;
        while(contributor == null && i < saveContributors.size())
        {
          contributor = (JRSaveContributor)saveContributors.get(i++);
          if (!contributor.accept(file))
          {
            contributor = null;
          }
        }

        if (contributor == null)
        {
          contributor = new JRPrintSaveContributor(getLocale(), viewerContext.getResourceBundle());
        }
      }

      lastSaveContributor = contributor;
     
      try
      {
        contributor.save(viewerContext.getJasperPrint(), file);
      }
      catch (JRException e)
      {
        if (log.isErrorEnabled())
        {
View Full Code Here


    {
      try
      {
        Class saveContribClass = JRClassLoader.loadClassForName(DEFAULT_CONTRIBUTORS[i]);
        Constructor constructor = saveContribClass.getConstructor(new Class[]{Locale.class, ResourceBundle.class});
        JRSaveContributor saveContrib = (JRSaveContributor)constructor.newInstance(new Object[]{getLocale(), viewerContext.getResourceBundle()});
        saveContributors.add(saveContrib);
      }
      catch (Exception e)
      {
      }
View Full Code Here

    // fileChooser.addChoosableFileFilter(rtfSaveContrib);
    // } catch (Exception ex) {
    // ex.printStackTrace();
    // }

    JRSaveContributor htmlSaver = null;
    try {
      Class htmlSaverClass = JRClassLoader
          .loadClassForName("net.sf.jasperreports.view.save.JRHtmlSaveContributor");
      htmlSaver = (JRSaveContributor) htmlSaverClass.newInstance();
      fileChooser.addChoosableFileFilter(htmlSaver);
    } catch (Exception e) {
      e.printStackTrace();
    }

    JRSaveContributor csvSaver = null;
    try {
      Class csvSaverClass = JRClassLoader
          .loadClassForName("net.sf.jasperreports.view.save.JRCsvSaveContributor");
      csvSaver = (JRSaveContributor) csvSaverClass.newInstance();
      fileChooser.addChoosableFileFilter(csvSaver);
    } catch (Exception e) {
      e.printStackTrace();
    }

    JRPdfSaveContributor pdfSaveContrib = null;
    try {
      // Class pdfSaveContribClass = JRClassLoader
      // .loadClassForName("net.sf.jasperreports.view.save.JRPdfSaveContributor");
      pdfSaveContrib = new JRPdfSaveContributor(null, null);
      // pdfSaveContrib = (JRSaveContributor) pdfSaveContribClass
      // .newInstance();
      fileChooser.addChoosableFileFilter(pdfSaveContrib);
    } catch (Exception e) {
      e.printStackTrace();
    }

    int retValue = fileChooser.showSaveDialog(this);
    if (retValue == JFileChooser.APPROVE_OPTION) {
      FileFilter fileFilter = fileChooser.getFileFilter();
      File file = fileChooser.getSelectedFile();
      String lowerCaseFileName = file.getName().toLowerCase();

      try {
        if (fileFilter instanceof JRSaveContributor) {
          ((JRSaveContributor) fileFilter).save(jasperPrint, file);
        } else {
          if (lowerCaseFileName.endsWith(".jrprint")) {
            JRSaver.saveObject(jasperPrint, file);
          } else if (lowerCaseFileName.endsWith(".pdf")
              && pdfSaveContrib != null) {
            pdfSaveContrib.save(jasperPrint, file);
          } else if ((lowerCaseFileName.endsWith(".html") || lowerCaseFileName
              .endsWith(".htm"))
              && htmlSaver != null) {
            htmlSaver.save(jasperPrint, file);
          } else if (lowerCaseFileName.endsWith(".csv")
              && csvSaver != null) {
            csvSaver.save(jasperPrint, file);
          } else {
            // if (!file.getName().endsWith(".jrprint")) {
            // file = new File(file.getAbsolutePath() + ".jrprint");
            // }
View Full Code Here

    {
      try
      {
        Class saveContribClass = JRClassLoader.loadClassForName(DEFAULT_CONTRIBUTORS[i]);
        Constructor constructor = saveContribClass.getConstructor(new Class[]{Locale.class, ResourceBundle.class});
        JRSaveContributor saveContrib = (JRSaveContributor)constructor.newInstance(new Object[]{getLocale(), resourceBundle});
        saveContributors.add(saveContrib);
      }
      catch (Exception e)
      {
      }
View Full Code Here

      FileFilter fileFilter = fileChooser.getFileFilter();
      File file = fileChooser.getSelectedFile();
     
      lastFolder = file.getParentFile();

      JRSaveContributor contributor = null;

      if (fileFilter instanceof JRSaveContributor)
      {
        contributor = (JRSaveContributor)fileFilter;
      }
      else
      {
        int i = 0;
        while(contributor == null && i < saveContributors.size())
        {
          contributor = (JRSaveContributor)saveContributors.get(i++);
          if (!contributor.accept(file))
          {
            contributor = null;
          }
        }

        if (contributor == null)
        {
          contributor = new JRPrintSaveContributor(getLocale(), this.resourceBundle);
        }
      }

      lastSaveContributor = contributor;
     
      try
      {
        contributor.save(jasperPrint, file);
      }
      catch (JRException e)
      {
        e.printStackTrace();
        JOptionPane.showMessageDialog(this, getBundleString("error.saving"));
View Full Code Here

    {
      try
      {
        Class saveContribClass = JRClassLoader.loadClassForName(DEFAULT_CONTRIBUTORS[i]);
        Constructor constructor = saveContribClass.getConstructor(new Class[]{Locale.class, ResourceBundle.class});
        JRSaveContributor saveContrib = (JRSaveContributor)constructor.newInstance(new Object[]{getLocale(), resourceBundle});
        saveContributors.add(saveContrib);
      }
      catch (Exception e)
      {
      }
View Full Code Here

      FileFilter fileFilter = fileChooser.getFileFilter();
      File file = fileChooser.getSelectedFile();
     
      lastFolder = file.getParentFile();

      JRSaveContributor contributor = null;

      if (fileFilter instanceof JRSaveContributor)
      {
        contributor = (JRSaveContributor)fileFilter;
      }
      else
      {
        int i = 0;
        while(contributor == null && i < saveContributors.size())
        {
          contributor = (JRSaveContributor)saveContributors.get(i++);
          if (!contributor.accept(file))
          {
            contributor = null;
          }
        }

        if (contributor == null)
        {
          contributor = new JRPrintSaveContributor(getLocale(), this.resourceBundle);
        }
      }

      lastSaveContributor = contributor;
     
      try
      {
        contributor.save(jasperPrint, file);
      }
      catch (JRException e)
      {
        e.printStackTrace();
        JOptionPane.showMessageDialog(this, getBundleString("error.saving"));
View Full Code Here

TOP

Related Classes of net.sf.jasperreports.view.JRSaveContributor

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.