8176530: JDK support for JavaFX modal print dialogs

Reviewed-by: serb, psadhukhan, kcr
This commit is contained in:
Phil Race 2017-03-15 11:14:23 -07:00
parent 8f4fb41bd7
commit 1fc6aae658
7 changed files with 125 additions and 2 deletions

View file

@ -785,7 +785,9 @@ public abstract class RasterPrinterJob extends PrinterJob {
PrintService pservice = getPrintService();
PageFormat pageFrmAttrib = attributeToPageFormat(pservice,
attributes);
setParentWindowID(attributes);
PageFormat page = pageDialog(pageFrmAttrib);
clearParentWindowID();
// If user cancels the dialog, pageDialog() will return the original
// page object and as per spec, we should return null in that case.
@ -828,6 +830,9 @@ public abstract class RasterPrinterJob extends PrinterJob {
int x = gcBounds.x+50;
int y = gcBounds.y+50;
ServiceDialog pageDialog;
if (onTop != null) {
attributes.add(onTop);
}
if (w instanceof Frame) {
pageDialog = new ServiceDialog(gc, x, y, service,
DocFlavor.SERVICE_FORMATTED.PAGEABLE,
@ -837,6 +842,7 @@ public abstract class RasterPrinterJob extends PrinterJob {
DocFlavor.SERVICE_FORMATTED.PAGEABLE,
attributes, (Dialog)w);
}
Rectangle dlgBounds = pageDialog.getBounds();
// if portion of dialog is not within the gc boundary
@ -923,7 +929,9 @@ public abstract class RasterPrinterJob extends PrinterJob {
}
setParentWindowID(attributes);
boolean ret = printDialog();
clearParentWindowID();
this.attributes = attributes;
return ret;
@ -2539,4 +2547,26 @@ public abstract class RasterPrinterJob extends PrinterJob {
return new String(out_chars, 0, pos);
}
}
private DialogOnTop onTop = null;
private long parentWindowID = 0L;
/* Called from native code */
private long getParentWindowID() {
return parentWindowID;
}
private void clearParentWindowID() {
parentWindowID = 0L;
onTop = null;
}
private void setParentWindowID(PrintRequestAttributeSet attrs) {
parentWindowID = 0L;
onTop = (DialogOnTop)attrs.get(DialogOnTop.class);
if (onTop != null) {
parentWindowID = onTop.getID();
}
}
}