Community
Participate
Working Groups
- open text file - File / Print - check Print to File, hit OK - it tries to send it to the printer, and does not even prompt for a file NOTES: NE (10/1/2001 11:34:48 AM) Most likely an SWT bug, since TextViewer.print() just creates a Printer from the PrinterData returned by the PrintDialog.
PRODUCT VERSION: 137
Has this been fixed? Pls, mark as either FIXED or LATER as appropriate.
The file name to print to is supposed to be completely up to the application. We didn't want SWT to gratuitously bring up a FileDialog. For example, what if the application wanted to specify the file name without asking the user? So the original intent of the printing API was for the application to: - check if the user set the "PrintToFile" bit (PrinterData.printToFile) - if so, open a FileDialog and ask the user to choose a file name - set the "fileName" field of the PrinterData to the user's chosen name - then create the Printer using the PrinterData, and start the print job However, having said that, I have discovered a little-used "feature" of Windows printing that will bring up a (very ugly) text-entry dialog if "Print To File" was selected and no filename was specified. I do warn you that this dialog is very ugly, and to be honest, I haven't seen anything like it in many years. :) If you prefer not to use the current printer API, I can turn on this feature (if McQ and Steve think it's ok) and you won't have to write any further code. However, I think you would probably prefer to bring up your own FileDialog and set the PrinterData's fileName field. Much prettier. I guess I should turn on this feature in either case (as a default), because it is confusing to the user to have the file sent to the printer when they check "Print To File". McQ, Nick - comments? Drop by to see the ugly text dialog.
I know what the "ugly"dialog looks like. I think it should be enabled, if we can easily do it. I also think that the javadoc needs to include the description of the right way to enable print to file, so well behaved applications don't need to use the ugly one.
SWT should at least give the ugly text dialog. However, I don't see why the app needs to get involved here. It would be better if SWT used a nice file dialog by default. Deluxe would be to allow the app to override this if needed.
The reason I think the app should get involved is because I think it's possible that some application might want to always use some hardcoded file name. Or maybe they have already asked the user for a filename and don't want to ask again. Or maybe they are running headless and they want to force the output to go to a file (to do this, they set the "printToFile" flag in the PrinterData as well as setting the "fileName" field - you don't need the PrintDialog at all). I just thought it was restrictive for us to bring up a FileDialog, even if it can be overridden. I have released the "ugly" dialog and I will mark this PR fixed, but a new PR can be opened to consider changing the behavior post 2.0. McQ, please verify.
Our code needs to ensure that people who relied on the old behavior will continue to work. We need to *detect* that the ugly dialog was activated and use the name from it only in that case.
Yes, this case is covered.
*** Bug 5126 has been marked as a duplicate of this bug. ***