Beispiel #1
0
  /**
   * Constructor de la clase ...
   *
   * @param re
   */
  public Viewer(ReportEngine re) {
    super();
    log.info("");
    m_WindowNo = Env.createWindowNo(this);
    m_reportEngine = re;
    m_AD_Table_ID = re.getPrintFormat().getAD_Table_ID();

    if (!MRole.getDefault().isCanReport(m_AD_Table_ID)) {
      ADialog.error(m_WindowNo, this, "AccessCannotReport", m_reportEngine.getName());
      this.dispose();
    }

    m_isCanExport = MRole.getDefault().isCanExport(m_AD_Table_ID);

    try {
      m_viewPanel = re.getView();
      m_ctx = m_reportEngine.getCtx();
      jbInit();
      dynInit();

      if (!m_viewPanel.isArchivable()) {
        log.warning("Cannot archive Document");
      }

      AEnv.showCenterScreen(this);
    } catch (Exception e) {
      log.log(Level.SEVERE, "Viewer", e);
      ADialog.error(m_WindowNo, this, "LoadError", e.getLocalizedMessage());
      this.dispose();
    }
  } // Viewer
Beispiel #2
0
  /**
   * Descripción de Método
   *
   * @param e
   */
  public void dataStatusChanged(DataStatusEvent e) {

    // if (e.getChangedColumn() == 0)
    // return;

    int col = e.getChangedColumn();

    log.config("(" + m_mTab + ") Col=" + col + ": " + e.toString());

    // Process Callout only for specific columns

    if (col != 0) {
      MField mField = m_mTab.getField(col);

      if ((mField != null) /*&& (mField.getCallout().length() > 0)*/) {
        String msg = m_mTab.processFieldChange(mField); // Dependencies & Callout

        if (msg.length() > 0) {
          ADialog.error(m_WindowNo, this, msg);
        }
        // Agregado por Disytel - Franco Bonafine
        // Si el campo no tiene callout igual se procesan las dependencias para actualizar
        // los valores mostrados de campos dependientes.
      } else if (mField != null) {
        m_mTab.processDependencies(mField);
      }
    }

    dynamicDisplay(col);
  } // dataStatusChanged
Beispiel #3
0
  /**
   * Descripción de Método
   *
   * @param query
   */
  private void executeDrill(MQuery query) {
    int AD_Table_ID = AReport.getAD_Table_ID(query.getTableName());

    if (!MRole.getDefault().isCanReport(AD_Table_ID)) {
      ADialog.error(m_WindowNo, this, "AccessCannotReport", query.getTableName());

      return;
    }

    if (AD_Table_ID != 0) {
      new AReport(AD_Table_ID, null, query);
    } else {
      log.warning("No Table found for " + query.getWhereClause(true));
    }
  } // executeDrill
Beispiel #4
0
  /** Descripción de Método */
  private void actionOK() {
    if (fCreateNew.isSelected()) {

      // Get Warehouse Info

      KeyNamePair pp = (KeyNamePair) fWarehouse.getSelectedItem();

      if (pp != null) {
        getWarehouseInfo(pp.getKey());
      }

      // Check mandatory values

      String mandatoryFields = "";

      if (m_M_Warehouse_ID == 0) {
        mandatoryFields += lWarehouse.getText() + " - ";
      }

      if (fValue.getText().length() == 0) {
        mandatoryFields += lValue.getText() + " - ";
      }

      if (fX.getText().length() == 0) {
        mandatoryFields += lX.getText() + " - ";
      }

      if (fY.getText().length() == 0) {
        mandatoryFields += lY.getText() + " - ";
      }

      if (fZ.getText().length() == 0) {
        mandatoryFields += lZ.getText() + " - ";
      }

      if (mandatoryFields.length() != 0) {
        ADialog.error(
            m_WindowNo,
            this,
            "FillMandatory",
            mandatoryFields.substring(0, mandatoryFields.length() - 3));

        return;
      }

      MLocator loc =
          MLocator.get(
              Env.getCtx(),
              m_M_Warehouse_ID,
              fValue.getText(),
              fX.getText(),
              fY.getText(),
              fZ.getText());

      m_M_Locator_ID = loc.getM_Locator_ID();
      fLocator.addItem(loc);
      fLocator.setSelectedItem(loc);
    } // createNew

    //

    log.config("M_Locator_ID=" + m_M_Locator_ID);
  } // actionOK
Beispiel #5
0
  /** Descripción de Método */
  private void cmd_archive() {
    boolean success = false;
    ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
    org.openXpertya.print.pdf.text.Document document = null;
    org.openXpertya.print.pdf.text.pdf.PdfWriter writer = null;

    try {
      if (m_reportEngine.getLayout().getPageable(false) instanceof LayoutEngine) {
        LayoutEngine layoutengine = (LayoutEngine) (m_reportEngine.getLayout().getPageable(false));
        CPaper cpaper = layoutengine.getPaper();
        int i = (int) cpaper.getWidth(true);
        int j = (int) cpaper.getHeight(true);
        int k = 0;

        do {
          if (k >= layoutengine.getNumberOfPages()) {
            break;
          }

          if (document == null) {

            // Paso 1: se crea el documento

            document =
                new org.openXpertya.print.pdf.text.Document(
                    new org.openXpertya.print.pdf.text.Rectangle(i, j));

            // Paso 2: se crea el acceso al documento

            writer =
                org.openXpertya.print.pdf.text.pdf.PdfWriter.getInstance(
                    document, bytearrayoutputstream);

            // Paso 3: se habre el documento

            document.open();
          }

          if (document != null) {

            // Paso 4: se completa el contenido y se a�ade al documento

            // se crea el mapeador de fuentes y se leen todas las fuentes del directorio de fuentes

            org.openXpertya.print.pdf.text.pdf.DefaultFontMapper mapper =
                new org.openXpertya.print.pdf.text.pdf.DefaultFontMapper();

            org.openXpertya.print.pdf.text.FontFactory.registerDirectories();
            mapper.insertDirectory("c:\\windows\\fonts");

            // se crea una plantilla y el panel Graphics2D para dibujar en �l

            org.openXpertya.print.pdf.text.pdf.PdfContentByte cb = writer.getDirectContent();
            org.openXpertya.print.pdf.text.pdf.PdfTemplate tp = cb.createTemplate(i, j);
            java.awt.Graphics2D g2 = tp.createGraphics(i, j, mapper);

            layoutengine.print(g2, layoutengine.getPageFormat(), k);
            g2.dispose();
            cb.addTemplate(tp, 0, 0);
            document.newPage();
          }

          k++;
        } while (true);
      }

      // Paso 5: se cierra el documento

      if (document != null) {
        document.close();
      }

      bytearrayoutputstream.close();
    } catch (Exception exception) {
      exception.printStackTrace();
    }

    byte[] data = bytearrayoutputstream.toByteArray(); // No Copy

    if (data != null) {
      MArchive archive = new MArchive(Env.getCtx(), m_reportEngine.getPrintInfo(), null);

      archive.setBinaryData(data);
      success = archive.save();
    }

    if (success) {
      ADialog.info(m_WindowNo, this, "Archived");
    } else {
      ADialog.error(m_WindowNo, this, "ArchiveError");
    }
  } // cmd_archive
Beispiel #6
0
  /** Descripción de Método */
  private void cmd_export() {
    log.config("");

    if (!m_isCanExport) {
      ADialog.error(m_WindowNo, this, "AccessCannotExport", getTitle());

      return;
    }

    //

    JFileChooser chooser = new JFileChooser();

    chooser.setDialogType(JFileChooser.SAVE_DIALOG);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setDialogTitle(Msg.getMsg(m_ctx, "Export") + ": " + getTitle());

    //

    chooser.addChoosableFileFilter(new ExtensionFileFilter("ps", Msg.getMsg(m_ctx, "FilePS")));
    chooser.addChoosableFileFilter(new ExtensionFileFilter("xml", Msg.getMsg(m_ctx, "FileXML")));
    chooser.addChoosableFileFilter(new ExtensionFileFilter("pdf", Msg.getMsg(m_ctx, "FilePDF")));
    chooser.addChoosableFileFilter(new ExtensionFileFilter("html", Msg.getMsg(m_ctx, "FileHTML")));
    chooser.addChoosableFileFilter(new ExtensionFileFilter("txt", Msg.getMsg(m_ctx, "FileTXT")));
    chooser.addChoosableFileFilter(new ExtensionFileFilter("ssv", Msg.getMsg(m_ctx, "FileSSV")));
    chooser.addChoosableFileFilter(new ExtensionFileFilter("csv", Msg.getMsg(m_ctx, "FileCSV")));

    //

    if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
      return;
    }

    // Create File

    File outFile = ExtensionFileFilter.getFile(chooser.getSelectedFile(), chooser.getFileFilter());

    try {
      outFile.createNewFile();
    } catch (IOException e) {
      log.log(Level.SEVERE, "", e);
      ADialog.error(m_WindowNo, this, "FileCannotCreate", e.getLocalizedMessage());

      return;
    }

    String ext = outFile.getPath();

    // no extension

    if (ext.lastIndexOf(".") == -1) {
      ADialog.error(m_WindowNo, this, "FileInvalidExtension");

      return;
    }

    ext = ext.substring(ext.lastIndexOf(".") + 1).toLowerCase();
    log.config("File=" + outFile.getPath() + "; Type=" + ext);
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    if (ext.equalsIgnoreCase("pdf")) {
      m_reportEngine.createPDF(outFile);
    } else if (ext.equals("ps")) {
      m_reportEngine.createPS(outFile);
    } else if (ext.equals("xml")) {
      m_reportEngine.createXML(outFile);
    } else if (ext.equals("csv")) {
      m_reportEngine.createCSV(outFile, ',', m_reportEngine.getPrintFormat().getLanguage());
    } else if (ext.equals("ssv")) {
      m_reportEngine.createCSV(outFile, ';', m_reportEngine.getPrintFormat().getLanguage());
    } else if (ext.equals("txt")) {
      m_reportEngine.createCSV(outFile, '\t', m_reportEngine.getPrintFormat().getLanguage());
    } else if (ext.equals("html") || ext.equals("htm")) {
      m_reportEngine.createHTML(outFile, false, m_reportEngine.getPrintFormat().getLanguage());
    } else {
      ADialog.error(m_WindowNo, this, "FileInvalidExtension");
    }

    cmd_drill(); // setCursor
  } // cmd_export