# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. Index: print/api/src/org/netbeans/modules/print/Trampoline.java --- print/api/src/org/netbeans/modules/print/Trampoline.java No Base Revision +++ print/api/src/org/netbeans/modules/print/Trampoline.java Locally New @@ -0,0 +1,40 @@ +/* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * 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 + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Portions Copyrighted 2007 Sun Microsystems, Inc. + */ +package org.netbeans.modules.print; + +import org.netbeans.modules.print.api.PrintManager; +import org.netbeans.modules.print.spi.PrintProvider; +import org.openide.util.Exceptions; + +/** + * + * @author Jaroslav Tulach + */ +public abstract class Trampoline { + + public static Trampoline API; + static { + try { + Class.forName(PrintManager.Job.class.getName(), true, Trampoline.class.getClassLoader()); + } catch (ClassNotFoundException ex) { + Exceptions.printStackTrace(ex); + } + } + + public abstract PrintManager.Job createJob(PrintProvider p); + public abstract PrintProvider findProvider(PrintManager.Job job); +} Index: print/api/src/org/netbeans/modules/print/api/PrintManager.java --- print/api/src/org/netbeans/modules/print/api/PrintManager.java Base (1.4) +++ print/api/src/org/netbeans/modules/print/api/PrintManager.java Locally Modified (Based On 1.4) @@ -41,6 +41,8 @@ package org.netbeans.modules.print.api; import javax.swing.Action; +import org.netbeans.modules.print.Trampoline; +import org.netbeans.modules.print.api.PrintManager.Job; import org.netbeans.modules.print.spi.PrintProvider; /** @@ -51,15 +53,38 @@ /** * Prints or shows preview dialog for given print provider. - * @param provider to be previewed + * @param job to be previewed * @param withPreview if true, shows preview dialog before printing * otherwise sends data to printer */ - void print(PrintProvider provider, boolean withPreview); + void print(Job job, boolean withPreview); /** * Returns Preview action. * @return Preview action */ Action getPreviewAction(); + + + public static final class Job { + private PrintProvider provider; + + Job(PrintProvider provider) { + this.provider = provider; } + static { + Trampoline.API = new Trampoline() { + + public Job createJob(PrintProvider p) { + return new Job(p); + } + + public PrintProvider findProvider(Job job) { + return job.provider; + } + + }; + } + } + +} Index: print/api/src/org/netbeans/modules/print/spi/PrintFactory.java --- print/api/src/org/netbeans/modules/print/spi/PrintFactory.java No Base Revision +++ print/api/src/org/netbeans/modules/print/spi/PrintFactory.java Locally New @@ -0,0 +1,37 @@ +/* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * 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 + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Portions Copyrighted 2007 Sun Microsystems, Inc. + */ +package org.netbeans.modules.print.spi; + +import org.netbeans.modules.print.Trampoline; +import org.netbeans.modules.print.api.PrintManager; + +/** Contains various factory methods to create objects usable in the + * Print API. + * + * @author Jaroslav Tulach + */ +public final class PrintFactory { + private PrintFactory() {} + + /** Creates new job based on a specified provider. + * @param p print provider that will back the job + * @return a job that can be send to {@link PrintManager} for preview/printing + */ + public static PrintManager.Job create(PrintProvider p) { + return Trampoline.API.createJob(p); + } +}