Example usage for java.awt.print PrinterException getMessage

List of usage examples for java.awt.print PrinterException getMessage

Introduction

In this page you can find the example usage for java.awt.print PrinterException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:gda.plots.SimplePlot.java

/**
 * This overrides the method in ChartPanel which seems to behave slightly differently. The replacement may be
 * unecessary -investigate.// www. ja v  a2  s . com
 */
@Override
public void createChartPrintJob() {
    PrinterJob printerJob = PrinterJob.getPrinterJob();
    PageFormat pageFormat = printerJob.defaultPage();
    pageFormat.setOrientation(PageFormat.LANDSCAPE);
    printerJob.setPrintable(this, pageFormat);
    try {
        if (printerJob.printDialog()) {
            printerJob.print();
        }
    } catch (PrinterException pe) {
        logger.error("Caught PrinterException: " + pe.getMessage());
    }
}

From source file:com.openbravo.pos.sales.JRetailPanelTicket.java

private synchronized void printRetailMoveTableTicket(RetailTicketInfo ticket,
        java.util.List<RetailTicketLineInfo> kot, Object ticketExt,
        java.util.List<ProductionPrinterInfo> printerInfo) {
    java.util.List<TicketLineConstructor> allLines = null;
    logger.info("start printing the kot" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
    com.openbravo.pos.printer.printer.KotImagePrinter printer = new KotImagePrinter();
    kotTicketlist = kot;//from  w w  w . j a  v  a 2  s  .  c om
    for (int j = 0; j < printerInfo.size(); j++) {
        java.util.List<RetailTicketLineInfo> uniqueProductionAreas = new ArrayList<RetailTicketLineInfo>();
        for (int i = 0; i < kotTicketlist.size(); i++) {
            if (printerInfo.get(j).getProductionAreaType()
                    .equals(kotTicketlist.get(i).getProductionAreaType())) {
                uniqueProductionAreas.add(kotTicketlist.get(i));
            }
        }
        logger.info("kot print count based on production areas" + uniqueProductionAreas.size());

        if (uniqueProductionAreas.size() != 0) {
            allLines = getMoveTableLines(ticket, ticketExt, uniqueProductionAreas);
            try {
                printer.printKot(allLines, printerInfo.get(j).getPath());
            } catch (PrinterException ex) {
                logger.info("Order NO." + m_oTicket.getOrderId() + " The printer action" + ex.getMessage());
                showMessage(this, "Print Unsucessfull! Please retry");
            }
        }

    }

}

From source file:com.openbravo.pos.sales.JRetailPanelTicket.java

private synchronized void printRetailKotTicket(String sresourcename, RetailTicketInfo ticket,
        java.util.List<RetailTicketLineInfo> kot, Object ticketExt,
        java.util.List<ProductionPrinterInfo> printerInfo, int kotTicket, String floorName) {
    java.util.List<TicketLineConstructor> allLines = null;
    logger.info("start printing the kot" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
    com.openbravo.pos.printer.printer.KotImagePrinter printer = new KotImagePrinter();
    com.openbravo.pos.printer.printer.KotBillPrinter printerKot = new KotBillPrinter();

    String storeLocation = m_App.getProperties().getProperty("machine.storelocation");
    kotTicketlist = kot;/*ww  w .  j ava2 s  . c o m*/
    //iterate the printers with non kot items
    for (int j = 0; j < printerInfo.size(); j++) {
        // list for saving the items having same production area type
        java.util.List<RetailTicketLineInfo> uniqueProductionAreas = new ArrayList<RetailTicketLineInfo>();
        for (int i = 0; i < kotTicketlist.size(); i++) {
            // if printer production area type matches with item production area type , add the line to the list
            if (printerInfo.get(j).getProductionAreaType()
                    .equals(kotTicketlist.get(i).getProductionAreaType())) {
                uniqueProductionAreas.add(kotTicketlist.get(i));
                kotTicketlist.get(i).setProductionArea(printerInfo.get(j).getProductionArea());
            }
        }
        logger.info("kot print count based on production areas" + uniqueProductionAreas.size());
        if (uniqueProductionAreas.size() != 0) {
            allLines = getRetailAllLines(ticket, ticketExt, uniqueProductionAreas, kotTicket, floorName);
            try {
                // sending for kot print based on store
                if (storeLocation.equals("BlrIndranagar") || storeLocation.equals("BlrKoramangala")
                        || storeLocation.equals("Chennai") || storeLocation.equals("Hyderabad")) {
                    //Thermal ?
                    printer.printKot(allLines, printerInfo.get(j).getPath());
                } else {
                    printerKot.print(allLines, printerInfo.get(j).getPath());
                }
                for (int i = 0; i < uniqueProductionAreas.size(); i++) {
                    kotlogger.info("KOT Printed Successfully " + "," + "Username: " + m_oTicket.printUser()
                            + "," + "Total kot count: " + uniqueProductionAreas.size() + "," + "Printer Name: "
                            + printerInfo.get(j).getPath() + "," + "Kot No: " + kotTicket + "," + "Table: "
                            + m_oTicketExt.toString() + "," + "Order No: " + ticket.getOrderId() + ","
                            + "Product Name: " + uniqueProductionAreas.get(i).getProductName() + "," + "Qty: "
                            + uniqueProductionAreas.get(i).getMultiply() + "," + "Timestamp: "
                            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
                    uniqueProductionAreas.get(i).setIsKot(1);
                    if (uniqueProductionAreas.get(i).getPreparationStatus() != 3) {
                        uniqueProductionAreas.get(i).setPreparationStatus(4);
                    }
                    System.out.println("uniqueProductionAreas.get(i). Station : "
                            + uniqueProductionAreas.get(i).getStation());
                    //New KDS Added on 7-03-17
                    String txstatus = "ADD";
                    String tableid_unique = uniqueProductionAreas.get(i).getTbl_orderId();
                    dlReceipts.insertServedTransaction(m_oTicket, txstatus, tableid_unique);

                }
            } catch (PrinterException ex) {
                logger.info("Order NO." + m_oTicket.getOrderId() + " The printer action" + ex.getMessage());
                ex.printStackTrace();
                kotprintIssue = 1;
                Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
                for (int i = 0; i < uniqueProductionAreas.size(); i++) {
                    logger.info("KOT Print Failed  " + "," + "Username: " + m_oTicket.printUser() + ","
                            + "Total kot count: " + uniqueProductionAreas.size() + "," + "Printer Name: "
                            + printerInfo.get(j).getPath() + "," + "Kot No: " + kotTicket + "," + "Table: "
                            + m_oTicketExt.toString() + "," + "Order No: " + ticket.getOrderId() + ","
                            + "Product Name: " + uniqueProductionAreas.get(i).getProductName() + "," + "Qty: "
                            + uniqueProductionAreas.get(i).getMultiply() + "," + "Timestamp: "
                            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
                    uniqueProductionAreas.get(i).setIsKot(0);
                    if (uniqueProductionAreas.get(i).getPreparationStatus() != 3) {
                        uniqueProductionAreas.get(i).setPreparationStatus(0);
                    }

                    //New KDS Added on 7-03-17
                    String txstatus = "ADD";
                    String tableid_unique = uniqueProductionAreas.get(i).getTbl_orderId();
                    System.out.println(
                            "uniqueProductionAreas Station " + uniqueProductionAreas.get(i).getStation());

                    dlReceipts.insertServedTransaction(m_oTicket, txstatus, tableid_unique);
                }
                kotaction = 1;
                showMessage(this, "KOT action not happened! Please retry");
            }
        }
    }

    for (int i = 0; i < ticket.getLinesCount(); i++) {
        paintKotTicketLine(i, ticket.getLine(i));
    }
    // Date updated = new Date();
    Object[] values = new Object[] { m_oTicket.getPlaceId(), m_oTicket.getName(), m_oTicket,
            m_oTicket.getSplitSharedId(), m_oTicket.isPrinted(), m_oTicket.isListModified() };
    Datas[] datas = new Datas[] { Datas.STRING, Datas.STRING, Datas.SERIALIZABLE, Datas.STRING, Datas.BOOLEAN,
            Datas.BOOLEAN };
    try {
        try {
            new PreparedSentence(m_App.getSession(),
                    "UPDATE SHAREDTICKETS SET NAME = ?, CONTENT = ?, ISPRINTED = ?, ISMODIFIED = ?,UPDATED=NOW() ,ISKDS=0  WHERE ID = ? AND SPLITID=? ",
                    new SerializerWriteBasicExt(datas, new int[] { 1, 2, 4, 5, 0, 3 })).exec(values);

        } catch (BasicException ex) {
            logger.info("Order NO." + m_oTicket.getOrderId() + " exception in  updating shared ticket"
                    + ex.getMessage());
            ex.printStackTrace();
            Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
        }
        String splitId = m_oTicket.getSplitSharedId();
        Object[] record = (Object[]) new StaticSentence(m_App.getSession(),
                "SELECT UPDATED FROM SHAREDTICKETS WHERE ID = ? AND SPLITID='" + splitId + "'",
                SerializerWriteString.INSTANCE, new SerializerReadBasic(new Datas[] { Datas.STRING }))
                        .find(m_oTicket.getPlaceId());
        if (record != null) {

            m_oTicket.setObjectUpdateDate(DateFormats.StringToDateTime((String) record[0]));

        }
    } catch (BasicException ex) {
        logger.info("Order NO." + m_oTicket.getOrderId()
                + " exception in  printRetailKotTicket updating shared ticket" + ex.getMessage());
        Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
    }

    logger.info("kot lines passing to print" + kotTicketlist.size());
    logger.info("end printing the kot" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

private synchronized void printRetailKotTicket(String sresourcename, RetailTicketInfo ticket,
        java.util.List<RetailTicketLineInfo> kot, Object ticketExt,
        java.util.List<ProductionPrinterInfo> printerInfo, int kotTicket) {
    java.util.List<TicketLineConstructor> allLines = null;
    logger.info("start printing the kot" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
    com.openbravo.pos.printer.printer.KotImagePrinter printer = new KotImagePrinter();
    com.openbravo.pos.printer.printer.KotBillPrinter printerKot = new KotBillPrinter();
    String storeLocation = m_App.getProperties().getProperty("machine.storelocation");
    kotTicketlist = kot;//  w ww. j  ava  2  s  .  co  m
    for (int j = 0; j < printerInfo.size(); j++) {
        java.util.List<RetailTicketLineInfo> uniqueProductionAreas = new ArrayList<RetailTicketLineInfo>();
        for (int i = 0; i < kotTicketlist.size(); i++) {
            if (printerInfo.get(j).getProductionAreaType()
                    .equals(kotTicketlist.get(i).getProductionAreaType())) {
                uniqueProductionAreas.add(kotTicketlist.get(i));
                kotTicketlist.get(i).setProductionArea(printerInfo.get(j).getProductionArea());
            }
        }
        logger.info("kot print count based on production areas" + uniqueProductionAreas.size());
        //  System.out.println("unique---"+uniqueProductionAreas.get(j).printName());
        System.out.println("uniqueProductionAreas:" + uniqueProductionAreas.size());
        if (uniqueProductionAreas.size() != 0) {
            allLines = getRetailAllLines(ticket, ticketExt, uniqueProductionAreas, kotTicket);
            try {
                if (storeLocation.equals("BlrIndranagar") || storeLocation.equals("BlrKoramangala")
                        || storeLocation.equals("Chennai") || storeLocation.equals("Hyderabad")) {
                    printer.printKot(allLines, printerInfo.get(j).getPath());
                } else {
                    printerKot.print(allLines, printerInfo.get(j).getPath());
                }
                //   kotprintIssue=0;
                // kotlogger.info("items printed successfully "+"By "+m_oTicket.printUser()+""+" in POS System "+m_App.getProperties().getPosNo()+" Table name "+m_oTicketExt.toString());
                for (int i = 0; i < uniqueProductionAreas.size(); i++) {
                    // kotlogger.info(uniqueProductionAreas.get(i).getProductName());
                    kotlogger.info("KOT Printed Successfully " + "," + "Username: " + m_oTicket.printUser()
                            + "," + "Total kot count: " + uniqueProductionAreas.size() + "," + "Printer Name: "
                            + printerInfo.get(j).getPath() + "," + "Kot No: " + kotTicket + "," + ","
                            + "Order No: " + ticket.getOrderId() + "," + "Product Name: "
                            + uniqueProductionAreas.get(i).getProductName() + "," + "Qty: "
                            + uniqueProductionAreas.get(i).getMultiply() + "," + "Timestamp: "
                            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
                    uniqueProductionAreas.get(i).setIsKot(1);
                    if (uniqueProductionAreas.get(i).getPreparationStatus() != 3) {
                        uniqueProductionAreas.get(i).setPreparationStatus(4);
                    }

                    //New KDS Added on 7-03-17
                    String txstatus = "ADD";
                    String tableid_unique = uniqueProductionAreas.get(i).getTbl_orderId();

                    System.out.println("STATION: " + uniqueProductionAreas.get(i).getStation());
                    dlReceipts.insertServedTransaction(m_oTicket, txstatus, tableid_unique);

                }
            } catch (PrinterException ex) {
                logger.info("Order NO." + m_oTicket.getOrderId() + " The printer action" + ex.getMessage());
                kotprintIssue = 1;
                System.out.println("within the catch of printer");
                Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
                for (int i = 0; i < uniqueProductionAreas.size(); i++) {
                    // kotlogger.info("items failed to print "+"By "+m_oTicket.printUser()+""+" in POS System "+m_App.getProperties().getPosNo()+" Table name "+m_oTicketExt.toString());
                    //  kotlogger.info("items failed to print :"+uniqueProductionAreas.get(i).getProductName());
                    logger.info("KOT Print Failed  " + "," + "Username: " + m_oTicket.printUser() + ","
                            + "Total kot count: " + uniqueProductionAreas.size() + "," + "Printer Name: "
                            + printerInfo.get(j).getPath() + "," + "Kot No: " + kotTicket + "," + "Table: "
                            + m_oTicketExt.toString() + "," + "Order No: " + ticket.getOrderId() + ","
                            + "Product Name: " + uniqueProductionAreas.get(i).getProductName() + "," + "Qty: "
                            + uniqueProductionAreas.get(i).getMultiply() + "," + "Timestamp: "
                            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
                    uniqueProductionAreas.get(i).setIsKot(0);
                    if (uniqueProductionAreas.get(i).getPreparationStatus() != 3) {
                        uniqueProductionAreas.get(i).setPreparationStatus(0);
                    }

                    //New KDS Added on 7-03-17
                    String txstatus = "ADD";
                    String tableid_unique = uniqueProductionAreas.get(i).getTbl_orderId();
                    dlReceipts.insertServedTransaction(m_oTicket, txstatus, tableid_unique);
                }
                kotaction = 1;
                showMessage(this, "KOT action not happened! Please retry");
            }
        }

    }

    for (int i = 0; i < ticket.getLinesCount(); i++) {
        paintKotTicketLine(i, ticket.getLine(i));
    }
    //        Object[] values = new Object[] {m_oTicket.getPlaceId(), m_oTicket.getName(), m_oTicket,m_oTicket.getSplitSharedId(),m_oTicket.isPrinted(),m_oTicket.isListModified()};
    //        Datas[] datas = new Datas[] {Datas.STRING, Datas.STRING, Datas.SERIALIZABLE, Datas.STRING,Datas.BOOLEAN,Datas.BOOLEAN};
    //        try {
    //            new PreparedSentence(m_App.getSession()
    //          , "UPDATE SHAREDTICKETS SET NAME = ?, CONTENT = ?, ISPRINTED = ?, ISMODIFIED = ? WHERE ID = ? AND SPLITID=? "
    //          , new SerializerWriteBasicExt(datas, new int[] {1, 2, 4, 5, 0,3})).exec(values);
    //        } catch (BasicException ex) {
    //            logger.info("Order NO."+m_oTicket.getOrderId()+" exception in  printRetailKotTicket updating shared ticket"+ex.getMessage());
    //            Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
    //        }
    logger.info("kot lines passing to print" + kotTicketlist.size());
    logger.info("end printing the kot" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
}