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 49674 Details for
Bug 156581
[Workbench] Inconsistent adapter usage in the workbench
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 for ui.views
156581_ui_views_patch.txt (text/plain), 8.55 KB, created by
Stefan Xenos
on 2006-09-07 19:48:35 EDT
(
hide
)
Description:
Patch for ui.views
Filename:
MIME Type:
Creator:
Stefan Xenos
Created:
2006-09-07 19:48:35 EDT
Size:
8.55 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.views >Index: src/org/eclipse/ui/internal/views/ViewsPlugin.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.views/src/org/eclipse/ui/internal/views/ViewsPlugin.java,v >retrieving revision 1.8 >diff -u -r1.8 ViewsPlugin.java >--- src/org/eclipse/ui/internal/views/ViewsPlugin.java 15 Jun 2005 18:41:22 -0000 1.8 >+++ src/org/eclipse/ui/internal/views/ViewsPlugin.java 7 Sep 2006 23:51:44 -0000 >@@ -10,6 +10,10 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.views; > >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.PlatformObject; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.ui.plugin.AbstractUIPlugin; > >@@ -60,4 +64,54 @@ > public static ImageDescriptor getViewImageDescriptor(String relativePath){ > return imageDescriptorFromPlugin(PLUGIN_ID, ICONS_PATH + relativePath); > } >+ >+ /** >+ * If it is possible to adapt the given object to the given type, this >+ * returns the adapter. Performs the following checks: >+ * >+ * <ol> >+ * <li>Returns <code>sourceObject</code> if it is an instance of the >+ * adapter type.</li> >+ * <li>If sourceObject implements IAdaptable, it is queried for adapters.</li> >+ * <li>If sourceObject is not an instance of PlatformObject (which would have >+ * already done so), the adapter manager is queried for adapters</li> >+ * </ol> >+ * >+ * Otherwise returns null. >+ * >+ * @param sourceObject >+ * object to adapt >+ * @param adapter >+ * type to adapt to >+ * @return a representation of sourceObject that is assignable to the >+ * adapter type, or null if no such representation exists >+ */ >+ public static Object getAdapter(Object sourceObject, Class adapter) { >+ if (sourceObject == null || adapter == null) { >+ return null; >+ } >+ if (adapter.isInstance(sourceObject)) { >+ return sourceObject; >+ } >+ >+ if (sourceObject instanceof IAdaptable) { >+ IAdaptable adaptable = (IAdaptable) sourceObject; >+ >+ Object result = adaptable.getAdapter(adapter); >+ if (result != null) { >+ // Sanity-check >+ Assert.isTrue(adapter.isInstance(result)); >+ return result; >+ } >+ } >+ >+ if (!(sourceObject instanceof PlatformObject)) { >+ Object result = Platform.getAdapterManager().loadAdapter(sourceObject, adapter.getName()); >+ if (result != null) { >+ return result; >+ } >+ } >+ >+ return null; >+ } > } >Index: src/org/eclipse/ui/views/properties/PropertySheetEntry.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheetEntry.java,v >retrieving revision 1.24 >diff -u -r1.24 PropertySheetEntry.java >--- src/org/eclipse/ui/views/properties/PropertySheetEntry.java 8 May 2006 20:53:18 -0000 1.24 >+++ src/org/eclipse/ui/views/properties/PropertySheetEntry.java 7 Sep 2006 23:51:44 -0000 >@@ -19,13 +19,12 @@ > import java.util.Map; > > import org.eclipse.core.commands.common.EventManager; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.viewers.CellEditor; > import org.eclipse.jface.viewers.ICellEditorListener; > import org.eclipse.jface.viewers.ILabelProvider; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.internal.views.ViewsPlugin; > > /** > * <code>PropertySheetEntry</code> is an implementation of >@@ -462,22 +461,16 @@ > IPropertySource result = null; > IPropertySourceProvider provider = propertySourceProvider; > >- if (provider == null && object != null) >- provider = (IPropertySourceProvider) Platform.getAdapterManager() >- .getAdapter(object, IPropertySourceProvider.class); >+ if (provider == null && object != null) { >+ provider = (IPropertySourceProvider) ViewsPlugin.getAdapter(object, >+ IPropertySourceProvider.class); >+ } > > if (provider != null) { > result = provider.getPropertySource(object); >- } else if (object instanceof IPropertySource) { >- result = (IPropertySource) object; >- } else if (object instanceof IAdaptable) { >- result = (IPropertySource) ((IAdaptable) object) >- .getAdapter(IPropertySource.class); > } else { >- if (object != null) >- result = (IPropertySource) Platform.getAdapterManager() >- .getAdapter(object, IPropertySource.class); >- } >+ result = (IPropertySource)ViewsPlugin.getAdapter(object, IPropertySource.class); >+ } > > sources.put(object, result); > return result; >Index: src/org/eclipse/ui/views/properties/PropertySheet.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.views/src/org/eclipse/ui/views/properties/PropertySheet.java,v >retrieving revision 1.13 >diff -u -r1.13 PropertySheet.java >--- src/org/eclipse/ui/views/properties/PropertySheet.java 8 May 2006 20:53:18 -0000 1.13 >+++ src/org/eclipse/ui/views/properties/PropertySheet.java 7 Sep 2006 23:51:44 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.ui.views.properties; > >-import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.ui.ISaveablePart; >@@ -19,6 +18,7 @@ > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.internal.views.ViewsPlugin; > import org.eclipse.ui.part.IContributedContentsView; > import org.eclipse.ui.part.IPage; > import org.eclipse.ui.part.IPageBookViewPage; >@@ -115,14 +115,8 @@ > */ > protected PageRec doCreatePage(IWorkbenchPart part) { > // Try to get a custom property sheet page. >- IPropertySheetPage page = (IPropertySheetPage) part >- .getAdapter(IPropertySheetPage.class); >- if (page == null) { >- // Look for a declaratively-contributed adapter. >- // See bug 86362 [PropertiesView] Can not access AdapterFactory, when plugin is not loaded. >- page = (IPropertySheetPage) Platform.getAdapterManager() >- .loadAdapter(part, IPropertySheetPage.class.getName()); >- } >+ IPropertySheetPage page = (IPropertySheetPage) ViewsPlugin.getAdapter(part, >+ IPropertySheetPage.class); > if (page != null) { > if (page instanceof IPageBookViewPage) { > initPage((IPageBookViewPage) page); >@@ -180,8 +174,8 @@ > * adapter and if so, asks it for its contributing part. > */ > public void partActivated(IWorkbenchPart part) { >- IContributedContentsView view = (IContributedContentsView) part >- .getAdapter(IContributedContentsView.class); >+ IContributedContentsView view = (IContributedContentsView) ViewsPlugin.getAdapter(part, >+ IContributedContentsView.class); > IWorkbenchPart source = null; > if (view != null) { > source = view.getContributingPart(); >Index: src/org/eclipse/ui/views/contentoutline/ContentOutline.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.views/src/org/eclipse/ui/views/contentoutline/ContentOutline.java,v >retrieving revision 1.13 >diff -u -r1.13 ContentOutline.java >--- src/org/eclipse/ui/views/contentoutline/ContentOutline.java 8 May 2006 20:53:18 -0000 1.13 >+++ src/org/eclipse/ui/views/contentoutline/ContentOutline.java 7 Sep 2006 23:51:44 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.views.ViewsPlugin; > import org.eclipse.ui.internal.views.contentoutline.ContentOutlineMessages; > import org.eclipse.ui.part.IContributedContentsView; > import org.eclipse.ui.part.IPage; >@@ -125,7 +126,7 @@ > */ > protected PageRec doCreatePage(IWorkbenchPart part) { > // Try to get an outline page. >- Object obj = part.getAdapter(IContentOutlinePage.class); >+ Object obj = ViewsPlugin.getAdapter(part, IContentOutlinePage.class); > if (obj instanceof IContentOutlinePage) { > IContentOutlinePage page = (IContentOutlinePage) obj; > if (page instanceof IPageBookViewPage) {
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 156581
:
49647
|
49674
|
49675
|
49961
|
49970
|
49972