Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2019-12-27 08:19:00 +0000
committerLakshmi Shanmugam2020-01-03 17:44:44 +0000
commita6f29f81dff824804992ea2d85515cd607f38817 (patch)
tree25ae30332dc617c1b0693c11a4fde0681becf145
parente0d51a44f0793dd7e3e39d80ba2d67fb7fce990b (diff)
downloadeclipse.platform.swt-a6f29f81dff824804992ea2d85515cd607f38817.tar.gz
eclipse.platform.swt-a6f29f81dff824804992ea2d85515cd607f38817.tar.xz
eclipse.platform.swt-a6f29f81dff824804992ea2d85515cd607f38817.zip
Bug 144689 - MessageBox doesn't show correct icon
Set icon for info and warning style MessageBox Change-Id: Ib0fcef49b8f889fc96acb2e47bb1d1882fbed57e
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAlert.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MessageBox.java20
4 files changed, 25 insertions, 7 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 39c1762c55..d382fd70d0 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
@@ -45,6 +45,10 @@
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method selector="setIcon:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="setMessageText:" 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/NSAlert.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAlert.java
index c113594043..70685f40c5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAlert.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAlert.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -44,6 +44,10 @@ public void setAlertStyle(long alertStyle) {
OS.objc_msgSend(this.id, OS.sel_setAlertStyle_, alertStyle);
}
+public void setIcon(NSImage icon) {
+ OS.objc_msgSend(this.id, OS.sel_setIcon_, icon != null ? icon.id : 0);
+}
+
public void setMessageText(NSString messageText) {
OS.objc_msgSend(this.id, OS.sel_setMessageText_, messageText != null ? messageText.id : 0);
}
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 50e461137b..e32d9daed2 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
@@ -2009,7 +2009,7 @@ public Cursor getSystemCursor (int id) {
return cursors [id];
}
-NSImage getSystemImageForID(int osType) {
+static NSImage getSystemImageForID(int osType) {
long iconRef[] = new long [1];
OS.GetIconRefFromTypeInfo(OS.kSystemIconsCreator, osType, 0, 0, 0, iconRef);
NSImage nsImage = (NSImage)new NSImage().alloc();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MessageBox.java
index bd01a5394d..7ca42e70fc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MessageBox.java
@@ -141,11 +141,21 @@ public String getMessage () {
public int open () {
NSAlert alert = (NSAlert) new NSAlert().alloc().init();
int alertType = OS.NSInformationalAlertStyle;
- if ((style & SWT.ICON_ERROR) != 0) alertType = OS.NSCriticalAlertStyle;
- if ((style & SWT.ICON_INFORMATION) != 0) alertType = OS.NSInformationalAlertStyle;
- if ((style & SWT.ICON_QUESTION) != 0) alertType = OS.NSInformationalAlertStyle;
- if ((style & SWT.ICON_WARNING) != 0) alertType = OS.NSWarningAlertStyle;
- if ((style & SWT.ICON_WORKING) != 0) alertType = OS.NSInformationalAlertStyle;
+ if ((style & SWT.ICON_ERROR) != 0) {
+ alertType = OS.NSCriticalAlertStyle;
+ }
+ if (((style & SWT.ICON_INFORMATION) != 0) || ((style & SWT.ICON_WORKING) != 0) || ((style & SWT.ICON_QUESTION) != 0)) {
+ alertType = OS.NSInformationalAlertStyle;
+ NSImage icon = Display.getSystemImageForID(OS.kAlertNoteIcon);
+ alert.setIcon(icon);
+ icon.release();
+ }
+ if ((style & SWT.ICON_WARNING) != 0) {
+ alertType = OS.NSWarningAlertStyle;
+ NSImage icon = Display.getSystemImageForID(OS.kAlertCautionIcon);
+ alert.setIcon(icon);
+ icon.release();
+ }
alert.setAlertStyle(alertType);
int mask = (SWT.YES | SWT.NO | SWT.OK | SWT.CANCEL | SWT.ABORT | SWT.RETRY | SWT.IGNORE);

Back to the top