7161437: [macosx] awt.FileDialog doesn't respond appropriately for mac when selecting folders
Reviewed-by: art, anthony
This commit is contained in:
parent
dd32d97101
commit
4bd6fb3f68
@ -30,12 +30,14 @@ import java.awt.peer.*;
|
|||||||
import java.awt.BufferCapabilities.FlipContents;
|
import java.awt.BufferCapabilities.FlipContents;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.awt.image.*;
|
import java.awt.image.*;
|
||||||
|
import java.security.AccessController;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import sun.awt.CausedFocusEvent.Cause;
|
import sun.awt.CausedFocusEvent.Cause;
|
||||||
import sun.awt.AWTAccessor;
|
import sun.awt.AWTAccessor;
|
||||||
import sun.java2d.pipe.Region;
|
import sun.java2d.pipe.Region;
|
||||||
|
import sun.security.action.GetBooleanAction;
|
||||||
|
|
||||||
class CFileDialog implements FileDialogPeer {
|
class CFileDialog implements FileDialogPeer {
|
||||||
|
|
||||||
@ -53,11 +55,14 @@ class CFileDialog implements FileDialogPeer {
|
|||||||
if (title == null) {
|
if (title == null) {
|
||||||
title = " ";
|
title = " ";
|
||||||
}
|
}
|
||||||
|
Boolean chooseDirectories = AccessController.doPrivileged(
|
||||||
|
new GetBooleanAction("apple.awt.fileDialogForDirectories"));
|
||||||
|
|
||||||
String[] userFileNames = nativeRunFileDialog(title,
|
String[] userFileNames = nativeRunFileDialog(title,
|
||||||
dialogMode,
|
dialogMode,
|
||||||
target.isMultipleMode(),
|
target.isMultipleMode(),
|
||||||
navigateApps,
|
navigateApps,
|
||||||
|
chooseDirectories,
|
||||||
target.getFilenameFilter() != null,
|
target.getFilenameFilter() != null,
|
||||||
target.getDirectory(),
|
target.getDirectory(),
|
||||||
target.getFile());
|
target.getFile());
|
||||||
@ -142,7 +147,8 @@ class CFileDialog implements FileDialogPeer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private native String[] nativeRunFileDialog(String title, int mode,
|
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);
|
String directory, String file);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,6 +52,9 @@
|
|||||||
// Should we navigate into apps?
|
// Should we navigate into apps?
|
||||||
BOOL fNavigateApps;
|
BOOL fNavigateApps;
|
||||||
|
|
||||||
|
// Can the dialog choose directories ?
|
||||||
|
BOOL fChooseDirectories;
|
||||||
|
|
||||||
// Contains the absolute paths of the selected files as URLs
|
// Contains the absolute paths of the selected files as URLs
|
||||||
NSArray *fURLs;
|
NSArray *fURLs;
|
||||||
}
|
}
|
||||||
@ -65,6 +68,7 @@
|
|||||||
mode:(jint)inMode
|
mode:(jint)inMode
|
||||||
multipleMode:(BOOL)inMultipleMode
|
multipleMode:(BOOL)inMultipleMode
|
||||||
shouldNavigate:(BOOL)inNavigateApps
|
shouldNavigate:(BOOL)inNavigateApps
|
||||||
|
canChooseDirectories:(BOOL)inChooseDirectories
|
||||||
withEnv:(JNIEnv*)env;
|
withEnv:(JNIEnv*)env;
|
||||||
|
|
||||||
// Invoked from the main thread
|
// Invoked from the main thread
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
mode:(jint)inMode
|
mode:(jint)inMode
|
||||||
multipleMode:(BOOL)inMultipleMode
|
multipleMode:(BOOL)inMultipleMode
|
||||||
shouldNavigate:(BOOL)inNavigateApps
|
shouldNavigate:(BOOL)inNavigateApps
|
||||||
|
canChooseDirectories:(BOOL)inChooseDirectories
|
||||||
withEnv:(JNIEnv*)env;
|
withEnv:(JNIEnv*)env;
|
||||||
{
|
{
|
||||||
if (self == [super init]) {
|
if (self == [super init]) {
|
||||||
@ -57,6 +58,7 @@
|
|||||||
fMode = inMode;
|
fMode = inMode;
|
||||||
fMultipleMode = inMultipleMode;
|
fMultipleMode = inMultipleMode;
|
||||||
fNavigateApps = inNavigateApps;
|
fNavigateApps = inNavigateApps;
|
||||||
|
fChooseDirectories = inChooseDirectories;
|
||||||
fPanelResult = NSCancelButton;
|
fPanelResult = NSCancelButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +111,7 @@
|
|||||||
NSOpenPanel *openPanel = (NSOpenPanel *)thePanel;
|
NSOpenPanel *openPanel = (NSOpenPanel *)thePanel;
|
||||||
[openPanel setAllowsMultipleSelection:fMultipleMode];
|
[openPanel setAllowsMultipleSelection:fMultipleMode];
|
||||||
[openPanel setCanChooseFiles:YES];
|
[openPanel setCanChooseFiles:YES];
|
||||||
[openPanel setCanChooseDirectories:NO];
|
[openPanel setCanChooseDirectories:fChooseDirectories];
|
||||||
[openPanel setCanCreateDirectories:YES];
|
[openPanel setCanCreateDirectories:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +184,8 @@
|
|||||||
JNIEXPORT jobjectArray JNICALL
|
JNIEXPORT jobjectArray JNICALL
|
||||||
Java_sun_lwawt_macosx_CFileDialog_nativeRunFileDialog
|
Java_sun_lwawt_macosx_CFileDialog_nativeRunFileDialog
|
||||||
(JNIEnv *env, jobject peer, jstring title, jint mode, jboolean multipleMode,
|
(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;
|
jobjectArray returnValue = NULL;
|
||||||
|
|
||||||
@ -200,6 +203,7 @@ JNF_COCOA_ENTER(env);
|
|||||||
mode:mode
|
mode:mode
|
||||||
multipleMode:multipleMode
|
multipleMode:multipleMode
|
||||||
shouldNavigate:navigateApps
|
shouldNavigate:navigateApps
|
||||||
|
canChooseDirectories:chooseDirectories
|
||||||
withEnv:env];
|
withEnv:env];
|
||||||
|
|
||||||
[JNFRunLoop performOnMainThread:@selector(safeSaveOrLoad)
|
[JNFRunLoop performOnMainThread:@selector(safeSaveOrLoad)
|
||||||
|
Loading…
Reference in New Issue
Block a user