Re: RFR: 8223717: javafx printing: Support Specifying Print to File in the API [v4]
On Mon, 28 Jun 2021 19:47:39 GMT, Phil Race wrote: >> 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. > > Phil Race has updated the pull request incrementally with one additional > commit since the last revision: > > 8223717: javafx printing: Support Specifying Print to File in the API CSR: https://bugs.openjdk.java.net/browse/JDK-8269642 - PR: https://git.openjdk.java.net/jfx/pull/543
Re: RFR: 8223717: javafx printing: Support Specifying Print to File in the API [v4]
On Mon, 28 Jun 2021 19:47:39 GMT, Phil Race wrote: >> 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. > > Phil Race has updated the pull request incrementally with one additional > commit since the last revision: > > 8223717: javafx printing: Support Specifying Print to File in the API 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 line 503: > 501: * If a {@code SecurityManager} is installed and it denies access to > the > 502: * specified file a {@code SecurityException} may be thrown. > 503: * @defaultValue an empty String Minor: I recommend either `string` (lower case) or `{@code String}`. Very minor: can you move the `@defaultValue` below the blank like with the other javadoc tags? - PR: https://git.openjdk.java.net/jfx/pull/543
Re: RFR: 8223717: javafx printing: Support Specifying Print to File in the API [v4]
On Thu, 24 Jun 2021 22:53:33 GMT, Phil Race wrote: >> modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java line 490: >> >>> 488: * setting will be ignored. >>> 489: * If the URL specifies a non-existent path, or does not specify >>> 490: * a writable file it may be ignored, or a SecurityException may >>> be thrown. >> >> I want to look at what we do for other properties like this. I'm not sure >> how feasible it is to throw an exception back to the application. And I >> wouldn't want to single out a security exception (what about a read-only >> file system?). I think that whatever the reason, if the file can't be >> written to, we should treat it consistently. Probably by ignoring the >> request. I presume that's what will happen if the print driver doesn't >> support print-to-file? > > Not easy to specify exactly. We are handing it off to 2D > We aren't doing any up-front verification here, but I don't want to copy 2D > behaviour into the docs, even if I could be sure about that .. I may just > want to be more waffly about what happens. > Could be printed to the printer, could be a failed job, could be an exception > of some kind if some nice piece of Java code recognises a problem up-front So the SE will occur only if there is a SM and the code in J2DPrinterJob.checkPermission() rejects it. - PR: https://git.openjdk.java.net/jfx/pull/543
Re: RFR: 8223717: javafx printing: Support Specifying Print to File in the API [v4]
On Fri, 25 Jun 2021 21:08:31 GMT, Kevin Rushforth wrote: >> I agree with @kevinrushforth that if a String without protocol is passed, it >> should be treated as a file (absolute or relative to ?) >> I'm also not sure that the URL should be exposed here. I understand it's >> needed in the lower-level print API but you already do the conversion in the >> `syncOutputFile` method. Hence, since only the file protocol is supported, >> it might be easier for API users to pass the location of the file instead of >> a URL. >> In case later other URL protocols are supported, a property `outputURL` >> might be introduced? > > I like the flexibility and consistency of defining it as a URL, as long as we > also interpret a url without a scheme as a file name. Borrowing language from > the Image docs, perhaps something like this? > > > The URL string can either be a URL with a "file:" protocol that can be > resolved > by @link java.net.URL} or a file path that can be resolved by {@link > java.io.File}. I am changing it to be just a file path. We can extend it later if ever needed. It does simplify the code and the potential for errors. - PR: https://git.openjdk.java.net/jfx/pull/543
Re: RFR: 8223717: javafx printing: Support Specifying Print to File in the API [v4]
> 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. Phil Race has updated the pull request incrementally with one additional commit since the last revision: 8223717: javafx printing: Support Specifying Print to File in the API - Changes: - all: https://git.openjdk.java.net/jfx/pull/543/files - new: https://git.openjdk.java.net/jfx/pull/543/files/8050d5f9..34221a95 Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jfx&pr=543&range=03 - incr: https://webrevs.openjdk.java.net/?repo=jfx&pr=543&range=02-03 Stats: 85 lines in 3 files changed: 21 ins; 38 del; 26 mod Patch: https://git.openjdk.java.net/jfx/pull/543.diff Fetch: git fetch https://git.openjdk.java.net/jfx pull/543/head:pull/543 PR: https://git.openjdk.java.net/jfx/pull/543