Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2019-06-18 10:11:53 +0000
committerLakshmi Shanmugam2019-06-18 11:16:55 +0000
commit47276e7681ad612719fc947fb2ec0fb2cecd3690 (patch)
tree81f46b8430fe338e3ea73ea0c3a1c64a0557f28e
parenteebc5e7cbb549ba580cb7b91ce8443dde9c056dc (diff)
downloadeclipse.platform.swt-47276e7681ad612719fc947fb2ec0fb2cecd3690.tar.gz
eclipse.platform.swt-47276e7681ad612719fc947fb2ec0fb2cecd3690.tar.xz
eclipse.platform.swt-47276e7681ad612719fc947fb2ec0fb2cecd3690.zip
Bug 548378: [Mac]Replace deprecated method used FileDialog
Replace panel:shouldShowFilename: which has been deprecated in Mac 10.6. with NSOpenSavePanelDelegate.panel:shouldEnableURL: Change-Id: If2eba8a2b1bba959cda18a7ac56be5405d1ddfca
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTOpenSavePanelDelegate.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java10
6 files changed, 50 insertions, 17 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 f970f78fe4..7b9dae576e 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
@@ -5311,6 +5311,13 @@
<retval></retval>
</method>
</informal_protocol>
+ <informal_protocol name="NSOpenSavePanelDelegate" swt_gen="mixed">
+ <method selector="panel:shouldEnableURL:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
+ </informal_protocol>
<informal_protocol name="NSOutlineViewDataSource" swt_gen="mixed">
<method selector="outlineView:acceptDrop:item:childIndex:" swt_gen="true">
<arg swt_gen="true"></arg>
@@ -5410,12 +5417,6 @@
<retval></retval>
</method>
</informal_protocol>
- <informal_protocol name="NSSavePanelDelegate" swt_gen="mixed">
- <method selector="panel:shouldShowFilename:" swt_gen="true">
- <arg swt_gen="true"></arg>
- <arg swt_gen="true"></arg>
- </method>
- </informal_protocol>
<informal_protocol name="NSTabViewDelegate" swt_gen="mixed">
<method selector="tabView:didSelectTabViewItem:" swt_gen="true">
<arg swt_gen="true"></arg>
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 ef08209ae4..65ecd5c95e 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
@@ -942,11 +942,11 @@ public static final long protocol_NSFontManagerResponderMethod = objc_getProtoco
public static final long protocol_NSFontPanelValidationAdditions = objc_getProtocol("NSFontPanelValidationAdditions");
public static final long protocol_NSMenuDelegate = objc_getProtocol("NSMenuDelegate");
public static final long protocol_NSMenuValidation = objc_getProtocol("NSMenuValidation");
+public static final long protocol_NSOpenSavePanelDelegate = objc_getProtocol("NSOpenSavePanelDelegate");
public static final long protocol_NSOutlineViewDataSource = objc_getProtocol("NSOutlineViewDataSource");
public static final long protocol_NSOutlineViewDelegate = objc_getProtocol("NSOutlineViewDelegate");
public static final long protocol_NSOutlineViewNotifications = objc_getProtocol("NSOutlineViewNotifications");
public static final long protocol_NSPasteboardOwner = objc_getProtocol("NSPasteboardOwner");
-public static final long protocol_NSSavePanelDelegate = objc_getProtocol("NSSavePanelDelegate");
public static final long protocol_NSTabViewDelegate = objc_getProtocol("NSTabViewDelegate");
public static final long protocol_NSTableDataSource = objc_getProtocol("NSTableDataSource");
public static final long protocol_NSTableViewDelegate = objc_getProtocol("NSTableViewDelegate");
@@ -1713,7 +1713,7 @@ public static final long sel_owner = Selector.sel_owner.value;
public static final long sel_pageDown_ = Selector.sel_pageDown_.value;
public static final long sel_pageTitle = Selector.sel_pageTitle.value;
public static final long sel_pageUp_ = Selector.sel_pageUp_.value;
-public static final long sel_panel_shouldShowFilename_ = Selector.sel_panel_shouldShowFilename_.value;
+public static final long sel_panel_shouldEnableURL_ = Selector.sel_panel_shouldEnableURL_.value;
public static final long sel_panelConvertFont_ = Selector.sel_panelConvertFont_.value;
public static final long sel_paperSize = Selector.sel_paperSize.value;
public static final long sel_paragraphs = Selector.sel_paragraphs.value;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTOpenSavePanelDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTOpenSavePanelDelegate.java
new file mode 100644
index 0000000000..989367d431
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTOpenSavePanelDelegate.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.cocoa;
+
+public class SWTOpenSavePanelDelegate extends NSObject {
+
+public SWTOpenSavePanelDelegate() {
+ super(0);
+}
+
+public SWTOpenSavePanelDelegate(long id) {
+ super(id);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
index 6045f563fc..f4ab9558ca 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
@@ -824,7 +824,7 @@ public enum Selector {
, sel_pageDown_("pageDown:")
, sel_pageTitle("pageTitle")
, sel_pageUp_("pageUp:")
- , sel_panel_shouldShowFilename_("panel:shouldShowFilename:")
+ , sel_panel_shouldEnableURL_("panel:shouldEnableURL:")
, sel_panelConvertFont_("panelConvertFont:")
, sel_paperSize("paperSize")
, sel_paragraphs("paragraphs")
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index cc443d2368..2ed0858d29 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -2680,6 +2680,13 @@ void initClasses () {
createMenuSubclass(OS.class_NSMenu, "SWTMenu", false);
createMenuItemSubclass(OS.class_NSMenuItem, "SWTMenuItem", false);
+ className = "SWTOpenSavePanelDelegate";
+ cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+ OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
+ OS.class_addMethod(cls, OS.sel_sendSelection_, dialogProc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_panel_shouldEnableURL_, dialogProc4, "@:@@");
+ OS.objc_registerClassPair(cls);
+
className = "SWTOutlineView";
cls = OS.objc_allocateClassPair(OS.class_NSOutlineView, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
@@ -2726,7 +2733,6 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_changeFont_, dialogProc3, "@:@");
OS.class_addMethod(cls, OS.sel_validModesForFontPanel_, dialogProc3, "@:@");
OS.class_addMethod(cls, OS.sel_sendSelection_, dialogProc3, "@:@");
- OS.class_addMethod(cls, OS.sel_panel_shouldShowFilename_, dialogProc4, "@:@@");
OS.class_addMethod(cls, OS.sel_panelDidEnd_returnCode_contextInfo_, dialogProc5, "@:@i@");
OS.objc_registerClassPair(cls);
@@ -5724,10 +5730,10 @@ static long dialogProc(long id, long sel, long arg0, long arg1) {
long [] jniRef = new long [1];
OS.object_getInstanceVariable(id, SWT_OBJECT, jniRef);
if (jniRef[0] == 0) return 0;
- if (sel == OS.sel_panel_shouldShowFilename_) {
+ if (sel == OS.sel_panel_shouldEnableURL_) {
FileDialog dialog = (FileDialog)OS.JNIGetObject(jniRef[0]);
if (dialog == null) return 0;
- return dialog.panel_shouldShowFilename(id, sel, arg0, arg1);
+ return dialog.panel_shouldEnableURL(id, sel, arg0, arg1);
}
if (sel == OS.sel_setColor_forAttribute_) {
FontDialog dialog = (FontDialog)OS.JNIGetObject(jniRef[0]);
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 89ec8fbe3c..cb9ab4f46f 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
@@ -50,7 +50,7 @@ public class FileDialog extends Dialog {
String [] fileNames = new String[0];
String filterPath = "", fileName = "";
String fullPath;
- SWTPanelDelegate delegate = null;
+ SWTOpenSavePanelDelegate delegate = null;
int filterIndex = -1;
long jniRef = 0;
long method = 0;
@@ -286,7 +286,6 @@ public String open () {
openPanel.setAllowsMultipleSelection((style & SWT.MULTI) != 0);
panel = openPanel;
}
-
panel.setCanCreateDirectories(true);
/*
* This line is intentionally commented. Don't show hidden files forcefully,
@@ -296,7 +295,7 @@ public String open () {
jniRef = 0;
delegate = null;
if (filterExtensions != null && filterExtensions.length != 0) {
- delegate = (SWTPanelDelegate)new SWTPanelDelegate().alloc().init();
+ delegate = (SWTOpenSavePanelDelegate)new SWTOpenSavePanelDelegate().alloc().init();
jniRef = OS.NewGlobalRef(this);
if (jniRef == 0) error(SWT.ERROR_NO_HANDLES);
OS.object_setInstanceVariable(delegate.id, Display.SWT_OBJECT, jniRef);
@@ -353,12 +352,13 @@ public String open () {
return fullPath;
}
-long panel_shouldShowFilename (long id, long sel, long arg0, long arg1) {
+long panel_shouldEnableURL (long id, long sel, long arg0, long 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);
+ NSURL url = new NSURL(arg1);
+ NSString path = url.path();
if (filterExtensions != null && filterExtensions.length != 0) {
NSFileManager manager = NSFileManager.defaultManager();
long ptr = C.malloc(1);

Back to the top