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 152927
Collapse All | Expand All

(-)Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorsTestSuite.java (+1 lines)
Lines 30-35 Link Here
30
		addTest(new TestSuite(ExceptionDecoratorTestCase.class));
30
		addTest(new TestSuite(ExceptionDecoratorTestCase.class));
31
		addTest(new TestSuite(DecoratorTestCase.class));
31
		addTest(new TestSuite(DecoratorTestCase.class));
32
		addTest(new TestSuite(LightweightDecoratorTestCase.class));
32
		addTest(new TestSuite(LightweightDecoratorTestCase.class));
33
		addTest(new TestSuite(BadIndexDecoratorTestCase.class));
33
//		addTest(new TestSuite(DecoratorTreeTest.class));
34
//		addTest(new TestSuite(DecoratorTreeTest.class));
34
//		addTest(new TestSuite(DecoratorTableTest.class));
35
//		addTest(new TestSuite(DecoratorTableTest.class));
35
//		addTest(new TestSuite(DecoratorTableTreeTest.class));
36
//		addTest(new TestSuite(DecoratorTableTreeTest.class));
(-)plugin.xml (+12 lines)
Lines 1548-1553 Link Here
1548
            A test decorator for resource mappings
1548
            A test decorator for resource mappings
1549
         </description>
1549
         </description>
1550
      </decorator>
1550
      </decorator>
1551
      <decorator
1552
            adaptable="true"
1553
            class="org.eclipse.ui.tests.decorators.BadIndexDecorator"
1554
            id="org.eclipse.ui.tests.decorators.badIndexDecorator"
1555
            label="Bad Index Decorator"
1556
            lightweight="true">
1557
         <enablement>
1558
            <objectClass
1559
                  name="org.eclipse.core.resources.IResource">
1560
            </objectClass>
1561
         </enablement>
1562
      </decorator>
1551
      
1563
      
1552
   </extension>
1564
   </extension>
1553
<!-- Working set tests -->
1565
<!-- Working set tests -->
(-)Eclipse (+65 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
12
package org.eclipse.ui.tests.decorators;
13
14
import org.eclipse.ui.internal.WorkbenchPlugin;
15
import org.eclipse.ui.internal.decorators.DecoratorDefinition;
16
17
/**
18
 * @since 3.2
19
 *
20
 */
21
public class BadIndexDecoratorTestCase extends DecoratorEnablementTestCase {
22
	
23
	 /**
24
	 * @param testName
25
	 */
26
	public BadIndexDecoratorTestCase(String testName) {
27
		super(testName);
28
	}
29
30
	/**
31
     * Sets up the hierarchy.
32
     */
33
    protected void doSetUp() throws Exception {
34
        super.doSetUp();
35
        createTestFile();
36
        showNav();
37
38
        WorkbenchPlugin.getDefault().getDecoratorManager().addListener(this);
39
40
        DecoratorDefinition[] definitions = WorkbenchPlugin.getDefault()
41
                .getDecoratorManager().getAllDecoratorDefinitions();
42
        for (int i = 0; i < definitions.length; i++) {
43
            if (definitions[i].getId().equals(
44
                    "org.eclipse.ui.tests.decorators.badIndexDecorator"))
45
                definition = definitions[i];
46
        }
47
    }
48
    
49
    /**
50
     * Turn off an on the bad index decorator without
51
     * generating an exception.
52
     */
53
    public void testNoException() {
54
55
        updated = false;
56
        getDecoratorManager().clearCaches();
57
        definition.setEnabled(true);
58
        getDecoratorManager().updateForEnablementChange();
59
        definition.setEnabled(false);
60
        getDecoratorManager().updateForEnablementChange();
61
        updated = false;
62
63
    }
64
65
}
(-)Eclipse (+94 lines)
Added Link Here
1
package org.eclipse.ui.tests.decorators;
2
3
import java.net.MalformedURLException;
4
import java.net.URL;
5
import java.util.HashSet;
6
import java.util.Iterator;
7
import java.util.Set;
8
9
import org.eclipse.core.resources.IResource;
10
import org.eclipse.core.runtime.Assert;
11
import org.eclipse.jface.resource.ImageDescriptor;
12
import org.eclipse.jface.viewers.IDecoration;
13
import org.eclipse.jface.viewers.ILabelProviderListener;
14
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
15
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
16
import org.eclipse.ui.tests.TestPlugin;
17
18
public class BadIndexDecorator implements ILightweightLabelDecorator {
19
20
     private Set listeners = new HashSet();
21
22
    private ImageDescriptor descriptor;
23
   
24
25
    /*
26
     * @see IBaseLabelProvider#addListener(ILabelProviderListener)
27
     */
28
    public void addListener(ILabelProviderListener listener) {
29
        listeners.add(listener);
30
    }
31
32
    /*
33
     * @see IBaseLabelProvider#dispose()
34
     */
35
    public void dispose() {
36
        listeners = new HashSet();
37
    }
38
39
    /*
40
     * @see IBaseLabelProvider#isLabelProperty(Object, String)
41
     */
42
    public boolean isLabelProperty(Object element, String property) {
43
        return false;
44
    }
45
46
    /*
47
     * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
48
     */
49
    public void removeListener(ILabelProviderListener listener) {
50
        listeners.remove(listener);
51
    }
52
53
    /**
54
     * Refresh the listeners to update the decorators for 
55
     * element.
56
     */
57
58
    public void refreshListeners(Object element) {
59
        Iterator iterator = listeners.iterator();
60
        while (iterator.hasNext()) {
61
            LabelProviderChangedEvent event = new LabelProviderChangedEvent(
62
                    this, element);
63
            ((ILabelProviderListener) iterator.next())
64
                    .labelProviderChanged(event);
65
        }
66
    }
67
68
    /**
69
     * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#getOverlay(java.lang.Object)
70
     */
71
    public ImageDescriptor getOverlay(Object element) {
72
        Assert.isTrue(element instanceof IResource);
73
        if (descriptor == null) {
74
            URL source = TestPlugin.getDefault().getDescriptor()
75
                    .getInstallURL();
76
            try {
77
                descriptor = ImageDescriptor.createFromURL(new URL(source,
78
                        "icons/binary_co.gif"));
79
            } catch (MalformedURLException exception) {
80
                return null;
81
            }
82
        }
83
        return descriptor;
84
85
    }
86
87
    /**
88
     * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
89
     */
90
    public void decorate(Object element, IDecoration decoration) {
91
        decoration.addOverlay(getOverlay(element), 17);
92
    }
93
94
}
(-)Eclipse UI/org/eclipse/ui/internal/decorators/DecorationBuilder.java (-1 / +1 lines)
Lines 86-92 Link Here
86
	 * @see org.eclipse.jface.viewers.IDecoration#addOverlay(org.eclipse.jface.resource.ImageDescriptor)
86
	 * @see org.eclipse.jface.viewers.IDecoration#addOverlay(org.eclipse.jface.resource.ImageDescriptor)
87
	 */
87
	 */
88
	public void addOverlay(ImageDescriptor overlay, int quadrant) {
88
	public void addOverlay(ImageDescriptor overlay, int quadrant) {
89
		if (quadrant >= 0 && quadrant <= DECORATOR_ARRAY_SIZE) {
89
		if (quadrant >= 0 && quadrant < DECORATOR_ARRAY_SIZE) {
90
			if (descriptors[quadrant] == null) {
90
			if (descriptors[quadrant] == null) {
91
				descriptors[quadrant] = overlay;
91
				descriptors[quadrant] = overlay;
92
			}
92
			}

Return to bug 152927