more printer debugging; print all printers and attributes
authorBill Erickson <berick@esilibrary.com>
Mon, 24 Feb 2014 17:04:14 +0000 (12:04 -0500)
committerBill Erickson <berick@esilibrary.com>
Mon, 24 Feb 2014 17:04:14 +0000 (12:04 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
src/org/evergreen_ils/hatch/PrintDriver.java

index c93ee3b..79a013a 100644 (file)
@@ -81,19 +81,29 @@ public class PrintDriver implements Printable {
 
     private void debugPrintService(PrintService printer) {
 
-        if (printer == null) {
-            printer = PrintServiceLookup.lookupDefaultPrintService();
-            if (printer == null) {
-                logger.warn("No print service found in debugPrintService()");
-                return;
-            }
+        PrintService[] printServices;
+        String defaultPrinter = "";
+
+        if (printer != null) {
+            printServices = new PrintService[] {printer};
+        } else {
+            printServices = PrintServiceLookup.lookupPrintServices(null, null);
+            PrintService def = PrintServiceLookup.lookupDefaultPrintService();
+            if (def != null) defaultPrinter = def.getName();
         }
-        AttributeSet attributes = printer.getAttributes();
-        for (Attribute a : attributes.toArray()) {
-            String name = a.getName();
-            String value = attributes.get(a.getClass()).toString();
-            logger.info("Printer Debug: " + name + " => " + value);
+
+        for (PrintService service : printServices) {
+            logger.info("Printer Debug: found printer " + service.getName());
+            if (service.getName().equals(defaultPrinter)) {
+                logger.info("    Printer Debug: Is Default");
+            }
+
+            AttributeSet attributes = service.getAttributes();
+            for (Attribute a : attributes.toArray()) {
+                String name = a.getName();
+                String value = attributes.get(a.getClass()).toString();
+                logger.info("    Printer Debug: " + name + " => " + value);
+            }
         }
     }