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