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