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. package javax.print;
  8. /**
  9. * Services may optionally provide UIs which allow different styles
  10. * of interaction in different roles.
  11. * One role may be end-user browsing and setting of print options.
  12. * Another role may be administering the print service.
  13. * <p>
  14. * Although the Print Service API does not presently provide standardised
  15. * support for administering a print service, monitoring of the print
  16. * service is possible and a UI may provide for private update mechanisms.
  17. * <p>
  18. * The basic design intent is to allow applications to lazily locate and
  19. * initialize services only when needed without any API dependencies
  20. * except in an environment in which they are used.
  21. * <p>
  22. * Swing UIs are preferred as they provide a more consistent L&F and
  23. * can support accessibility APIs.
  24. * <p>
  25. * Example usage:
  26. * <pre>
  27. * ServiceUIFactory factory = printService.getServiceUIFactory();
  28. * if (factory != null) {
  29. * JComponent swingui = (JComponent)factory.getUI(
  30. * ServiceUIFactory.MAIN_UIROLE,
  31. * ServiceUIFactory.JCOMPONENT_UI);
  32. * if (swingui != null) {
  33. * tabbedpane.add("Custom UI", swingui);
  34. * }
  35. * }
  36. * </pre>
  37. */
  38. public abstract class ServiceUIFactory {
  39. /**
  40. * Denotes a UI implemented as a Swing component.
  41. * The value of the String is the fully qualified classname :
  42. * "javax.swing.JComponent".
  43. */
  44. public static final String JCOMPONENT_UI = "javax.swing.JComponent";
  45. /**
  46. * Denotes a UI implemented as an AWT panel.
  47. * The value of the String is the fully qualified classname :
  48. * "java.awt.Panel"
  49. */
  50. public static final String PANEL_UI = "java.awt.Panel";
  51. /**
  52. * Denotes a UI implemented as an AWT dialog.
  53. * The value of the String is the fully qualified classname :
  54. * "java.awt.Dialog"
  55. */
  56. public static final String DIALOG_UI = "java.awt.Dialog";
  57. /**
  58. * Denotes a UI implemented as a Swing dialog.
  59. * The value of the String is the fully qualified classname :
  60. * "javax.swing.JDialog"
  61. */
  62. public static final String JDIALOG_UI = "javax.swing.JDialog";
  63. /**
  64. * Denotes a UI which performs an informative "About" role.
  65. */
  66. public static final int ABOUT_UIROLE = 1;
  67. /**
  68. * Denotes a UI which performs an administrative role.
  69. */
  70. public static final int ADMIN_UIROLE = 2;
  71. /**
  72. * Denotes a UI which performs the normal end user role.
  73. */
  74. public static final int MAIN_UIROLE = 3;
  75. /**
  76. * Not a valid role but role id's greater than this may be used
  77. * for private roles supported by a service. Knowledge of the
  78. * function performed by this role is required to make proper use
  79. * of it.
  80. */
  81. public static final int RESERVED_UIROLE = 99;
  82. /**
  83. * Get a UI object which may be cast to the requested UI type
  84. * by the application and used in its user interface.
  85. * <P>
  86. * @param role requested. Must be one of the standard roles or
  87. * a private role supported by this factory.
  88. * @param ui type in which the role is requested.
  89. * @return the UI role or null if the requested UI role is not available
  90. * from this factory
  91. * @throws IllegalArgumentException if the role or ui is neither
  92. * one of the standard ones, nor a private one
  93. * supported by the factory.
  94. */
  95. public abstract Object getUI(int role, String ui) ;
  96. /**
  97. * Given a UI role obtained from this factory obtain the UI
  98. * types available from this factory which implement this role.
  99. * The returned Strings should refer to the static variables defined
  100. * in this class so that applications can use equality of reference
  101. * ("==").
  102. * @param role to be looked up.
  103. * @return the UI types supported by this class for the specified role,
  104. * null if no UIs are available for the role.
  105. * @throws IllegalArgumentException is the role is a non-standard
  106. * role not supported by this factory.
  107. */
  108. public abstract String[] getUIClassNamesForRole(int role) ;
  109. }