aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbhishek Kishore2014-03-06 01:25:56 (EST)
committerArun Thondapu2014-03-24 07:06:08 (EDT)
commitd2444ea11626b1e659e4e7a174b1438fa903c689 (patch)
tree2ef1dac04ec71c98b50cff83126360bc219fd936
parent6eeebae3ebde877ff7feb6787edf7a9a37b88b61 (diff)
downloadeclipse.platform.swt-d2444ea11626b1e659e4e7a174b1438fa903c689.zip
eclipse.platform.swt-d2444ea11626b1e659e4e7a174b1438fa903c689.tar.gz
eclipse.platform.swt-d2444ea11626b1e659e4e7a174b1438fa903c689.tar.bz2
Bug 347430 - FileDialog's overwrite & setFilterExtensions options do notrefs/changes/99/23299/4
play well together. Change-Id: I1de07ef28e9db451df06a3c180643571ffa95895 Signed-off-by: Abhishek Kishore <abhishek.kishore@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSSavePanel.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java38
4 files changed, 40 insertions, 18 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index 32c58dc..c2e0038 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -2737,6 +2737,14 @@
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method selector="setAllowedFileTypes:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
+ <method selector="setAllowsOtherFileTypes:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="setCanCreateDirectories:" swt_gen="true">
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSSavePanel.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSSavePanel.java
index 0047304..8629222 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSSavePanel.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSSavePanel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -46,6 +46,14 @@ public void setAccessoryView(NSView view) {
OS.objc_msgSend(this.id, OS.sel_setAccessoryView_, view != null ? view.id : 0);
}
+public void setAllowedFileTypes(NSArray types) {
+ OS.objc_msgSend(this.id, OS.sel_setAllowedFileTypes_, types != null ? types.id : 0);
+}
+
+public void setAllowsOtherFileTypes(boolean flag) {
+ OS.objc_msgSend(this.id, OS.sel_setAllowsOtherFileTypes_, flag);
+}
+
public void setCanCreateDirectories(boolean flag) {
OS.objc_msgSend(this.id, OS.sel_setCanCreateDirectories_, flag);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index 59d241b..a4b8eb6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -1803,10 +1803,12 @@ public static final long /*int*/ sel_setAccessoryView_ = sel_registerName("setAc
public static final long /*int*/ sel_setAction_ = sel_registerName("setAction:");
public static final long /*int*/ sel_setAlertStyle_ = sel_registerName("setAlertStyle:");
public static final long /*int*/ sel_setAlignment_ = sel_registerName("setAlignment:");
+public static final long /*int*/ sel_setAllowedFileTypes_ = sel_registerName("setAllowedFileTypes:");
public static final long /*int*/ sel_setAllowsColumnReordering_ = sel_registerName("setAllowsColumnReordering:");
public static final long /*int*/ sel_setAllowsFloats_ = sel_registerName("setAllowsFloats:");
public static final long /*int*/ sel_setAllowsMixedState_ = sel_registerName("setAllowsMixedState:");
public static final long /*int*/ sel_setAllowsMultipleSelection_ = sel_registerName("setAllowsMultipleSelection:");
+public static final long /*int*/ sel_setAllowsOtherFileTypes_ = sel_registerName("setAllowsOtherFileTypes:");
public static final long /*int*/ sel_setAllowsUndo_ = sel_registerName("setAllowsUndo:");
public static final long /*int*/ sel_setAllowsUserCustomization_ = sel_registerName("setAllowsUserCustomization:");
public static final long /*int*/ sel_setAlpha_ = sel_registerName("setAlpha:");
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 cfb4ece..8277164 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
@@ -251,6 +251,9 @@ public String open () {
widget.sizeToFit();
panel.setAccessoryView(widget);
popup = widget;
+
+ setAllowedFileType(filterExtensions[0]);
+ panel.setAllowsOtherFileTypes(true);
}
panel.setTitle(NSString.stringWith(title != null ? title : ""));
NSApplication application = NSApplication.sharedApplication();
@@ -277,23 +280,6 @@ public String open () {
if (response == OS.NSFileHandlingPanelOKButton) {
NSString filename = panel.filename();
if ((style & SWT.SAVE) != 0) {
- if (filterExtensions != null && filterExtensions.length != 0) {
- if (0 <= filterIndex && filterIndex < filterExtensions.length) {
- /* Append extension if not present */
- NSString ext = filename.pathExtension();
- if (ext == null || ext.length() == 0) {
- String exts = filterExtensions [filterIndex];
- int length = exts.length ();
- int index = exts.indexOf (EXTENSION_SEPARATOR);
- if (index == -1) index = length;
- String filter = exts.substring (0, index).trim ();
- if (!filter.equals ("*") && !filter.equals ("*.*")) {
- if (filter.startsWith ("*.")) filter = filter.substring (2);
- filename = filename.stringByAppendingPathExtension(NSString.stringWith(filter));
- }
- }
- }
- }
fullPath = filename.getString();
fileNames = new String [1];
fileName = fileNames [0] = filename.lastPathComponent().getString();
@@ -379,8 +365,26 @@ long /*int*/ panel_shouldShowFilename (long /*int*/ id, long /*int*/ sel, long /
void sendSelection (long /*int*/ id, long /*int*/ sel, long /*int*/ arg) {
panel.validateVisibleColumns();
+ if (filterExtensions != null && filterExtensions.length > 0) {
+ setAllowedFileType(filterExtensions[(int)/*64*/popup.indexOfSelectedItem()]);
+ }
}
+void setAllowedFileType (String fileType) {
+ if (fileType == null) return;
+ if (fileType.equals("*") || fileType.equals("*.*")) {
+ panel.setAllowedFileTypes(null);
+ return;
+ }
+ if (fileType.startsWith ("*.")) {
+ fileType = fileType.substring (2);
+ }
+ NSMutableArray allowedFileTypes = NSMutableArray.arrayWithCapacity(1);
+ allowedFileTypes.addObject(NSString.stringWith(fileType));
+ panel.setAllowedFileTypes(allowedFileTypes);
+}
+
+
/**
* Set the initial filename which the dialog will
* select by default when opened to the argument,