Path: blob/master/src/java.desktop/share/classes/javax/print/ServiceUIFactory.java
41153 views
/*1* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.print;2627/**28* Services may optionally provide UIs which allow different styles of29* interaction in different roles. One role may be end-user browsing and setting30* of print options. Another role may be administering the print service.31* <p>32* Although the Print Service API does not presently provide standardised33* support for administering a print service, monitoring of the print service is34* possible and a UI may provide for private update mechanisms.35* <p>36* The basic design intent is to allow applications to lazily locate and37* initialize services only when needed without any API dependencies except in38* an environment in which they are used.39* <p>40* Swing UIs are preferred as they provide a more consistent {@literal L&F} and41* can support accessibility APIs.42* <p>43* Example usage:44* <pre>45* ServiceUIFactory factory = printService.getServiceUIFactory();46* if (factory != null) {47* JComponent swingui = (JComponent)factory.getUI(48* ServiceUIFactory.MAIN_UIROLE,49* ServiceUIFactory.JCOMPONENT_UI);50* if (swingui != null) {51* tabbedpane.add("Custom UI", swingui);52* }53* }54* </pre>55*/56public abstract class ServiceUIFactory {5758/**59* Constructor for subclasses to call.60*/61protected ServiceUIFactory() {}6263/**64* Denotes a UI implemented as a Swing component. The value of the string is65* the fully qualified classname : "javax.swing.JComponent".66*/67public static final String JCOMPONENT_UI = "javax.swing.JComponent";6869/**70* Denotes a UI implemented as an AWT panel. The value of the string is the71* fully qualified classname : "java.awt.Panel"72*/73public static final String PANEL_UI = "java.awt.Panel";7475/**76* Denotes a UI implemented as an AWT dialog. The value of the string is the77* fully qualified classname : "java.awt.Dialog"78*/79public static final String DIALOG_UI = "java.awt.Dialog";8081/**82* Denotes a UI implemented as a Swing dialog. The value of the string is83* the fully qualified classname : "javax.swing.JDialog"84*/85public static final String JDIALOG_UI = "javax.swing.JDialog";8687/**88* Denotes a UI which performs an informative "About" role.89*/90public static final int ABOUT_UIROLE = 1;9192/**93* Denotes a UI which performs an administrative role.94*/95public static final int ADMIN_UIROLE = 2;9697/**98* Denotes a UI which performs the normal end user role.99*/100public static final int MAIN_UIROLE = 3;101102/**103* Not a valid role but role id's greater than this may be used for private104* roles supported by a service. Knowledge of the function performed by this105* role is required to make proper use of it.106*/107public static final int RESERVED_UIROLE = 99;108109/**110* Get a UI object which may be cast to the requested UI type by the111* application and used in its user interface.112*113* @param role requested. Must be one of the standard roles or a private114* role supported by this factory.115* @param ui type in which the role is requested116* @return the UI role or {@code null} if the requested UI role is not117* available from this factory118* @throws IllegalArgumentException if the role or ui is neither one of the119* standard ones, nor a private one supported by the factory120*/121public abstract Object getUI(int role, String ui) ;122123/**124* Given a UI role obtained from this factory obtain the UI types available125* from this factory which implement this role. The returned {@code Strings}126* should refer to the static variables defined in this class so that127* applications can use equality of reference ("==").128*129* @param role to be looked up130* @return the UI types supported by this class for the specified role,131* {@code null} if no UIs are available for the role132* @throws IllegalArgumentException is the role is a non-standard role not133* supported by this factory134*/135public abstract String[] getUIClassNamesForRole(int role) ;136137}138139140