author | serb |
Fri, 17 Apr 2015 16:54:13 +0300 | |
changeset 30469 | bac0a7ff7e1e |
parent 25859 | 3317bb8137f4 |
child 32865 | f9cb6e427f9e |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23272 | 2 |
* Copyright (c) 1996, 2014, 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 |
package sun.awt.windows; |
|
26 |
||
27 |
import java.awt.*; |
|
28 |
import java.awt.peer.*; |
|
29 |
||
30 |
import sun.awt.*; |
|
31 |
import sun.awt.im.*; |
|
32 |
||
23272 | 33 |
final class WDialogPeer extends WWindowPeer implements DialogPeer { |
2 | 34 |
// Toolkit & peer internals |
35 |
||
36 |
// Platform default background for dialogs. Gets set on target if |
|
37 |
// target has none explicitly specified. |
|
38 |
final static Color defaultBackground = SystemColor.control; |
|
39 |
||
40 |
// If target doesn't have its background color set, we set its |
|
41 |
// background to platform default. |
|
42 |
boolean needDefaultBackground; |
|
43 |
||
44 |
WDialogPeer(Dialog target) { |
|
45 |
super(target); |
|
46 |
||
47 |
InputMethodManager imm = InputMethodManager.getInstance(); |
|
48 |
String menuString = imm.getTriggerMenuString(); |
|
49 |
if (menuString != null) |
|
50 |
{ |
|
51 |
pSetIMMOption(menuString); |
|
52 |
} |
|
53 |
} |
|
54 |
||
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
55 |
native void createAwtDialog(WComponentPeer parent); |
23272 | 56 |
@Override |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
57 |
void create(WComponentPeer parent) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
58 |
preCreate(parent); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
59 |
createAwtDialog(parent); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
60 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
61 |
|
2 | 62 |
native void showModal(); |
63 |
native void endModal(); |
|
64 |
||
23272 | 65 |
@Override |
2 | 66 |
void initialize() { |
67 |
Dialog target = (Dialog)this.target; |
|
68 |
// Need to set target's background to default _before_ a call |
|
69 |
// to super.initialize. |
|
70 |
if (needDefaultBackground) { |
|
71 |
target.setBackground(defaultBackground); |
|
72 |
} |
|
73 |
||
74 |
super.initialize(); |
|
75 |
||
76 |
if (target.getTitle() != null) { |
|
77 |
setTitle(target.getTitle()); |
|
78 |
} |
|
79 |
setResizable(target.isResizable()); |
|
80 |
} |
|
81 |
||
23272 | 82 |
@Override |
2 | 83 |
protected void realShow() { |
84 |
Dialog dlg = (Dialog)target; |
|
85 |
if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) { |
|
86 |
showModal(); |
|
87 |
} else { |
|
88 |
super.realShow(); |
|
89 |
} |
|
90 |
} |
|
91 |
||
23272 | 92 |
@Override |
11271
f10f98b24801
7117011: Reduce number of warnings in sun/awt/windows and sun/awt/datatransfer
denis
parents:
5506
diff
changeset
|
93 |
@SuppressWarnings("deprecation") |
23272 | 94 |
void hide() { |
2 | 95 |
Dialog dlg = (Dialog)target; |
96 |
if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) { |
|
97 |
endModal(); |
|
98 |
} else { |
|
99 |
super.hide(); |
|
100 |
} |
|
101 |
} |
|
102 |
||
23272 | 103 |
@Override |
2 | 104 |
public void blockWindows(java.util.List<Window> toBlock) { |
105 |
for (Window w : toBlock) { |
|
30469 | 106 |
WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(w); |
2 | 107 |
if (wp != null) { |
108 |
wp.setModalBlocked((Dialog)target, true); |
|
109 |
} |
|
110 |
} |
|
111 |
} |
|
112 |
||
23272 | 113 |
@Override |
2 | 114 |
public Dimension getMinimumSize() { |
115 |
if (((Dialog)target).isUndecorated()) { |
|
116 |
return super.getMinimumSize(); |
|
117 |
} else { |
|
118 |
return new Dimension(getSysMinWidth(), getSysMinHeight()); |
|
119 |
} |
|
120 |
} |
|
121 |
||
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
122 |
@Override |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
123 |
boolean isTargetUndecorated() { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
124 |
return ((Dialog)target).isUndecorated(); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
125 |
} |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
126 |
|
23272 | 127 |
@Override |
2 | 128 |
public void reshape(int x, int y, int width, int height) { |
129 |
if (((Dialog)target).isUndecorated()) { |
|
2643
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
715
diff
changeset
|
130 |
super.reshape(x, y, width, height); |
2 | 131 |
} else { |
2643
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
715
diff
changeset
|
132 |
reshapeFrame(x, y, width, height); |
2 | 133 |
} |
134 |
} |
|
135 |
||
136 |
/* Native create() peeks at target's background and if it's null |
|
137 |
* calls this method to arrage for default background to be set on |
|
138 |
* target. Can't make the check in Java, since getBackground will |
|
139 |
* return owner's background if target has none set. |
|
140 |
*/ |
|
141 |
private void setDefaultColor() { |
|
142 |
// Can't call target.setBackground directly, since we are |
|
143 |
// called on toolkit thread. Can't schedule a Runnable on the |
|
144 |
// EventHandlerThread because of the race condition. So just |
|
145 |
// set a flag and call target.setBackground in initialize. |
|
146 |
needDefaultBackground = true; |
|
147 |
} |
|
148 |
||
149 |
native void pSetIMMOption(String option); |
|
150 |
void notifyIMMOptionChange(){ |
|
151 |
InputMethodManager.getInstance().notifyChangeRequest((Component)target); |
|
152 |
} |
|
153 |
} |