1. /*
  2. * @(#)MultiFileChooserUI.java 1.21 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.plaf.multi;
  8. import java.util.Vector;
  9. import javax.swing.plaf.FileChooserUI;
  10. import javax.swing.filechooser.FileFilter;
  11. import javax.swing.JFileChooser;
  12. import javax.swing.filechooser.FileView;
  13. import java.lang.String;
  14. import java.io.File;
  15. import javax.swing.plaf.ComponentUI;
  16. import javax.swing.JComponent;
  17. import java.awt.Graphics;
  18. import java.awt.Dimension;
  19. import javax.accessibility.Accessible;
  20. /**
  21. * MultiFileChooserUI implementation
  22. *
  23. * <p>This file was automatically generated by AutoMulti.
  24. *
  25. * @version 1.21 11/29/01 23:12:57
  26. * @author Otto Multey
  27. */
  28. public class MultiFileChooserUI extends FileChooserUI {
  29. /**
  30. * The Vector containing the real UI's. This is populated
  31. * in the call to createUI, and can be obtained by calling
  32. * getUIs. The first element is guaranteed to the real UI
  33. * obtained from the default look and feel.
  34. */
  35. protected Vector uis = new Vector();
  36. ////////////////////
  37. // Common UI methods
  38. ////////////////////
  39. /**
  40. * Return the list of UI's associated with this multiplexing UI. This
  41. * allows processing of the UI's by an application aware of multiplexing
  42. * UI's on components.
  43. */
  44. public ComponentUI[] getUIs() {
  45. return MultiLookAndFeel.uisToArray(uis);
  46. }
  47. ////////////////////
  48. // FileChooserUI methods
  49. ////////////////////
  50. /**
  51. * Call getAcceptAllFileFilter on each UI handled by this MultiUI.
  52. * Return only the value obtained from the first UI, which is
  53. * the UI obtained from the default LookAndFeel.
  54. */
  55. public FileFilter getAcceptAllFileFilter(JFileChooser a) {
  56. FileFilter returnValue =
  57. ((FileChooserUI) (uis.elementAt(0))).getAcceptAllFileFilter(a);
  58. for (int i = 1; i < uis.size(); i++) {
  59. ((FileChooserUI) (uis.elementAt(i))).getAcceptAllFileFilter(a);
  60. }
  61. return returnValue;
  62. }
  63. /**
  64. * Call getFileView on each UI handled by this MultiUI.
  65. * Return only the value obtained from the first UI, which is
  66. * the UI obtained from the default LookAndFeel.
  67. */
  68. public FileView getFileView(JFileChooser a) {
  69. FileView returnValue =
  70. ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
  71. for (int i = 1; i < uis.size(); i++) {
  72. ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
  73. }
  74. return returnValue;
  75. }
  76. /**
  77. * Call getApproveButtonText on each UI handled by this MultiUI.
  78. * Return only the value obtained from the first UI, which is
  79. * the UI obtained from the default LookAndFeel.
  80. */
  81. public String getApproveButtonText(JFileChooser a) {
  82. String returnValue =
  83. ((FileChooserUI) (uis.elementAt(0))).getApproveButtonText(a);
  84. for (int i = 1; i < uis.size(); i++) {
  85. ((FileChooserUI) (uis.elementAt(i))).getApproveButtonText(a);
  86. }
  87. return returnValue;
  88. }
  89. /**
  90. * Call getDialogTitle on each UI handled by this MultiUI.
  91. * Return only the value obtained from the first UI, which is
  92. * the UI obtained from the default LookAndFeel.
  93. */
  94. public String getDialogTitle(JFileChooser a) {
  95. String returnValue =
  96. ((FileChooserUI) (uis.elementAt(0))).getDialogTitle(a);
  97. for (int i = 1; i < uis.size(); i++) {
  98. ((FileChooserUI) (uis.elementAt(i))).getDialogTitle(a);
  99. }
  100. return returnValue;
  101. }
  102. /**
  103. * Call rescanCurrentDirectory on each UI handled by this MultiUI.
  104. */
  105. public void rescanCurrentDirectory(JFileChooser a) {
  106. for (int i = 0; i < uis.size(); i++) {
  107. ((FileChooserUI) (uis.elementAt(i))).rescanCurrentDirectory(a);
  108. }
  109. }
  110. /**
  111. * Call ensureFileIsVisible on each UI handled by this MultiUI.
  112. */
  113. public void ensureFileIsVisible(JFileChooser a, File b) {
  114. for (int i = 0; i < uis.size(); i++) {
  115. ((FileChooserUI) (uis.elementAt(i))).ensureFileIsVisible(a,b);
  116. }
  117. }
  118. ////////////////////
  119. // ComponentUI methods
  120. ////////////////////
  121. /**
  122. * Call installUI on each UI handled by this MultiUI.
  123. */
  124. public void installUI(JComponent a) {
  125. for (int i = 0; i < uis.size(); i++) {
  126. ((ComponentUI) (uis.elementAt(i))).installUI(a);
  127. }
  128. }
  129. /**
  130. * Call uninstallUI on each UI handled by this MultiUI.
  131. */
  132. public void uninstallUI(JComponent a) {
  133. for (int i = 0; i < uis.size(); i++) {
  134. ((ComponentUI) (uis.elementAt(i))).uninstallUI(a);
  135. }
  136. }
  137. /**
  138. * Call paint on each UI handled by this MultiUI.
  139. */
  140. public void paint(Graphics a, JComponent b) {
  141. for (int i = 0; i < uis.size(); i++) {
  142. ((ComponentUI) (uis.elementAt(i))).paint(a,b);
  143. }
  144. }
  145. /**
  146. * Call update on each UI handled by this MultiUI.
  147. */
  148. public void update(Graphics a, JComponent b) {
  149. for (int i = 0; i < uis.size(); i++) {
  150. ((ComponentUI) (uis.elementAt(i))).update(a,b);
  151. }
  152. }
  153. /**
  154. * Call getPreferredSize on each UI handled by this MultiUI.
  155. * Return only the value obtained from the first UI, which is
  156. * the UI obtained from the default LookAndFeel.
  157. */
  158. public Dimension getPreferredSize(JComponent a) {
  159. Dimension returnValue =
  160. ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
  161. for (int i = 1; i < uis.size(); i++) {
  162. ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
  163. }
  164. return returnValue;
  165. }
  166. /**
  167. * Call getMinimumSize on each UI handled by this MultiUI.
  168. * Return only the value obtained from the first UI, which is
  169. * the UI obtained from the default LookAndFeel.
  170. */
  171. public Dimension getMinimumSize(JComponent a) {
  172. Dimension returnValue =
  173. ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
  174. for (int i = 1; i < uis.size(); i++) {
  175. ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
  176. }
  177. return returnValue;
  178. }
  179. /**
  180. * Call getMaximumSize on each UI handled by this MultiUI.
  181. * Return only the value obtained from the first UI, which is
  182. * the UI obtained from the default LookAndFeel.
  183. */
  184. public Dimension getMaximumSize(JComponent a) {
  185. Dimension returnValue =
  186. ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
  187. for (int i = 1; i < uis.size(); i++) {
  188. ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
  189. }
  190. return returnValue;
  191. }
  192. /**
  193. * Call contains on each UI handled by this MultiUI.
  194. * Return only the value obtained from the first UI, which is
  195. * the UI obtained from the default LookAndFeel.
  196. */
  197. public boolean contains(JComponent a, int b, int c) {
  198. boolean returnValue =
  199. ((ComponentUI) (uis.elementAt(0))).contains(a,b,c);
  200. for (int i = 1; i < uis.size(); i++) {
  201. ((ComponentUI) (uis.elementAt(i))).contains(a,b,c);
  202. }
  203. return returnValue;
  204. }
  205. /**
  206. * Return a multiplexing UI instance if any of the auxiliary
  207. * LookAndFeels support this UI. Otherwise, just return a
  208. * UI obtained using the normal methods.
  209. */
  210. public static ComponentUI createUI(JComponent a) {
  211. ComponentUI mui = new MultiFileChooserUI();
  212. return MultiLookAndFeel.createUIs(mui,
  213. ((MultiFileChooserUI) mui).uis,
  214. a);
  215. }
  216. /**
  217. * Call getAccessibleChildrenCount on each UI handled by this MultiUI.
  218. * Return only the value obtained from the first UI, which is
  219. * the UI obtained from the default LookAndFeel.
  220. */
  221. public int getAccessibleChildrenCount(JComponent a) {
  222. int returnValue =
  223. ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a);
  224. for (int i = 1; i < uis.size(); i++) {
  225. ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a);
  226. }
  227. return returnValue;
  228. }
  229. /**
  230. * Call getAccessibleChild on each UI handled by this MultiUI.
  231. * Return only the value obtained from the first UI, which is
  232. * the UI obtained from the default LookAndFeel.
  233. */
  234. public Accessible getAccessibleChild(JComponent a, int b) {
  235. Accessible returnValue =
  236. ((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
  237. for (int i = 1; i < uis.size(); i++) {
  238. ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
  239. }
  240. return returnValue;
  241. }
  242. }