Search in sources :

Example 1 with SwingWorker

use of org.compiere.apps.SwingWorker in project lar_361 by comitsrl.

the class FiscalPrinterClosing method executeAction.

private void executeAction() {
    SwingWorker worker = new SwingWorker() {

        @Override
        public Object construct() {
            resultMsg = null;
            if (!currentAction.execute()) {
                resultMsg = currentAction.getErrorMsg() + ": " + currentAction.getErrorDesc();
            }
            return resultMsg == null;
        }

        @Override
        public void finished() {
            boolean success = (Boolean) getValue();
            if (success) {
                resultMsg = "OK";
            }
            infoFiscalPrinter.setVisible(false);
        }
    };
    worker.start();
    infoFiscalPrinter.setVisible(true);
}
Also used : SwingWorker(org.compiere.apps.SwingWorker)

Example 2 with SwingWorker

use of org.compiere.apps.SwingWorker in project lar_361 by comitsrl.

the class PosBasePanel method printFiscalTicket.

protected boolean printFiscalTicket(final PO document) {
    log.info("Printing fiscal ticket for " + document);
    final SwingWorker worker = new SwingWorker() {

        @Override
        public Object construct() {
            boolean success = true;
            int c_DocType_ID = document.get_ValueAsInt("C_DocType_ID");
            try {
                final MDocType docType = new MDocType(m_ctx, c_DocType_ID, null);
                int lar_Fiscal_Printer_ID = docType.get_ValueAsInt("LAR_Fiscal_Printer_ID");
                log.info("doc type asociated " + docType);
                final FiscalDocumentPrint fdp = new FiscalDocumentPrint(lar_Fiscal_Printer_ID, infoFiscalPrinter, infoFiscalPrinter);
                log.info("fiscal document print created: " + fdp);
                infoFiscalPrinter.setFiscalDocumentPrint(fdp);
                success = printDocument(fdp, document);
            } catch (Exception e) {
                log.log(Level.SEVERE, "Fiscal printing error", e);
                success = false;
            }
            return Boolean.valueOf(success);
        }

        @Override
        public void finished() {
            boolean result = (Boolean) getValue();
            log.info("Finish fiscal printing thread. Printed Ok?: " + result);
            if (result) {
                newOrder();
            }
        }
    };
    worker.start();
    // Thread stops here until fiscal printing finished
    infoFiscalPrinter.setVisible(true);
    return (Boolean) worker.get();
}
Also used : FiscalDocumentPrint(ar.com.ergio.model.FiscalDocumentPrint) MDocType(org.compiere.model.MDocType) SwingWorker(org.compiere.apps.SwingWorker) FiscalDocumentPrint(ar.com.ergio.model.FiscalDocumentPrint) JposException(jpos.JposException)

Example 3 with SwingWorker

use of org.compiere.apps.SwingWorker in project lar_361 by comitsrl.

the class LAR_Validator method anularOperación.

// Marcos Zúñiga -end
/**
 * Anular toda la operación de venta (OV - Recibos - Factura y Remito).
 *
 * @param invoice
 */
private void anularOperación(final MInvoice invoice, final String documentNo, final String fiscalreceiptnumber) {
    SwingWorker worker = new SwingWorker() {

        private String errorMsg = null;

        @Override
        public Object construct() {
            // Crea parámetro que se enviará al proceso
            final ProcessInfoParameter param = new ProcessInfoParameter("C_Order_ID", invoice.getC_Order_ID(), "", "", "");
            // Crea información del proceso
            int AD_Process_ID = 3000037;
            final ProcessInfo pi = new ProcessInfo("PosOrderGlobalVoiding", AD_Process_ID);
            pi.setParameter(new ProcessInfoParameter[] { param });
            // Crea una instancia de proceso (para registro y
            // sincronizacion)
            final MPInstance pinstance = new MPInstance(Env.getCtx(), 0, null);
            pinstance.setAD_Process_ID(AD_Process_ID);
            pinstance.setRecord_ID(0);
            pinstance.save();
            // Conecta el proceso con la instancia de proceso
            pi.setAD_PInstance_ID(pinstance.get_ID());
            // Crea el proceso a ejecutar
            final PosOrderGlobalVoiding process = new PosOrderGlobalVoiding();
            log.info("Iniciando proceso global de anulaci\u00f3n");
            return process.startProcess(Env.getCtx(), pi, null);
        }

        // construct
        @Override
        public void finished() {
            boolean success = (Boolean) getValue();
            if (!success) {
                ADialog.error(0, Env.getWindow(0), errorMsg);
            } else {
                ADialog.warn(0, Env.getWindow(0), "Número de Documento " + documentNo + " duplicado.", "Operación anulada.");
                // Corregir Secuencia.
                MSequence.setFiscalDocTypeNextNroComprobante(invoice.getC_DocType().getDefiniteSequence_ID(), Integer.parseInt(fiscalreceiptnumber) + 1, null);
            }
        }
    };
    // new SwingWorker
    worker.start();
    worker.finished();
}
Also used : ProcessInfoParameter(org.compiere.process.ProcessInfoParameter) PosOrderGlobalVoiding(ar.com.ergio.process.PosOrderGlobalVoiding) MPInstance(org.compiere.model.MPInstance) SwingWorker(org.compiere.apps.SwingWorker) ProcessInfo(org.compiere.process.ProcessInfo)

Example 4 with SwingWorker

use of org.compiere.apps.SwingWorker in project lar_361 by comitsrl.

the class AInfoFiscalPrinter method reprintDocument.

/**
 * Realiza el intento de reimpresión del documento invocando al
 * FiscalDocumentPrint bajo un nuevo hilo (SwingWorker)
 */
private void reprintDocument() {
    SwingWorker worker = new SwingWorker() {

        @Override
        public Object construct() {
            return getFiscalDocumentPrint().reprintDocument();
        }

        @Override
        public void finished() {
            boolean success = (Boolean) getValue();
            if (success) {
                fireReprintFinishedAction();
            }
        }
    };
    worker.start();
}
Also used : SwingWorker(org.compiere.apps.SwingWorker)

Example 5 with SwingWorker

use of org.compiere.apps.SwingWorker in project lar_361 by comitsrl.

the class FiscalDocumentPrintManager method print.

/**
 */
public boolean print() {
    final SwingWorker worker = new SwingWorker() {

        @Override
        public Object construct() {
            boolean success = false;
            {
                try {
                    final MDocType docType = new MDocType(document.getCtx(), document.get_ValueAsInt("C_DocType_ID"), document.get_TrxName());
                    int lar_Fiscal_Printer_ID = docType.get_ValueAsInt("LAR_Fiscal_Printer_ID");
                    final FiscalDocumentPrint fdp = new FiscalDocumentPrint(lar_Fiscal_Printer_ID, infoFiscalPrinter, infoFiscalPrinter);
                    log.info("fiscal document print created: " + fdp);
                    infoFiscalPrinter.setFiscalDocumentPrint(fdp);
                    success = printDocument(fdp);
                } catch (Exception e) {
                    log.log(Level.SEVERE, "Error en la Impresi\u00f3n Fiscal", e);
                    success = false;
                }
            }
            return Boolean.valueOf(success);
        }

        @Override
        public void finished() {
            boolean result = (Boolean) getValue();
            log.info("Finaliza impresi\u00f3n fiscal. Impreso correctamente?: " + result);
        }
    };
    worker.start();
    // Thread stops here until fiscal printing finished
    infoFiscalPrinter.setVisible(true);
    return (Boolean) worker.get();
}
Also used : FiscalDocumentPrint(ar.com.ergio.model.FiscalDocumentPrint) MDocType(org.compiere.model.MDocType) SwingWorker(org.compiere.apps.SwingWorker)

Aggregations

SwingWorker (org.compiere.apps.SwingWorker)6 FiscalDocumentPrint (ar.com.ergio.model.FiscalDocumentPrint)3 PosOrderGlobalVoiding (ar.com.ergio.process.PosOrderGlobalVoiding)2 MDocType (org.compiere.model.MDocType)2 MPInstance (org.compiere.model.MPInstance)2 ProcessInfo (org.compiere.process.ProcessInfo)2 ProcessInfoParameter (org.compiere.process.ProcessInfoParameter)2 JposException (jpos.JposException)1