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 107753 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/decorators/FullDecoratorRunnable.java (-6 / +13 lines)
Lines 12-19 Link Here
12
12
13
import org.eclipse.core.runtime.ISafeRunnable;
13
import org.eclipse.core.runtime.ISafeRunnable;
14
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.ui.internal.WorkbenchPlugin;
15
import org.eclipse.core.runtime.Status;
16
import org.eclipse.ui.internal.misc.StatusUtil;
16
import org.eclipse.osgi.util.NLS;
17
import org.eclipse.ui.PlatformUI;
18
import org.eclipse.ui.internal.WorkbenchMessages;
19
import org.eclipse.ui.statushandlers.StatusManager;
17
20
18
/**
21
/**
19
 * The FullDecoratorRunnable is the ISafeRunnable that runs
22
 * The FullDecoratorRunnable is the ISafeRunnable that runs
Lines 39-48 Link Here
39
     * @see ISafeRunnable.handleException(Throwable).
42
     * @see ISafeRunnable.handleException(Throwable).
40
     */
43
     */
41
    public void handleException(Throwable exception) {
44
    public void handleException(Throwable exception) {
42
        IStatus status = StatusUtil.newStatus(IStatus.ERROR, exception
45
		String message = WorkbenchMessages.DecoratorError
43
                .getMessage(), exception);
46
				+ " " //$NON-NLS-1$
44
        WorkbenchPlugin.log("Exception in Decorator", status); //$NON-NLS-1$
47
				+ NLS.bind(WorkbenchMessages.DecoratorWillBeDisabled, decorator
45
        decorator.crashDisable();
48
						.getName());
49
		StatusManager.getManager().handle(
50
				new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, message,
51
						exception), StatusManager.LOG | StatusManager.SHOW);
52
		decorator.crashDisable();
46
    }
53
    }
47
54
48
}
55
}
(-)Eclipse UI/org/eclipse/ui/internal/decorators/LightweightDecoratorManager.java (-5 / +13 lines)
Lines 18-28 Link Here
18
import org.eclipse.core.runtime.ISafeRunnable;
18
import org.eclipse.core.runtime.ISafeRunnable;
19
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.SafeRunner;
20
import org.eclipse.core.runtime.SafeRunner;
21
import org.eclipse.core.runtime.Status;
21
import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
22
import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
23
import org.eclipse.osgi.util.NLS;
24
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.ui.internal.ObjectContributorManager;
25
import org.eclipse.ui.internal.ObjectContributorManager;
23
import org.eclipse.ui.internal.WorkbenchPlugin;
26
import org.eclipse.ui.internal.WorkbenchMessages;
24
import org.eclipse.ui.internal.misc.StatusUtil;
25
import org.eclipse.ui.internal.util.Util;
27
import org.eclipse.ui.internal.util.Util;
28
import org.eclipse.ui.statushandlers.StatusManager;
26
29
27
/**
30
/**
28
 * The LightweightDecoratorManager is a decorator manager that encapsulates the
31
 * The LightweightDecoratorManager is a decorator manager that encapsulates the
Lines 56-64 Link Here
56
		 * @see ISafeRunnable.handleException(Throwable).
59
		 * @see ISafeRunnable.handleException(Throwable).
57
		 */
60
		 */
58
		public void handleException(Throwable exception) {
61
		public void handleException(Throwable exception) {
59
			IStatus status = StatusUtil.newStatus(IStatus.ERROR, exception
62
			String message = WorkbenchMessages.DecoratorError;
60
					.getMessage(), exception);
63
			if (decorator != null) {
61
			WorkbenchPlugin.log("Exception in Decorator", status); //$NON-NLS-1$
64
				message += " " + NLS.bind(WorkbenchMessages.DecoratorWillBeDisabled, //$NON-NLS-1$
65
										decorator.getName());
66
			}
67
			StatusManager.getManager().handle(
68
					new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, message,
69
							exception), StatusManager.LOG | StatusManager.SHOW);
62
			if (decorator != null) {
70
			if (decorator != null) {
63
				decorator.crashDisable();
71
				decorator.crashDisable();
64
			}
72
			}
(-)Eclipse UI/org/eclipse/ui/internal/messages.properties (+2 lines)
Lines 467-472 Link Here
467
DecoratorsPreferencePage_description = Descriptio&n:
467
DecoratorsPreferencePage_description = Descriptio&n:
468
DecoratorsPreferencePage_decoratorsLabel = Available &label decorations:
468
DecoratorsPreferencePage_decoratorsLabel = Available &label decorations:
469
DecoratorsPreferencePage_explanation = Label decorations show extra information about an item on its label or icon.\nSelect which additional decorations should be displayed.
469
DecoratorsPreferencePage_explanation = Label decorations show extra information about an item on its label or icon.\nSelect which additional decorations should be displayed.
470
DecoratorError = Exception in Decorator.
471
DecoratorWillBeDisabled = The ''{0}'' decorator will be disabled.
470
472
471
# --- Startup preferences ---
473
# --- Startup preferences ---
472
StartupPreferencePage_label=&Plug-ins activated on startup:
474
StartupPreferencePage_label=&Plug-ins activated on startup:
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java (+2 lines)
Lines 501-506 Link Here
501
	public static String DecoratorsPreferencePage_description;
501
	public static String DecoratorsPreferencePage_description;
502
	public static String DecoratorsPreferencePage_decoratorsLabel;
502
	public static String DecoratorsPreferencePage_decoratorsLabel;
503
	public static String DecoratorsPreferencePage_explanation;
503
	public static String DecoratorsPreferencePage_explanation;
504
	public static String DecoratorError;
505
	public static String DecoratorWillBeDisabled;
504
506
505
	// --- Startup preferences ---
507
	// --- Startup preferences ---
506
	public static String StartupPreferencePage_label;
508
	public static String StartupPreferencePage_label;
(-)Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java (+1 lines)
Lines 28-33 Link Here
28
	 */
28
	 */
29
	public DecoratorsTestSuite() {
29
	public DecoratorsTestSuite() {
30
		addTest(new TestSuite(ExceptionDecoratorTestCase.class));
30
		addTest(new TestSuite(ExceptionDecoratorTestCase.class));
31
		addTest(new TestSuite(ExceptionDecoratorErrorHandlingTest.class));
31
		addTest(new TestSuite(DecoratorTestCase.class));
32
		addTest(new TestSuite(DecoratorTestCase.class));
32
		addTest(new TestSuite(LightweightDecoratorTestCase.class));
33
		addTest(new TestSuite(LightweightDecoratorTestCase.class));
33
		addTest(new TestSuite(BadIndexDecoratorTestCase.class));
34
		addTest(new TestSuite(BadIndexDecoratorTestCase.class));
(-)Eclipse UI Tests/org/eclipse/ui/tests/statushandlers/StatusDialogUtil.java (+3 lines)
Lines 142-147 Link Here
142
	
142
	
143
	public static Table getTable(){
143
	public static Table getTable(){
144
		Composite c = getListAreaComposite();
144
		Composite c = getListAreaComposite();
145
		if(c == null){
146
			return null;
147
		}
145
		if(c.getChildren().length == 0){
148
		if(c.getChildren().length == 0){
146
			return null;
149
			return null;
147
		}
150
		}
(-)Eclipse (+132 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation 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
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.decorators;
12
13
import java.util.ArrayList;
14
import java.util.Collection;
15
16
import org.eclipse.core.runtime.OperationCanceledException;
17
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.jface.dialogs.ErrorDialog;
19
import org.eclipse.jface.viewers.ILabelProviderListener;
20
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
21
import org.eclipse.osgi.util.NLS;
22
import org.eclipse.swt.widgets.Display;
23
import org.eclipse.ui.internal.WorkbenchMessages;
24
import org.eclipse.ui.internal.WorkbenchPlugin;
25
import org.eclipse.ui.internal.decorators.DecoratorDefinition;
26
import org.eclipse.ui.internal.decorators.DecoratorManager;
27
import org.eclipse.ui.tests.navigator.AbstractNavigatorTest;
28
import org.eclipse.ui.tests.statushandlers.StatusDialogUtil;
29
30
/**
31
 * @version 	1.0
32
 */
33
public class ExceptionDecoratorErrorHandlingTest extends AbstractNavigatorTest
34
        implements ILabelProviderListener {
35
	
36
	protected DecoratorDefinition definition;
37
38
	protected boolean updated = false;
39
    
40
    private Collection problemDecorators = new ArrayList();
41
42
    private DecoratorDefinition light;
43
44
    /**
45
     * Constructor for DecoratorTestCase.
46
     * @param testName
47
     */
48
    public ExceptionDecoratorErrorHandlingTest(String testName) {
49
        super(testName);
50
    }
51
52
    /**
53
     * Sets up the hierarchy.
54
     */
55
    protected void doSetUp() throws Exception {
56
    	ErrorDialog.AUTOMATED_MODE = false;
57
    	super.doSetUp();
58
        createTestFile();
59
        showNav();
60
61
        WorkbenchPlugin.getDefault().getDecoratorManager().addListener(this);
62
63
        //reset the static fields so that the decorators will fail
64
        HeavyNullImageDecorator.fail = true;
65
        HeavyNullTextDecorator.fail = true;
66
        NullImageDecorator.fail = true;
67
        DecoratorDefinition[] definitions = WorkbenchPlugin.getDefault()
68
                .getDecoratorManager().getAllDecoratorDefinitions();
69
        for (int i = 0; i < definitions.length; i++) {
70
            String id = definitions[i].getId();
71
            if (id.equals("org.eclipse.ui.tests.heavyNullImageDecorator")
72
                    || id.equals("org.eclipse.ui.tests.heavyNullTextDecorator")) {
73
                definitions[i].setEnabled(true);
74
                problemDecorators.add(definitions[i]);
75
            }
76
77
            //Do not cache the light one - the disabling issues
78
            //still need to be worked out.
79
            if (id.equals("org.eclipse.ui.tests.lightNullImageDecorator")) {
80
                definitions[i].setEnabled(true);
81
                light = definitions[i];
82
            }
83
        }
84
    } /* (non-Javadoc)
85
     * @see org.eclipse.ui.tests.navigator.LightweightDecoratorTestCase#doTearDown()
86
     */
87
88
    protected void doTearDown() throws Exception {
89
        super.doTearDown();
90
        ErrorDialog.AUTOMATED_MODE = true;
91
    }
92
93
	/* (non-Javadoc)
94
	 * @see org.eclipse.jface.viewers.ILabelProviderListener#labelProviderChanged(org.eclipse.jface.viewers.LabelProviderChangedEvent)
95
	 */
96
	public void labelProviderChanged(
97
		LabelProviderChangedEvent event) {
98
		updated = true;
99
100
	}
101
102
	public void testStatusHandlingDialog() {
103
		// Need to wait for decoration to end to allow for all
104
		// errors to occur
105
		try {
106
			Job.getJobManager().join(DecoratorManager.FAMILY_DECORATE, null);
107
		} catch (OperationCanceledException e) {
108
		} catch (InterruptedException e) {
109
		}
110
		int count1 = 50;
111
		while(StatusDialogUtil.getStatusShell() == null && count1-- != 0){
112
			Display.getDefault().readAndDispatch();
113
			Thread.yield();
114
		}
115
		// be sure that dialog was displayed
116
		assertTrue(count1 > 0);
117
		
118
		int count2 = 50;
119
		while (StatusDialogUtil.getTable() == null && count2-- != 0) {
120
			Display.getDefault().readAndDispatch();
121
			Thread.yield();
122
		}
123
		// be sure that more than one status was reported
124
		assertTrue(count2 > 0);
125
		String message = StatusDialogUtil.getTable().getItem(0).getText();
126
		String pattern = WorkbenchMessages.DecoratorError + " "
127
				+ NLS.bind(WorkbenchMessages.DecoratorWillBeDisabled, ".*");
128
		assertTrue(message.matches(pattern));
129
		// Turnoff the lightweight one so as not to clutter the methods.
130
		light.setEnabled(false);
131
	}
132
}

Return to bug 107753