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.

View | Details | Raw Unified | Return to bug 115365
Collapse All | Expand All

(-)print/api/src/org/netbeans/modules/print/Trampoline.java (+40 lines)
Line 0 Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
16
 */
17
package org.netbeans.modules.print;
18
19
import org.netbeans.modules.print.api.PrintManager;
20
import org.netbeans.modules.print.spi.PrintProvider;
21
import org.openide.util.Exceptions;
22
23
/**
24
 *
25
 * @author Jaroslav Tulach
26
 */
27
public abstract class Trampoline {
28
29
    public static Trampoline API;
30
    static {
31
        try {
32
            Class.forName(PrintManager.Job.class.getName(), true, Trampoline.class.getClassLoader());
33
        } catch (ClassNotFoundException ex) {
34
            Exceptions.printStackTrace(ex);
35
        }
36
    }
37
38
    public abstract PrintManager.Job createJob(PrintProvider p);
39
    public abstract PrintProvider findProvider(PrintManager.Job job);
40
}
(-)print/api/src/org/netbeans/modules/print/api/PrintManager.java (-2 / +27 lines)
Lines 41-46 Link Here
41
package org.netbeans.modules.print.api;
41
package org.netbeans.modules.print.api;
42
42
43
import javax.swing.Action;
43
import javax.swing.Action;
44
import org.netbeans.modules.print.Trampoline;
45
import org.netbeans.modules.print.api.PrintManager.Job;
44
import org.netbeans.modules.print.spi.PrintProvider;
46
import org.netbeans.modules.print.spi.PrintProvider;
45
47
46
/**
48
/**
Lines 51-65 Link Here
51
53
52
  /**
54
  /**
53
   * Prints or shows preview dialog for given print provider.
55
   * Prints or shows preview dialog for given print provider.
54
   * @param provider to be previewed
56
   * @param job to be previewed
55
   * @param withPreview if true, shows preview dialog before printing
57
   * @param withPreview if true, shows preview dialog before printing
56
   * otherwise sends data to printer
58
   * otherwise sends data to printer
57
   */
59
   */
58
  void print(PrintProvider provider, boolean withPreview);
60
  void print(Job job, boolean withPreview);
59
61
60
  /**
62
  /**
61
   * Returns Preview action.
63
   * Returns Preview action.
62
   * @return Preview action
64
   * @return Preview action
63
   */
65
   */
64
  Action getPreviewAction();
66
  Action getPreviewAction();
67
  
68
  
69
    public static final class Job {
70
        private PrintProvider provider;
71
72
        Job(PrintProvider provider) {
73
            this.provider = provider;
65
}
74
}
75
        static {
76
            Trampoline.API = new Trampoline() {
77
78
                public Job createJob(PrintProvider p) {
79
                    return new Job(p);
80
                }
81
82
                public PrintProvider findProvider(Job job) {
83
                    return job.provider;
84
                }
85
                
86
            };
87
        }
88
    }
89
    
90
}
(-)print/api/src/org/netbeans/modules/print/spi/PrintFactory.java (+37 lines)
Line 0 Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 * 
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 * 
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 * 
15
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
16
 */
17
package org.netbeans.modules.print.spi;
18
19
import org.netbeans.modules.print.Trampoline;
20
import org.netbeans.modules.print.api.PrintManager;
21
22
/** Contains various factory methods to create objects usable in the
23
 * Print API.
24
 *
25
 * @author Jaroslav Tulach
26
 */
27
public final class PrintFactory {
28
    private PrintFactory() {}
29
    
30
    /** Creates new job based on a specified provider.
31
     * @param p print provider that will back the job
32
     * @return a job that can be send to {@link PrintManager} for preview/printing
33
     */
34
    public static PrintManager.Job create(PrintProvider p) {
35
        return Trampoline.API.createJob(p);
36
    }
37
}

Return to bug 115365