author | jqzuo |
Thu, 30 Jan 2014 10:36:40 -0500 | |
changeset 23276 | add6f5c93bc6 |
parent 23261 | 49117dc9e97c |
parent 22060 | cd4f9d7dbeda |
child 23900 | fd98305f0d19 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
2 |
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
12047 | 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. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle 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 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. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.lwawt; |
|
27 |
||
28 |
import java.awt.*; |
|
29 |
import java.awt.List; |
|
30 |
import java.awt.datatransfer.*; |
|
31 |
import java.awt.image.*; |
|
32 |
import java.awt.peer.*; |
|
33 |
import java.security.*; |
|
34 |
import java.util.*; |
|
35 |
||
36 |
import sun.awt.*; |
|
37 |
import sun.print.*; |
|
38 |
||
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
39 |
import static sun.lwawt.LWWindowPeer.PeerType; |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
40 |
|
12047 | 41 |
public abstract class LWToolkit extends SunToolkit implements Runnable { |
42 |
||
43 |
private final static int STATE_NONE = 0; |
|
44 |
private final static int STATE_INIT = 1; |
|
45 |
private final static int STATE_MESSAGELOOP = 2; |
|
46 |
private final static int STATE_SHUTDOWN = 3; |
|
47 |
private final static int STATE_CLEANUP = 4; |
|
48 |
private final static int STATE_DONE = 5; |
|
49 |
||
50 |
private int runState = STATE_NONE; |
|
51 |
||
52 |
private Clipboard clipboard; |
|
53 |
private MouseInfoPeer mouseInfoPeer; |
|
54 |
||
17410
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
55 |
/** |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
56 |
* Dynamic Layout Resize client code setting. |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
57 |
*/ |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
58 |
private volatile boolean dynamicLayoutSetting = true; |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
59 |
|
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
60 |
protected LWToolkit() { |
12047 | 61 |
} |
62 |
||
63 |
/* |
|
64 |
* This method is called by subclasses to start this toolkit |
|
65 |
* by launching the message loop. |
|
66 |
* |
|
67 |
* This method waits for the toolkit to be completely initialized |
|
68 |
* and returns before the message pump is started. |
|
69 |
*/ |
|
70 |
protected final void init() { |
|
71 |
AWTAutoShutdown.notifyToolkitThreadBusy(); |
|
72 |
||
73 |
ThreadGroup mainTG = AccessController.doPrivileged( |
|
74 |
new PrivilegedAction<ThreadGroup>() { |
|
75 |
public ThreadGroup run() { |
|
76 |
ThreadGroup currentTG = Thread.currentThread().getThreadGroup(); |
|
77 |
ThreadGroup parentTG = currentTG.getParent(); |
|
78 |
while (parentTG != null) { |
|
79 |
currentTG = parentTG; |
|
80 |
parentTG = currentTG.getParent(); |
|
81 |
} |
|
82 |
return currentTG; |
|
83 |
} |
|
84 |
} |
|
85 |
); |
|
86 |
||
87 |
Runtime.getRuntime().addShutdownHook( |
|
88 |
new Thread(mainTG, new Runnable() { |
|
89 |
public void run() { |
|
90 |
shutdown(); |
|
91 |
waitForRunState(STATE_CLEANUP); |
|
92 |
} |
|
93 |
}) |
|
94 |
); |
|
95 |
||
96 |
Thread toolkitThread = new Thread(mainTG, this, "AWT-LW"); |
|
97 |
toolkitThread.setDaemon(true); |
|
98 |
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1); |
|
99 |
toolkitThread.start(); |
|
100 |
||
101 |
waitForRunState(STATE_MESSAGELOOP); |
|
102 |
} |
|
103 |
||
104 |
/* |
|
105 |
* Implemented in subclasses to initialize platform-dependent |
|
106 |
* part of the toolkit (open X display connection, create |
|
107 |
* toolkit HWND, etc.) |
|
108 |
* |
|
109 |
* This method is called on the toolkit thread. |
|
110 |
*/ |
|
111 |
protected abstract void platformInit(); |
|
112 |
||
113 |
/* |
|
114 |
* Sends a request to stop the message pump. |
|
115 |
*/ |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
116 |
public final void shutdown() { |
12047 | 117 |
setRunState(STATE_SHUTDOWN); |
118 |
platformShutdown(); |
|
119 |
} |
|
120 |
||
121 |
/* |
|
122 |
* Implemented in subclasses to release all the platform- |
|
123 |
* dependent resources. Called after the message loop is |
|
124 |
* terminated. |
|
125 |
* |
|
126 |
* Could be called (always called?) on a non-toolkit thread. |
|
127 |
*/ |
|
128 |
protected abstract void platformShutdown(); |
|
129 |
||
130 |
/* |
|
131 |
* Implemented in subclasses to release all the platform |
|
132 |
* resources before the application is terminated. |
|
133 |
* |
|
134 |
* This method is called on the toolkit thread. |
|
135 |
*/ |
|
136 |
protected abstract void platformCleanup(); |
|
137 |
||
138 |
private synchronized int getRunState() { |
|
139 |
return runState; |
|
140 |
} |
|
141 |
||
142 |
private synchronized void setRunState(int state) { |
|
143 |
runState = state; |
|
144 |
notifyAll(); |
|
145 |
} |
|
146 |
||
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
147 |
public final boolean isTerminating() { |
12047 | 148 |
return getRunState() >= STATE_SHUTDOWN; |
149 |
} |
|
150 |
||
151 |
private void waitForRunState(int state) { |
|
152 |
while (getRunState() < state) { |
|
153 |
try { |
|
154 |
synchronized (this) { |
|
155 |
wait(); |
|
156 |
} |
|
157 |
} catch (InterruptedException z) { |
|
158 |
// TODO: log |
|
159 |
break; |
|
160 |
} |
|
161 |
} |
|
162 |
} |
|
163 |
||
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
164 |
@Override |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
165 |
public final void run() { |
12047 | 166 |
setRunState(STATE_INIT); |
167 |
platformInit(); |
|
168 |
AWTAutoShutdown.notifyToolkitThreadFree(); |
|
169 |
setRunState(STATE_MESSAGELOOP); |
|
170 |
while (getRunState() < STATE_SHUTDOWN) { |
|
171 |
try { |
|
172 |
platformRunMessage(); |
|
173 |
if (Thread.currentThread().isInterrupted()) { |
|
174 |
if (AppContext.getAppContext().isDisposed()) { |
|
175 |
break; |
|
176 |
} |
|
177 |
} |
|
178 |
} catch (ThreadDeath td) { |
|
179 |
//XXX: if there isn't native code on the stack, the VM just |
|
180 |
//kills the thread right away. Do we expect to catch it |
|
181 |
//nevertheless? |
|
182 |
break; |
|
183 |
} catch (Throwable t) { |
|
184 |
// TODO: log |
|
185 |
System.err.println("Exception on the toolkit thread"); |
|
186 |
t.printStackTrace(System.err); |
|
187 |
} |
|
188 |
} |
|
189 |
//XXX: if that's a secondary loop, jump back to the STATE_MESSAGELOOP |
|
190 |
setRunState(STATE_CLEANUP); |
|
191 |
AWTAutoShutdown.notifyToolkitThreadFree(); |
|
192 |
platformCleanup(); |
|
193 |
setRunState(STATE_DONE); |
|
194 |
} |
|
195 |
||
196 |
/* |
|
197 |
* Process the next message(s) from the native event queue. |
|
198 |
* |
|
199 |
* Initially, all the LWToolkit implementations were supposed |
|
200 |
* to have the similar message loop sequence: check if any events |
|
201 |
* available, peek events, wait. However, the later analysis shown |
|
202 |
* that X11 and Windows implementations are really different, so |
|
203 |
* let the subclasses do whatever they require. |
|
204 |
*/ |
|
205 |
protected abstract void platformRunMessage(); |
|
206 |
||
207 |
public static LWToolkit getLWToolkit() { |
|
208 |
return (LWToolkit)Toolkit.getDefaultToolkit(); |
|
209 |
} |
|
210 |
||
211 |
// ---- TOPLEVEL PEERS ---- // |
|
212 |
||
213 |
/* |
|
214 |
* Note that LWWindowPeer implements WindowPeer, FramePeer |
|
215 |
* and DialogPeer interfaces. |
|
216 |
*/ |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
217 |
protected LWWindowPeer createDelegatedPeer(Window target, |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
218 |
PlatformComponent platformComponent, |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
219 |
PlatformWindow platformWindow, |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
220 |
PeerType peerType) { |
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
13993
diff
changeset
|
221 |
LWWindowPeer peer = new LWWindowPeer(target, platformComponent, platformWindow, peerType); |
12047 | 222 |
targetCreatedPeer(target, peer); |
223 |
peer.initialize(); |
|
224 |
return peer; |
|
225 |
} |
|
226 |
||
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
227 |
@Override |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
228 |
public final FramePeer createLightweightFrame(LightweightFrame target) { |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
229 |
PlatformComponent platformComponent = createLwPlatformComponent(); |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
230 |
PlatformWindow platformWindow = createPlatformWindow(PeerType.LW_FRAME); |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
231 |
LWLightweightFramePeer peer = new LWLightweightFramePeer(target, |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
232 |
platformComponent, |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
233 |
platformWindow); |
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15323
diff
changeset
|
234 |
targetCreatedPeer(target, peer); |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15323
diff
changeset
|
235 |
peer.initialize(); |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15323
diff
changeset
|
236 |
return peer; |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15323
diff
changeset
|
237 |
} |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15323
diff
changeset
|
238 |
|
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15323
diff
changeset
|
239 |
@Override |
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
240 |
public final WindowPeer createWindow(Window target) { |
12047 | 241 |
PlatformComponent platformComponent = createPlatformComponent(); |
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
242 |
PlatformWindow platformWindow = createPlatformWindow(PeerType.SIMPLEWINDOW); |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
243 |
return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.SIMPLEWINDOW); |
12047 | 244 |
} |
245 |
||
246 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
247 |
public final FramePeer createFrame(Frame target) { |
12047 | 248 |
PlatformComponent platformComponent = createPlatformComponent(); |
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
249 |
PlatformWindow platformWindow = createPlatformWindow(PeerType.FRAME); |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
250 |
return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.FRAME); |
12047 | 251 |
} |
252 |
||
253 |
@Override |
|
254 |
public DialogPeer createDialog(Dialog target) { |
|
255 |
PlatformComponent platformComponent = createPlatformComponent(); |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
256 |
PlatformWindow platformWindow = createPlatformWindow(PeerType.DIALOG); |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
257 |
return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.DIALOG); |
12047 | 258 |
} |
259 |
||
260 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
261 |
public final FileDialogPeer createFileDialog(FileDialog target) { |
12047 | 262 |
FileDialogPeer peer = createFileDialogPeer(target); |
263 |
targetCreatedPeer(target, peer); |
|
264 |
return peer; |
|
265 |
} |
|
266 |
||
267 |
// ---- LIGHTWEIGHT COMPONENT PEERS ---- // |
|
268 |
||
269 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
270 |
public final ButtonPeer createButton(Button target) { |
12047 | 271 |
PlatformComponent platformComponent = createPlatformComponent(); |
272 |
LWButtonPeer peer = new LWButtonPeer(target, platformComponent); |
|
273 |
targetCreatedPeer(target, peer); |
|
274 |
peer.initialize(); |
|
275 |
return peer; |
|
276 |
} |
|
277 |
||
278 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
279 |
public final CheckboxPeer createCheckbox(Checkbox target) { |
12047 | 280 |
PlatformComponent platformComponent = createPlatformComponent(); |
281 |
LWCheckboxPeer peer = new LWCheckboxPeer(target, platformComponent); |
|
282 |
targetCreatedPeer(target, peer); |
|
283 |
peer.initialize(); |
|
284 |
return peer; |
|
285 |
} |
|
286 |
||
287 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
288 |
public final ChoicePeer createChoice(Choice target) { |
12047 | 289 |
PlatformComponent platformComponent = createPlatformComponent(); |
290 |
LWChoicePeer peer = new LWChoicePeer(target, platformComponent); |
|
291 |
targetCreatedPeer(target, peer); |
|
292 |
peer.initialize(); |
|
293 |
return peer; |
|
294 |
} |
|
295 |
||
296 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
297 |
public final LabelPeer createLabel(Label target) { |
12047 | 298 |
PlatformComponent platformComponent = createPlatformComponent(); |
299 |
LWLabelPeer peer = new LWLabelPeer(target, platformComponent); |
|
300 |
targetCreatedPeer(target, peer); |
|
301 |
peer.initialize(); |
|
302 |
return peer; |
|
303 |
} |
|
304 |
||
305 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
306 |
public final CanvasPeer createCanvas(Canvas target) { |
12047 | 307 |
PlatformComponent platformComponent = createPlatformComponent(); |
13993 | 308 |
LWCanvasPeer<?, ?> peer = new LWCanvasPeer<>(target, platformComponent); |
12047 | 309 |
targetCreatedPeer(target, peer); |
310 |
peer.initialize(); |
|
311 |
return peer; |
|
312 |
} |
|
313 |
||
314 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
315 |
public final ListPeer createList(List target) { |
12047 | 316 |
PlatformComponent platformComponent = createPlatformComponent(); |
317 |
LWListPeer peer = new LWListPeer(target, platformComponent); |
|
318 |
targetCreatedPeer(target, peer); |
|
319 |
peer.initialize(); |
|
320 |
return peer; |
|
321 |
} |
|
322 |
||
323 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
324 |
public final PanelPeer createPanel(Panel target) { |
12047 | 325 |
PlatformComponent platformComponent = createPlatformComponent(); |
326 |
LWPanelPeer peer = new LWPanelPeer(target, platformComponent); |
|
327 |
targetCreatedPeer(target, peer); |
|
328 |
peer.initialize(); |
|
329 |
return peer; |
|
330 |
} |
|
331 |
||
332 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
333 |
public final ScrollPanePeer createScrollPane(ScrollPane target) { |
12047 | 334 |
PlatformComponent platformComponent = createPlatformComponent(); |
335 |
LWScrollPanePeer peer = new LWScrollPanePeer(target, platformComponent); |
|
336 |
targetCreatedPeer(target, peer); |
|
337 |
peer.initialize(); |
|
338 |
return peer; |
|
339 |
} |
|
340 |
||
341 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
342 |
public final ScrollbarPeer createScrollbar(Scrollbar target) { |
12047 | 343 |
PlatformComponent platformComponent = createPlatformComponent(); |
344 |
LWScrollBarPeer peer = new LWScrollBarPeer(target, platformComponent); |
|
345 |
targetCreatedPeer(target, peer); |
|
346 |
peer.initialize(); |
|
347 |
return peer; |
|
348 |
} |
|
349 |
||
350 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
351 |
public final TextAreaPeer createTextArea(TextArea target) { |
12047 | 352 |
PlatformComponent platformComponent = createPlatformComponent(); |
353 |
LWTextAreaPeer peer = new LWTextAreaPeer(target, platformComponent); |
|
354 |
targetCreatedPeer(target, peer); |
|
355 |
peer.initialize(); |
|
356 |
return peer; |
|
357 |
} |
|
358 |
||
359 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
360 |
public final TextFieldPeer createTextField(TextField target) { |
12047 | 361 |
PlatformComponent platformComponent = createPlatformComponent(); |
362 |
LWTextFieldPeer peer = new LWTextFieldPeer(target, platformComponent); |
|
363 |
targetCreatedPeer(target, peer); |
|
364 |
peer.initialize(); |
|
365 |
return peer; |
|
366 |
} |
|
367 |
||
368 |
// ---- NON-COMPONENT PEERS ---- // |
|
369 |
||
370 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
371 |
public final ColorModel getColorModel() throws HeadlessException { |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
372 |
return GraphicsEnvironment.getLocalGraphicsEnvironment() |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
373 |
.getDefaultScreenDevice() |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
374 |
.getDefaultConfiguration().getColorModel(); |
12047 | 375 |
} |
376 |
||
377 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
378 |
public final boolean isDesktopSupported() { |
12047 | 379 |
return true; |
380 |
} |
|
381 |
||
382 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
383 |
public final KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() { |
13648
90effcfc064f
7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents:
13233
diff
changeset
|
384 |
return LWKeyboardFocusManagerPeer.getInstance(); |
12047 | 385 |
} |
386 |
||
387 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
388 |
public final synchronized MouseInfoPeer getMouseInfoPeer() { |
12047 | 389 |
if (mouseInfoPeer == null) { |
390 |
mouseInfoPeer = createMouseInfoPeerImpl(); |
|
391 |
} |
|
392 |
return mouseInfoPeer; |
|
393 |
} |
|
394 |
||
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
395 |
protected final MouseInfoPeer createMouseInfoPeerImpl() { |
12047 | 396 |
return new LWMouseInfoPeer(); |
397 |
} |
|
398 |
||
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
399 |
@Override |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
400 |
public final PrintJob getPrintJob(Frame frame, String doctitle, |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
401 |
Properties props) { |
12047 | 402 |
return getPrintJob(frame, doctitle, null, null); |
403 |
} |
|
404 |
||
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
405 |
@Override |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
406 |
public final PrintJob getPrintJob(Frame frame, String doctitle, |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
407 |
JobAttributes jobAttributes, |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
408 |
PageAttributes pageAttributes) { |
12047 | 409 |
if (GraphicsEnvironment.isHeadless()) { |
410 |
throw new IllegalArgumentException(); |
|
411 |
} |
|
412 |
||
413 |
PrintJob2D printJob = new PrintJob2D(frame, doctitle, jobAttributes, pageAttributes); |
|
414 |
||
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
415 |
if (!printJob.printDialog()) { |
12047 | 416 |
printJob = null; |
417 |
} |
|
418 |
||
419 |
return printJob; |
|
420 |
} |
|
421 |
||
422 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
423 |
public final Clipboard getSystemClipboard() { |
12047 | 424 |
SecurityManager security = System.getSecurityManager(); |
425 |
if (security != null) { |
|
22060
cd4f9d7dbeda
8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents:
20153
diff
changeset
|
426 |
security.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION); |
12047 | 427 |
} |
428 |
||
429 |
synchronized (this) { |
|
430 |
if (clipboard == null) { |
|
431 |
clipboard = createPlatformClipboard(); |
|
432 |
} |
|
433 |
} |
|
434 |
return clipboard; |
|
435 |
} |
|
436 |
||
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
437 |
protected abstract SecurityWarningWindow createSecurityWarning( |
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
438 |
Window ownerWindow, LWWindowPeer ownerPeer); |
18241 | 439 |
|
12047 | 440 |
// ---- DELEGATES ---- // |
441 |
||
442 |
public abstract Clipboard createPlatformClipboard(); |
|
443 |
||
444 |
/* |
|
445 |
* Creates a delegate for the given peer type (window, frame, dialog, etc.) |
|
446 |
*/ |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
447 |
protected abstract PlatformWindow createPlatformWindow(PeerType peerType); |
12047 | 448 |
|
449 |
protected abstract PlatformComponent createPlatformComponent(); |
|
450 |
||
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15323
diff
changeset
|
451 |
protected abstract PlatformComponent createLwPlatformComponent(); |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15323
diff
changeset
|
452 |
|
12047 | 453 |
protected abstract FileDialogPeer createFileDialogPeer(FileDialog target); |
454 |
||
455 |
// ---- UTILITY METHODS ---- // |
|
456 |
||
457 |
/* |
|
458 |
* Expose non-public targetToPeer() method. |
|
459 |
*/ |
|
460 |
public final static Object targetToPeer(Object target) { |
|
461 |
return SunToolkit.targetToPeer(target); |
|
462 |
} |
|
463 |
||
464 |
/* |
|
465 |
* Expose non-public targetDisposedPeer() method. |
|
466 |
*/ |
|
467 |
public final static void targetDisposedPeer(Object target, Object peer) { |
|
468 |
SunToolkit.targetDisposedPeer(target, peer); |
|
469 |
} |
|
470 |
||
471 |
/* |
|
472 |
* Returns the current cursor manager. |
|
473 |
*/ |
|
474 |
public abstract LWCursorManager getCursorManager(); |
|
475 |
||
476 |
public static void postEvent(AWTEvent event) { |
|
477 |
postEvent(targetToAppContext(event.getSource()), event); |
|
478 |
} |
|
479 |
||
480 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
481 |
public final void grab(final Window w) { |
20153 | 482 |
final Object peer = AWTAccessor.getComponentAccessor().getPeer(w); |
483 |
if (peer != null) { |
|
484 |
((LWWindowPeer) peer).grab(); |
|
12047 | 485 |
} |
486 |
} |
|
487 |
||
488 |
@Override |
|
23261
49117dc9e97c
8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents:
20153
diff
changeset
|
489 |
public final void ungrab(final Window w) { |
20153 | 490 |
final Object peer = AWTAccessor.getComponentAccessor().getPeer(w); |
491 |
if (peer != null) { |
|
492 |
((LWWindowPeer) peer).ungrab(false); |
|
12047 | 493 |
} |
494 |
} |
|
17410
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
495 |
|
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
496 |
@Override |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
497 |
protected final Object lazilyLoadDesktopProperty(final String name) { |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
498 |
if (name.equals("awt.dynamicLayoutSupported")) { |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
499 |
return isDynamicLayoutSupported(); |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
500 |
} |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
501 |
return super.lazilyLoadDesktopProperty(name); |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
502 |
} |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
503 |
|
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
504 |
@Override |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
505 |
public final void setDynamicLayout(final boolean dynamic) { |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
506 |
dynamicLayoutSetting = dynamic; |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
507 |
} |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
508 |
|
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
509 |
@Override |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
510 |
protected final boolean isDynamicLayoutSet() { |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
511 |
return dynamicLayoutSetting; |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
512 |
} |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
513 |
|
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
514 |
@Override |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
515 |
public final boolean isDynamicLayoutActive() { |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
516 |
// "Live resizing" is active by default and user's data is ignored. |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
517 |
return isDynamicLayoutSupported(); |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
518 |
} |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
519 |
|
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
520 |
/** |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
521 |
* Returns true if dynamic layout of Containers on resize is supported by |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
522 |
* the underlying operating system and/or window manager. |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
523 |
*/ |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
524 |
protected final boolean isDynamicLayoutSupported() { |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
525 |
// "Live resizing" is supported by default. |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
526 |
return true; |
c9c726c5ce7e
7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents:
15983
diff
changeset
|
527 |
} |
12047 | 528 |
} |