harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apavle...@apache.org
Subject svn commit: r595261 - /harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/print/PrinterJobImpl.java
Date Thu, 15 Nov 2007 10:32:42 GMT
Author: apavlenko
Date: Thu Nov 15 02:32:42 2007
New Revision: 595261

URL: http://svn.apache.org/viewvc?rev=595261&view=rev
Log:
The method pageDialog(PrintRequestAttributeSet) should store all page settings in the user's
attribute set passed to the method.

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/print/PrinterJobImpl.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/print/PrinterJobImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/print/PrinterJobImpl.java?rev=595261&r1=595260&r2=595261&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/print/PrinterJobImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/print/PrinterJobImpl.java
Thu Nov 15 02:32:42 2007
@@ -66,6 +66,11 @@
 
     @Override
     public PrintService getPrintService() {
+        if (printService == null) {
+            printService = PrintServiceLookup.lookupDefaultPrintService();
+            printService = isServiceSupported(printService) ? printService
+                            : null;
+        }
         return printService;
     }
 
@@ -130,15 +135,8 @@
     @Override
     public PageFormat pageDialog(final PrintRequestAttributeSet attributes)
                     throws HeadlessException {
-        return pageDialog(attrsToFormat(attributes));
-    }
-
-    @Override
-    public PageFormat pageDialog(final PageFormat page)
-                    throws HeadlessException {
         checkHeadless();
 
-        final PrintRequestAttributeSet attributes = formatToAttrs(page);
         final Window wnd = KeyboardFocusManager
                         .getCurrentKeyboardFocusManager().getActiveWindow();
         final Window owner = (((wnd instanceof Dialog) || (wnd instanceof Frame))
@@ -156,8 +154,19 @@
             owner.dispose();
         }
 
+        if (attributes != dialog.getAttributes()) {
+            attributes.addAll(dialog.getAttributes());
+        }
+
         return (dialog.getResult() == ServiceUIDialog.APPROVE_PRINT)
-                        ? attrsToFormat(attributes) : page;
+                        ? attrsToFormat(attributes) : null;
+    }
+
+    @Override
+    public PageFormat pageDialog(final PageFormat page)
+                    throws HeadlessException {
+        final PageFormat format = pageDialog(formatToAttrs(page));
+        return format != null ? format : page;
     }
 
     @Override
@@ -174,8 +183,7 @@
         }
 
         final PrintRequestAttributeSet attrs = mergeAttrs(attributes);
-        final PrintService service = printService != null ? printService
-                        : PrintServiceLookup.lookupDefaultPrintService();
+        final PrintService service = getPrintService();
 
         if (service == null) {
             // Printer not found
@@ -207,16 +215,12 @@
         }
 
         final PrintRequestAttributeSet attrs = mergeAttrs(attributes);
-        final PrintService defaultPrintService = PrintServiceLookup
-                        .lookupDefaultPrintService();
         final Rectangle screen = GraphicsEnvironment
                         .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                         .getDefaultConfiguration().getBounds();
         final PrintService newService = ServiceUI.printDialog(null,
                         screen.width / 3, screen.height / 3,
-                        lookupPrintServices(),
-                        (isServiceSupported(defaultPrintService)
-                                        ? defaultPrintService : null),
+                        lookupPrintServices(), getPrintService(),
                         DocFlavor.SERVICE_FORMATTED.PRINTABLE, attrs);
 
         if (newService != null) {
@@ -271,9 +275,8 @@
     }
 
     private static boolean isServiceSupported(final PrintService service) {
-        return (service != null)
-                        && service
-                                        .isDocFlavorSupported(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
+        return (service != null) && service.isDocFlavorSupported(
+                        DocFlavor.SERVICE_FORMATTED.PAGEABLE);
     }
 
     private static PrintRequestAttributeSet formatToAttrs(



Mime
View raw message