Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2018-01-05 06:53:25 +0000
committerLakshmi Shanmugam2018-01-05 08:01:10 +0000
commit4141423bffef24cca9c4330756dc348a735e6c49 (patch)
tree2ebd328d8b94080c3bdb7c5ad376ac8e618732f6
parent1ff2c34d2ef095910af58421ecc2b0e6f8a0ee88 (diff)
downloadeclipse.platform.swt-4141423bffef24cca9c4330756dc348a735e6c49.tar.gz
eclipse.platform.swt-4141423bffef24cca9c4330756dc348a735e6c49.tar.xz
eclipse.platform.swt-4141423bffef24cca9c4330756dc348a735e6c49.zip
Bug 529227: FileDialog setFilterExtensions() doesn’t allow to choose
files that were filtered with two dots in their extension FileDialog Improvements: -All filenames are always disabled in the NSSavePanel, so return from panel_shouldShowFilename() for Save Dialog to improve performance. -Add support for extension of type (.)ext in filter extension in panel_shouldShowFilename(). setAllowedFileType() already handles it. -Formatting fixed from previous commit. Change-Id: I3e484f138808d743ffe0b8e2084a03546b0216a5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java
index 24b1b27a21..16903d51c4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java
@@ -350,6 +350,10 @@ public String open () {
}
long /*int*/ panel_shouldShowFilename (long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1) {
+ if ((style & SWT.SAVE) != 0) {
+ /* All filenames are always disabled in the NSSavePanel, so return from here. */
+ return 1;
+ }
NSString path = new NSString(arg1);
if (filterExtensions != null && filterExtensions.length != 0) {
NSFileManager manager = NSFileManager.defaultManager();
@@ -372,7 +376,11 @@ long /*int*/ panel_shouldShowFilename (long /*int*/ id, long /*int*/ sel, long /
String filter = extensions.substring (start, index).trim ();
if (filter.equalsIgnoreCase (fileName)) return 1;
if (filter.equals ("*") || filter.equals ("*.*")) return 1;
- if (filter.startsWith ("*.")) filter = filter.substring (2);
+ if (filter.startsWith ("*.")) {
+ filter = filter.substring (2);
+ } else if (filter.startsWith (".")) {
+ filter = filter.substring (1);
+ }
if ((fileName.toLowerCase ()).endsWith("." + filter.toLowerCase ())) return 1;
start = index + 1;
}
@@ -447,8 +455,8 @@ void setAllowedFileType (String fileTypes) {
*/
if ((style & SWT.SAVE) == 0) {
int index = fileType.lastIndexOf(".");
- if (index != -1 && index+1 < fileType.length()) {
- fileType = fileType.substring(index+1);
+ if (index != -1 && ((index + 1) < fileType.length())) {
+ fileType = fileType.substring(index + 1);
}
}
allowedFileTypes.addObject(NSString.stringWith(fileType));

Back to the top