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 115915 Details for
Bug 107753
[Decorators] Exception handling message in decoration job could be improved
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]
Patch with tests
decorators.txt (text/plain), 12.81 KB, created by
Krzysztof Daniel
on 2008-10-23 07:42:43 EDT
(
hide
)
Description:
Patch with tests
Filename:
MIME Type:
Creator:
Krzysztof Daniel
Created:
2008-10-23 07:42:43 EDT
Size:
12.81 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/decorators/FullDecoratorRunnable.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/decorators/FullDecoratorRunnable.java,v >retrieving revision 1.7 >diff -u -r1.7 FullDecoratorRunnable.java >--- Eclipse UI/org/eclipse/ui/internal/decorators/FullDecoratorRunnable.java 16 Mar 2007 18:00:40 -0000 1.7 >+++ Eclipse UI/org/eclipse/ui/internal/decorators/FullDecoratorRunnable.java 23 Oct 2008 11:33:38 -0000 >@@ -12,8 +12,11 @@ > > import org.eclipse.core.runtime.ISafeRunnable; > import org.eclipse.core.runtime.IStatus; >-import org.eclipse.ui.internal.WorkbenchPlugin; >-import org.eclipse.ui.internal.misc.StatusUtil; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.WorkbenchMessages; >+import org.eclipse.ui.statushandlers.StatusManager; > > /** > * The FullDecoratorRunnable is the ISafeRunnable that runs >@@ -39,10 +42,14 @@ > * @see ISafeRunnable.handleException(Throwable). > */ > public void handleException(Throwable exception) { >- IStatus status = StatusUtil.newStatus(IStatus.ERROR, exception >- .getMessage(), exception); >- WorkbenchPlugin.log("Exception in Decorator", status); //$NON-NLS-1$ >- decorator.crashDisable(); >+ String message = WorkbenchMessages.DecoratorError >+ + " " //$NON-NLS-1$ >+ + NLS.bind(WorkbenchMessages.DecoratorWillBeDisabled, decorator >+ .getName()); >+ StatusManager.getManager().handle( >+ new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, message, >+ exception), StatusManager.LOG | StatusManager.SHOW); >+ decorator.crashDisable(); > } > > } >Index: Eclipse UI/org/eclipse/ui/internal/decorators/LightweightDecoratorManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/decorators/LightweightDecoratorManager.java,v >retrieving revision 1.31 >diff -u -r1.31 LightweightDecoratorManager.java >--- Eclipse UI/org/eclipse/ui/internal/decorators/LightweightDecoratorManager.java 12 May 2008 19:35:20 -0000 1.31 >+++ Eclipse UI/org/eclipse/ui/internal/decorators/LightweightDecoratorManager.java 23 Oct 2008 11:33:38 -0000 >@@ -18,11 +18,14 @@ > import org.eclipse.core.runtime.ISafeRunnable; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.SafeRunner; >+import org.eclipse.core.runtime.Status; > import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.internal.ObjectContributorManager; >-import org.eclipse.ui.internal.WorkbenchPlugin; >-import org.eclipse.ui.internal.misc.StatusUtil; >+import org.eclipse.ui.internal.WorkbenchMessages; > import org.eclipse.ui.internal.util.Util; >+import org.eclipse.ui.statushandlers.StatusManager; > > /** > * The LightweightDecoratorManager is a decorator manager that encapsulates the >@@ -56,9 +59,14 @@ > * @see ISafeRunnable.handleException(Throwable). > */ > public void handleException(Throwable exception) { >- IStatus status = StatusUtil.newStatus(IStatus.ERROR, exception >- .getMessage(), exception); >- WorkbenchPlugin.log("Exception in Decorator", status); //$NON-NLS-1$ >+ String message = WorkbenchMessages.DecoratorError; >+ if (decorator != null) { >+ message += " " + NLS.bind(WorkbenchMessages.DecoratorWillBeDisabled, //$NON-NLS-1$ >+ decorator.getName()); >+ } >+ StatusManager.getManager().handle( >+ new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, message, >+ exception), StatusManager.LOG | StatusManager.SHOW); > if (decorator != null) { > decorator.crashDisable(); > } >Index: Eclipse UI/org/eclipse/ui/internal/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties,v >retrieving revision 1.383 >diff -u -r1.383 messages.properties >--- Eclipse UI/org/eclipse/ui/internal/messages.properties 30 May 2008 17:10:15 -0000 1.383 >+++ Eclipse UI/org/eclipse/ui/internal/messages.properties 23 Oct 2008 11:33:38 -0000 >@@ -467,6 +467,8 @@ > DecoratorsPreferencePage_description = Descriptio&n: > DecoratorsPreferencePage_decoratorsLabel = Available &label decorations: > DecoratorsPreferencePage_explanation = Label decorations show extra information about an item on its label or icon.\nSelect which additional decorations should be displayed. >+DecoratorError = Exception in Decorator. >+DecoratorWillBeDisabled = The ''{0}'' decorator will be disabled. > > # --- Startup preferences --- > StartupPreferencePage_label=&Plug-ins activated on startup: >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java,v >retrieving revision 1.106 >diff -u -r1.106 WorkbenchMessages.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java 14 May 2008 17:11:06 -0000 1.106 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java 23 Oct 2008 11:33:38 -0000 >@@ -501,6 +501,8 @@ > public static String DecoratorsPreferencePage_description; > public static String DecoratorsPreferencePage_decoratorsLabel; > public static String DecoratorsPreferencePage_explanation; >+ public static String DecoratorError; >+ public static String DecoratorWillBeDisabled; > > // --- Startup preferences --- > public static String StartupPreferencePage_label; >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java,v >retrieving revision 1.11 >diff -u -r1.11 DecoratorsTestSuite.java >--- Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java 24 Mar 2008 19:13:47 -0000 1.11 >+++ Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java 23 Oct 2008 11:33:39 -0000 >@@ -28,6 +28,7 @@ > */ > public DecoratorsTestSuite() { > addTest(new TestSuite(ExceptionDecoratorTestCase.class)); >+ addTest(new TestSuite(ExceptionDecoratorErrorHandlingTest.class)); > addTest(new TestSuite(DecoratorTestCase.class)); > addTest(new TestSuite(LightweightDecoratorTestCase.class)); > addTest(new TestSuite(BadIndexDecoratorTestCase.class)); >Index: Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogUtil.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogUtil.java,v >retrieving revision 1.1 >diff -u -r1.1 StatusDialogUtil.java >--- Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogUtil.java 25 Apr 2008 18:01:26 -0000 1.1 >+++ Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogUtil.java 23 Oct 2008 11:33:39 -0000 >@@ -142,6 +142,9 @@ > > public static Table getTable(){ > Composite c = getListAreaComposite(); >+ if(c == null){ >+ return null; >+ } > if(c.getChildren().length == 0){ > return null; > } >Index: Eclipse UI Tests/org/eclipse/ui/tests/decorators/ExceptionDecoratorErrorHandlingTest.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/decorators/ExceptionDecoratorErrorHandlingTest.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/decorators/ExceptionDecoratorErrorHandlingTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/decorators/ExceptionDecoratorErrorHandlingTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,132 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2006 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.tests.decorators; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+ >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.jface.dialogs.ErrorDialog; >+import org.eclipse.jface.viewers.ILabelProviderListener; >+import org.eclipse.jface.viewers.LabelProviderChangedEvent; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.ui.internal.WorkbenchMessages; >+import org.eclipse.ui.internal.WorkbenchPlugin; >+import org.eclipse.ui.internal.decorators.DecoratorDefinition; >+import org.eclipse.ui.internal.decorators.DecoratorManager; >+import org.eclipse.ui.tests.navigator.AbstractNavigatorTest; >+import org.eclipse.ui.tests.statushandlers.StatusDialogUtil; >+ >+/** >+ * @version 1.0 >+ */ >+public class ExceptionDecoratorErrorHandlingTest extends AbstractNavigatorTest >+ implements ILabelProviderListener { >+ >+ protected DecoratorDefinition definition; >+ >+ protected boolean updated = false; >+ >+ private Collection problemDecorators = new ArrayList(); >+ >+ private DecoratorDefinition light; >+ >+ /** >+ * Constructor for DecoratorTestCase. >+ * @param testName >+ */ >+ public ExceptionDecoratorErrorHandlingTest(String testName) { >+ super(testName); >+ } >+ >+ /** >+ * Sets up the hierarchy. >+ */ >+ protected void doSetUp() throws Exception { >+ ErrorDialog.AUTOMATED_MODE = false; >+ super.doSetUp(); >+ createTestFile(); >+ showNav(); >+ >+ WorkbenchPlugin.getDefault().getDecoratorManager().addListener(this); >+ >+ //reset the static fields so that the decorators will fail >+ HeavyNullImageDecorator.fail = true; >+ HeavyNullTextDecorator.fail = true; >+ NullImageDecorator.fail = true; >+ DecoratorDefinition[] definitions = WorkbenchPlugin.getDefault() >+ .getDecoratorManager().getAllDecoratorDefinitions(); >+ for (int i = 0; i < definitions.length; i++) { >+ String id = definitions[i].getId(); >+ if (id.equals("org.eclipse.ui.tests.heavyNullImageDecorator") >+ || id.equals("org.eclipse.ui.tests.heavyNullTextDecorator")) { >+ definitions[i].setEnabled(true); >+ problemDecorators.add(definitions[i]); >+ } >+ >+ //Do not cache the light one - the disabling issues >+ //still need to be worked out. >+ if (id.equals("org.eclipse.ui.tests.lightNullImageDecorator")) { >+ definitions[i].setEnabled(true); >+ light = definitions[i]; >+ } >+ } >+ } /* (non-Javadoc) >+ * @see org.eclipse.ui.tests.navigator.LightweightDecoratorTestCase#doTearDown() >+ */ >+ >+ protected void doTearDown() throws Exception { >+ super.doTearDown(); >+ ErrorDialog.AUTOMATED_MODE = true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ILabelProviderListener#labelProviderChanged(org.eclipse.jface.viewers.LabelProviderChangedEvent) >+ */ >+ public void labelProviderChanged( >+ LabelProviderChangedEvent event) { >+ updated = true; >+ >+ } >+ >+ public void testStatusHandlingDialog() { >+ // Need to wait for decoration to end to allow for all >+ // errors to occur >+ try { >+ Job.getJobManager().join(DecoratorManager.FAMILY_DECORATE, null); >+ } catch (OperationCanceledException e) { >+ } catch (InterruptedException e) { >+ } >+ int count1 = 50; >+ while(StatusDialogUtil.getStatusShell() == null && count1-- != 0){ >+ Display.getDefault().readAndDispatch(); >+ Thread.yield(); >+ } >+ // be sure that dialog was displayed >+ assertTrue(count1 > 0); >+ >+ int count2 = 50; >+ while (StatusDialogUtil.getTable() == null && count2-- != 0) { >+ Display.getDefault().readAndDispatch(); >+ Thread.yield(); >+ } >+ // be sure that more than one status was reported >+ assertTrue(count2 > 0); >+ String message = StatusDialogUtil.getTable().getItem(0).getText(); >+ String pattern = WorkbenchMessages.DecoratorError + " " >+ + NLS.bind(WorkbenchMessages.DecoratorWillBeDisabled, ".*"); >+ assertTrue(message.matches(pattern)); >+ // Turnoff the lightweight one so as not to clutter the methods. >+ light.setEnabled(false); >+ } >+}
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 107753
:
110346
|
115371
|
115915
|
120456
|
120545