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/views/ViewsPlugin.java (+62 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.views;
11
package org.eclipse.ui.internal.views;
12
12
13
import org.eclipse.core.runtime.Assert;
14
import org.eclipse.core.runtime.IAdaptable;
15
import org.eclipse.core.runtime.Platform;
16
import org.eclipse.core.runtime.PlatformObject;
13
import org.eclipse.jface.resource.ImageDescriptor;
17
import org.eclipse.jface.resource.ImageDescriptor;
14
import org.eclipse.ui.plugin.AbstractUIPlugin;
18
import org.eclipse.ui.plugin.AbstractUIPlugin;
15
19
Lines 60-63 Link Here
60
	public static ImageDescriptor getViewImageDescriptor(String relativePath){
64
	public static ImageDescriptor getViewImageDescriptor(String relativePath){
61
		return imageDescriptorFromPlugin(PLUGIN_ID, ICONS_PATH + relativePath);
65
		return imageDescriptorFromPlugin(PLUGIN_ID, ICONS_PATH + relativePath);
62
	}
66
	}
67
    
68
    /**
69
     * If it is possible to adapt the given object to the given type, this
70
     * returns the adapter. Performs the following checks:
71
     * 
72
     * <ol>
73
     * <li>Returns <code>sourceObject</code> if it is an instance of the
74
     * adapter type.</li>
75
     * <li>If sourceObject implements IAdaptable, it is queried for adapters.</li>
76
     * <li>If sourceObject is not an instance of PlatformObject (which would have
77
     * already done so), the adapter manager is queried for adapters</li>
78
     * </ol>
79
     * 
80
     * Otherwise returns null.
81
     * 
82
     * @param sourceObject
83
     *            object to adapt, or null
84
     * @param adapter
85
     *            type to adapt to
86
     * @param activatePlugins 
87
     *            true if IAdapterManager.loadAdapter should be used (may trigger plugin activation)
88
     * @return a representation of sourceObject that is assignable to the
89
     *         adapter type, or null if no such representation exists
90
     */
91
    public static Object getAdapter(Object sourceObject, Class adapter, boolean activatePlugins) {
92
    	Assert.isNotNull(adapter);
93
        if (sourceObject == null) {
94
            return null;
95
        }
96
        if (adapter.isInstance(sourceObject)) {
97
            return sourceObject;
98
        }
99
100
        if (sourceObject instanceof IAdaptable) {
101
            IAdaptable adaptable = (IAdaptable) sourceObject;
102
103
            Object result = adaptable.getAdapter(adapter);
104
            if (result != null) {
105
                // Sanity-check
106
                Assert.isTrue(adapter.isInstance(result));
107
                return result;
108
            }
109
        } 
110
        
111
        if (!(sourceObject instanceof PlatformObject)) {
112
        	Object result;
113
        	if (activatePlugins) {
114
        		result = Platform.getAdapterManager().loadAdapter(sourceObject, adapter.getName());
115
        	} else {
116
        		result = Platform.getAdapterManager().getAdapter(sourceObject, adapter);
117
        	}
118
            if (result != null) {
119
                return result;
120
            }
121
        }
122
123
        return null;
124
    }
63
}
125
}
(-)src/org/eclipse/ui/views/properties/PropertySheetEntry.java (-14 / +7 lines)
Lines 19-31 Link Here
19
import java.util.Map;
19
import java.util.Map;
20
20
21
import org.eclipse.core.commands.common.EventManager;
21
import org.eclipse.core.commands.common.EventManager;
22
import org.eclipse.core.runtime.IAdaptable;
23
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.jface.viewers.CellEditor;
22
import org.eclipse.jface.viewers.CellEditor;
25
import org.eclipse.jface.viewers.ICellEditorListener;
23
import org.eclipse.jface.viewers.ICellEditorListener;
26
import org.eclipse.jface.viewers.ILabelProvider;
24
import org.eclipse.jface.viewers.ILabelProvider;
27
import org.eclipse.swt.graphics.Image;
25
import org.eclipse.swt.graphics.Image;
28
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.ui.internal.views.ViewsPlugin;
29
28
30
/**
29
/**
31
 * <code>PropertySheetEntry</code> is an implementation of
30
 * <code>PropertySheetEntry</code> is an implementation of
Lines 462-483 Link Here
462
		IPropertySource result = null;
461
		IPropertySource result = null;
463
		IPropertySourceProvider provider = propertySourceProvider;
462
		IPropertySourceProvider provider = propertySourceProvider;
464
463
465
		if (provider == null && object != null)
464
		if (provider == null && object != null) {
466
			provider = (IPropertySourceProvider) Platform.getAdapterManager()
465
			provider = (IPropertySourceProvider) ViewsPlugin.getAdapter(object, 
467
					.getAdapter(object, IPropertySourceProvider.class);
466
                    IPropertySourceProvider.class, false);
467
        }
468
468
469
		if (provider != null) {
469
		if (provider != null) {
470
			result = provider.getPropertySource(object);
470
			result = provider.getPropertySource(object);
471
		} else if (object instanceof IPropertySource) {
472
			result = (IPropertySource) object;
473
		} else if (object instanceof IAdaptable) {
474
			result = (IPropertySource) ((IAdaptable) object)
475
					.getAdapter(IPropertySource.class);
476
		} else {
471
		} else {
477
			if (object != null)
472
            result = (IPropertySource)ViewsPlugin.getAdapter(object, IPropertySource.class, false);
478
				result = (IPropertySource) Platform.getAdapterManager()
473
        }
479
						.getAdapter(object, IPropertySource.class);
480
		}
481
474
482
		sources.put(object, result);
475
		sources.put(object, result);
483
		return result;
476
		return result;
(-)src/org/eclipse/ui/views/properties/PropertySheet.java (-11 / +7 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.views.properties;
11
package org.eclipse.ui.views.properties;
12
12
13
import org.eclipse.core.runtime.Platform;
14
import org.eclipse.jface.viewers.ISelection;
13
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.swt.widgets.Composite;
14
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.ui.ISaveablePart;
15
import org.eclipse.ui.ISaveablePart;
Lines 19-24 Link Here
19
import org.eclipse.ui.IWorkbenchPage;
18
import org.eclipse.ui.IWorkbenchPage;
20
import org.eclipse.ui.IWorkbenchPart;
19
import org.eclipse.ui.IWorkbenchPart;
21
import org.eclipse.ui.PartInitException;
20
import org.eclipse.ui.PartInitException;
21
import org.eclipse.ui.internal.views.ViewsPlugin;
22
import org.eclipse.ui.part.IContributedContentsView;
22
import org.eclipse.ui.part.IContributedContentsView;
23
import org.eclipse.ui.part.IPage;
23
import org.eclipse.ui.part.IPage;
24
import org.eclipse.ui.part.IPageBookViewPage;
24
import org.eclipse.ui.part.IPageBookViewPage;
Lines 115-128 Link Here
115
     */
115
     */
116
    protected PageRec doCreatePage(IWorkbenchPart part) {
116
    protected PageRec doCreatePage(IWorkbenchPart part) {
117
        // Try to get a custom property sheet page.
117
        // Try to get a custom property sheet page.
118
        IPropertySheetPage page = (IPropertySheetPage) part
118
        IPropertySheetPage page = (IPropertySheetPage) ViewsPlugin.getAdapter(part,
119
                .getAdapter(IPropertySheetPage.class);
119
                IPropertySheetPage.class, false);
120
        if (page == null) {
121
        	// Look for a declaratively-contributed adapter.
122
        	// See bug 86362 [PropertiesView] Can not access AdapterFactory, when plugin is not loaded.
123
			page = (IPropertySheetPage) Platform.getAdapterManager()
124
					.loadAdapter(part, IPropertySheetPage.class.getName());
125
		}
126
        if (page != null) {
120
        if (page != null) {
127
            if (page instanceof IPageBookViewPage) {
121
            if (page instanceof IPageBookViewPage) {
128
				initPage((IPageBookViewPage) page);
122
				initPage((IPageBookViewPage) page);
Lines 180-187 Link Here
180
     * adapter and if so, asks it for its contributing part.
174
     * adapter and if so, asks it for its contributing part.
181
     */
175
     */
182
    public void partActivated(IWorkbenchPart part) {
176
    public void partActivated(IWorkbenchPart part) {
183
        IContributedContentsView view = (IContributedContentsView) part
177
    	// Look for a declaratively-contributed adapter - including not yet loaded adapter factories.
184
                .getAdapter(IContributedContentsView.class);
178
    	// See bug 86362 [PropertiesView] Can not access AdapterFactory, when plugin is not loaded.
179
        IContributedContentsView view = (IContributedContentsView) ViewsPlugin.getAdapter(part,
180
                IContributedContentsView.class, true);
185
        IWorkbenchPart source = null;
181
        IWorkbenchPart source = null;
186
        if (view != null) {
182
        if (view != null) {
187
			source = view.getContributingPart();
183
			source = view.getContributingPart();
(-)src/org/eclipse/ui/views/contentoutline/ContentOutline.java (-1 / +2 lines)
Lines 20-25 Link Here
20
import org.eclipse.ui.IWorkbenchPage;
20
import org.eclipse.ui.IWorkbenchPage;
21
import org.eclipse.ui.IWorkbenchPart;
21
import org.eclipse.ui.IWorkbenchPart;
22
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.internal.views.ViewsPlugin;
23
import org.eclipse.ui.internal.views.contentoutline.ContentOutlineMessages;
24
import org.eclipse.ui.internal.views.contentoutline.ContentOutlineMessages;
24
import org.eclipse.ui.part.IContributedContentsView;
25
import org.eclipse.ui.part.IContributedContentsView;
25
import org.eclipse.ui.part.IPage;
26
import org.eclipse.ui.part.IPage;
Lines 125-131 Link Here
125
     */
126
     */
126
    protected PageRec doCreatePage(IWorkbenchPart part) {
127
    protected PageRec doCreatePage(IWorkbenchPart part) {
127
        // Try to get an outline page.
128
        // Try to get an outline page.
128
        Object obj = part.getAdapter(IContentOutlinePage.class);
129
        Object obj = ViewsPlugin.getAdapter(part, IContentOutlinePage.class, false);
129
        if (obj instanceof IContentOutlinePage) {
130
        if (obj instanceof IContentOutlinePage) {
130
            IContentOutlinePage page = (IContentOutlinePage) obj;
131
            IContentOutlinePage page = (IContentOutlinePage) obj;
131
            if (page instanceof IPageBookViewPage) {
132
            if (page instanceof IPageBookViewPage) {

Return to bug 156581