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

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/navigator/AdaptabilityUtility.java (-8 / +28 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.navigator;
11
package org.eclipse.ui.internal.navigator;
12
12
13
import org.eclipse.core.runtime.Assert;
13
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.core.runtime.Platform;
15
import org.eclipse.core.runtime.Platform;
16
import org.eclipse.core.runtime.PlatformObject;
15
17
16
/**
18
/**
17
 * Provides utilities for working with adaptable and non-adaptable objects.
19
 * Provides utilities for working with adaptable and non-adaptable objects.
Lines 32-45 Link Here
32
	 * @return An adapter of the requested type or null
34
	 * @return An adapter of the requested type or null
33
	 */
35
	 */
34
	public static Object getAdapter(Object anElement, Class anAdapterType) {
36
	public static Object getAdapter(Object anElement, Class anAdapterType) {
35
		if (anElement == null) {
37
        if (anElement == null || anAdapterType == null) {
36
			return null;
38
            return null;
37
		} else if (anElement instanceof IAdaptable) {
39
        }
38
			return ((IAdaptable) anElement).getAdapter(anAdapterType);
40
        if (anAdapterType.isInstance(anElement)) {
39
		} else {
41
            return anElement;
40
			return Platform.getAdapterManager().getAdapter(anElement,
42
        }
41
					anAdapterType);
43
42
		}
44
        if (anElement instanceof IAdaptable) {
45
            IAdaptable adaptable = (IAdaptable) anElement;
46
47
            Object result = adaptable.getAdapter(anAdapterType);
48
            if (result != null) {
49
                // Sanity-check
50
                Assert.isTrue(anAdapterType.isInstance(result));
51
                return result;
52
            }
53
        } 
54
        
55
        if (!(anElement instanceof PlatformObject)) {
56
            Object result = Platform.getAdapterManager().loadAdapter(anElement, anAdapterType.getName());
57
            if (result != null) {
58
                return result;
59
            }
60
        }
61
62
        return null;
43
	}
63
	}
44
64
45
}
65
}
(-)src/org/eclipse/ui/internal/navigator/NavigatorSaveablesService.java (-6 / +2 lines)
Lines 21-27 Link Here
21
import java.util.Set;
21
import java.util.Set;
22
import java.util.TreeMap;
22
import java.util.TreeMap;
23
23
24
import org.eclipse.core.runtime.IAdaptable;
25
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.core.runtime.Platform;
26
import org.eclipse.jface.viewers.IStructuredSelection;
25
import org.eclipse.jface.viewers.IStructuredSelection;
27
import org.eclipse.jface.viewers.ITreeContentProvider;
26
import org.eclipse.jface.viewers.ITreeContentProvider;
Lines 449-459 Link Here
449
				.getExtension(descriptor, true);
448
				.getExtension(descriptor, true);
450
		ITreeContentProvider contentProvider = extension
449
		ITreeContentProvider contentProvider = extension
451
				.getContentProvider();
450
				.getContentProvider();
452
		if (contentProvider instanceof IAdaptable) {
451
        
453
			return (SaveablesProvider) ((IAdaptable) contentProvider)
452
        return (SaveablesProvider)AdaptabilityUtility.getAdapter(contentProvider, SaveablesProvider.class);
454
					.getAdapter(SaveablesProvider.class);
455
		}
456
		return null;
457
	}
453
	}
458
454
459
	private Saveable[] getShownSaveables(Saveable[] saveables) {
455
	private Saveable[] getShownSaveables(Saveable[] saveables) {

Return to bug 156581