author | ant |
Tue, 10 Mar 2009 18:33:29 +0300 | |
changeset 2464 | 3c6755bdc55f |
parent 1962 | 6c293d33645b |
child 2809 | b373581f6507 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1957
diff
changeset
|
2 |
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.awt; |
|
27 |
||
28 |
import java.awt.*; |
|
29 |
import java.awt.dnd.*; |
|
30 |
import java.awt.dnd.peer.DragSourceContextPeer; |
|
31 |
import java.awt.event.*; |
|
32 |
import java.awt.im.InputMethodHighlight; |
|
33 |
import java.awt.im.spi.InputMethodDescriptor; |
|
34 |
import java.awt.image.*; |
|
35 |
import java.awt.datatransfer.Clipboard; |
|
36 |
import java.awt.peer.*; |
|
37 |
import java.beans.PropertyChangeListener; |
|
38 |
import java.lang.reflect.Constructor; |
|
39 |
import java.lang.reflect.InvocationTargetException; |
|
40 |
import java.net.URL; |
|
41 |
import java.util.Map; |
|
42 |
import java.util.Properties; |
|
43 |
import sun.awt.im.InputContext; |
|
44 |
import sun.awt.image.ImageRepresentation; |
|
45 |
||
46 |
public class HeadlessToolkit extends Toolkit |
|
47 |
implements ComponentFactory, KeyboardFocusManagerPeerProvider { |
|
48 |
||
49 |
private Toolkit tk; |
|
50 |
private ComponentFactory componentFactory; |
|
51 |
||
52 |
public HeadlessToolkit(Toolkit tk) { |
|
53 |
this.tk = tk; |
|
54 |
if (tk instanceof ComponentFactory) { |
|
55 |
componentFactory = (ComponentFactory)tk; |
|
56 |
} |
|
57 |
} |
|
58 |
||
59 |
public Toolkit getUnderlyingToolkit() { |
|
60 |
return tk; |
|
61 |
} |
|
62 |
||
63 |
/* |
|
64 |
* Component peer objects. |
|
65 |
*/ |
|
66 |
||
67 |
/* Lightweight implementation of Canvas and Panel */ |
|
68 |
||
69 |
public CanvasPeer createCanvas(Canvas target) { |
|
70 |
return (CanvasPeer)createComponent(target); |
|
71 |
} |
|
72 |
||
73 |
public PanelPeer createPanel(Panel target) { |
|
74 |
return (PanelPeer)createComponent(target); |
|
75 |
} |
|
76 |
||
77 |
/* |
|
78 |
* Component peer objects - unsupported. |
|
79 |
*/ |
|
80 |
||
81 |
public WindowPeer createWindow(Window target) |
|
82 |
throws HeadlessException { |
|
83 |
throw new HeadlessException(); |
|
84 |
} |
|
85 |
||
86 |
public FramePeer createFrame(Frame target) |
|
87 |
throws HeadlessException { |
|
88 |
throw new HeadlessException(); |
|
89 |
} |
|
90 |
||
91 |
public DialogPeer createDialog(Dialog target) |
|
92 |
throws HeadlessException { |
|
93 |
throw new HeadlessException(); |
|
94 |
} |
|
95 |
||
96 |
public ButtonPeer createButton(Button target) |
|
97 |
throws HeadlessException { |
|
98 |
throw new HeadlessException(); |
|
99 |
} |
|
100 |
||
101 |
public TextFieldPeer createTextField(TextField target) |
|
102 |
throws HeadlessException { |
|
103 |
throw new HeadlessException(); |
|
104 |
} |
|
105 |
||
106 |
public ChoicePeer createChoice(Choice target) |
|
107 |
throws HeadlessException { |
|
108 |
throw new HeadlessException(); |
|
109 |
} |
|
110 |
||
111 |
public LabelPeer createLabel(Label target) |
|
112 |
throws HeadlessException { |
|
113 |
throw new HeadlessException(); |
|
114 |
} |
|
115 |
||
116 |
public ListPeer createList(List target) |
|
117 |
throws HeadlessException { |
|
118 |
throw new HeadlessException(); |
|
119 |
} |
|
120 |
||
121 |
public CheckboxPeer createCheckbox(Checkbox target) |
|
122 |
throws HeadlessException { |
|
123 |
throw new HeadlessException(); |
|
124 |
} |
|
125 |
||
126 |
public ScrollbarPeer createScrollbar(Scrollbar target) |
|
127 |
throws HeadlessException { |
|
128 |
throw new HeadlessException(); |
|
129 |
} |
|
130 |
||
131 |
public ScrollPanePeer createScrollPane(ScrollPane target) |
|
132 |
throws HeadlessException { |
|
133 |
throw new HeadlessException(); |
|
134 |
} |
|
135 |
||
136 |
public TextAreaPeer createTextArea(TextArea target) |
|
137 |
throws HeadlessException { |
|
138 |
throw new HeadlessException(); |
|
139 |
} |
|
140 |
||
141 |
public FileDialogPeer createFileDialog(FileDialog target) |
|
142 |
throws HeadlessException { |
|
143 |
throw new HeadlessException(); |
|
144 |
} |
|
145 |
||
146 |
public MenuBarPeer createMenuBar(MenuBar target) |
|
147 |
throws HeadlessException { |
|
148 |
throw new HeadlessException(); |
|
149 |
} |
|
150 |
||
151 |
public MenuPeer createMenu(Menu target) |
|
152 |
throws HeadlessException { |
|
153 |
throw new HeadlessException(); |
|
154 |
} |
|
155 |
||
156 |
public PopupMenuPeer createPopupMenu(PopupMenu target) |
|
157 |
throws HeadlessException { |
|
158 |
throw new HeadlessException(); |
|
159 |
} |
|
160 |
||
161 |
public MenuItemPeer createMenuItem(MenuItem target) |
|
162 |
throws HeadlessException { |
|
163 |
throw new HeadlessException(); |
|
164 |
} |
|
165 |
||
166 |
public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) |
|
167 |
throws HeadlessException { |
|
168 |
throw new HeadlessException(); |
|
169 |
} |
|
170 |
||
171 |
public DragSourceContextPeer createDragSourceContextPeer( |
|
172 |
DragGestureEvent dge) |
|
173 |
throws InvalidDnDOperationException { |
|
174 |
throw new InvalidDnDOperationException("Headless environment"); |
|
175 |
} |
|
176 |
||
177 |
public RobotPeer createRobot(Robot target, GraphicsDevice screen) |
|
178 |
throws AWTException, HeadlessException { |
|
179 |
throw new HeadlessException(); |
|
180 |
} |
|
181 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
1962
diff
changeset
|
182 |
public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
1962
diff
changeset
|
183 |
throws HeadlessException { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
1962
diff
changeset
|
184 |
throw new HeadlessException(); |
2 | 185 |
} |
186 |
||
187 |
public TrayIconPeer createTrayIcon(TrayIcon target) |
|
188 |
throws HeadlessException { |
|
189 |
throw new HeadlessException(); |
|
190 |
} |
|
191 |
||
192 |
public SystemTrayPeer createSystemTray(SystemTray target) |
|
193 |
throws HeadlessException { |
|
194 |
throw new HeadlessException(); |
|
195 |
} |
|
196 |
||
197 |
public boolean isTraySupported() { |
|
198 |
return false; |
|
199 |
} |
|
200 |
||
201 |
public GlobalCursorManager getGlobalCursorManager() |
|
202 |
throws HeadlessException { |
|
203 |
throw new HeadlessException(); |
|
204 |
} |
|
205 |
||
206 |
/* |
|
207 |
* Headless toolkit - unsupported. |
|
208 |
*/ |
|
209 |
protected void loadSystemColors(int[] systemColors) |
|
210 |
throws HeadlessException { |
|
211 |
throw new HeadlessException(); |
|
212 |
} |
|
213 |
||
214 |
public ColorModel getColorModel() |
|
215 |
throws HeadlessException { |
|
216 |
throw new HeadlessException(); |
|
217 |
} |
|
218 |
||
219 |
public int getScreenResolution() |
|
220 |
throws HeadlessException { |
|
221 |
throw new HeadlessException(); |
|
222 |
} |
|
223 |
||
224 |
public Map mapInputMethodHighlight(InputMethodHighlight highlight) |
|
225 |
throws HeadlessException { |
|
226 |
throw new HeadlessException(); |
|
227 |
} |
|
228 |
||
229 |
public int getMenuShortcutKeyMask() |
|
230 |
throws HeadlessException { |
|
231 |
throw new HeadlessException(); |
|
232 |
} |
|
233 |
||
234 |
public boolean getLockingKeyState(int keyCode) |
|
235 |
throws UnsupportedOperationException { |
|
236 |
throw new HeadlessException(); |
|
237 |
} |
|
238 |
||
239 |
public void setLockingKeyState(int keyCode, boolean on) |
|
240 |
throws UnsupportedOperationException { |
|
241 |
throw new HeadlessException(); |
|
242 |
} |
|
243 |
||
244 |
public Cursor createCustomCursor(Image cursor, Point hotSpot, String name) |
|
245 |
throws IndexOutOfBoundsException, HeadlessException { |
|
246 |
throw new HeadlessException(); |
|
247 |
} |
|
248 |
||
249 |
public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) |
|
250 |
throws HeadlessException { |
|
251 |
throw new HeadlessException(); |
|
252 |
} |
|
253 |
||
254 |
public int getMaximumCursorColors() |
|
255 |
throws HeadlessException { |
|
256 |
throw new HeadlessException(); |
|
257 |
} |
|
258 |
||
259 |
public <T extends DragGestureRecognizer> T |
|
260 |
createDragGestureRecognizer(Class<T> abstractRecognizerClass, |
|
261 |
DragSource ds, Component c, |
|
262 |
int srcActions, DragGestureListener dgl) |
|
263 |
{ |
|
264 |
return null; |
|
265 |
} |
|
266 |
||
267 |
public int getScreenHeight() |
|
268 |
throws HeadlessException { |
|
269 |
throw new HeadlessException(); |
|
270 |
} |
|
271 |
||
272 |
public int getScreenWidth() |
|
273 |
throws HeadlessException { |
|
274 |
throw new HeadlessException(); |
|
275 |
} |
|
276 |
||
277 |
public Dimension getScreenSize() |
|
278 |
throws HeadlessException { |
|
279 |
throw new HeadlessException(); |
|
280 |
} |
|
281 |
||
282 |
public Insets getScreenInsets(GraphicsConfiguration gc) |
|
283 |
throws HeadlessException { |
|
284 |
throw new HeadlessException(); |
|
285 |
} |
|
286 |
||
287 |
public void setDynamicLayout(boolean dynamic) |
|
288 |
throws HeadlessException { |
|
289 |
throw new HeadlessException(); |
|
290 |
} |
|
291 |
||
292 |
protected boolean isDynamicLayoutSet() |
|
293 |
throws HeadlessException { |
|
294 |
throw new HeadlessException(); |
|
295 |
} |
|
296 |
||
297 |
public boolean isDynamicLayoutActive() |
|
298 |
throws HeadlessException { |
|
299 |
throw new HeadlessException(); |
|
300 |
} |
|
301 |
||
302 |
public Clipboard getSystemClipboard() |
|
303 |
throws HeadlessException { |
|
304 |
throw new HeadlessException(); |
|
305 |
} |
|
306 |
||
307 |
/* |
|
308 |
* Printing |
|
309 |
*/ |
|
310 |
public PrintJob getPrintJob(Frame frame, String jobtitle, |
|
311 |
JobAttributes jobAttributes, |
|
312 |
PageAttributes pageAttributes) { |
|
313 |
if (frame != null) { |
|
314 |
// Should never happen |
|
315 |
throw new HeadlessException(); |
|
316 |
} |
|
317 |
throw new IllegalArgumentException( |
|
318 |
"PrintJob not supported in a headless environment"); |
|
319 |
} |
|
320 |
||
321 |
public PrintJob getPrintJob(Frame frame, String doctitle, Properties props) |
|
322 |
{ |
|
323 |
if (frame != null) { |
|
324 |
// Should never happen |
|
325 |
throw new HeadlessException(); |
|
326 |
} |
|
327 |
throw new IllegalArgumentException( |
|
328 |
"PrintJob not supported in a headless environment"); |
|
329 |
} |
|
330 |
||
331 |
/* |
|
332 |
* Headless toolkit - supported. |
|
333 |
*/ |
|
334 |
||
335 |
public void sync() { |
|
336 |
// Do nothing |
|
337 |
} |
|
338 |
||
339 |
public void beep() { |
|
340 |
// Send alert character |
|
341 |
System.out.write(0x07); |
|
342 |
} |
|
343 |
||
344 |
/* |
|
345 |
* Event Queue |
|
346 |
*/ |
|
347 |
public EventQueue getSystemEventQueueImpl() { |
|
348 |
return SunToolkit.getSystemEventQueueImplPP(); |
|
349 |
} |
|
350 |
||
351 |
/* |
|
352 |
* Images. |
|
353 |
*/ |
|
354 |
public int checkImage(Image img, int w, int h, ImageObserver o) { |
|
355 |
return tk.checkImage(img, w, h, o); |
|
356 |
} |
|
357 |
||
358 |
public boolean prepareImage( |
|
359 |
Image img, int w, int h, ImageObserver o) { |
|
360 |
return tk.prepareImage(img, w, h, o); |
|
361 |
} |
|
362 |
||
363 |
public Image getImage(String filename) { |
|
364 |
return tk.getImage(filename); |
|
365 |
} |
|
366 |
||
367 |
public Image getImage(URL url) { |
|
368 |
return tk.getImage(url); |
|
369 |
} |
|
370 |
||
371 |
public Image createImage(String filename) { |
|
372 |
return tk.createImage(filename); |
|
373 |
} |
|
374 |
||
375 |
public Image createImage(URL url) { |
|
376 |
return tk.createImage(url); |
|
377 |
} |
|
378 |
||
379 |
public Image createImage(byte[] data, int offset, int length) { |
|
380 |
return tk.createImage(data, offset, length); |
|
381 |
} |
|
382 |
||
383 |
public Image createImage(ImageProducer producer) { |
|
384 |
return tk.createImage(producer); |
|
385 |
} |
|
386 |
||
387 |
public Image createImage(byte[] imagedata) { |
|
388 |
return tk.createImage(imagedata); |
|
389 |
} |
|
390 |
||
391 |
||
392 |
/* |
|
393 |
* Fonts |
|
394 |
*/ |
|
395 |
public FontPeer getFontPeer(String name, int style) { |
|
396 |
if (componentFactory != null) { |
|
397 |
return componentFactory.getFontPeer(name, style); |
|
398 |
} |
|
399 |
return null; |
|
400 |
} |
|
401 |
||
402 |
public FontMetrics getFontMetrics(Font font) { |
|
403 |
return tk.getFontMetrics(font); |
|
404 |
} |
|
405 |
||
406 |
public String[] getFontList() { |
|
407 |
return tk.getFontList(); |
|
408 |
} |
|
409 |
||
410 |
/* |
|
411 |
* Desktop properties |
|
412 |
*/ |
|
413 |
||
414 |
public void addPropertyChangeListener(String name, |
|
415 |
PropertyChangeListener pcl) { |
|
416 |
tk.addPropertyChangeListener(name, pcl); |
|
417 |
} |
|
418 |
||
419 |
public void removePropertyChangeListener(String name, |
|
420 |
PropertyChangeListener pcl) { |
|
421 |
tk.removePropertyChangeListener(name, pcl); |
|
422 |
} |
|
423 |
||
424 |
/* |
|
425 |
* Modality |
|
426 |
*/ |
|
427 |
public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) { |
|
428 |
return false; |
|
429 |
} |
|
430 |
||
431 |
public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) { |
|
432 |
return false; |
|
433 |
} |
|
434 |
||
435 |
/* |
|
436 |
* Always on top |
|
437 |
*/ |
|
438 |
public boolean isAlwaysOnTopSupported() { |
|
439 |
return false; |
|
440 |
} |
|
441 |
||
442 |
/* |
|
443 |
* AWT Event listeners |
|
444 |
*/ |
|
445 |
||
446 |
public void addAWTEventListener(AWTEventListener listener, |
|
447 |
long eventMask) { |
|
448 |
tk.addAWTEventListener(listener, eventMask); |
|
449 |
} |
|
450 |
||
451 |
public void removeAWTEventListener(AWTEventListener listener) { |
|
452 |
tk.removeAWTEventListener(listener); |
|
453 |
} |
|
454 |
||
455 |
public AWTEventListener[] getAWTEventListeners() { |
|
456 |
return tk.getAWTEventListeners(); |
|
457 |
} |
|
458 |
||
1957
1da46e48ada5
6738181: api/java_awt/Toolkit/index.html#GetAWTEventListeners Fails with:empty array returned unexpectedly
dav
parents:
2
diff
changeset
|
459 |
public AWTEventListener[] getAWTEventListeners(long eventMask) { |
1da46e48ada5
6738181: api/java_awt/Toolkit/index.html#GetAWTEventListeners Fails with:empty array returned unexpectedly
dav
parents:
2
diff
changeset
|
460 |
return tk.getAWTEventListeners(eventMask); |
1da46e48ada5
6738181: api/java_awt/Toolkit/index.html#GetAWTEventListeners Fails with:empty array returned unexpectedly
dav
parents:
2
diff
changeset
|
461 |
} |
1da46e48ada5
6738181: api/java_awt/Toolkit/index.html#GetAWTEventListeners Fails with:empty array returned unexpectedly
dav
parents:
2
diff
changeset
|
462 |
|
2 | 463 |
public boolean isDesktopSupported() { |
464 |
return false; |
|
465 |
} |
|
466 |
||
467 |
public DesktopPeer createDesktopPeer(Desktop target) |
|
468 |
throws HeadlessException{ |
|
469 |
throw new HeadlessException(); |
|
470 |
} |
|
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1957
diff
changeset
|
471 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1957
diff
changeset
|
472 |
public boolean areExtraMouseButtonsEnabled() throws HeadlessException{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1957
diff
changeset
|
473 |
throw new HeadlessException(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
1957
diff
changeset
|
474 |
} |
2 | 475 |
} |