Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32642,6 +32642,10 @@
<arg declared_type='NSURL * _Nonnull' index='0' name='url' type='@'/>
<retval declared_type='NSURL * _Nullable' type='@'/>
</method>
<method selector='URLForApplicationToOpenContentType:'>
<arg declared_type='UTType * _Nonnull' index='0' name='contentType' type='@'/>
<retval declared_type='NSURL * _Nullable' type='@'/>
</method>
<method selector='URLForApplicationWithBundleIdentifier:'>
<arg declared_type='NSString * _Nonnull' index='0' name='bundleIdentifier' type='@'/>
<retval declared_type='NSURL * _Nullable' type='@'/>
Expand Down Expand Up @@ -32935,6 +32939,12 @@
<retval declared_type='BOOL' type='B'/>
</method>
</class>
<class name='UTType'>
<method class_method='true' selector='typeWithFilenameExtension:'>
<arg declared_type='NSString * _Nonnull' index='0' name='filenameExtension' type='@'/>
<retval declared_type='UTType * _Nullable' type='@'/>
</method>
</class>
<informal_protocol name='NSAccessibility'>
<method selector='accessibilityActionDescription:' type='@12@0:4@8' type64='@24@0:8@16'>
<arg declared_type='NSString * _Nonnull' index='0' name='action' type='@'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4154,6 +4154,14 @@
</method>
</class>
<class name="NSWorkspace" swt_gen="mixed">
<method selector="URLForApplicationToOpenContentType:" swt_gen="true">
<arg swt_gen="true" swt_java_type="UTType"></arg>
<retval swt_gen="true"></retval>
</method>
<method selector="URLForApplicationToOpenURL:" swt_gen="true">
<arg swt_gen="true" swt_java_type="NSURL"></arg>
<retval swt_gen="true"></retval>
</method>
<method selector="fullPathForApplication:" swt_gen="true">
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
Expand Down Expand Up @@ -4192,6 +4200,12 @@
<retval swt_gen="true"></retval>
</method>
</class>
<class name="UTType" swt_gen="mixed">
<method class_method="true" selector="typeWithFilenameExtension:" swt_gen="true">
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
</class>
<constant name="NSAccessibilityAttributedStringForRangeParameterizedAttribute" swt_gen="true"></constant>
<constant name="NSAccessibilityBackgroundColorTextAttribute" swt_gen="true"></constant>
<constant name="NSAccessibilityBoundsForRangeParameterizedAttribute" swt_gen="true"></constant>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
* 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;

Expand All @@ -27,6 +24,16 @@ public NSWorkspace(id id) {
super(id);
}

public NSURL URLForApplicationToOpenURL(NSURL url) {
long result = OS.objc_msgSend(this.id, OS.sel_URLForApplicationToOpenURL_, url != null ? url.id : 0);
return result != 0 ? new NSURL(result) : null;
}

public NSURL URLForApplicationToOpenContentType(UTType contentType) {
long result = OS.objc_msgSend(this.id, OS.sel_URLForApplicationToOpenContentType_, contentType != null ? contentType.id : 0);
return result != 0 ? new NSURL(result) : null;
}

public NSString fullPathForApplication(NSString appName) {
long result = OS.objc_msgSend(this.id, OS.sel_fullPathForApplication_, appName != null ? appName.id : 0);
return result != 0 ? new NSString(result) : null;
Expand All @@ -45,16 +52,6 @@ public boolean openURL(NSURL url) {
return OS.objc_msgSend_bool(this.id, OS.sel_openURL_, url != null ? url.id : 0);
}

public NSURL urlForApplicationToOpenURL(NSURL url) {
long result = OS.objc_msgSend(this.id, OS.sel_URLForApplicationToOpenURL_, url != null ? url.id : 0);
return result != 0 ? new NSURL(result) : null;
}

public NSURL urlForApplicationToOpenContentType(long contentType) {
long result = OS.objc_msgSend(this.id, OS.sel_URLForApplicationToOpenContentType_, contentType);
return result != 0 ? new NSURL(result) : null;
}

public boolean openURLs(NSArray urls, NSString bundleIdentifier, long options, NSAppleEventDescriptor descriptor, long identifiers) {
return OS.objc_msgSend_bool(this.id, OS.sel_openURLs_withAppBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifiers_, urls != null ? urls.id : 0, bundleIdentifier != null ? bundleIdentifier.id : 0, options, descriptor != null ? descriptor.id : 0, identifiers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ public static boolean isSystemDarkAppearance() {
public static final long class_NSWorkspace = objc_getClass("NSWorkspace");
public static final long class_SFCertificatePanel = objc_getClass("SFCertificatePanel");
public static final long class_SFCertificateTrustPanel = objc_getClass("SFCertificateTrustPanel");
public static final long class_UTType = objc_getClass("UTType");
public static final long class_WebDataSource = objc_getClass("WebDataSource");
public static final long class_WebFrame = objc_getClass("WebFrame");
public static final long class_WebFrameView = objc_getClass("WebFrameView");
Expand Down Expand Up @@ -830,9 +831,9 @@ public static Selector getSelector (long value) {
public static final long sel_PMPrintSettings = Selector.sel_PMPrintSettings.value;
public static final long sel_TIFFRepresentation = Selector.sel_TIFFRepresentation.value;
public static final long sel_URL = Selector.sel_URL.value;
public static final long sel_URLFromPasteboard_ = Selector.sel_URLFromPasteboard_.value;
public static final long sel_URLForApplicationToOpenURL_ = Selector.sel_URLForApplicationToOpenURL_.value;
public static final long sel_URLForApplicationToOpenContentType_ = Selector.sel_URLForApplicationToOpenContentType_.value;
public static final long sel_URLForApplicationToOpenURL_ = Selector.sel_URLForApplicationToOpenURL_.value;
public static final long sel_URLFromPasteboard_ = Selector.sel_URLFromPasteboard_.value;
public static final long sel_URLWithString_ = Selector.sel_URLWithString_.value;
public static final long sel_UTF8String = Selector.sel_UTF8String.value;
public static final long sel_abortEditing = Selector.sel_abortEditing.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ public enum Selector {
, sel_PMPrintSettings("PMPrintSettings")
, sel_TIFFRepresentation("TIFFRepresentation")
, sel_URL("URL")
, sel_URLFromPasteboard_("URLFromPasteboard:")
, sel_URLForApplicationToOpenURL_("URLForApplicationToOpenURL:")
, sel_URLForApplicationToOpenContentType_("URLForApplicationToOpenContentType:")
, sel_URLForApplicationToOpenURL_("URLForApplicationToOpenURL:")
, sel_URLFromPasteboard_("URLFromPasteboard:")
, sel_URLWithString_("URLWithString:")
, sel_UTF8String("UTF8String")
, sel_abortEditing("abortEditing")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2026 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
*******************************************************************************/
package org.eclipse.swt.internal.cocoa;

public class UTType extends NSObject {

public UTType() {
super();
}

public UTType(long id) {
super(id);
}

public UTType(id id) {
super(id);
}

public static UTType typeWithFilenameExtension(NSString filenameExtension) {
long result = OS.objc_msgSend(OS.class_UTType, OS.sel_typeWithFilenameExtension_, filenameExtension != null ? filenameExtension.id : 0);
return result != 0 ? new UTType(result) : null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,17 @@ private static NSURL findAppURLForExtension(NSString ext) {
// On macOS 12.0+, use the content type-based API which works reliably
// for all file types including third-party ones.
if (OS.VERSION >= OS.VERSION(12, 0, 0)) {
long UTTypeClass = OS.objc_getClass("UTType");
if (UTTypeClass != 0) {
long utType = OS.objc_msgSend(UTTypeClass, OS.sel_typeWithFilenameExtension_, ext.id);
if (utType != 0) {
NSURL appURL = workspace.urlForApplicationToOpenContentType(utType);
if (appURL != null) {
return appURL;
}
UTType utType = UTType.typeWithFilenameExtension(ext);
if (utType != null) {
NSURL appURL = workspace.URLForApplicationToOpenContentType(utType);
if (appURL != null) {
return appURL;
}
}
}
// Fallback: URL-based lookup (available since macOS 10.6, deprecated in macOS 12.0)
NSURL fileURL = NSURL.fileURLWithPath(NSString.stringWith("/tmp/dummy." + ext.getString()));
return workspace.urlForApplicationToOpenURL(fileURL);
return workspace.URLForApplicationToOpenURL(fileURL);
}

static Program getProgram(NSBundle bundle) {
Expand Down
Loading