jdk/src/share/classes/javax/print/ServiceUIFactory.java
author never
Mon, 12 Jul 2010 22:27:18 -0700
changeset 5926 a36f90d986b6
parent 5506 202f599c92aa
child 19166 e6cd1eb44237
permissions -rw-r--r--
6968385: malformed xml in sweeper logging Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.print;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * Services may optionally provide UIs which allow different styles
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * of interaction in different roles.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * One role may be end-user browsing and setting of print options.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Another role may be administering the print service.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * Although the Print Service API does not presently provide standardised
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * support for administering a print service, monitoring of the print
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * service is possible and a UI may provide for private update mechanisms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * The basic design intent is to allow applications to lazily locate and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * initialize services only when needed without any API dependencies
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * except in an environment in which they are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * Swing UIs are preferred as they provide a more consistent L&F and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * can support accessibility APIs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Example usage:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *  ServiceUIFactory factory = printService.getServiceUIFactory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *  if (factory != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *      JComponent swingui = (JComponent)factory.getUI(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *                                         ServiceUIFactory.MAIN_UIROLE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *                                         ServiceUIFactory.JCOMPONENT_UI);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *      if (swingui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *          tabbedpane.add("Custom UI", swingui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
public abstract class ServiceUIFactory {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Denotes a UI implemented as a Swing component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * The value of the String is the fully qualified classname :
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * "javax.swing.JComponent".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    public static final String JCOMPONENT_UI = "javax.swing.JComponent";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Denotes a UI implemented as an AWT panel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * The value of the String is the fully qualified classname :
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * "java.awt.Panel"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public static final String PANEL_UI = "java.awt.Panel";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Denotes a UI implemented as an AWT dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * The value of the String is the fully qualified classname :
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * "java.awt.Dialog"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    public static final String DIALOG_UI = "java.awt.Dialog";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * Denotes a UI implemented as a Swing dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * The value of the String is the fully qualified classname :
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * "javax.swing.JDialog"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public static final String JDIALOG_UI = "javax.swing.JDialog";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * Denotes a UI which performs an informative "About" role.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public static final int ABOUT_UIROLE = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Denotes a UI which performs an administrative role.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public static final int ADMIN_UIROLE = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Denotes a UI which performs the normal end user role.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public static final int MAIN_UIROLE = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Not a valid role but role id's greater than this may be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * for private roles supported by a service. Knowledge of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * function performed by this role is required to make proper use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * of it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public static final int RESERVED_UIROLE = 99;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Get a UI object which may be cast to the requested UI type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * by the application and used in its user interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @param role requested. Must be one of the standard roles or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * a private role supported by this factory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @param ui type in which the role is requested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @return the UI role or null if the requested UI role is not available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * from this factory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @throws IllegalArgumentException if the role or ui is neither
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * one of the standard ones, nor a private one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * supported by the factory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public abstract Object getUI(int role, String ui) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Given a UI role obtained from this factory obtain the UI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * types available from this factory which implement this role.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * The returned Strings should refer to the static variables defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * in this class so that applications can use equality of reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * ("==").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param role to be looked up.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @return the UI types supported by this class for the specified role,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * null if no UIs are available for the role.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @throws IllegalArgumentException is the role is a non-standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * role not supported by this factory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public abstract String[] getUIClassNamesForRole(int role) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
}