Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 224182 Details for
Bug 395426
[JFace] StatusDialog should escape ampersand in status message
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed solution
0001-Bug-395426-JFace-StatusDialog-should-escape-ampersan.patch (text/plain), 5.36 KB, created by
Rüdiger Herrmann
on 2012-11-30 18:19:11 EST
(
hide
)
Description:
Proposed solution
Filename:
MIME Type:
Creator:
Rüdiger Herrmann
Created:
2012-11-30 18:19:11 EST
Size:
5.36 KB
patch
obsolete
>From a3497ed31fc042cd5efbf845762b0deceed5e5fe Mon Sep 17 00:00:00 2001 >From: Ruediger Herrmann <ruediger.herrmann@gmx.de> >Date: Fri, 30 Nov 2012 23:56:21 +0100 >Subject: [PATCH] Bug 395426 [JFace] StatusDialog should escape ampersand in > status message > >--- > .../org/eclipse/jface/dialogs/StatusDialog.java | 4 +- > .../org/eclipse/jface/tests/dialogs/AllTests.java | 1 + > .../jface/tests/dialogs/StatusDialogTest.java | 77 ++++++++++++++++++++ > 3 files changed, 81 insertions(+), 1 deletions(-) > create mode 100755 tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/StatusDialogTest.java > >diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/StatusDialog.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/StatusDialog.java >index 7c7f436..32c08db 100644 >--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/StatusDialog.java >+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/StatusDialog.java >@@ -7,11 +7,13 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Rüdiger Herrmann - 395426: [JFace] StatusDialog should escape ampersand in status message > *******************************************************************************/ > package org.eclipse.jface.dialogs; > > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.action.LegacyActionTools; > import org.eclipse.jface.resource.JFaceColors; > import org.eclipse.jface.resource.JFaceResources; > import org.eclipse.jface.util.Policy; >@@ -107,7 +109,7 @@ public abstract class StatusDialog extends TrayDialog { > if (status != null && !status.isOK()) { > String message = status.getMessage(); > if (message != null && message.length() > 0) { >- setText(message); >+ setText(LegacyActionTools.escapeMnemonics(message)); > // unqualified call of setImage is too ambiguous for > // Foundation 1.0 compiler > // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=140576 >diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/AllTests.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/AllTests.java >index 2e74b55..11a6e47 100644 >--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/AllTests.java >+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/AllTests.java >@@ -25,6 +25,7 @@ public class AllTests extends TestSuite { > > public AllTests() { > addTestSuite(DialogTest.class); >+ addTestSuite(StatusDialogTest.class); > addTestSuite(DialogSettingsTest.class); > addTestSuite(InputDialogTest.class); > addTestSuite(TitleAreaDialogTest.class); >diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/StatusDialogTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/StatusDialogTest.java >new file mode 100755 >index 0000000..f7d5261 >--- /dev/null >+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/dialogs/StatusDialogTest.java >@@ -0,0 +1,77 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 Rüdiger Herrmann 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Rüdiger Herrmann - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.jface.tests.dialogs; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.dialogs.StatusDialog; >+import org.eclipse.swt.custom.CLabel; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Shell; >+ >+public class StatusDialogTest extends TestCase { >+ >+ private static final String PLUGIN_ID = "org.eclipse.ui.tests"; >+ >+ private Shell shell; >+ >+ public void testEscapeAmpesandInStatusLabelBug395426() { >+ TestableStatusDialog dialog = new TestableStatusDialog(shell); >+ dialog.open(); >+ dialog.updateStatus(new Status(IStatus.ERROR, PLUGIN_ID, "&")); >+ CLabel statusLabel = findStatusLabel(dialog.getShell()); >+ assertEquals( "&&", statusLabel.getText()); >+ } >+ >+ @Override >+ protected void setUp() throws Exception { >+ shell = new Shell(); >+ } >+ >+ @Override >+ protected void tearDown() throws Exception { >+ shell.dispose(); >+ } >+ >+ private CLabel findStatusLabel(Composite parent) { >+ CLabel result = null; >+ Control[] children = parent.getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ if (children[i] instanceof CLabel) { >+ result = (CLabel) children[i]; >+ } >+ } >+ if (result == null) { >+ for (int i = 0; i < children.length; i++) { >+ if (children[i] instanceof Composite) { >+ result = findStatusLabel((Composite) children[i]); >+ } >+ } >+ } >+ return result; >+ } >+ >+ public class TestableStatusDialog extends StatusDialog { >+ >+ public TestableStatusDialog(Shell parent) { >+ super(parent); >+ setBlockOnOpen(false); >+ } >+ >+ @Override >+ protected void updateStatus(IStatus status) { >+ super.updateStatus(status); >+ } >+ } >+} >-- >1.7.5.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 395426
: 224182