461 } 462 } 463 // Update attributes, this will preserve the page settings. 464 // - same code as in RasterPrinterJob.java 465 updatePageAttributes(myService, pageClone); 466 467 return pageClone; 468 } else { 469 return page; 470 } 471 } 472 473 474 private boolean displayNativeDialog() { 475 // "attributes" is required for getting the updated attributes 476 if (attributes == null) { 477 return false; 478 } 479 480 DialogOwner dlgOwner = (DialogOwner)attributes.get(DialogOwner.class); 481 Frame ownerFrame = (dlgOwner != null) ? dlgOwner.getOwner() : null; 482 483 WPrintDialog dialog = new WPrintDialog(ownerFrame, this); 484 dialog.setRetVal(false); 485 dialog.setVisible(true); 486 boolean prv = dialog.getRetVal(); 487 dialog.dispose(); 488 489 Destination dest = 490 (Destination)attributes.get(Destination.class); 491 if ((dest == null) || !prv){ 492 return prv; 493 } else { 494 String title = null; 495 String strBundle = "sun.print.resources.serviceui"; 496 ResourceBundle rb = ResourceBundle.getBundle(strBundle); 497 try { 498 title = rb.getString("dialog.printtofile"); 499 } catch (MissingResourceException e) { 500 } 501 FileDialog fileDialog = new FileDialog(ownerFrame, title, 502 FileDialog.SAVE); 503 504 URI destURI = dest.getURI(); 505 // Old code destURI.getPath() would return null for "file:out.prn" 506 // so we use getSchemeSpecificPart instead. 507 String pathName = (destURI != null) ? 508 destURI.getSchemeSpecificPart() : null; 509 if (pathName != null) { 510 File file = new File(pathName); 511 fileDialog.setFile(file.getName()); 512 File parent = file.getParentFile(); 513 if (parent != null) { 514 fileDialog.setDirectory(parent.getPath()); 515 } 516 } else { 517 fileDialog.setFile("out.prn"); 518 } 519 520 fileDialog.setVisible(true); 521 String fileName = fileDialog.getFile(); 522 if (fileName == null) { 523 fileDialog.dispose(); 524 return false; 525 } 526 String fullName = fileDialog.getDirectory() + fileName; 527 File f = new File(fullName); 528 File pFile = f.getParentFile(); 529 while ((f.exists() && 530 (!f.isFile() || !f.canWrite())) || 531 ((pFile != null) && 532 (!pFile.exists() || (pFile.exists() && !pFile.canWrite())))) { 533 534 (new PrintToFileErrorDialog(ownerFrame, 535 ServiceDialog.getMsg("dialog.owtitle"), 536 ServiceDialog.getMsg("dialog.writeerror")+" "+fullName, 537 ServiceDialog.getMsg("button.ok"))).setVisible(true); 538 539 fileDialog.setVisible(true); 540 fileName = fileDialog.getFile(); 541 if (fileName == null) { 542 fileDialog.dispose(); 543 return false; 544 } 545 fullName = fileDialog.getDirectory() + fileName; 546 f = new File(fullName); 547 pFile = f.getParentFile(); 548 } 549 fileDialog.dispose(); 550 attributes.add(new Destination(f.toURI())); 551 return true; 552 } 553 554 } 555 556 /** 557 * Presents the user a dialog for changing properties of the | 461 } 462 } 463 // Update attributes, this will preserve the page settings. 464 // - same code as in RasterPrinterJob.java 465 updatePageAttributes(myService, pageClone); 466 467 return pageClone; 468 } else { 469 return page; 470 } 471 } 472 473 474 private boolean displayNativeDialog() { 475 // "attributes" is required for getting the updated attributes 476 if (attributes == null) { 477 return false; 478 } 479 480 DialogOwner dlgOwner = (DialogOwner)attributes.get(DialogOwner.class); 481 Window owner = (dlgOwner != null) ? dlgOwner.getOwner() : null; 482 483 WPrintDialog dialog = (owner instanceof Frame) ? 484 new WPrintDialog((Frame)owner, this) : 485 new WPrintDialog((Dialog)owner, this); 486 487 dialog.setRetVal(false); 488 dialog.setVisible(true); 489 boolean prv = dialog.getRetVal(); 490 dialog.dispose(); 491 492 Destination dest = 493 (Destination)attributes.get(Destination.class); 494 if ((dest == null) || !prv){ 495 return prv; 496 } else { 497 String title = null; 498 String strBundle = "sun.print.resources.serviceui"; 499 ResourceBundle rb = ResourceBundle.getBundle(strBundle); 500 try { 501 title = rb.getString("dialog.printtofile"); 502 } catch (MissingResourceException e) { 503 } 504 FileDialog fileDialog = (owner instanceof Frame) ? 505 new FileDialog((Frame)owner, title, FileDialog.SAVE) : 506 new FileDialog((Dialog)owner, title, FileDialog.SAVE); 507 508 URI destURI = dest.getURI(); 509 // Old code destURI.getPath() would return null for "file:out.prn" 510 // so we use getSchemeSpecificPart instead. 511 String pathName = (destURI != null) ? 512 destURI.getSchemeSpecificPart() : null; 513 if (pathName != null) { 514 File file = new File(pathName); 515 fileDialog.setFile(file.getName()); 516 File parent = file.getParentFile(); 517 if (parent != null) { 518 fileDialog.setDirectory(parent.getPath()); 519 } 520 } else { 521 fileDialog.setFile("out.prn"); 522 } 523 524 fileDialog.setVisible(true); 525 String fileName = fileDialog.getFile(); 526 if (fileName == null) { 527 fileDialog.dispose(); 528 return false; 529 } 530 String fullName = fileDialog.getDirectory() + fileName; 531 File f = new File(fullName); 532 File pFile = f.getParentFile(); 533 while ((f.exists() && 534 (!f.isFile() || !f.canWrite())) || 535 ((pFile != null) && 536 (!pFile.exists() || (pFile.exists() && !pFile.canWrite())))) { 537 538 if (owner instanceof Frame) { 539 (new PrintToFileErrorDialog((Frame)owner, 540 ServiceDialog.getMsg("dialog.owtitle"), 541 ServiceDialog.getMsg("dialog.writeerror")+" "+fullName, 542 ServiceDialog.getMsg("button.ok"))).setVisible(true); 543 } else { 544 (new PrintToFileErrorDialog((Dialog)owner, 545 ServiceDialog.getMsg("dialog.owtitle"), 546 ServiceDialog.getMsg("dialog.writeerror")+" "+fullName, 547 ServiceDialog.getMsg("button.ok"))).setVisible(true); 548 } 549 550 fileDialog.setVisible(true); 551 fileName = fileDialog.getFile(); 552 if (fileName == null) { 553 fileDialog.dispose(); 554 return false; 555 } 556 fullName = fileDialog.getDirectory() + fileName; 557 f = new File(fullName); 558 pFile = f.getParentFile(); 559 } 560 fileDialog.dispose(); 561 attributes.add(new Destination(f.toURI())); 562 return true; 563 } 564 565 } 566 567 /** 568 * Presents the user a dialog for changing properties of the |