New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8223717: javafx printing: Support Specifying Print to File in the API #543
Conversation
/csr |
/reviewers 2 |
|
@prrace has indicated that a compatibility and specification (CSR) request is needed for this pull request. |
@kevinrushforth |
Webrevs
|
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java
Outdated
Show resolved
Hide resolved
One more comment on the API for the getters and setter methods.
modules/javafx.graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java
Outdated
Show resolved
Hide resolved
Overall the new API and functionality looks good, and fills a void that was discussed in this thread a couple years ago.
General comments:
-
If the user selects "print to file" from the native dialog, it will write to the
outputFile
property. This should be documented. -
On the question of error handling. There are two types of errors we could consider.
The first, which is the one we had been discussing, is where the URL is a valid file URL, but the program can't write to it, either because we are running with a security manager and the application doesn't have permission, or because we can't write to the output file (e.g., the path doesn't exist or is read-only).
The second is a bad URL. If the URL is malformed or uses an unsupported protocol (anything other than file:
), we could throw IllegalArgumentException, either when the invalid URL is set or when the print job is run. We might want to do this regardless of what we do about the first type of error. This could be done as simple as adding @throws IllegalArgumentException if the url uses a protocol other than "file:"
. What do you think?
For files that can't be written (the first type of error), we have three choices:
-
Define it loosely such that using a file that cannot be written to will either throw an exception when the print job is run or it will be ignored.
-
Define it to always throw an exception. We would need to add validation logic in PrintJob before calling the implementation methods, but we wouldn't necessarily be able to catch all errors (e.g., an IOEXception that only happens after you start writing to the file). This seems like overkill.
-
Define it to never throw an exception. The implementation would need to wrap the call to print in a try / catch, probably logging the result.
I would probably lean towards 1 (which is what you are suggesting), but 3 could work as well.
I left a couple inline comments on the API.
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java
Outdated
Show resolved
Hide resolved
I left a comment on the implementation and a couple on the test inline.
modules/javafx.graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java
Outdated
Show resolved
Hide resolved
The API looks fine now, although I may have some minor wording suggestions after I do another pass tomorrow. Go ahead and file the CSR and move it to proposed as soon as you can to see if Joe has any comments in parallel with our finishing the review.
I also need to do some testing on Mac and Linux (the manual test now works as expected on Windows).
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java
Outdated
Show resolved
Hide resolved
I've added my final comments on the API docs. Some of them are pretty nit-picky, so take them as suggestions.
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java
Outdated
Show resolved
Hide resolved
@prrace This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 19 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
|
/integrate |
Going to push as commit 386f6d7.
Your commit was automatically rebased without conflicts. |
This enhancement adds the String property outputFileProperty() to the JobSettings class.
The value should be a string that references a local file encoded as a URL.
If this is non-null and set to a location that the user has permission to write to,
then the printer output will be spooled there instead of the printer, so long as the platform printing system supports this.
The user can of course also set a print-to-file destination in the platform printer dialogs which may over-ride what the application set. But now the application can also see what it was set to, and cancel or alter it if necessary.
A simple manual test is provided, manual mainly because the few real printing functional tests are all manual as they are only useful if run with a printer configured.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/543/head:pull/543
$ git checkout pull/543
Update a local copy of the PR:
$ git checkout pull/543
$ git pull https://git.openjdk.java.net/jfx pull/543/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 543
View PR using the GUI difftool:
$ git pr show -t 543
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/543.diff