001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package javax.swing.plaf.multi;
019:
020: import java.awt.Dimension;
021: import java.awt.Graphics;
022: import java.io.File;
023: import java.util.Vector;
024:
025: import javax.accessibility.Accessible;
026: import javax.swing.JComponent;
027: import javax.swing.JFileChooser;
028: import javax.swing.filechooser.FileFilter;
029: import javax.swing.filechooser.FileView;
030: import javax.swing.plaf.ComponentUI;
031: import javax.swing.plaf.FileChooserUI;
032:
033: /**
034: * All the methods described in public api
035: */
036: public class MultiFileChooserUI extends FileChooserUI {
037:
038: protected Vector uis = new Vector();
039:
040: /**
041: * Used in cycles. numberOfUIs = Correct number of UIs + 1, but the variable
042: * used in that sence
043: */
044: private int numberOfUIs;
045:
046: public static ComponentUI createUI(JComponent a) {
047: MultiFileChooserUI mui = new MultiFileChooserUI();
048: ComponentUI result = MultiLookAndFeel
049: .createUIs(mui, mui.uis, a);
050: mui.numberOfUIs = mui.uis.size();
051: return result;
052: }
053:
054: @Override
055: public boolean contains(JComponent a, int b, int c) {
056: for (int i = 1; i < numberOfUIs; i++) {
057: ((ComponentUI) uis.get(i)).contains(a, b, c);
058: }
059: return ((ComponentUI) uis.firstElement()).contains(a, b, c);
060: }
061:
062: @Override
063: public Accessible getAccessibleChild(JComponent a, int b) {
064: for (int i = 1; i < numberOfUIs; i++) {
065: ((ComponentUI) uis.get(i)).getAccessibleChild(a, b);
066: }
067: return ((ComponentUI) uis.firstElement()).getAccessibleChild(a,
068: b);
069: }
070:
071: @Override
072: public int getAccessibleChildrenCount(JComponent a) {
073: for (int i = 1; i < numberOfUIs; i++) {
074: ((ComponentUI) uis.get(i)).getAccessibleChildrenCount(a);
075: }
076: return ((ComponentUI) uis.firstElement())
077: .getAccessibleChildrenCount(a);
078: }
079:
080: @Override
081: public Dimension getMaximumSize(JComponent a) {
082: for (int i = 1; i < numberOfUIs; i++) {
083: ((ComponentUI) uis.get(i)).getMaximumSize(a);
084: }
085: return ((ComponentUI) uis.firstElement()).getMaximumSize(a);
086: }
087:
088: @Override
089: public Dimension getMinimumSize(JComponent a) {
090: for (int i = 1; i < numberOfUIs; i++) {
091: ((ComponentUI) uis.get(i)).getMinimumSize(a);
092: }
093: return ((ComponentUI) uis.firstElement()).getMinimumSize(a);
094: }
095:
096: @Override
097: public Dimension getPreferredSize(JComponent a) {
098: for (int i = 1; i < numberOfUIs; i++) {
099: ((ComponentUI) uis.get(i)).getPreferredSize(a);
100: }
101: return ((ComponentUI) uis.firstElement()).getPreferredSize(a);
102: }
103:
104: public ComponentUI[] getUIs() {
105: return MultiLookAndFeel.uisToArray(uis);
106: }
107:
108: @Override
109: public void installUI(JComponent a) {
110: for (Object ui : uis) {
111: ((ComponentUI) ui).installUI(a);
112: }
113: }
114:
115: @Override
116: public void paint(Graphics a, JComponent b) {
117: for (Object ui : uis) {
118: ((ComponentUI) ui).paint(a, b);
119: }
120: }
121:
122: @Override
123: public void uninstallUI(JComponent a) {
124: for (Object ui : uis) {
125: ((ComponentUI) ui).uninstallUI(a);
126: }
127: }
128:
129: @Override
130: public void update(Graphics a, JComponent b) {
131: for (Object ui : uis) {
132: ((ComponentUI) ui).update(a, b);
133: }
134: }
135:
136: @Override
137: public FileFilter getAcceptAllFileFilter(JFileChooser fc) {
138: for (int i = 1; i < numberOfUIs; i++) {
139: ((FileChooserUI) uis.get(i)).getAcceptAllFileFilter(fc);
140: }
141: return ((FileChooserUI) uis.firstElement())
142: .getAcceptAllFileFilter(fc);
143: }
144:
145: @Override
146: public FileView getFileView(JFileChooser fc) {
147: for (int i = 1; i < numberOfUIs; i++) {
148: ((FileChooserUI) uis.get(i)).getFileView(fc);
149: }
150: return ((FileChooserUI) uis.firstElement()).getFileView(fc);
151: }
152:
153: @Override
154: public String getApproveButtonText(JFileChooser fc) {
155: for (int i = 1; i < numberOfUIs; i++) {
156: ((FileChooserUI) uis.get(i)).getApproveButtonText(fc);
157: }
158: return ((FileChooserUI) uis.firstElement())
159: .getApproveButtonText(fc);
160: }
161:
162: @Override
163: public String getDialogTitle(JFileChooser fc) {
164: for (int i = 1; i < numberOfUIs; i++) {
165: ((FileChooserUI) uis.get(i)).getDialogTitle(fc);
166: }
167: return ((FileChooserUI) uis.firstElement()).getDialogTitle(fc);
168: }
169:
170: @Override
171: public void rescanCurrentDirectory(JFileChooser fc) {
172: for (Object ui : uis) {
173: ((FileChooserUI) ui).rescanCurrentDirectory(fc);
174: }
175:
176: }
177:
178: @Override
179: public void ensureFileIsVisible(JFileChooser fc, File f) {
180: for (Object ui : uis) {
181: ((FileChooserUI) ui).ensureFileIsVisible(fc, f);
182: }
183: }
184:
185: }
|