Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 395426
Collapse All | Expand All

(-)a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/StatusDialog.java (-1 / +3 lines)
Lines 7-17 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Rüdiger Herrmann - 395426: [JFace] StatusDialog should escape ampersand in status message
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jface.dialogs;
12
package org.eclipse.jface.dialogs;
12
13
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.Status;
15
import org.eclipse.core.runtime.Status;
16
import org.eclipse.jface.action.LegacyActionTools;
15
import org.eclipse.jface.resource.JFaceColors;
17
import org.eclipse.jface.resource.JFaceColors;
16
import org.eclipse.jface.resource.JFaceResources;
18
import org.eclipse.jface.resource.JFaceResources;
17
import org.eclipse.jface.util.Policy;
19
import org.eclipse.jface.util.Policy;
Lines 107-113 public abstract class StatusDialog extends TrayDialog { Link Here
107
			if (status != null && !status.isOK()) {
109
			if (status != null && !status.isOK()) {
108
				String message = status.getMessage();
110
				String message = status.getMessage();
109
				if (message != null && message.length() > 0) {
111
				if (message != null && message.length() > 0) {
110
					setText(message);
112
					setText(LegacyActionTools.escapeMnemonics(message));
111
					// unqualified call of setImage is too ambiguous for
113
					// unqualified call of setImage is too ambiguous for
112
					// Foundation 1.0 compiler
114
					// Foundation 1.0 compiler
113
					// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=140576
115
					// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=140576
(-)a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/AllTests.java (+1 lines)
Lines 25-30 public class AllTests extends TestSuite { Link Here
25
25
26
    public AllTests() {
26
    public AllTests() {
27
    	addTestSuite(DialogTest.class);
27
    	addTestSuite(DialogTest.class);
28
    	addTestSuite(StatusDialogTest.class);
28
    	addTestSuite(DialogSettingsTest.class);
29
    	addTestSuite(DialogSettingsTest.class);
29
    	addTestSuite(InputDialogTest.class);
30
    	addTestSuite(InputDialogTest.class);
30
        addTestSuite(TitleAreaDialogTest.class);
31
        addTestSuite(TitleAreaDialogTest.class);
(-)a/tests/org.eclipse.ui.tests/Eclipse (-1 / +77 lines)
Added Link Here
0
- 
1
/*******************************************************************************
2
 * Copyright (c) 2012 Rüdiger Herrmann and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Rüdiger Herrmann - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.jface.tests.dialogs;
12
13
import junit.framework.TestCase;
14
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.core.runtime.Status;
17
import org.eclipse.jface.dialogs.StatusDialog;
18
import org.eclipse.swt.custom.CLabel;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.swt.widgets.Shell;
22
23
public class StatusDialogTest extends TestCase {
24
25
	private static final String PLUGIN_ID = "org.eclipse.ui.tests";
26
27
	private Shell shell;
28
29
	public void testEscapeAmpesandInStatusLabelBug395426() {
30
		TestableStatusDialog dialog = new TestableStatusDialog(shell);
31
		dialog.open();
32
		dialog.updateStatus(new Status(IStatus.ERROR, PLUGIN_ID, "&"));
33
		CLabel statusLabel = findStatusLabel(dialog.getShell());
34
		assertEquals( "&&", statusLabel.getText());
35
	}
36
37
	@Override
38
	protected void setUp() throws Exception {
39
		shell = new Shell();
40
	}
41
42
	@Override
43
	protected void tearDown() throws Exception {
44
		shell.dispose();
45
	}
46
47
	private CLabel findStatusLabel(Composite parent) {
48
		CLabel result = null;
49
		Control[] children = parent.getChildren();
50
		for (int i = 0; i < children.length; i++) {
51
			if (children[i] instanceof CLabel) {
52
				result = (CLabel) children[i];
53
			}
54
		}
55
		if (result == null) {
56
			for (int i = 0; i < children.length; i++) {
57
				if (children[i] instanceof Composite) {
58
					result = findStatusLabel((Composite) children[i]);
59
				}
60
			}
61
		}
62
		return result;
63
	}
64
65
	public class TestableStatusDialog extends StatusDialog {
66
67
		public TestableStatusDialog(Shell parent) {
68
			super(parent);
69
			setBlockOnOpen(false);
70
		}
71
72
		@Override
73
		protected void updateStatus(IStatus status) {
74
			super.updateStatus(status);
75
		}
76
	}
77
}

Return to bug 395426