/** * 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
/** * 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
/** * 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
/** 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
/** 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
/** Descripción de Método */ private void cmd_translate() { ArrayList list = new ArrayList(); ValueNamePair pp = null; String sql = "SELECT Name, AD_Language FROM AD_Language WHERE IsSystemLanguage='Y' ORDER BY 1"; try { PreparedStatement pstmt = DB.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { list.add(new ValueNamePair(rs.getString(2), rs.getString(1))); } rs.close(); pstmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, "", e); } if (list.size() == 0) { ADialog.warn(m_WindowNo, this, "NoTranslation"); return; } // Dialog String title = Msg.getMsg(Env.getCtx(), "PrintFormatTrl", true); String message = Msg.getMsg(Env.getCtx(), "PrintFormatTrl", false); int choice = JOptionPane.showOptionDialog( this, message, title, JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, list.toArray(), null); if (choice == JOptionPane.CLOSED_OPTION) { return; } // pp = (ValueNamePair) list.get(choice); String AD_Language = pp.getValue(); int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().getID(); log.config(AD_Language + " - AD_PrintFormat_ID=" + AD_PrintFormat_ID); StringBuffer sb = new StringBuffer(); // English if (Language.isBaseLanguage(AD_Language)) { sb.append( "UPDATE AD_PrintFormatItem pfi " + "SET Name = (SELECT e.Name FROM AD_Element e, AD_Column c" + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)," + "PrintName = (SELECT e.PrintName FROM AD_Element e, AD_Column c" + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID) " + "WHERE AD_PrintFormat_ID=") .append(AD_PrintFormat_ID) .append( " AND EXISTS (SELECT * FROM AD_Element e, AD_Column c" + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)"); } else { AD_Language = "'" + AD_Language + "'"; sb.append( "UPDATE AD_PrintFormatItem pfi " + "SET Name = (SELECT e.Name FROM AD_Element_Trl e, AD_Column c" + " WHERE e.AD_Language=") .append(AD_Language) .append( " AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID), " + "PrintName = (SELECT e.PrintName FROM AD_Element_Trl e, AD_Column c" + " WHERE e.AD_Language=") .append(AD_Language) .append( " AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID) " + "WHERE AD_PrintFormat_ID=") .append(AD_PrintFormat_ID) .append( " AND EXISTS (SELECT * FROM AD_Element_Trl e, AD_Column c" + " WHERE e.AD_Language=") .append(AD_Language) .append(" AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)"); } int count = DB.executeUpdate(sb.toString()); log.config("Count=" + count); // m_reportEngine.setPrintFormat(MPrintFormat.get(Env.getCtx(), AD_PrintFormat_ID, true)); revalidate(); } // cmd_translate
/** 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
/** * Descripción de Método * * @param e * @throws PropertyVetoException */ public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException { log.config( "En vetoableChange(" + m_mTab.toString() + ") " + e.getPropertyName() + "=" + e.getNewValue() + " (" + e.getOldValue() + ") " + ((e.getOldValue() == null) ? "" : e.getOldValue().getClass().getName())); // Save Confirmation dialog MTable-RowSave if (e.getPropertyName().equals(MTable.PROPERTY)) { // throw new PropertyVetoException calls this method (??) again if (m_vetoActive) { m_vetoActive = false; return; } if (!Env.isAutoCommit(Env.getCtx(), m_WindowNo) || (m_mTab.getCommitWarning().length() > 0)) { if (!ADialog.ask(m_WindowNo, this, "SaveChanges?", m_mTab.getCommitWarning())) { m_vetoActive = true; throw new PropertyVetoException("UserDeniedSave", e); } } return; } // saveConfirmation // Get Row/Col Info MTable mTable = m_mTab.getTableModel(); int row = m_mTab.getCurrentRow(); int col = mTable.findColumn(e.getPropertyName()); // // Modificado por Disytel - Franco Bonafine // Cuando un editor devuelve null, la ejecución entra por esta rama del if // haciendo que no se guarde el valor null en el MTable. Esto produce que // al asignar un null a un editor, y luego guardar los cambios (desde una ventana) // el APanel dispare el mensaje "No Guardado", dado que no se detectan // modificaciones en la fila. // Por esto, por mas que el valor sea null, se debe guardar el valor en la MTable. // **************** // Codigo Original // if((e.getNewValue() == null) && (e.getOldValue() != null) && // (e.getOldValue().toString().length() > 0) ) { // some editors return "" instead of null // mTable.setChanged( true ); // } else { // ***************** // mTable.setValueAt (e.getNewValue(), row, col, true); mTable.setValueAt(e.getNewValue(), row, col); // -> dataStatusChanged -> dynamicDisplay // Force Callout if (e.getPropertyName().equals("S_ResourceAssignment_ID")) { MField mField = m_mTab.getField(col); if ((mField != null) /*&& (mField.getCallout().length() > 0)*/) { m_mTab.processFieldChange(mField); // Dependencies & Callout } } // } // log.config( "GridController.vetoableChange (" + m_mTab.toString() + ") - fini", // e.getPropertyName() + "=" + e.getNewValue()); } // vetoableChange