001: package org.uispec4j.interception.toolkit;
002:
003: import sun.awt.ComponentFactory;
004: import sun.awt.SunToolkit;
005:
006: import java.awt.*;
007: import java.awt.datatransfer.Clipboard;
008: import java.awt.dnd.*;
009: import java.awt.dnd.peer.DragSourceContextPeer;
010: import java.awt.event.AWTEventListener;
011: import java.awt.im.InputMethodHighlight;
012: import java.awt.image.ColorModel;
013: import java.awt.image.ImageObserver;
014: import java.awt.image.ImageProducer;
015: import java.awt.peer.*;
016: import java.beans.PropertyChangeListener;
017: import java.net.URL;
018: import java.util.Map;
019: import java.util.Properties;
020:
021: /**
022: * Delegates to the underlying Toolkit.
023: * <p>Note: this does not work if the underlying toolkit is not a Sun one.</p>
024: */
025: ///CLOVER:OFF
026: public abstract class ToolkitDelegate extends Toolkit implements
027: ComponentFactory {
028:
029: protected static Toolkit underlyingToolkit;
030:
031: public int getMaximumCursorColors() throws HeadlessException {
032: return getUnderlyingToolkit().getMaximumCursorColors();
033: }
034:
035: public int getMenuShortcutKeyMask() throws HeadlessException {
036: return getUnderlyingToolkit().getMenuShortcutKeyMask();
037: }
038:
039: public int getScreenResolution() throws HeadlessException {
040: return getUnderlyingToolkit().getScreenResolution();
041: }
042:
043: public void beep() {
044: getUnderlyingToolkit().beep();
045: }
046:
047: public void sync() {
048: getUnderlyingToolkit().sync();
049: }
050:
051: public boolean isDynamicLayoutActive() throws HeadlessException {
052: return getUnderlyingToolkit().isDynamicLayoutActive();
053: }
054:
055: public boolean getLockingKeyState(int keyCode)
056: throws UnsupportedOperationException {
057: return getUnderlyingToolkit().getLockingKeyState(keyCode);
058: }
059:
060: public boolean isFrameStateSupported(int state)
061: throws HeadlessException {
062: return getUnderlyingToolkit().isFrameStateSupported(state);
063: }
064:
065: public void setLockingKeyState(int keyCode, boolean on)
066: throws UnsupportedOperationException {
067: getUnderlyingToolkit().setLockingKeyState(keyCode, on);
068: }
069:
070: public void setDynamicLayout(boolean dynamic)
071: throws HeadlessException {
072: getUnderlyingToolkit().setDynamicLayout(dynamic);
073: }
074:
075: public Dimension getScreenSize() throws HeadlessException {
076: return getUnderlyingToolkit().getScreenSize();
077: }
078:
079: public Dimension getBestCursorSize(int preferredWidth,
080: int preferredHeight) throws HeadlessException {
081: return getUnderlyingToolkit().getBestCursorSize(preferredWidth,
082: preferredHeight);
083: }
084:
085: public EventQueue getSystemEventQueueImpl() {
086: return getUnderlyingToolkit().getSystemEventQueue();
087: }
088:
089: public Image createImage(byte[] imagedata) {
090: return getUnderlyingToolkit().createImage(imagedata);
091: }
092:
093: public Image createImage(byte[] imagedata, int imageoffset,
094: int imagelength) {
095: return getUnderlyingToolkit().createImage(imagedata,
096: imageoffset, imagelength);
097: }
098:
099: public Clipboard getSystemClipboard() throws HeadlessException {
100: return getUnderlyingToolkit().getSystemClipboard();
101: }
102:
103: public AWTEventListener[] getAWTEventListeners() {
104: return getUnderlyingToolkit().getAWTEventListeners();
105: }
106:
107: public AWTEventListener[] getAWTEventListeners(long eventMask) {
108: return getUnderlyingToolkit().getAWTEventListeners(eventMask);
109: }
110:
111: public void removeAWTEventListener(AWTEventListener listener) {
112: getUnderlyingToolkit().removeAWTEventListener(listener);
113: }
114:
115: public void addAWTEventListener(AWTEventListener listener,
116: long eventMask) {
117: getUnderlyingToolkit().addAWTEventListener(listener, eventMask);
118: }
119:
120: public ColorModel getColorModel() throws HeadlessException {
121: return getUnderlyingToolkit().getColorModel();
122: }
123:
124: public PropertyChangeListener[] getPropertyChangeListeners() {
125: return getUnderlyingToolkit().getPropertyChangeListeners();
126: }
127:
128: public String[] getFontList() {
129: return getUnderlyingToolkit().getFontList();
130: }
131:
132: public FontMetrics getFontMetrics(Font font) {
133: return getUnderlyingToolkit().getFontMetrics(font);
134: }
135:
136: public Image createImage(ImageProducer producer) {
137: return getUnderlyingToolkit().createImage(producer);
138: }
139:
140: public Image createImage(String filename) {
141: return getUnderlyingToolkit().createImage(filename);
142: }
143:
144: public Image getImage(String filename) {
145: return getUnderlyingToolkit().getImage(filename);
146: }
147:
148: public Image createImage(URL url) {
149: return getUnderlyingToolkit().createImage(url);
150: }
151:
152: public Image getImage(URL url) {
153: return getUnderlyingToolkit().getImage(url);
154: }
155:
156: public Insets getScreenInsets(GraphicsConfiguration gc)
157: throws HeadlessException {
158: return getUnderlyingToolkit().getScreenInsets(gc);
159: }
160:
161: public DragSourceContextPeer createDragSourceContextPeer(
162: DragGestureEvent dge) throws InvalidDnDOperationException {
163: return getUnderlyingToolkit().createDragSourceContextPeer(dge);
164: }
165:
166: public int checkImage(Image image, int width, int height,
167: ImageObserver observer) {
168: return getUnderlyingToolkit().checkImage(image, width, height,
169: observer);
170: }
171:
172: public boolean prepareImage(Image image, int width, int height,
173: ImageObserver observer) {
174: return getUnderlyingToolkit().prepareImage(image, width,
175: height, observer);
176: }
177:
178: public ButtonPeer createButton(Button target)
179: throws HeadlessException {
180: return asSun().createButton(target);
181: }
182:
183: public CanvasPeer createCanvas(Canvas target) {
184: return asSun().createCanvas(target);
185: }
186:
187: public CheckboxMenuItemPeer createCheckboxMenuItem(
188: CheckboxMenuItem target) throws HeadlessException {
189: return asSun().createCheckboxMenuItem(target);
190: }
191:
192: public CheckboxPeer createCheckbox(Checkbox target)
193: throws HeadlessException {
194: return asSun().createCheckbox(target);
195: }
196:
197: public ChoicePeer createChoice(Choice target)
198: throws HeadlessException {
199: return asSun().createChoice(target);
200: }
201:
202: public DialogPeer createDialog(Dialog target)
203: throws HeadlessException {
204: return asSun().createDialog(target);
205: }
206:
207: public FileDialogPeer createFileDialog(FileDialog target)
208: throws HeadlessException {
209: return asSun().createFileDialog(target);
210: }
211:
212: public FontPeer getFontPeer(String name, int style) {
213: return asSun().getFontPeer(name, style);
214: }
215:
216: public FramePeer createFrame(Frame target) throws HeadlessException {
217: return asSun().createFrame(target);
218: }
219:
220: public LabelPeer createLabel(Label target) throws HeadlessException {
221: return asSun().createLabel(target);
222: }
223:
224: public ListPeer createList(List target) throws HeadlessException {
225: return asSun().createList(target);
226: }
227:
228: public MenuBarPeer createMenuBar(MenuBar target)
229: throws HeadlessException {
230: return asSun().createMenuBar(target);
231: }
232:
233: public MenuItemPeer createMenuItem(MenuItem target)
234: throws HeadlessException {
235: return asSun().createMenuItem(target);
236: }
237:
238: public MenuPeer createMenu(Menu target) throws HeadlessException {
239: return asSun().createMenu(target);
240: }
241:
242: public PanelPeer createPanel(Panel target) {
243: return asSun().createPanel(target);
244: }
245:
246: public PopupMenuPeer createPopupMenu(PopupMenu target)
247: throws HeadlessException {
248: return asSun().createPopupMenu(target);
249: }
250:
251: public ScrollPanePeer createScrollPane(ScrollPane target)
252: throws HeadlessException {
253: return asSun().createScrollPane(target);
254: }
255:
256: public ScrollbarPeer createScrollbar(Scrollbar target)
257: throws HeadlessException {
258: return asSun().createScrollbar(target);
259: }
260:
261: public TextAreaPeer createTextArea(TextArea target)
262: throws HeadlessException {
263: return asSun().createTextArea(target);
264: }
265:
266: public TextFieldPeer createTextField(TextField target)
267: throws HeadlessException {
268: return asSun().createTextField(target);
269: }
270:
271: public WindowPeer createWindow(Window target)
272: throws HeadlessException {
273: return asSun().createWindow(target);
274: }
275:
276: public PropertyChangeListener[] getPropertyChangeListeners(
277: String propertyName) {
278: return getUnderlyingToolkit().getPropertyChangeListeners(
279: propertyName);
280: }
281:
282: public void addPropertyChangeListener(String name,
283: PropertyChangeListener pcl) {
284: getUnderlyingToolkit().addPropertyChangeListener(name, pcl);
285: }
286:
287: public void removePropertyChangeListener(String name,
288: PropertyChangeListener pcl) {
289: getUnderlyingToolkit().removePropertyChangeListener(name, pcl);
290: }
291:
292: public Map mapInputMethodHighlight(InputMethodHighlight highlight)
293: throws HeadlessException {
294: return getUnderlyingToolkit()
295: .mapInputMethodHighlight(highlight);
296: }
297:
298: public Cursor createCustomCursor(Image cursor, Point hotSpot,
299: String name) throws IndexOutOfBoundsException,
300: HeadlessException {
301: return getUnderlyingToolkit().createCustomCursor(cursor,
302: hotSpot, name);
303: }
304:
305: public PrintJob getPrintJob(Frame frame, String jobtitle,
306: Properties props) {
307: return getUnderlyingToolkit().getPrintJob(frame, jobtitle,
308: props);
309: }
310:
311: public PrintJob getPrintJob(Frame frame, String jobtitle,
312: JobAttributes jobAttributes, PageAttributes pageAttributes) {
313: return getUnderlyingToolkit().getPrintJob(frame, jobtitle,
314: jobAttributes, pageAttributes);
315: }
316:
317: public DragGestureRecognizer createDragGestureRecognizer(
318: Class abstractRecognizerClass, DragSource ds, Component cp,
319: int srcActions, DragGestureListener dgl) {
320: return getUnderlyingToolkit().createDragGestureRecognizer(
321: abstractRecognizerClass, ds, cp, srcActions, dgl);
322: }
323:
324: private SunToolkit asSun() {
325: return (SunToolkit) underlyingToolkit;
326: }
327:
328: public Toolkit getUnderlyingToolkit() {
329: return underlyingToolkit;
330: }
331: }
|