7161437: [macosx] awt.FileDialog doesn't respond appropriately for mac when selecting folders

Reviewed-by: art, anthony
This commit is contained in:
Marco Dinacci 2012-08-13 17:43:37 +04:00 committed by Sergey Bylokhov
parent dd32d97101
commit 4bd6fb3f68
3 changed files with 17 additions and 3 deletions

View File

@ -30,12 +30,14 @@ import java.awt.peer.*;
import java.awt.BufferCapabilities.FlipContents;
import java.awt.event.*;
import java.awt.image.*;
import java.security.AccessController;
import java.util.List;
import java.io.*;
import sun.awt.CausedFocusEvent.Cause;
import sun.awt.AWTAccessor;
import sun.java2d.pipe.Region;
import sun.security.action.GetBooleanAction;
class CFileDialog implements FileDialogPeer {
@ -53,11 +55,14 @@ class CFileDialog implements FileDialogPeer {
if (title == null) {
title = " ";
}
Boolean chooseDirectories = AccessController.doPrivileged(
new GetBooleanAction("apple.awt.fileDialogForDirectories"));
String[] userFileNames = nativeRunFileDialog(title,
dialogMode,
target.isMultipleMode(),
navigateApps,
chooseDirectories,
target.getFilenameFilter() != null,
target.getDirectory(),
target.getFile());
@ -142,7 +147,8 @@ class CFileDialog implements FileDialogPeer {
}
private native String[] nativeRunFileDialog(String title, int mode,
boolean multipleMode, boolean shouldNavigateApps, boolean hasFilenameFilter,
boolean multipleMode, boolean shouldNavigateApps,
boolean canChooseDirectories, boolean hasFilenameFilter,
String directory, String file);
@Override

View File

@ -52,6 +52,9 @@
// Should we navigate into apps?
BOOL fNavigateApps;
// Can the dialog choose directories ?
BOOL fChooseDirectories;
// Contains the absolute paths of the selected files as URLs
NSArray *fURLs;
}
@ -65,6 +68,7 @@
mode:(jint)inMode
multipleMode:(BOOL)inMultipleMode
shouldNavigate:(BOOL)inNavigateApps
canChooseDirectories:(BOOL)inChooseDirectories
withEnv:(JNIEnv*)env;
// Invoked from the main thread

View File

@ -43,6 +43,7 @@
mode:(jint)inMode
multipleMode:(BOOL)inMultipleMode
shouldNavigate:(BOOL)inNavigateApps
canChooseDirectories:(BOOL)inChooseDirectories
withEnv:(JNIEnv*)env;
{
if (self == [super init]) {
@ -57,6 +58,7 @@
fMode = inMode;
fMultipleMode = inMultipleMode;
fNavigateApps = inNavigateApps;
fChooseDirectories = inChooseDirectories;
fPanelResult = NSCancelButton;
}
@ -109,7 +111,7 @@
NSOpenPanel *openPanel = (NSOpenPanel *)thePanel;
[openPanel setAllowsMultipleSelection:fMultipleMode];
[openPanel setCanChooseFiles:YES];
[openPanel setCanChooseDirectories:NO];
[openPanel setCanChooseDirectories:fChooseDirectories];
[openPanel setCanCreateDirectories:YES];
}
@ -182,7 +184,8 @@
JNIEXPORT jobjectArray JNICALL
Java_sun_lwawt_macosx_CFileDialog_nativeRunFileDialog
(JNIEnv *env, jobject peer, jstring title, jint mode, jboolean multipleMode,
jboolean navigateApps, jboolean hasFilter, jstring directory, jstring file)
jboolean navigateApps, jboolean chooseDirectories, jboolean hasFilter,
jstring directory, jstring file)
{
jobjectArray returnValue = NULL;
@ -200,6 +203,7 @@ JNF_COCOA_ENTER(env);
mode:mode
multipleMode:multipleMode
shouldNavigate:navigateApps
canChooseDirectories:chooseDirectories
withEnv:env];
[JNFRunLoop performOnMainThread:@selector(safeSaveOrLoad)