KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > print > ServiceUIFactory


1 /*
2  * @(#)ServiceUIFactory.java 1.4 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.print;
9
10 /**
11  * Services may optionally provide UIs which allow different styles
12  * of interaction in different roles.
13  * One role may be end-user browsing and setting of print options.
14  * Another role may be administering the print service.
15  * <p>
16  * Although the Print Service API does not presently provide standardised
17  * support for administering a print service, monitoring of the print
18  * service is possible and a UI may provide for private update mechanisms.
19  * <p>
20  * The basic design intent is to allow applications to lazily locate and
21  * initialize services only when needed without any API dependencies
22  * except in an environment in which they are used.
23  * <p>
24  * Swing UIs are preferred as they provide a more consistent L&F and
25  * can support accessibility APIs.
26  * <p>
27  * Example usage:
28  * <pre>
29  * ServiceUIFactory factory = printService.getServiceUIFactory();
30  * if (factory != null) {
31  * JComponent swingui = (JComponent)factory.getUI(
32  * ServiceUIFactory.MAIN_UIROLE,
33  * ServiceUIFactory.JCOMPONENT_UI);
34  * if (swingui != null) {
35  * tabbedpane.add("Custom UI", swingui);
36  * }
37  * }
38  * </pre>
39  */

40
41 public abstract class ServiceUIFactory {
42
43     /**
44      * Denotes a UI implemented as a Swing component.
45      * The value of the String is the fully qualified classname :
46      * "javax.swing.JComponent".
47      */

48     public static final String JavaDoc JCOMPONENT_UI = "javax.swing.JComponent";
49
50     /**
51      * Denotes a UI implemented as an AWT panel.
52      * The value of the String is the fully qualified classname :
53      * "java.awt.Panel"
54      */

55     public static final String JavaDoc PANEL_UI = "java.awt.Panel";
56
57     /**
58      * Denotes a UI implemented as an AWT dialog.
59      * The value of the String is the fully qualified classname :
60      * "java.awt.Dialog"
61      */

62     public static final String JavaDoc DIALOG_UI = "java.awt.Dialog";
63
64     /**
65      * Denotes a UI implemented as a Swing dialog.
66      * The value of the String is the fully qualified classname :
67      * "javax.swing.JDialog"
68      */

69     public static final String JavaDoc JDIALOG_UI = "javax.swing.JDialog";
70
71     /**
72      * Denotes a UI which performs an informative "About" role.
73      */

74     public static final int ABOUT_UIROLE = 1;
75
76     /**
77      * Denotes a UI which performs an administrative role.
78      */

79     public static final int ADMIN_UIROLE = 2;
80
81     /**
82      * Denotes a UI which performs the normal end user role.
83      */

84     public static final int MAIN_UIROLE = 3;
85
86     /**
87      * Not a valid role but role id's greater than this may be used
88      * for private roles supported by a service. Knowledge of the
89      * function performed by this role is required to make proper use
90      * of it.
91      */

92     public static final int RESERVED_UIROLE = 99;
93     /**
94      * Get a UI object which may be cast to the requested UI type
95      * by the application and used in its user interface.
96      * <P>
97      * @param role requested. Must be one of the standard roles or
98      * a private role supported by this factory.
99      * @param ui type in which the role is requested.
100      * @return the UI role or null if the requested UI role is not available
101      * from this factory
102      * @throws IllegalArgumentException if the role or ui is neither
103      * one of the standard ones, nor a private one
104      * supported by the factory.
105      */

106     public abstract Object JavaDoc getUI(int role, String JavaDoc ui) ;
107
108     /**
109      * Given a UI role obtained from this factory obtain the UI
110      * types available from this factory which implement this role.
111      * The returned Strings should refer to the static variables defined
112      * in this class so that applications can use equality of reference
113      * ("==").
114      * @param role to be looked up.
115      * @return the UI types supported by this class for the specified role,
116      * null if no UIs are available for the role.
117      * @throws IllegalArgumentException is the role is a non-standard
118      * role not supported by this factory.
119      */

120     public abstract String JavaDoc[] getUIClassNamesForRole(int role) ;
121
122     
123
124 }
125
Popular Tags