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 118229 Details for
Bug 242821
[ErrorHandling] [statushandling ]Need a way to configure label providers on StatusDialog
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 Fix
clipboard.txt (text/plain), 7.58 KB, created by
Krzysztof Daniel
on 2008-11-19 06:51:08 EST
(
hide
)
Description:
Proposed Fix
Filename:
MIME Type:
Creator:
Krzysztof Daniel
Created:
2008-11-19 06:51:08 EST
Size:
7.58 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchStatusDialogManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchStatusDialogManager.java,v >retrieving revision 1.20 >diff -u -r1.20 WorkbenchStatusDialogManager.java >--- Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchStatusDialogManager.java 21 Oct 2008 16:36:14 -0000 1.20 >+++ Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchStatusDialogManager.java 19 Nov 2008 11:49:47 -0000 >@@ -41,6 +41,7 @@ > import org.eclipse.jface.resource.ResourceManager; > import org.eclipse.jface.util.Policy; > import org.eclipse.jface.viewers.IContentProvider; >+import org.eclipse.jface.viewers.ILabelDecorator; > import org.eclipse.jface.viewers.ILabelProviderListener; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.ISelectionChangedListener; >@@ -1095,6 +1096,8 @@ > * Header area. > */ > private Composite titleArea; >+ >+ private ILabelDecorator messageDecorator; > > /** > * Creates workbench status dialog. >@@ -1667,14 +1670,14 @@ > if (property instanceof String) { > String header = (String) property; > if (header.trim().length() > 0) { >- return header; >+ return decorate(header, statusAdapter); > } > } > // if there was message set in the status > IStatus status = statusAdapter.getStatus(); > if (status.getMessage() != null > && status.getMessage().trim().length() > 0) { >- return status.getMessage(); >+ return decorate(status.getMessage(), statusAdapter); > } > > // if status has children >@@ -1686,9 +1689,9 @@ > Throwable t = status.getException(); > if (t != null) { > if (t.getMessage() != null && t.getMessage().trim().length() > 0) { >- return t.getMessage(); >+ return decorate(t.getMessage(), statusAdapter); > } >- return t.getClass().getName(); >+ return decorate(t.getClass().getName(), statusAdapter); > } > return WorkbenchMessages.WorkbenchStatusDialog_ProblemOccurred; > } >@@ -1719,26 +1722,32 @@ > > // if there was message set in the status > IStatus status = statusAdapter.getStatus(); >- if (status.getMessage() != null >- && status.getMessage().trim().length() > 0 >- && !primary.equals(status.getMessage())) { // we have not >- // displayed it yet >- return status.getMessage(); >+ String message = status.getMessage(); >+ String decoratedMessage = message == null ? null : decorate(message, >+ statusAdapter); >+ if (message != null && message.trim().length() > 0 >+ && !primary.equals(decoratedMessage)) { >+ /* we have not displayed it yet */ >+ return decoratedMessage; > } > // if status has children > if (status.getChildren().length > 0 >- && !primary.equals(status.getMessage())) { >+ && !primary.equals(decoratedMessage)) { > return WorkbenchMessages.WorkbenchStatusDialog_StatusWithChildren; > } > > // check the exception > Throwable t = status.getException(); > if (t != null) { >- if (t.getMessage() != null && t.getMessage().trim().length() > 0 >- && !primary.equals(t.getMessage())) { >- return t.getMessage(); >+ if (t.getMessage() != null) { >+ String decoratedThrowable = decorate(t.getMessage(), >+ statusAdapter); >+ if (t.getMessage().trim().length() > 0 >+ && !primary.equals(decoratedThrowable)) { >+ return decoratedThrowable; >+ } > } >- String throwableName = t.getClass().getName(); >+ String throwableName = decorate(t.getClass().getName(), statusAdapter); > if (!primary.equals(throwableName)) { > return throwableName; > } >@@ -2289,4 +2298,42 @@ > return null; > return this.dialog.getShell(); > } >+ >+ /** >+ * <p> >+ * This methods sets up the decorator, which is used to modify displayed >+ * strings extracted from StatusAdapter. The decorator should be used to >+ * remove technical codes from the dialog, f.e. following message >+ * "<i>ERR2008 Invalid password</i>" can be translated into >+ * "<i>Invalid password</i>". >+ * </p> >+ * <p> >+ * The decorator will be applied only to messages extracted from >+ * StatusAdapter (predefined messages like >+ * "This status has children statuses. See 'Details' for more information." >+ * are not affected. >+ * </p> >+ * <p> >+ * This method should not be used together with >+ * {@link #setStatusListLabelProvider(ITableLabelProvider)}. >+ * </p> >+ * >+ * @param decorator >+ * - the decorator to be set. Only >+ * {@link ILabelDecorator#decorateText(String, Object)} method >+ * will be used. This method should return <code>null</code> if >+ * and only if the first argument is null. StatusAdapter is >+ * passed as second parameter. >+ * @since 3.5 >+ */ >+ public void setMessageDecorator(ILabelDecorator decorator){ >+ this.messageDecorator = decorator; >+ } >+ >+ private String decorate(String string, StatusAdapter adapter) { >+ if(messageDecorator != null){ >+ string = messageDecorator.decorateText(string, adapter); >+ } >+ return string; >+ } > } >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogManagerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogManagerTest.java,v >retrieving revision 1.7 >diff -u -r1.7 StatusDialogManagerTest.java >--- Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogManagerTest.java 21 Oct 2008 10:42:42 -0000 1.7 >+++ Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogManagerTest.java 19 Nov 2008 11:49:48 -0000 >@@ -21,6 +21,7 @@ > import org.eclipse.jface.dialogs.ErrorDialog; > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.util.Policy; >+import org.eclipse.jface.viewers.ILabelDecorator; > import org.eclipse.jface.viewers.ILabelProviderListener; > import org.eclipse.jface.viewers.ITableLabelProvider; > import org.eclipse.osgi.util.NLS; >@@ -249,6 +250,52 @@ > assertTrue(((GridData) layoutData).exclude); > } > >+ public void testWithStatusAdapterAndLabelProvider1(){ >+ wsdm.setMessageDecorator(new ILabelDecorator(){ >+ >+ public Image decorateImage(Image image, Object element) { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public String decorateText(String text, Object element) { >+ // TODO Auto-generated method stub >+ return text.replaceAll("[A-Z][A-Z][A-Z][0-9][0-9]", ""); >+ } >+ >+ public void addListener(ILabelProviderListener listener) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public void dispose() { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public boolean isLabelProperty(Object element, String property) { >+ // TODO Auto-generated method stub >+ return false; >+ } >+ >+ public void removeListener(ILabelProviderListener listener) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ }); >+ wsdm.addStatusAdapter(createStatusAdapter("XYZ01" + MESSAGE_1), false); >+ Label titleLabel = StatusDialogUtil.getTitleLabel(); >+ assertNotNull(titleLabel); >+ assertEquals(MESSAGE_1, titleLabel.getText()); >+ >+ Label secondaryLabel = StatusDialogUtil.getSingleStatusLabel(); >+ assertNotNull(secondaryLabel); >+ assertEquals(WorkbenchMessages.WorkbenchStatusDialog_SeeDetails, >+ secondaryLabel.getText()); >+ } >+ >+ > /** > * Simple status with title. Check primary and secondary message. Verify > * closing.
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 242821
: 118229 |
118230