jdk/src/java.desktop/windows/classes/sun/awt/windows/WDialogPeer.java
author pkbalakr
Tue, 24 May 2016 14:19:53 +0530
changeset 38992 5e8d53377c10
parent 32865 f9cb6e427f9e
permissions -rw-r--r--
8057574: inconsistent behavior for setBackground (Windows/Linux) Reviewed-by: serb, arapte
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 11271
diff changeset
     2
 * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.awt.windows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.awt.im.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 11271
diff changeset
    33
final class WDialogPeer extends WWindowPeer implements DialogPeer {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    // Toolkit & peer internals
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    // Platform default background for dialogs.  Gets set on target if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    // target has none explicitly specified.
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 30469
diff changeset
    38
    static final Color defaultBackground =  SystemColor.control;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    WDialogPeer(Dialog target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        super(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        InputMethodManager imm = InputMethodManager.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        String menuString = imm.getTriggerMenuString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        if (menuString != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
            pSetIMMOption(menuString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 2643
diff changeset
    51
    native void createAwtDialog(WComponentPeer parent);
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 11271
diff changeset
    52
    @Override
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 2643
diff changeset
    53
    void create(WComponentPeer parent) {
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 2643
diff changeset
    54
        preCreate(parent);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 2643
diff changeset
    55
        createAwtDialog(parent);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 2643
diff changeset
    56
    }
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 2643
diff changeset
    57
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    native void showModal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    native void endModal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 11271
diff changeset
    61
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    void initialize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        Dialog target = (Dialog)this.target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        // Need to set target's background to default _before_ a call
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        // to super.initialize.
38992
5e8d53377c10 8057574: inconsistent behavior for setBackground (Windows/Linux)
pkbalakr
parents: 32865
diff changeset
    66
        if (!target.isBackgroundSet()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            target.setBackground(defaultBackground);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        super.initialize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        if (target.getTitle() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            setTitle(target.getTitle());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        setResizable(target.isResizable());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 11271
diff changeset
    78
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    protected void realShow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        Dialog dlg = (Dialog)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            showModal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            super.realShow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 11271
diff changeset
    88
    @Override
11271
f10f98b24801 7117011: Reduce number of warnings in sun/awt/windows and sun/awt/datatransfer
denis
parents: 5506
diff changeset
    89
    @SuppressWarnings("deprecation")
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 11271
diff changeset
    90
    void hide() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        Dialog dlg = (Dialog)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            endModal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            super.hide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 11271
diff changeset
    99
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public void blockWindows(java.util.List<Window> toBlock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        for (Window w : toBlock) {
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 25859
diff changeset
   102
            WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(w);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            if (wp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                wp.setModalBlocked((Dialog)target, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 11271
diff changeset
   109
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public Dimension getMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        if (((Dialog)target).isUndecorated()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            return super.getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            return new Dimension(getSysMinWidth(), getSysMinHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
   118
    @Override
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
   119
    boolean isTargetUndecorated() {
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
   120
        return ((Dialog)target).isUndecorated();
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
   121
    }
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
   122
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 11271
diff changeset
   123
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public void reshape(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        if (((Dialog)target).isUndecorated()) {
2643
ea218b1a2000 6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents: 715
diff changeset
   126
            super.reshape(x, y, width, height);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        } else {
2643
ea218b1a2000 6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents: 715
diff changeset
   128
            reshapeFrame(x, y, width, height);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    native void pSetIMMOption(String option);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    void notifyIMMOptionChange(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
      InputMethodManager.getInstance().notifyChangeRequest((Component)target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
}