Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/print/ServiceUIFactory.java
38829 views
/*1* Copyright (c) 2000, 2013, 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 styles29* of interaction in different roles.30* One role may be end-user browsing and setting of print options.31* Another role may be administering the print service.32* <p>33* Although the Print Service API does not presently provide standardised34* support for administering a print service, monitoring of the print35* service is possible and a UI may provide for private update mechanisms.36* <p>37* The basic design intent is to allow applications to lazily locate and38* initialize services only when needed without any API dependencies39* except in an environment in which they are used.40* <p>41* Swing UIs are preferred as they provide a more consistent {@literal L&F}42* and can support accessibility APIs.43* <p>44* Example usage:45* <pre>46* ServiceUIFactory factory = printService.getServiceUIFactory();47* if (factory != null) {48* JComponent swingui = (JComponent)factory.getUI(49* ServiceUIFactory.MAIN_UIROLE,50* ServiceUIFactory.JCOMPONENT_UI);51* if (swingui != null) {52* tabbedpane.add("Custom UI", swingui);53* }54* }55* </pre>56*/5758public abstract class ServiceUIFactory {5960/**61* Denotes a UI implemented as a Swing component.62* The value of the String is the fully qualified classname :63* "javax.swing.JComponent".64*/65public static final String JCOMPONENT_UI = "javax.swing.JComponent";6667/**68* Denotes a UI implemented as an AWT panel.69* The value of the String is the fully qualified classname :70* "java.awt.Panel"71*/72public static final String PANEL_UI = "java.awt.Panel";7374/**75* Denotes a UI implemented as an AWT dialog.76* The value of the String is the fully qualified classname :77* "java.awt.Dialog"78*/79public static final String DIALOG_UI = "java.awt.Dialog";8081/**82* Denotes a UI implemented as a Swing dialog.83* The value of the String is the fully qualified classname :84* "javax.swing.JDialog"85*/86public static final String JDIALOG_UI = "javax.swing.JDialog";8788/**89* Denotes a UI which performs an informative "About" role.90*/91public static final int ABOUT_UIROLE = 1;9293/**94* Denotes a UI which performs an administrative role.95*/96public static final int ADMIN_UIROLE = 2;9798/**99* Denotes a UI which performs the normal end user role.100*/101public static final int MAIN_UIROLE = 3;102103/**104* Not a valid role but role id's greater than this may be used105* for private roles supported by a service. Knowledge of the106* function performed by this role is required to make proper use107* of it.108*/109public static final int RESERVED_UIROLE = 99;110/**111* Get a UI object which may be cast to the requested UI type112* by the application and used in its user interface.113* <P>114* @param role requested. Must be one of the standard roles or115* a private role supported by this factory.116* @param ui type in which the role is requested.117* @return the UI role or null if the requested UI role is not available118* from this factory119* @throws IllegalArgumentException if the role or ui is neither120* one of the standard ones, nor a private one121* supported by the factory.122*/123public abstract Object getUI(int role, String ui) ;124125/**126* Given a UI role obtained from this factory obtain the UI127* types available from this factory which implement this role.128* The returned Strings should refer to the static variables defined129* in this class so that applications can use equality of reference130* ("==").131* @param role to be looked up.132* @return the UI types supported by this class for the specified role,133* null if no UIs are available for the role.134* @throws IllegalArgumentException is the role is a non-standard135* role not supported by this factory.136*/137public abstract String[] getUIClassNamesForRole(int role) ;138139140141}142143144