This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 115769 - New PrintAction implementation is broken
Summary: New PrintAction implementation is broken
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Print (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Vladimir Yaroslavskiy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-18 00:08 UTC by pblemel
Modified: 2007-09-26 14:06 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pblemel 2007-09-18 00:08:29 UTC
PrintAction is no longer based on PrintCookie.  There is a posting on the mailing list that says it has 
been "simplified" and that to enable Print/Preview actions one must add

putClientProperty(java.awt.print.Printable.class, "");

to a swing component.  This breaks the functionality of anything presently using PrintCookie.  It appears that the 
implementation makes it possible to *only* print Swing components from the Print actions (with no additional logic 
possible).   

If this is true, then it's a serious defect.  This issue is specifically against PrintAction.  Is there a work around, 
short of removing PrintAction from the layer and adding my own "copy of it" that works correctly?   I have all of my 
Print code, including Pageables, Printables, etc, working in 5.5.1.  I don't mind changing it a bit.  Is there a 
cookie, listener, or property that must be set so that the platform will invoke a method of my own used when this new 
Print implementation wants to know the number of pages, and what is on each page, etc?  

This may not be a bug, however I posted on the mailing list and got no reply so I assume that it is at least a 
documentation issue and most likely a bug.
Comment 1 Vladimir Yaroslavskiy 2007-09-18 15:29:53 UTC
Which version of NetBeans do you use: Java, Mobility, ..., or Full version?
Comment 2 Vladimir Yaroslavskiy 2007-09-18 15:38:34 UTC
New version of Print and Print Preview is available in Full version only (in soa1 cluster).
So, it is important to know your configuration.
Comment 3 pblemel 2007-09-18 15:46:18 UTC
While I am developing I am using the full version (6.0 B1), however it would be terrible to force my RCP app to include 
the full version's worth of modules!  That would make the size of the application explode just to get functions back 
that were already working.
Comment 4 Vladimir Yaroslavskiy 2007-09-18 17:47:24 UTC
Please try with small version (without SOA pack) to be sure that PrintProvider from openide works fine.
Comment 5 pblemel 2007-09-18 18:36:10 UTC
I don't mean to be completely obtuse, but I just googled PrintProvider and nothing turns up but the source code for PrintProvider.java itself.   How does one 
go about using it?   Does the node need to impliment it instead of PrintCookie?
Comment 6 pblemel 2007-09-18 20:23:58 UTC
I've been thrashing around with this for a couple of hours now, without success.

org.openide.modules.print doesn't show up in the filtered list of modules until I check "Show non IDE modules", at which point I can add the module 
dependencies for Print/PrintAPI.

Having done that, I get an error that my module is not a friend of org-netbeans-modules-print.jar or print-api.jar.

What would you like me to try next?   Even if you could just sketch out the basic steps, I could write a tutorial for the wiki -- but I really need to get printing 
working again.

Comment 7 Vladimir Yaroslavskiy 2007-09-19 12:36:04 UTC
To clear situation:

1. NetBeans (version Java, C++, Ruby, Mobility, J2EE etc. - not Full version) has only one Print action in File menu.
   No Print Preview action. This action lives in openide and operates with PrintCookie from org.openide.cookies package.
  
   If you have Print Preview action (enabled or disabled) - it is Full version.
   
   PS. I downloaded the Java build 20070919044214 and tried to print a java source: I see empty page
   with header/footer only. I think that it is a bug in editor. Please file it against openide or editor.
   PrintContainer doesn't work for BaseDocument.

2. Full version of NetBeans (it has netbeans/soa1 folder in installation directory) has Print and Print Preview actions.
   New version of Print action overrides old action. New version of Print action doesn't work with PrintCookie,
   it is a bug and I'll fix it in a few days.

3. Print Preview (and Print) action works with PrintProvder from o.n.m.print.spi package. If you wish that your data
   will be printable, you should put implemented print provider in lookup of your topComponent or dataObject.
   In this case your module must a friend of print.api because packages are not real public (it will happen in
   future). Let me know and I'll add your module in the list of friends. Note that API/SPI is under discussion
   and may be little bit changed.

4. All text sources (java, text, c++, html, xml, etc.) in editor are printable and available in print preview.
   You should not do anything in this case. There are a lot of options of text printing.

5. If your data is represented by javax.swing.JComponent (or class which extends it) you may not be a friend
   of print.api and has dependency on it. Just add one line in your code:
   
   putClientProperty(java.awt.print.Printable.class, <name>);

Let me know if your have questions/comments.
Comment 8 Vladimir Yaroslavskiy 2007-09-26 14:06:55 UTC
fixed.