Skip to content
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

Closed
wants to merge 10 commits into from

Conversation

prrace
Copy link
Collaborator

@prrace prrace commented Jun 24, 2021

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

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8223717: javafx printing: Support Specifying Print to File in the API

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

@prrace
Copy link
Collaborator Author

prrace commented Jun 24, 2021

/csr

@kevinrushforth
Copy link
Member

kevinrushforth commented Jun 24, 2021

/reviewers 2

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 24, 2021

👋 Welcome back prr! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the csr label Jun 24, 2021
@openjdk
Copy link

openjdk bot commented Jun 24, 2021

@prrace has indicated that a compatibility and specification (CSR) request is needed for this pull request.
@prrace please create a CSR request for issue JDK-8223717. This pull request cannot be integrated until the CSR request is approved.

@openjdk
Copy link

openjdk bot commented Jun 24, 2021

@kevinrushforth
The number of required reviews for this PR is now set to 2 (with at least 1 of role reviewers).

@openjdk openjdk bot added the rfr label Jun 24, 2021
@mlbridge
Copy link

mlbridge bot commented Jun 24, 2021

Webrevs

Copy link
Member

@kevinrushforth kevinrushforth left a comment

I left some preliminary comments on the API spec.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

One more comment on the API for the getters and setter methods.

@kevinrushforth kevinrushforth self-requested a review Jun 25, 2021
Copy link
Member

@kevinrushforth kevinrushforth left a comment

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:

  1. 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.

  2. 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.

  3. 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.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

I left a comment on the implementation and a couple on the test inline.

@openjdk openjdk bot removed the rfr label Jun 28, 2021
Copy link
Member

@kevinrushforth kevinrushforth left a comment

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).

@prrace
Copy link
Collaborator Author

prrace commented Jun 30, 2021

@openjdk openjdk bot added the rfr label Jun 30, 2021
@kevinrushforth kevinrushforth self-requested a review Jun 30, 2021
Copy link
Member

@kevinrushforth kevinrushforth left a comment

I've added my final comments on the API docs. Some of them are pretty nit-picky, so take them as suggestions.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Looks good.

@openjdk openjdk bot removed the csr label Jul 2, 2021
@openjdk
Copy link

openjdk bot commented Jul 7, 2021

@prrace This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8223717: javafx printing: Support Specifying Print to File in the API

Reviewed-by: kcr, psadhukhan

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 master branch:

  • 52c076c: 8269131: Update libxml2 to version 2.9.12
  • 47c2ec3: 8187229: Tree/TableCell: cancel event must return correct editing location
  • 0e7cf62: 8185447: The special high-contrast mode of JavaFX Controls in Japanese environment do not work.
  • 6403d67: 8231558: [macos] Platform.exit causes assertion error on macOS 10.15 or later
  • 61aff1c: 8258499: JavaFX: Move src.zip out of the lib directory
  • cfa60ff: 8268683: JavaFX MediaPlayer onEndOfMedia behaviour different from Javadoc
  • 098c0f3: 8269147: Update GStreamer to version 1.18.4
  • a1be1d5: 8267418: IntelliJ build and test of JavaFX does not work
  • b0d1586: 8266224: GitHub actions: use gcc 10.3 on Linux
  • 12fb4da: 8269259: Remove obsolete apps, tests, and scripts
  • ... and 9 more: https://git.openjdk.java.net/jfx/compare/13cffbaad4068177d2d3239fa297302c3f94c217...master

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Jul 7, 2021
@prrace
Copy link
Collaborator Author

prrace commented Jul 7, 2021

/integrate

@openjdk
Copy link

openjdk bot commented Jul 7, 2021

Going to push as commit 386f6d7.
Since your change was applied there have been 20 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jul 7, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jul 7, 2021
@openjdk
Copy link

openjdk bot commented Jul 7, 2021

@prrace Pushed as commit 386f6d7.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated
5 participants