jdk/src/windows/native/sun/windows/awt_FileDialog.cpp
author asaha
Wed, 04 May 2011 16:39:05 -0700
changeset 9851 23bd656b112e
parent 9829 59c2c48a4b9e
parent 9201 c2c745bb19a6
child 10411 f63e5bab1676
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 5506
diff changeset
     2
 * Copyright (c) 1996, 2010, 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: 4913
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: 4913
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: 4913
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4913
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4913
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include "awt.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "awt_FileDialog.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "awt_Dialog.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "awt_Toolkit.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "ComCtl32Util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <commdlg.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include <cderr.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include <shlobj.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * AwtFileDialog fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/* WFileDialogPeer ids */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
jfieldID AwtFileDialog::parentID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
jfieldID AwtFileDialog::fileFilterID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
jmethodID AwtFileDialog::setHWndMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
jmethodID AwtFileDialog::handleSelectedMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
jmethodID AwtFileDialog::handleCancelMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
jmethodID AwtFileDialog::checkFilenameFilterMID;
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
    47
jmethodID AwtFileDialog::isMultipleModeMID;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
/* FileDialog ids */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
jfieldID AwtFileDialog::modeID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
jfieldID AwtFileDialog::dirID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
jfieldID AwtFileDialog::fileID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
jfieldID AwtFileDialog::filterID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
/* Localized filter string */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#define MAX_FILTER_STRING       128
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
static TCHAR s_fileFilterString[MAX_FILTER_STRING];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
/* Non-localized suffix of the filter string */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
static const TCHAR s_additionalString[] = TEXT(" (*.*)\0*.*\0");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
    61
// Default limit of the output buffer.
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
    62
#define SINGLE_MODE_BUFFER_LIMIT     MAX_PATH+1
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
    63
#define MULTIPLE_MODE_BUFFER_LIMIT   32768
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
    64
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
    65
// The name of the property holding the pointer to the OPENFILENAME structure.
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
    66
static LPCTSTR OpenFileNameProp = TEXT("AWT_OFN");
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
    67
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/***********************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
AwtFileDialog::Initialize(JNIEnv *env, jstring filterDescription)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    int length = env->GetStringLength(filterDescription);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    DASSERT(length + 1 < MAX_FILTER_STRING);
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
    75
    LPCTSTR tmp = JNU_GetStringPlatformChars(env, filterDescription, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    _tcscpy(s_fileFilterString, tmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    JNU_ReleaseStringPlatformChars(env, filterDescription, tmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    //AdditionalString should be terminated by two NULL characters (Windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    //requirement), so we have to organize the following cycle and use memcpy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    //unstead of, for example, strcat.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    LPTSTR s = s_fileFilterString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    while (*s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        ++s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        DASSERT(s < s_fileFilterString + MAX_FILTER_STRING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    DASSERT(s + sizeof(s_additionalString) < s_fileFilterString + MAX_FILTER_STRING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    memcpy(s, s_additionalString, sizeof(s_additionalString));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
LRESULT CALLBACK FileDialogWndProc(HWND hWnd, UINT message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                                        WPARAM wParam, LPARAM lParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    switch (message) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        case WM_COMMAND: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            if (LOWORD(wParam) == IDCANCEL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                // Unlike Print/Page dialogs, we only handle IDCANCEL here and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                // don't handle IDOK. This is because user can press OK button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                // when no file is selected, and the dialog is not closed. So
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                // OK button is handled in the CDN_FILEOK notification handler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                // (see FileDialogHookProc below)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                jobject peer = (jobject)(::GetProp(hWnd, ModalDialogPeerProp));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                env->CallVoidMethod(peer, AwtFileDialog::setHWndMID, (jlong)0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
2456
45ee87a35349 6792023: Print suspends on Windows 2000 Pro since 6u12 b01
dcherepanov
parents: 1954
diff changeset
   112
    WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(hWnd, NativeDialogWndProcProp));
45ee87a35349 6792023: Print suspends on Windows 2000 Pro since 6u12 b01
dcherepanov
parents: 1954
diff changeset
   113
    return ComCtl32Util::GetInstance().DefWindowProc(lpfnWndProc, hWnd, message, wParam, lParam);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
static UINT_PTR CALLBACK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
FileDialogHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    HWND parent = ::GetParent(hdlg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    switch(uiMsg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        case WM_INITDIALOG: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            OPENFILENAME *ofn = (OPENFILENAME *)lParam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            jobject peer = (jobject)(ofn->lCustData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            env->CallVoidMethod(peer, AwtFileDialog::setHWndMID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                (jlong)parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            ::SetProp(parent, ModalDialogPeerProp, reinterpret_cast<HANDLE>(peer));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            // fix for 4508670 - disable CS_SAVEBITS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            DWORD style = ::GetClassLong(hdlg,GCL_STYLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            ::SetClassLong(hdlg,GCL_STYLE,style & ~CS_SAVEBITS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            // set appropriate icon for parentless dialogs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            jobject awtParent = env->GetObjectField(peer, AwtFileDialog::parentID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            if (awtParent == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                ::SendMessage(parent, WM_SETICON, (WPARAM)ICON_BIG,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                              (LPARAM)AwtToolkit::GetInstance().GetAwtIcon());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                env->DeleteLocalRef(awtParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            // subclass dialog's parent to receive additional messages
2456
45ee87a35349 6792023: Print suspends on Windows 2000 Pro since 6u12 b01
dcherepanov
parents: 1954
diff changeset
   147
            WNDPROC lpfnWndProc = ComCtl32Util::GetInstance().SubclassHWND(parent,
45ee87a35349 6792023: Print suspends on Windows 2000 Pro since 6u12 b01
dcherepanov
parents: 1954
diff changeset
   148
                                                                           FileDialogWndProc);
45ee87a35349 6792023: Print suspends on Windows 2000 Pro since 6u12 b01
dcherepanov
parents: 1954
diff changeset
   149
            ::SetProp(parent, NativeDialogWndProcProp, reinterpret_cast<HANDLE>(lpfnWndProc));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   151
            ::SetProp(parent, OpenFileNameProp, (void *)lParam);
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   152
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        case WM_DESTROY: {
2456
45ee87a35349 6792023: Print suspends on Windows 2000 Pro since 6u12 b01
dcherepanov
parents: 1954
diff changeset
   156
            WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(parent, NativeDialogWndProcProp));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            ComCtl32Util::GetInstance().UnsubclassHWND(parent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                                                       FileDialogWndProc,
2456
45ee87a35349 6792023: Print suspends on Windows 2000 Pro since 6u12 b01
dcherepanov
parents: 1954
diff changeset
   159
                                                       lpfnWndProc);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            ::RemoveProp(parent, ModalDialogPeerProp);
2456
45ee87a35349 6792023: Print suspends on Windows 2000 Pro since 6u12 b01
dcherepanov
parents: 1954
diff changeset
   161
            ::RemoveProp(parent, NativeDialogWndProcProp);
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   162
            ::RemoveProp(parent, OpenFileNameProp);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        case WM_NOTIFY: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            OFNOTIFYEX *notifyEx = (OFNOTIFYEX *)lParam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            if (notifyEx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                jobject peer = (jobject)(::GetProp(parent, ModalDialogPeerProp));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                if (notifyEx->hdr.code == CDN_INCLUDEITEM) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    LPITEMIDLIST pidl = (LPITEMIDLIST)notifyEx->pidl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                    // Get the filename and directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                    TCHAR szPath[MAX_PATH];
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   173
                    if (!::SHGetPathFromIDList(pidl, szPath)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                        return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                    jstring strPath = JNU_NewStringPlatform(env, szPath);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    // Call FilenameFilter.accept with path and filename
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                    UINT uRes = (env->CallBooleanMethod(peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                        AwtFileDialog::checkFilenameFilterMID, strPath) == JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                    env->DeleteLocalRef(strPath);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                    return uRes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                } else if (notifyEx->hdr.code == CDN_FILEOK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                    // This notification is sent when user selects some file and presses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                    // OK button; it is not sent when no file is selected. So it's time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                    // to unblock all the windows blocked by this dialog as it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                    // be closed soon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                    env->CallVoidMethod(peer, AwtFileDialog::setHWndMID, (jlong)0);
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   188
                } else if (notifyEx->hdr.code == CDN_SELCHANGE) {
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   189
                    // reallocate the buffer if the buffer is too small
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   190
                    LPOPENFILENAME lpofn = (LPOPENFILENAME)GetProp(parent, OpenFileNameProp);
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   191
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   192
                    UINT nLength = CommDlg_OpenSave_GetSpec(parent, NULL, 0) +
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   193
                                   CommDlg_OpenSave_GetFolderPath(parent, NULL, 0);
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   194
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   195
                    if (lpofn->nMaxFile < nLength)
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   196
                    {
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   197
                        // allocate new buffer
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   198
                        LPTSTR newBuffer = new TCHAR[nLength];
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   199
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   200
                        if (newBuffer) {
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   201
                            memset(newBuffer, 0, nLength * sizeof(TCHAR));
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   202
                            LPTSTR oldBuffer = lpofn->lpstrFile;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   203
                            lpofn->lpstrFile = newBuffer;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   204
                            lpofn->nMaxFile = nLength;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   205
                            // free the previously allocated buffer
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   206
                            if (oldBuffer) {
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   207
                                delete[] oldBuffer;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   208
                            }
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   209
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   210
                        }
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   211
                    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    CATCH_BAD_ALLOC_RET(TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
AwtFileDialog::Show(void *p)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    jobject peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    LPTSTR fileBuffer = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    LPTSTR currentDirectory = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    jint mode = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    BOOL result = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    DWORD dlgerr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    jstring directory = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    jstring title = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    jstring file = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    jobject fileFilter = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    jobject target = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    jobject parent = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    AwtComponent* awtParent = NULL;
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   240
    jboolean multipleMode = JNI_FALSE;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   241
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   242
    OPENFILENAME ofn;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   243
    memset(&ofn, 0, sizeof(ofn));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * There's a situation (see bug 4906972) when InvokeFunction (by which this method is called)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * returnes earlier than this method returnes. Probably it's caused due to ReplyMessage system call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * So for the avoidance of this mistiming we need to make new global reference here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * (not local as it's used by the hook) and then manage it independently of the calling thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    peer = env->NewGlobalRef((jobject)p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        DASSERT(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        target = env->GetObjectField(peer, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        parent = env->GetObjectField(peer, AwtFileDialog::parentID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        if (parent != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            awtParent = (AwtComponent *)JNI_GET_PDATA(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
//      DASSERT(awtParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        title = (jstring)(env)->GetObjectField(target, AwtDialog::titleID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        if (title == NULL || env->GetStringLength(title)==0) {
9201
c2c745bb19a6 7031854: JCK 7 test FileDialogTest0001 fails on Windows with Russian locale
dav
parents: 7668
diff changeset
   265
            title = JNU_NewStringPlatform(env, L" ");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        JavaStringBuffer titleBuffer(env, title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        directory =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            (jstring)env->GetObjectField(target, AwtFileDialog::dirID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        JavaStringBuffer directoryBuffer(env, directory);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   273
        multipleMode = env->CallBooleanMethod(peer, AwtFileDialog::isMultipleModeMID);
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   274
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   275
        UINT bufferLimit;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   276
        if (multipleMode == JNI_TRUE) {
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   277
            bufferLimit = MULTIPLE_MODE_BUFFER_LIMIT;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   278
        } else {
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   279
            bufferLimit = SINGLE_MODE_BUFFER_LIMIT;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   280
        }
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   281
        LPTSTR fileBuffer = new TCHAR[bufferLimit];
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   282
        memset(fileBuffer, 0, bufferLimit * sizeof(TCHAR));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        file = (jstring)env->GetObjectField(target, AwtFileDialog::fileID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        if (file != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            LPCTSTR tmp = JNU_GetStringPlatformChars(env, file, NULL);
9829
59c2c48a4b9e 7012520: Heap overflow vulnerability in FileDialog.show()
dcherepanov
parents: 7668
diff changeset
   287
            _tcsncpy(fileBuffer, tmp, bufferLimit - 2); // the fileBuffer is double null terminated string
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            JNU_ReleaseStringPlatformChars(env, file, tmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            fileBuffer[0] = _T('\0');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        ofn.lStructSize = sizeof(ofn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        ofn.lpstrFilter = s_fileFilterString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        ofn.nFilterIndex = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
          Fix for 6488834.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
          To disable Win32 native parent modality we have to set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
          hwndOwner field to either NULL or some hidden window. For
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
          parentless dialogs we use NULL to show them in the taskbar,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
          and for all other dialogs AwtToolkit's HWND is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        if (awtParent != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            ofn.hwndOwner = AwtToolkit::GetInstance().GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            ofn.hwndOwner = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        ofn.lpstrFile = fileBuffer;
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   312
        ofn.nMaxFile = bufferLimit;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        ofn.lpstrTitle = titleBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        ofn.lpstrInitialDir = directoryBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        ofn.Flags = OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                    OFN_ENABLEHOOK | OFN_EXPLORER | OFN_ENABLESIZING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        fileFilter = env->GetObjectField(peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        AwtFileDialog::fileFilterID);
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   319
        if (!JNU_IsNull(env,fileFilter)) {
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   320
            ofn.Flags |= OFN_ENABLEINCLUDENOTIFY;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   321
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        ofn.lCustData = (LPARAM)peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        ofn.lpfnHook = (LPOFNHOOKPROC)FileDialogHookProc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   325
        if (multipleMode == JNI_TRUE) {
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   326
            ofn.Flags |= OFN_ALLOWMULTISELECT;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   327
        }
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   328
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        // Save current directory, so we can reset if it changes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        currentDirectory = new TCHAR[MAX_PATH+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        VERIFY(::GetCurrentDirectory(MAX_PATH, currentDirectory) > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        mode = env->GetIntField(target, AwtFileDialog::modeID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        AwtDialog::CheckInstallModalHook();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        // show the Win32 file dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        if (mode == java_awt_FileDialog_LOAD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            result = AwtFileDialog::GetOpenFileName(&ofn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            result = AwtFileDialog::GetSaveFileName(&ofn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        // Fix for 4181310: FileDialog does not show up.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        // If the dialog is not shown because of invalid file name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        // replace the file name by empty string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        if (!result) {
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   348
            dlgerr = ::CommDlgExtendedError();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            if (dlgerr == FNERR_INVALIDFILENAME) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                _tcscpy(fileBuffer, TEXT(""));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                if (mode == java_awt_FileDialog_LOAD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                    result = AwtFileDialog::GetOpenFileName(&ofn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                    result = AwtFileDialog::GetSaveFileName(&ofn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        AwtDialog::CheckUninstallModalHook();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        DASSERT(env->GetLongField(peer, AwtComponent::hwndID) == 0L);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        AwtDialog::ModalActivateNextWindow(NULL, target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        VERIFY(::SetCurrentDirectory(currentDirectory));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        // Report result to peer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        if (result) {
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   369
            jint length = (jint)GetBufferLength(ofn.lpstrFile, ofn.nMaxFile);
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   370
            jcharArray jnames = env->NewCharArray(length);
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   371
            env->SetCharArrayRegion(jnames, 0, length, (jchar*)ofn.lpstrFile);
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   372
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   373
            env->CallVoidMethod(peer, AwtFileDialog::handleSelectedMID, jnames);
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   374
            env->DeleteLocalRef(jnames);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            env->CallVoidMethod(peer, AwtFileDialog::handleCancelMID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    } catch (...) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        env->DeleteLocalRef(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        env->DeleteLocalRef(title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        env->DeleteLocalRef(directory);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        env->DeleteLocalRef(file);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        env->DeleteLocalRef(fileFilter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        env->DeleteGlobalRef(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        delete[] currentDirectory;
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   390
        if (ofn.lpstrFile)
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   391
            delete[] ofn.lpstrFile;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        throw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    env->DeleteLocalRef(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    env->DeleteLocalRef(title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    env->DeleteLocalRef(directory);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    env->DeleteLocalRef(file);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    env->DeleteLocalRef(fileFilter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    env->DeleteGlobalRef(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    delete[] currentDirectory;
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   404
    if (ofn.lpstrFile)
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   405
        delete[] ofn.lpstrFile;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
BOOL
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   409
AwtFileDialog::GetOpenFileName(LPOPENFILENAME data) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    return static_cast<BOOL>(reinterpret_cast<INT_PTR>(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        AwtToolkit::GetInstance().InvokeFunction((void*(*)(void*))
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   412
                     ::GetOpenFileName, data)));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
BOOL
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   417
AwtFileDialog::GetSaveFileName(LPOPENFILENAME data) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    return static_cast<BOOL>(reinterpret_cast<INT_PTR>(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        AwtToolkit::GetInstance().InvokeFunction((void *(*)(void *))
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   420
                     ::GetSaveFileName, data)));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
BOOL AwtFileDialog::InheritsNativeMouseWheelBehavior() {return true;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
void AwtFileDialog::_DisposeOrHide(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    HWND hdlg = (HWND)(env->GetLongField(self, AwtComponent::hwndID));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    if (::IsWindow(hdlg))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        ::SendMessage(hdlg, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                      (LPARAM)hdlg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
void AwtFileDialog::_ToFront(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    HWND hdlg = (HWND)(env->GetLongField(self, AwtComponent::hwndID));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    if (::IsWindow(hdlg))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        ::SetWindowPos(hdlg, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
void AwtFileDialog::_ToBack(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    HWND hdlg = (HWND)(env->GetLongField(self, AwtComponent::hwndID));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    if (::IsWindow(hdlg))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        ::SetWindowPos(hdlg, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   470
// Returns the length of the double null terminated output buffer
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   471
UINT AwtFileDialog::GetBufferLength(LPTSTR buffer, UINT limit)
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   472
{
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   473
    UINT index = 0;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   474
    while ((index < limit) &&
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   475
           (buffer[index] != NULL || buffer[index+1] != NULL))
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   476
    {
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   477
        index++;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   478
    }
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   479
    return index;
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   480
}
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   481
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
 * WFileDialogPeer native methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
extern "C" {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
Java_sun_awt_windows_WFileDialogPeer_initIDs(JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    AwtFileDialog::parentID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        env->GetFieldID(cls, "parent", "Lsun/awt/windows/WComponentPeer;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    AwtFileDialog::fileFilterID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        env->GetFieldID(cls, "fileFilter", "Ljava/io/FilenameFilter;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    AwtFileDialog::setHWndMID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        env->GetMethodID(cls, "setHWnd", "(J)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    AwtFileDialog::handleSelectedMID =
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   500
        env->GetMethodID(cls, "handleSelected", "([C)V");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    AwtFileDialog::handleCancelMID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        env->GetMethodID(cls, "handleCancel", "()V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    AwtFileDialog::checkFilenameFilterMID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        env->GetMethodID(cls, "checkFilenameFilter", "(Ljava/lang/String;)Z");
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   505
    AwtFileDialog::isMultipleModeMID = env->GetMethodID(cls, "isMultipleMode", "()Z");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    /* java.awt.FileDialog fields */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    cls = env->FindClass("java/awt/FileDialog");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    if (cls == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    AwtFileDialog::modeID = env->GetFieldID(cls, "mode", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    AwtFileDialog::dirID = env->GetFieldID(cls, "dir", "Ljava/lang/String;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    AwtFileDialog::fileID = env->GetFieldID(cls, "file", "Ljava/lang/String;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    AwtFileDialog::filterID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        env->GetFieldID(cls, "filter", "Ljava/io/FilenameFilter;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    DASSERT(AwtFileDialog::parentID != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    DASSERT(AwtFileDialog::setHWndMID != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    DASSERT(AwtFileDialog::handleSelectedMID != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    DASSERT(AwtFileDialog::handleCancelMID != NULL);
4913
9b3caa50afcf 6705345: Enable multiple file selection in AWT FileDialog
dcherepanov
parents: 2456
diff changeset
   522
    DASSERT(AwtFileDialog::isMultipleModeMID != NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    DASSERT(AwtFileDialog::modeID != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    DASSERT(AwtFileDialog::dirID != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    DASSERT(AwtFileDialog::fileID != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    DASSERT(AwtFileDialog::filterID != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
Java_sun_awt_windows_WFileDialogPeer_setFilterString(JNIEnv *env, jclass cls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                                                     jstring filterDescription)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    AwtFileDialog::Initialize(env, filterDescription);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
Java_sun_awt_windows_WFileDialogPeer__1show(JNIEnv *env, jobject peer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * Fix for 4906972.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * 'peer' reference has to be global as it's used further in another thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    jobject peerGlobal = env->NewGlobalRef(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    AwtToolkit::GetInstance().InvokeFunction(AwtFileDialog::Show, peerGlobal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    env->DeleteGlobalRef(peerGlobal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
Java_sun_awt_windows_WFileDialogPeer__1dispose(JNIEnv *env, jobject peer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    TRY_NO_VERIFY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    jobject peerGlobal = env->NewGlobalRef(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    AwtToolkit::GetInstance().SyncCall(AwtFileDialog::_DisposeOrHide,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        (void *)peerGlobal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    // peerGlobal ref is deleted in _DisposeOrHide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
Java_sun_awt_windows_WFileDialogPeer__1hide(JNIEnv *env, jobject peer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    jobject peerGlobal = env->NewGlobalRef(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    AwtToolkit::GetInstance().SyncCall(AwtFileDialog::_DisposeOrHide,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        (void *)peerGlobal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    // peerGlobal ref is deleted in _DisposeOrHide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
Java_sun_awt_windows_WFileDialogPeer_toFront(JNIEnv *env, jobject peer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    AwtToolkit::GetInstance().SyncCall(AwtFileDialog::_ToFront,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                                       (void *)(env->NewGlobalRef(peer)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    // global ref is deleted in _ToFront
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
Java_sun_awt_windows_WFileDialogPeer_toBack(JNIEnv *env, jobject peer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    AwtToolkit::GetInstance().SyncCall(AwtFileDialog::_ToBack,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                                       (void *)(env->NewGlobalRef(peer)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    // global ref is deleted in _ToBack
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
} /* extern "C" */