Index: wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLDesignMultiViewElement.java =================================================================== RCS file: /cvs/xml/wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/Attic/WSDLDesignMultiViewElement.java,v retrieving revision 1.1.4.5 diff -d -u -r1.1.4.5 WSDLDesignMultiViewElement.java --- wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLDesignMultiViewElement.java 8 Jan 2007 20:11:40 -0000 1.1.4.5 +++ wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLDesignMultiViewElement.java 10 Jan 2007 23:44:38 -0000 @@ -31,6 +31,8 @@ import java.awt.BorderLayout; import java.awt.Color; import java.io.IOException; +import java.util.Date; +import javax.swing.JComponent; import javax.swing.JToolBar; import javax.swing.UIManager; @@ -38,6 +40,8 @@ import org.netbeans.core.spi.multiview.MultiViewElement; import org.netbeans.core.spi.multiview.MultiViewElementCallback; import org.netbeans.core.spi.multiview.MultiViewFactory; +import org.netbeans.modules.print.spi.PrintProvider; +import org.netbeans.modules.print.spi.PrintProviderCookie; import org.netbeans.modules.xml.validation.ShowCookie; import org.netbeans.modules.xml.validation.ValidateAction; import org.netbeans.modules.xml.wsdl.model.WSDLModel; @@ -94,12 +98,11 @@ String errorMessage, String recommmendedCorrection) { assert false:"ShowCookie.showComponent method is deprecated"; } - - + public void show(ResultItem resultItem) { - Component component = resultItem.getComponents(); - - } +// Component component = resultItem.getComponents(); + // TODO: show the corresponding widget in the scene + } }; Node delegate = mObj.getNodeDelegate(); @@ -114,7 +117,9 @@ // project is closed. mObj, // The Show Cookie in lookup to show the component - showCookie + showCookie, + // Provides the PrintProvider for printing + new DesignViewPrintProvider(), }), nodesMediator.getLookup(), // The Node delegate Lookup must be the last one in the list @@ -365,5 +370,28 @@ super.requestFocusInWindow(); // Ensure the graph widgets have the focus. return graphComponent.requestFocusInWindow(); + } + + /** + * Provides the PrintProvider which allows us to print the design view + * to a printer using the Print API. + */ + private class DesignViewPrintProvider implements PrintProviderCookie { + + public PrintProvider getPrintProvider() { + return new PrintProvider.Component() { + public String getName() { + return mObj.getName(); + } + + public Date getLastModifiedDate() { + return mObj.getPrimaryFile().lastModified(); + } + + public JComponent getComponent() { + return graphComponent.getContent(); + } + }; + } } } Index: wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLEditorSupport.java =================================================================== RCS file: /cvs/xml/wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLEditorSupport.java,v retrieving revision 1.1.2.23.6.1 diff -d -u -r1.1.2.23.6.1 WSDLEditorSupport.java --- wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLEditorSupport.java 16 Nov 2006 01:55:00 -0000 1.1.2.23.6.1 +++ wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLEditorSupport.java 10 Jan 2007 23:44:38 -0000 @@ -45,7 +45,6 @@ import org.openide.cookies.EditorCookie; import org.openide.cookies.LineCookie; import org.openide.cookies.OpenCookie; -import org.openide.cookies.PrintCookie; import org.openide.filesystems.FileLock; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; @@ -69,7 +68,7 @@ */ public class WSDLEditorSupport extends DataEditorSupport implements WSDLModelCookie, OpenCookie, EditCookie, - EditorCookie.Observable, LineCookie, CloseCookie, PrintCookie { + EditorCookie.Observable, LineCookie, CloseCookie { /** Used for managing the prepareTask listener. */ private transient Task prepareTask2; Index: wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLMultiViewSupport.java =================================================================== RCS file: /cvs/xml/wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLMultiViewSupport.java,v retrieving revision 1.1.2.11 diff -d -u -r1.1.2.11 WSDLMultiViewSupport.java --- wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLMultiViewSupport.java 24 Aug 2006 23:15:47 -0000 1.1.2.11 +++ wsdlui/src/org/netbeans/modules/xml/wsdl/ui/netbeans/module/WSDLMultiViewSupport.java 10 Jan 2007 23:44:38 -0000 @@ -5,7 +5,7 @@ * * You can obtain a copy of the License at http://www.netbeans.org/cddl.html * or http://www.netbeans.org/cddl.txt. - + * * When distributing Covered Code, include this CDDL Header Notice in each file * and include the License file at http://www.netbeans.org/cddl.txt. * If applicable, add the following below the CDDL Header, with the fields @@ -24,25 +24,30 @@ import org.netbeans.core.api.multiview.MultiViewHandler; import org.netbeans.core.api.multiview.MultiViewPerspective; import org.netbeans.core.api.multiview.MultiViews; +import org.netbeans.modules.print.spi.PrintProvider; +import org.netbeans.modules.print.spi.PrintProviderCookie; import org.netbeans.modules.xml.validation.ShowCookie; -import org.netbeans.modules.xml.wsdl.model.WSDLComponent; import org.netbeans.modules.xml.wsdl.model.WSDLModel; import org.netbeans.modules.xml.xam.Component; import org.netbeans.modules.xml.xam.dom.DocumentComponent; import org.netbeans.modules.xml.xam.spi.Validator.ResultItem; import org.netbeans.modules.xml.xam.ui.cookies.ViewComponentCookie; +import org.netbeans.modules.xml.xam.ui.cookies.ViewComponentCookie.View; +import org.openide.loaders.DataObject; +import org.openide.util.Lookup; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; /** - * Implementation of ViewComponentCookie, ShowCookie + * Implementation of various cookie interfaces, in particular + * ViewComponentCookie and ShowCookie. * The instance of this class is in the WSDLDataObject cookie set. * - * - * * @author Ajit Bhate + * @author Nathan Fiedler */ -public class WSDLMultiViewSupport implements ViewComponentCookie, ShowCookie { +public class WSDLMultiViewSupport implements ViewComponentCookie, ShowCookie, + PrintProviderCookie { /** The data object */ private WSDLDataObject dobj; @@ -151,5 +156,21 @@ view(View.SOURCE, component, resultItem); } } - } + } + + public PrintProvider getPrintProvider() { + TopComponent component = TopComponent.getRegistry().getActivated(); + Lookup lookup = component.getLookup(); + DataObject dobj = (DataObject) lookup.lookup(DataObject.class); + if (dobj == this.dobj) { + PrintProviderCookie cookie = (PrintProviderCookie) lookup.lookup( + PrintProviderCookie.class); + // Avoid looping forever by ensuring we find a provider that + // is not ourselves. + if (cookie != null && cookie != this) { + return cookie.getPrintProvider(); + } + } + return null; + } } Index: wsdlui/src/org/netbeans/modules/xml/wsdl/ui/view/grapheditor/GraphView.java =================================================================== RCS file: /cvs/xml/wsdlui/src/org/netbeans/modules/xml/wsdl/ui/view/grapheditor/Attic/GraphView.java,v retrieving revision 1.1.4.14 diff -d -u -r1.1.4.14 GraphView.java --- wsdlui/src/org/netbeans/modules/xml/wsdl/ui/view/grapheditor/GraphView.java 2 Jan 2007 22:56:20 -0000 1.1.4.14 +++ wsdlui/src/org/netbeans/modules/xml/wsdl/ui/view/grapheditor/GraphView.java 10 Jan 2007 23:44:39 -0000 @@ -130,6 +130,16 @@ } /** + * Return the view content, suitable for printing (i.e. without a + * scroll pane, which would result in the scroll bars being printed). + * + * @return the view content, sans scroll pane. + */ + public JComponent getContent() { + return scene.getView(); + } + + /** * Adds the graph actions to the given toolbar (no separators are added). * * @param toolbar to which the actions are added.