--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java Mon Aug 13 17:53:56 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java Mon Aug 13 19:19:34 2012 +0400
@@ -30,12 +30,14 @@
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 @@
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 @@
}
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
--- a/jdk/src/macosx/native/sun/awt/CFileDialog.h Mon Aug 13 17:53:56 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/CFileDialog.h Mon Aug 13 19:19:34 2012 +0400
@@ -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
--- a/jdk/src/macosx/native/sun/awt/CFileDialog.m Mon Aug 13 17:53:56 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/CFileDialog.m Mon Aug 13 19:19:34 2012 +0400
@@ -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 @@
mode:mode
multipleMode:multipleMode
shouldNavigate:navigateApps
+ canChooseDirectories:chooseDirectories
withEnv:env];
[JNFRunLoop performOnMainThread:@selector(safeSaveOrLoad)