Skip to content

Commit

Permalink
8295324: Apply patch with junit from the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardsdv committed Oct 14, 2022
1 parent 9768b5e commit c76b820
Show file tree
Hide file tree
Showing 6 changed files with 443 additions and 7 deletions.
Expand Up @@ -153,17 +153,25 @@ public J2DPrinterJob(javafx.print.PrinterJob fxJob) {
fxPrinter = fxPrinterJob.getPrinter();
j2dPrinter = getJ2DPrinter(fxPrinter);
settings = fxPrinterJob.getJobSettings();
pJob2D = java.awt.print.PrinterJob.getPrinterJob();
pJob2D = createPrinterJob();
try {
pJob2D.setPrintService(j2dPrinter.getService());
} catch (PrinterException pe) {
}
printReqAttrSet = new HashPrintRequestAttributeSet();
printReqAttrSet.add(DialogTypeSelection.NATIVE);
j2dPageable = new J2DPageable();
j2dPageable = createJ2dPageable();
pJob2D.setPageable(j2dPageable);
}

protected java.awt.print.PrinterJob createPrinterJob() {
return java.awt.print.PrinterJob.getPrinterJob();
}

protected J2DPageable createJ2dPageable() {
return new J2DPageable();
}

private void setEnabledState(Window owner, boolean state) {
if (owner == null) {
return;
Expand Down Expand Up @@ -1035,7 +1043,7 @@ public void run() {
}
}

private class J2DPageable implements Pageable, Printable {
protected class J2DPageable implements Pageable, Printable {

private volatile boolean pageDone;

Expand All @@ -1061,7 +1069,7 @@ private boolean waitForNextPage(int pageIndex) {
}
}
currPageInfo = null;
pageDone = true;
setPageDone(true);
synchronized (monitor) {
if (newPageInfo == null) {
monitor.notify(); // page is printed and no new page to print
Expand Down Expand Up @@ -1171,6 +1179,10 @@ public Printable getPrintable(int pageIndex) {
return this;
}

protected PageFormat getCurrentPageFormat() {
return currPageFormat;
}

public PageFormat getPageFormat(int pageIndex) {
getPage(pageIndex);
return currPageFormat;
Expand Down Expand Up @@ -1202,7 +1214,7 @@ private void implPrintPage(PageLayout pageLayout, Node node) {
* So, when we are in here, we know that the app is providing
* the info for the next page.
*/
pageDone = false;
setPageDone(false);
synchronized (monitor) {
newPageInfo = new PageInfo(pageLayout, node);
monitor.notify();
Expand All @@ -1225,6 +1237,10 @@ private void implPrintPage(PageLayout pageLayout, Node node) {
}
}

protected void setPageDone(boolean pageDone) {
this.pageDone = pageDone;
}

} /* END J2DPageable class */


Expand Down
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package javafx.print;

public class PageLayoutShim {

public static PageLayout createPageLayout(Paper paper, PageOrientation orient){
return new PageLayout(paper, orient);
}

}
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package javafx.print;

import com.sun.javafx.print.PrinterImpl;

public class PrinterShim {
public static Printer createPrinter(PrinterImpl impl) {
return new Printer(impl);
}
}
2 changes: 2 additions & 0 deletions modules/javafx.graphics/src/test/addExports
Expand Up @@ -40,11 +40,13 @@
--add-exports javafx.graphics/com.sun.prism.impl.shape=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.prism=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.prism.paint=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.prism.j2d.print=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.scenario.animation=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.scenario.animation.shared=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.scenario.effect=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.scenario.effect.light=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.scenario=ALL-UNNAMED
--add-exports javafx.graphics/sun.print=ALL-UNNAMED
--add-opens javafx.graphics/javafx.scene=ALL-UNNAMED
--add-opens javafx.graphics/javafx.scene.robot=ALL-UNNAMED
--add-opens javafx.graphics/javafx.scene.layout=ALL-UNNAMED
Expand Down
Expand Up @@ -98,6 +98,9 @@ public class StubToolkit extends Toolkit {

private ScreenConfiguration[] screenConfigurations = DEFAULT_SCREEN_CONFIG;

// By default, always on the FX app thread
private boolean fxUserThread = true;

static {
try {
// ugly hack to initialize "runLater" method in Platform.java
Expand Down Expand Up @@ -153,8 +156,11 @@ public void checkFxUserThread() {

@Override
public boolean isFxUserThread() {
// Always on the FX app thread
return true;
return fxUserThread;
}

public void setFxUserThread(boolean fxUserThread) {
this.fxUserThread = fxUserThread;
}

@Override
Expand Down

0 comments on commit c76b820

Please sign in to comment.