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 49647 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]
Fixes all adapter usage in the org.eclipse.ui.workbench plugin
156581_ui_workbench_patch.txt (text/plain), 71.90 KB, created by
Stefan Xenos
on 2006-09-07 14:56:16 EDT
(
hide
)
Description:
Fixes all adapter usage in the org.eclipse.ui.workbench plugin
Filename:
MIME Type:
Creator:
Stefan Xenos
Created:
2006-09-07 14:56:16 EDT
Size:
71.90 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/WorkingSet.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkingSet.java,v >retrieving revision 1.26 >diff -u -r1.26 WorkingSet.java >--- Eclipse UI/org/eclipse/ui/internal/WorkingSet.java 6 Sep 2006 14:16:42 -0000 1.26 >+++ Eclipse UI/org/eclipse/ui/internal/WorkingSet.java 7 Sep 2006 18:54:00 -0000 >@@ -197,8 +197,8 @@ > Iterator iterator = elements.iterator(); > while (iterator.hasNext()) { > IAdaptable adaptable = (IAdaptable) iterator.next(); >- IPersistableElement persistable = (IPersistableElement) adaptable >- .getAdapter(IPersistableElement.class); >+ IPersistableElement persistable = (IPersistableElement) Util.getAdapter(adaptable, >+ IPersistableElement.class); > if (persistable != null) { > IMemento itemMemento = memento > .createChild(IWorkbenchConstants.TAG_ITEM); >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java,v >retrieving revision 1.351 >diff -u -r1.351 WorkbenchWindow.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java 5 Sep 2006 19:58:32 -0000 1.351 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java 7 Sep 2006 18:54:00 -0000 >@@ -133,6 +133,7 @@ > import org.eclipse.ui.internal.services.ISourceProviderService; > import org.eclipse.ui.internal.services.ServiceLocator; > import org.eclipse.ui.internal.util.PrefUtil; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.presentations.AbstractPresentationFactory; > > /** >@@ -524,8 +525,8 @@ > * </p> > */ > void submitGlobalActions() { >- final IHandlerService handlerService = (IHandlerService) PlatformUI >- .getWorkbench().getAdapter(IHandlerService.class); >+ final IHandlerService handlerService = (IHandlerService) Util.getAdapter(PlatformUI >+ .getWorkbench(), IHandlerService.class); > > /* > * Mash the action sets and global actions together, with global actions >@@ -850,8 +851,8 @@ > IWorkbenchHelpContextIds.WORKBENCH_WINDOW); > > // initializeDefaultServices(); >- final IContextService contextService = (IContextService) workbench >- .getAdapter(IContextService.class); >+ final IContextService contextService = (IContextService) Util.getAdapter( >+ workbench, IContextService.class); > contextService.registerShell(shell, IContextService.TYPE_WINDOW); > > trackShellActivation(shell); >@@ -1466,8 +1467,8 @@ > > // Remove the handler submissions. Bug 64024. > final IWorkbench workbench = getWorkbench(); >- final IHandlerService handlerService = (IHandlerService) workbench >- .getAdapter(IHandlerService.class); >+ final IHandlerService handlerService = (IHandlerService) Util.getAdapter(workbench, >+ IHandlerService.class); > handlerService.deactivateHandlers(handlerActivations); > final Iterator activationItr = handlerActivations.iterator(); > while (activationItr.hasNext()) { >@@ -1479,8 +1480,8 @@ > globalActionHandlersByCommandId.clear(); > > // Remove the enabled submissions. Bug 64024. >- final IContextService contextService = (IContextService) workbench >- .getAdapter(IContextService.class); >+ final IContextService contextService = (IContextService) Util.getAdapter(workbench, >+ IContextService.class); > contextService.unregisterShell(getShell()); > > closeAllPages(); >@@ -2446,8 +2447,8 @@ > // Get the input. > IAdaptable input = page.getInput(); > if (input != null) { >- IPersistableElement persistable = (IPersistableElement) input >- .getAdapter(IPersistableElement.class); >+ IPersistableElement persistable = (IPersistableElement) Util.getAdapter(input, >+ IPersistableElement.class); > if (persistable == null) { > WorkbenchPlugin > .log("Unable to save page input: " //$NON-NLS-1$ >Index: Eclipse UI/org/eclipse/ui/internal/EditorManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorManager.java,v >retrieving revision 1.111 >diff -u -r1.111 EditorManager.java >--- Eclipse UI/org/eclipse/ui/internal/EditorManager.java 2 Aug 2006 11:15:49 -0000 1.111 >+++ Eclipse UI/org/eclipse/ui/internal/EditorManager.java 7 Sep 2006 18:54:00 -0000 >@@ -169,8 +169,8 @@ > } > if (pinEditorHandlerActivation != null) { > // remove pin editor keyboard shortcut handler >- final IHandlerService handlerService = (IHandlerService) window >- .getWorkbench().getAdapter(IHandlerService.class); >+ final IHandlerService handlerService = (IHandlerService) Util.getAdapter(window >+ .getWorkbench(), IHandlerService.class); > handlerService.deactivateHandler(pinEditorHandlerActivation); > pinEditorHandlerActivation = null; > } >@@ -230,8 +230,8 @@ > }; > > // Assign the handler for the pin editor keyboard shortcut. >- final IHandlerService handlerService = (IHandlerService) window >- .getWorkbench().getAdapter(IHandlerService.class); >+ final IHandlerService handlerService = (IHandlerService) Util.getAdapter(window >+ .getWorkbench(), IHandlerService.class); > pinEditorHandlerActivation = handlerService.activateHandler( > "org.eclipse.ui.window.pinEditor", pinEditorHandler, //$NON-NLS-1$ > new ActiveShellExpression(shell)); >@@ -1451,7 +1451,7 @@ > return (IPathEditorInput) input; > } > >- return (IPathEditorInput) input.getAdapter(IPathEditorInput.class); >+ return (IPathEditorInput) Util.getAdapter(input, IPathEditorInput.class); > } > > private class InnerEditor extends EditorReference { >Index: Eclipse UI/org/eclipse/ui/internal/SelectionConversionService.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/SelectionConversionService.java,v >retrieving revision 1.3 >diff -u -r1.3 SelectionConversionService.java >--- Eclipse UI/org/eclipse/ui/internal/SelectionConversionService.java 24 Feb 2006 18:36:12 -0000 1.3 >+++ Eclipse UI/org/eclipse/ui/internal/SelectionConversionService.java 7 Sep 2006 18:54:00 -0000 >@@ -15,9 +15,9 @@ > import java.util.Iterator; > import java.util.List; > >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.ui.internal.util.Util; > > /** > * <p> >@@ -58,17 +58,10 @@ > > while (elements.hasNext()) { > Object currentElement = elements.next(); >- if (resourceClass.isInstance(currentElement)) { // already a >- // resource >- result.add(currentElement); >- } else if (currentElement instanceof IAdaptable) { >- Object adapter = ((IAdaptable) currentElement) >- .getAdapter(resourceClass); >- if (resourceClass.isInstance(adapter)) { >- result.add(adapter); // add the converted resource >- } >- >- } >+ Object resource = Util.getAdapter(currentElement, resourceClass); >+ if (resource != null) { >+ result.add(resource); >+ } > } > > // all that can be converted are done, answer new selection >Index: Eclipse UI/org/eclipse/ui/internal/ActionExpression.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ActionExpression.java,v >retrieving revision 1.24 >diff -u -r1.24 ActionExpression.java >--- Eclipse UI/org/eclipse/ui/internal/ActionExpression.java 8 May 2006 20:55:38 -0000 1.24 >+++ Eclipse UI/org/eclipse/ui/internal/ActionExpression.java 7 Sep 2006 18:54:00 -0000 >@@ -16,7 +16,6 @@ > import java.util.Iterator; > import java.util.List; > >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.viewers.IStructuredSelection; >@@ -471,14 +470,7 @@ > } > > private IActionFilter getActionFilter(Object object) { >- IActionFilter filter = null; >- if (object instanceof IActionFilter) { >- filter = (IActionFilter) object; >- } else if (object instanceof IAdaptable) { >- filter = (IActionFilter) ((IAdaptable) object) >- .getAdapter(IActionFilter.class); >- } >- return filter; >+ return (IActionFilter)Util.getAdapter(object, IActionFilter.class); > } > > /** >@@ -520,10 +512,7 @@ > return false; > } > >- Object res = null; >- if (object instanceof IAdaptable) { >- res = ((IAdaptable) object).getAdapter(resourceClass); >- } >+ Object res = Util.getAdapter(object, resourceClass); > if (res == null) { > return false; > } >Index: Eclipse UI/org/eclipse/ui/internal/ShowInMenu.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ShowInMenu.java,v >retrieving revision 1.11 >diff -u -r1.11 ShowInMenu.java >--- Eclipse UI/org/eclipse/ui/internal/ShowInMenu.java 8 May 2006 20:55:37 -0000 1.11 >+++ Eclipse UI/org/eclipse/ui/internal/ShowInMenu.java 7 Sep 2006 18:54:00 -0000 >@@ -31,6 +31,7 @@ > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.part.IShowInSource; > import org.eclipse.ui.part.IShowInTargetList; > import org.eclipse.ui.part.ShowInContext; >@@ -208,14 +209,7 @@ > * @return an <code>IShowInSource</code> or <code>null</code> > */ > private IShowInSource getShowInSource(IWorkbenchPart sourcePart) { >- if (sourcePart instanceof IShowInSource) { >- return (IShowInSource) sourcePart; >- } >- Object o = sourcePart.getAdapter(IShowInSource.class); >- if (o instanceof IShowInSource) { >- return (IShowInSource) o; >- } >- return null; >+ return (IShowInSource)Util.getAdapter(sourcePart, IShowInSource.class); > } > > /** >@@ -226,14 +220,7 @@ > * @return the <code>IShowInTargetList</code> or <code>null</code> > */ > private IShowInTargetList getShowInTargetList(IWorkbenchPart sourcePart) { >- if (sourcePart instanceof IShowInTargetList) { >- return (IShowInTargetList) sourcePart; >- } >- Object o = sourcePart.getAdapter(IShowInTargetList.class); >- if (o instanceof IShowInTargetList) { >- return (IShowInTargetList) o; >- } >- return null; >+ return (IShowInTargetList)Util.getAdapter(sourcePart, IShowInTargetList.class); > } > > /** >Index: Eclipse UI/org/eclipse/ui/internal/ShowInAction.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ShowInAction.java,v >retrieving revision 1.9 >diff -u -r1.9 ShowInAction.java >--- Eclipse UI/org/eclipse/ui/internal/ShowInAction.java 6 Jun 2006 19:52:08 -0000 1.9 >+++ Eclipse UI/org/eclipse/ui/internal/ShowInAction.java 7 Sep 2006 18:54:00 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.part.IShowInSource; > import org.eclipse.ui.part.IShowInTarget; > import org.eclipse.ui.part.ShowInContext; >@@ -90,14 +91,7 @@ > * @return an <code>IShowInSource</code> or <code>null</code> > */ > private IShowInSource getShowInSource(IWorkbenchPart sourcePart) { >- if (sourcePart instanceof IShowInSource) { >- return (IShowInSource) sourcePart; >- } >- Object o = sourcePart.getAdapter(IShowInSource.class); >- if (o instanceof IShowInSource) { >- return (IShowInSource) o; >- } >- return null; >+ return (IShowInSource)Util.getAdapter(sourcePart, IShowInSource.class); > } > > /** >@@ -108,14 +102,7 @@ > * @return the <code>IShowInTarget</code> or <code>null</code> > */ > private IShowInTarget getShowInTarget(IWorkbenchPart targetPart) { >- if (targetPart instanceof IShowInTarget) { >- return (IShowInTarget) targetPart; >- } >- Object o = targetPart.getAdapter(IShowInTarget.class); >- if (o instanceof IShowInTarget) { >- return (IShowInTarget) o; >- } >- return null; >+ return (IShowInTarget)Util.getAdapter(targetPart, IShowInTarget.class); > } > > /** >Index: Eclipse UI/org/eclipse/ui/internal/CyclePartAction.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CyclePartAction.java,v >retrieving revision 1.69 >diff -u -r1.69 CyclePartAction.java >--- Eclipse UI/org/eclipse/ui/internal/CyclePartAction.java 5 Sep 2006 16:48:42 -0000 1.69 >+++ Eclipse UI/org/eclipse/ui/internal/CyclePartAction.java 7 Sep 2006 18:54:00 -0000 >@@ -45,6 +45,7 @@ > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.commands.ICommandService; > import org.eclipse.ui.contexts.IContextService; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.keys.IBindingService; > > /** >@@ -441,15 +442,15 @@ > * will not change while the dialog is open, but the context will. Bug > * 55581. > */ >- final IBindingService bindingService = (IBindingService) PlatformUI >- .getWorkbench().getAdapter(IBindingService.class); >+ final IBindingService bindingService = (IBindingService) Util.getAdapter(PlatformUI >+ .getWorkbench(), IBindingService.class); > forwardTriggerSequences = bindingService > .getActiveBindingsFor(commandForward); > backwardTriggerSequences = bindingService > .getActiveBindingsFor(commandBackward); > >- final IContextService contextService = (IContextService) page >- .getWorkbenchWindow().getWorkbench().getAdapter( >+ final IContextService contextService = (IContextService) Util.getAdapter(page >+ .getWorkbenchWindow().getWorkbench(), > IContextService.class); > try { > dialog.open(); >@@ -526,8 +527,8 @@ > * the action > */ > public void setBackwardActionDefinitionId(String actionDefinitionId) { >- final ICommandService commandService = (ICommandService) getWorkbenchWindow() >- .getWorkbench().getAdapter(ICommandService.class); >+ final ICommandService commandService = (ICommandService) Util.getAdapter(getWorkbenchWindow() >+ .getWorkbench(), ICommandService.class); > final Command command = commandService.getCommand(actionDefinitionId); > commandBackward = new ParameterizedCommand(command, null); > } >@@ -539,8 +540,8 @@ > * the action > */ > public void setForwardActionDefinitionId(String actionDefinitionId) { >- final ICommandService commandService = (ICommandService) getWorkbenchWindow() >- .getWorkbench().getAdapter(ICommandService.class); >+ final ICommandService commandService = (ICommandService) Util.getAdapter(getWorkbenchWindow() >+ .getWorkbench(), ICommandService.class); > final Command command = commandService.getCommand(actionDefinitionId); > commandForward = new ParameterizedCommand(command, null); > } >Index: Eclipse UI/org/eclipse/ui/internal/BaseSaveAction.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BaseSaveAction.java,v >retrieving revision 1.12 >diff -u -r1.12 BaseSaveAction.java >--- Eclipse UI/org/eclipse/ui/internal/BaseSaveAction.java 1 Aug 2006 22:11:08 -0000 1.12 >+++ Eclipse UI/org/eclipse/ui/internal/BaseSaveAction.java 7 Sep 2006 18:54:00 -0000 >@@ -22,6 +22,7 @@ > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.internal.util.Util; > > /** > * The abstract superclass for save actions that depend on the active editor. >@@ -214,10 +215,8 @@ > if (activeView == null) { > return null; > } >- if (activeView instanceof ISaveablePart) { >- return (ISaveablePart) activeView; >- } >- return (ISaveablePart) activeView.getAdapter(ISaveablePart.class); >+ >+ return (ISaveablePart) Util.getAdapter(activeView, ISaveablePart.class); > } > > /* (non-Javadoc) >Index: Eclipse UI/org/eclipse/ui/internal/ObjectActionContributor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ObjectActionContributor.java,v >retrieving revision 1.21 >diff -u -r1.21 ObjectActionContributor.java >--- Eclipse UI/org/eclipse/ui/internal/ObjectActionContributor.java 8 May 2006 20:55:36 -0000 1.21 >+++ Eclipse UI/org/eclipse/ui/internal/ObjectActionContributor.java 7 Sep 2006 18:54:00 -0000 >@@ -28,6 +28,7 @@ > import org.eclipse.ui.SelectionEnabler; > import org.eclipse.ui.internal.misc.Policy; > import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.model.IWorkbenchAdapter; > > /** >@@ -273,14 +274,10 @@ > return true; > } > String objectName = null; >- if (object instanceof IAdaptable) { >- IAdaptable element = (IAdaptable) object; >- IWorkbenchAdapter de = (IWorkbenchAdapter) element >- .getAdapter(IWorkbenchAdapter.class); >- if (de != null) { >- objectName = de.getLabel(element); >- } >- } >+ IWorkbenchAdapter de = (IWorkbenchAdapter)Util.getAdapter(object, IWorkbenchAdapter.class); >+ if (de != null) { >+ objectName = de.getLabel(object); >+ } > if (objectName == null) { > objectName = object.toString(); > } >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java,v >retrieving revision 1.271 >diff -u -r1.271 WorkbenchPage.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 16 Aug 2006 20:36:34 -0000 1.271 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java 7 Sep 2006 18:54:00 -0000 >@@ -1938,13 +1938,11 @@ > */ > public String getLabel() { > String label = WorkbenchMessages.WorkbenchPage_UnknownLabel; >- if (input != null) { >- IWorkbenchAdapter adapter = (IWorkbenchAdapter) input >- .getAdapter(IWorkbenchAdapter.class); >- if (adapter != null) { >- label = adapter.getLabel(input); >- } >- } >+ IWorkbenchAdapter adapter = (IWorkbenchAdapter) Util.getAdapter(input, >+ IWorkbenchAdapter.class); >+ if (adapter != null) { >+ label = adapter.getLabel(input); >+ } > Perspective persp = getActivePerspective(); > if (persp != null) { > label = NLS.bind(WorkbenchMessages.WorkbenchPage_PerspectiveFormat, label, persp.getDesc().getLabel()); >Index: Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java,v >retrieving revision 1.43 >diff -u -r1.43 DetachedWindow.java >--- Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java 8 May 2006 20:55:38 -0000 1.43 >+++ Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java 7 Sep 2006 18:54:00 -0000 >@@ -43,6 +43,7 @@ > import org.eclipse.ui.internal.presentations.util.AbstractTabFolder; > import org.eclipse.ui.internal.presentations.util.AbstractTabItem; > import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.presentations.StackDropResult; > > >@@ -242,8 +243,8 @@ > bounds = windowShell.getBounds(); > > // Unregister this detached view as a window (for key bindings). >- final IContextService contextService = (IContextService) getWorkbenchPage() >- .getWorkbenchWindow().getWorkbench().getAdapter( >+ final IContextService contextService = (IContextService) Util.getAdapter(getWorkbenchPage() >+ .getWorkbenchWindow().getWorkbench(), > IContextService.class); > contextService.unregisterShell(windowShell); > >@@ -308,8 +309,8 @@ > shell.addListener(SWT.Resize, resizeListener); > > // Register this detached view as a window (for key bindings). >- final IContextService contextService = (IContextService) getWorkbenchPage() >- .getWorkbenchWindow().getWorkbench().getAdapter( >+ final IContextService contextService = (IContextService) Util.getAdapter(getWorkbenchPage() >+ .getWorkbenchWindow().getWorkbench(), > IContextService.class); > contextService.registerShell(shell, > IContextService.TYPE_WINDOW); >Index: Eclipse UI/org/eclipse/ui/internal/ObjectContributorManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ObjectContributorManager.java,v >retrieving revision 1.24 >diff -u -r1.24 ObjectContributorManager.java >--- Eclipse UI/org/eclipse/ui/internal/ObjectContributorManager.java 8 May 2006 20:55:35 -0000 1.24 >+++ Eclipse UI/org/eclipse/ui/internal/ObjectContributorManager.java 7 Sep 2006 18:54:00 -0000 >@@ -31,6 +31,7 @@ > import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.util.Util; > > /** > * This class is a default implementation of <code>IObjectContributorManager</code>. >@@ -312,14 +313,12 @@ > } > contributorList.add(contributor); > flushLookup(); >+ >+ IConfigurationElement element = (IConfigurationElement) Util.getAdapter(contributor, >+ IConfigurationElement.class); > > //hook the object listener >- if (contributor instanceof IAdaptable) { >- IConfigurationElement element = (IConfigurationElement) ((IAdaptable) contributor) >- .getAdapter(IConfigurationElement.class); >- if (element == null) { >- return; >- } >+ if (element != null) { > ContributorRecord contributorRecord = new ContributorRecord( > contributor, targetType); > contributorRecordSet.add(contributorRecord); >Index: Eclipse UI/org/eclipse/ui/internal/ViewReference.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewReference.java,v >retrieving revision 1.12 >diff -u -r1.12 ViewReference.java >--- Eclipse UI/org/eclipse/ui/internal/ViewReference.java 8 May 2006 20:55:36 -0000 1.12 >+++ Eclipse UI/org/eclipse/ui/internal/ViewReference.java 7 Sep 2006 18:54:00 -0000 >@@ -373,8 +373,8 @@ > > result = view; > >- IConfigurationElement element = (IConfigurationElement) desc >- .getAdapter(IConfigurationElement.class); >+ IConfigurationElement element = (IConfigurationElement) Util.getAdapter(desc, >+ IConfigurationElement.class); > if (element != null) { > factory.page.getExtensionTracker().registerObject( > element.getDeclaringExtension(), view, >Index: Eclipse UI/org/eclipse/ui/internal/ViewSite.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewSite.java,v >retrieving revision 1.15 >diff -u -r1.15 ViewSite.java >--- Eclipse UI/org/eclipse/ui/internal/ViewSite.java 8 May 2006 20:55:34 -0000 1.15 >+++ Eclipse UI/org/eclipse/ui/internal/ViewSite.java 7 Sep 2006 18:54:00 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.ui.IViewPart; > import org.eclipse.ui.IViewReference; > import org.eclipse.ui.IViewSite; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.views.IViewDescriptor; > > /** >@@ -37,8 +38,7 @@ > public ViewSite(IViewReference ref, IViewPart view, WorkbenchPage page, > IViewDescriptor desc) { > super(ref, view, page); >- setConfigurationElement((IConfigurationElement) desc >- .getAdapter(IConfigurationElement.class)); >+ setConfigurationElement((IConfigurationElement) Util.getAdapter(desc, IConfigurationElement.class)); > } > > /** >Index: Eclipse UI/org/eclipse/ui/internal/ObjectFilterTest.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ObjectFilterTest.java,v >retrieving revision 1.10 >diff -u -r1.10 ObjectFilterTest.java >--- Eclipse UI/org/eclipse/ui/internal/ObjectFilterTest.java 8 May 2006 20:55:35 -0000 1.10 >+++ Eclipse UI/org/eclipse/ui/internal/ObjectFilterTest.java 7 Sep 2006 18:54:00 -0000 >@@ -13,9 +13,9 @@ > import java.util.HashMap; > import java.util.Iterator; > >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.ui.IActionFilter; >+import org.eclipse.ui.internal.util.Util; > > /** > * An ObjectFilterTest is used to read an object filter from XML, >@@ -85,13 +85,7 @@ > */ > private boolean preciselyMatches(Object object) { > // Get the action filter. >- IActionFilter filter = null; >- if (object instanceof IActionFilter) { >- filter = (IActionFilter) object; >- } else if (object instanceof IAdaptable) { >- filter = (IActionFilter) ((IAdaptable) object) >- .getAdapter(IActionFilter.class); >- } >+ IActionFilter filter = (IActionFilter)Util.getAdapter(object, IActionFilter.class); > if (filter == null) { > return false; > } >Index: Eclipse UI/org/eclipse/ui/internal/actions/NewWizardShortcutAction.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/actions/NewWizardShortcutAction.java,v >retrieving revision 1.13 >diff -u -r1.13 NewWizardShortcutAction.java >--- Eclipse UI/org/eclipse/ui/internal/actions/NewWizardShortcutAction.java 29 Jun 2006 17:58:05 -0000 1.13 >+++ Eclipse UI/org/eclipse/ui/internal/actions/NewWizardShortcutAction.java 7 Sep 2006 18:54:00 -0000 >@@ -29,6 +29,7 @@ > import org.eclipse.ui.internal.IWorkbenchHelpContextIds; > import org.eclipse.ui.internal.LegacyResourceSupport; > import org.eclipse.ui.internal.WorkbenchMessages; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.wizards.IWizardDescriptor; > > /** >@@ -95,7 +96,7 @@ > IEditorInput input = ((IEditorPart) part).getEditorInput(); > Class fileClass = LegacyResourceSupport.getFileClass(); > if (input != null && fileClass != null) { >- Object file = input.getAdapter(fileClass); >+ Object file = Util.getAdapter(input, fileClass); > if (file != null) { > selectionToPass = new StructuredSelection(file); > } >@@ -155,7 +156,7 @@ > * @since 3.1 > */ > private IPluginContribution getPluginContribution() { >- return (IPluginContribution) wizardElement >- .getAdapter(IPluginContribution.class); >+ return (IPluginContribution) Util.getAdapter(wizardElement, >+ IPluginContribution.class); > } > } >Index: Eclipse UI/org/eclipse/ui/internal/operations/AdvancedValidationUserApprover.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/operations/AdvancedValidationUserApprover.java,v >retrieving revision 1.11 >diff -u -r1.11 AdvancedValidationUserApprover.java >--- Eclipse UI/org/eclipse/ui/internal/operations/AdvancedValidationUserApprover.java 6 Sep 2006 19:38:24 -0000 1.11 >+++ Eclipse UI/org/eclipse/ui/internal/operations/AdvancedValidationUserApprover.java 7 Sep 2006 18:54:00 -0000 >@@ -37,6 +37,7 @@ > import org.eclipse.ui.internal.WorkbenchMessages; > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.misc.StatusUtil; >+import org.eclipse.ui.internal.util.Util; > > /** > * <p> >@@ -387,7 +388,7 @@ > */ > Shell getShell(IAdaptable uiInfo) { > if (uiInfo != null) { >- Shell shell = (Shell) uiInfo.getAdapter(Shell.class); >+ Shell shell = (Shell) Util.getAdapter(uiInfo, Shell.class); > if (shell != null) { > return shell; > } >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchWizardNode.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchWizardNode.java,v >retrieving revision 1.15 >diff -u -r1.15 WorkbenchWizardNode.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchWizardNode.java 26 Jun 2006 14:50:19 -0000 1.15 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchWizardNode.java 7 Sep 2006 18:54:00 -0000 >@@ -26,6 +26,7 @@ > import org.eclipse.ui.IWorkbenchWizard; > import org.eclipse.ui.internal.WorkbenchMessages; > import org.eclipse.ui.internal.WorkbenchPlugin; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.wizards.IWizardDescriptor; > > /** >@@ -95,8 +96,8 @@ > * @see org.eclipse.ui.IPluginContribution#getLocalId() > */ > public String getLocalId() { >- IPluginContribution contribution = (IPluginContribution) wizardElement >- .getAdapter(IPluginContribution.class); >+ IPluginContribution contribution = (IPluginContribution) Util.getAdapter(wizardElement, >+ IPluginContribution.class); > if (contribution != null) { > return contribution.getLocalId(); > } >@@ -107,8 +108,8 @@ > * @see org.eclipse.ui.IPluginContribution#getPluginId() > */ > public String getPluginId() { >- IPluginContribution contribution = (IPluginContribution) wizardElement >- .getAdapter(IPluginContribution.class); >+ IPluginContribution contribution = (IPluginContribution) Util.getAdapter(wizardElement, >+ IPluginContribution.class); > if (contribution != null) { > return contribution.getLocalId(); > } >@@ -134,7 +135,7 @@ > * Add the exception details to status is one happens. > */ > public void handleException(Throwable e) { >- IPluginContribution contribution = (IPluginContribution) wizardElement.getAdapter(IPluginContribution.class); >+ IPluginContribution contribution = (IPluginContribution) Util.getAdapter(wizardElement, IPluginContribution.class); > statuses[0] = new Status( > IStatus.ERROR, > contribution != null ? contribution.getPluginId() : WorkbenchPlugin.PI_WORKBENCH, >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java,v >retrieving revision 1.26 >diff -u -r1.26 RegistryPageContributor.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java 8 May 2006 20:55:45 -0000 1.26 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java 7 Sep 2006 18:54:00 -0000 >@@ -35,6 +35,7 @@ > import org.eclipse.ui.internal.registry.CategorizedPageRegistryReader; > import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; > import org.eclipse.ui.internal.registry.PropertyPagesRegistryReader; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.model.IWorkbenchAdapter; > import org.eclipse.ui.plugin.AbstractUIPlugin; > >@@ -212,14 +213,12 @@ > .getAttribute(PropertyPagesRegistryReader.ATT_NAME_FILTER); > if (nameFilter != null) { > String objectName = object.toString(); >- if (object instanceof IAdaptable) { >- IWorkbenchAdapter adapter = (IWorkbenchAdapter) ((IAdaptable) object) >- .getAdapter(IWorkbenchAdapter.class); >- if (adapter != null) { >- String elementName = adapter.getLabel(object); >- if (elementName != null) { >- objectName = elementName; >- } >+ IWorkbenchAdapter adapter = (IWorkbenchAdapter) Util.getAdapter(object, >+ IWorkbenchAdapter.class); >+ if (adapter != null) { >+ String elementName = adapter.getLabel(object); >+ if (elementName != null) { >+ objectName = elementName; > } > } > if (!SelectionEnabler.verifyNameMatch(objectName, nameFilter)) >@@ -237,12 +236,7 @@ > object = adaptedObject; > } > >- if (object instanceof IActionFilter) { >- filter = (IActionFilter) object; >- } else if (object instanceof IAdaptable) { >- filter = (IActionFilter) ((IAdaptable) object) >- .getAdapter(IActionFilter.class); >- } >+ filter = (IActionFilter)Util.getAdapter(object, IActionFilter.class); > > if (filter != null) > return testCustom(object, filter); >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/AdaptableForwarder.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/AdaptableForwarder.java,v >retrieving revision 1.2 >diff -u -r1.2 AdaptableForwarder.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/AdaptableForwarder.java 4 Apr 2006 18:12:56 -0000 1.2 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/AdaptableForwarder.java 7 Sep 2006 18:54:00 -0000 >@@ -11,6 +11,7 @@ > package org.eclipse.ui.internal.dialogs; > > import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.ui.internal.util.Util; > > /** > * Class that wraps an object and forwards adapter calls if possible, otherwise >@@ -35,12 +36,6 @@ > * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) > */ > public Object getAdapter(Class adapter) { >- if(adapter.isInstance(element)) { >- return element; >- } >- if(element instanceof IAdaptable) { >- return ((IAdaptable)element).getAdapter(adapter); >- } >- return null; >+ return Util.getAdapter(element, adapter); > } > } >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/PreferencePageHistory.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PreferencePageHistory.java,v >retrieving revision 1.16 >diff -u -r1.16 PreferencePageHistory.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/PreferencePageHistory.java 8 May 2006 20:55:45 -0000 1.16 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/PreferencePageHistory.java 7 Sep 2006 18:54:00 -0000 >@@ -37,6 +37,7 @@ > import org.eclipse.ui.handlers.IHandlerService; > import org.eclipse.ui.internal.WorkbenchMessages; > import org.eclipse.ui.internal.WorkbenchPlugin; >+import org.eclipse.ui.internal.util.Util; > > /** > * History for navigating preference pages. >@@ -296,8 +297,8 @@ > */ > private void registerKeybindings(IAction action) { > final IHandler handler = new ActionHandler(action); >- final IHandlerService handlerService = (IHandlerService) PlatformUI >- .getWorkbench().getAdapter(IHandlerService.class); >+ final IHandlerService handlerService = (IHandlerService) Util.getAdapter(PlatformUI >+ .getWorkbench(), IHandlerService.class); > final IHandlerActivation activation = handlerService.activateHandler( > action.getActionDefinitionId(), handler, > new ActiveShellExpression(dialog.getShell())); >@@ -309,8 +310,8 @@ > * > */ > public void dispose() { >- final IHandlerService handlerService = (IHandlerService) PlatformUI >- .getWorkbench().getAdapter(IHandlerService.class); >+ final IHandlerService handlerService = (IHandlerService) Util.getAdapter(PlatformUI >+ .getWorkbench(), IHandlerService.class); > final Iterator iterator = activations.iterator(); > while (iterator.hasNext()) { > handlerService.deactivateHandler((IHandlerActivation) iterator >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyDialog.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyDialog.java,v >retrieving revision 1.27 >diff -u -r1.27 PropertyDialog.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyDialog.java 8 May 2006 20:55:45 -0000 1.27 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyDialog.java 7 Sep 2006 18:54:00 -0000 >@@ -12,8 +12,6 @@ > > import java.util.Iterator; > >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.preference.PreferenceManager; > import org.eclipse.jface.viewers.ISelection; >@@ -23,6 +21,7 @@ > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.internal.IWorkbenchHelpContextIds; > import org.eclipse.ui.internal.WorkbenchMessages; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.model.IWorkbenchAdapter; > > /** >@@ -98,14 +97,7 @@ > * @return the name of the element > */ > private static String getName(Object element) { >- IWorkbenchAdapter adapter = null; >- if (element instanceof IAdaptable) { >- adapter = (IWorkbenchAdapter) ((IAdaptable) element) >- .getAdapter(IWorkbenchAdapter.class); >- } else { >- adapter = (IWorkbenchAdapter) Platform.getAdapterManager() >- .getAdapter(element, IWorkbenchAdapter.class); >- } >+ IWorkbenchAdapter adapter = (IWorkbenchAdapter)Util.getAdapter(element, IWorkbenchAdapter.class); > if (adapter != null) { > return adapter.getLabel(element); > } >Index: Eclipse UI/org/eclipse/ui/SelectionEnabler.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/SelectionEnabler.java,v >retrieving revision 1.15 >diff -u -r1.15 SelectionEnabler.java >--- Eclipse UI/org/eclipse/ui/SelectionEnabler.java 8 May 2006 20:55:32 -0000 1.15 >+++ Eclipse UI/org/eclipse/ui/SelectionEnabler.java 7 Sep 2006 18:54:00 -0000 >@@ -487,8 +487,7 @@ > if (sc.nameFilter == null) { > return true; > } >- IWorkbenchAdapter de = (IWorkbenchAdapter) element >- .getAdapter(IWorkbenchAdapter.class); >+ IWorkbenchAdapter de = (IWorkbenchAdapter) Util.getAdapter(element, IWorkbenchAdapter.class); > if ((de != null) > && verifyNameMatch(de.getLabel(element), sc.nameFilter)) { > return true; >Index: Eclipse UI/org/eclipse/ui/internal/handlers/ShowKeyAssistHandler.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ShowKeyAssistHandler.java,v >retrieving revision 1.3 >diff -u -r1.3 ShowKeyAssistHandler.java >--- Eclipse UI/org/eclipse/ui/internal/handlers/ShowKeyAssistHandler.java 15 Jun 2005 18:41:21 -0000 1.3 >+++ Eclipse UI/org/eclipse/ui/internal/handlers/ShowKeyAssistHandler.java 7 Sep 2006 18:54:00 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.core.commands.ExecutionEvent; > import org.eclipse.ui.IWorkbench; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.keys.IBindingService; > > /** >@@ -33,8 +34,8 @@ > */ > public Object execute(final ExecutionEvent event) { > final IWorkbench workbench = PlatformUI.getWorkbench(); >- final IBindingService bindingService = (IBindingService) workbench >- .getAdapter(IBindingService.class); >+ final IBindingService bindingService = (IBindingService) Util.getAdapter(workbench, >+ IBindingService.class); > bindingService.openKeyAssistDialog(); > return null; > } >Index: Eclipse UI/org/eclipse/ui/actions/BaseNewWizardMenu.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/actions/BaseNewWizardMenu.java,v >retrieving revision 1.16 >diff -u -r1.16 BaseNewWizardMenu.java >--- Eclipse UI/org/eclipse/ui/actions/BaseNewWizardMenu.java 8 May 2006 20:55:38 -0000 1.16 >+++ Eclipse UI/org/eclipse/ui/actions/BaseNewWizardMenu.java 7 Sep 2006 18:54:00 -0000 >@@ -35,6 +35,7 @@ > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.WorkbenchWindow; > import org.eclipse.ui.internal.actions.NewWizardShortcutAction; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.wizards.IWizardDescriptor; > > /** >@@ -177,8 +178,8 @@ > action = new NewWizardShortcutAction(workbenchWindow, > wizardDesc); > actions.put(id, action); >- IConfigurationElement element = (IConfigurationElement) wizardDesc >- .getAdapter(IConfigurationElement.class); >+ IConfigurationElement element = (IConfigurationElement) Util >+ .getAdapter(wizardDesc, IConfigurationElement.class); > if (element != null) { > workbenchWindow.getExtensionTracker().registerObject( > element.getDeclaringExtension(), action, >Index: Eclipse UI/org/eclipse/ui/actions/NewWizardAction.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/actions/NewWizardAction.java,v >retrieving revision 1.26 >diff -u -r1.26 NewWizardAction.java >--- Eclipse UI/org/eclipse/ui/actions/NewWizardAction.java 8 May 2006 20:55:38 -0000 1.26 >+++ Eclipse UI/org/eclipse/ui/actions/NewWizardAction.java 7 Sep 2006 18:54:00 -0000 >@@ -30,6 +30,7 @@ > import org.eclipse.ui.internal.WorkbenchMessages; > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.dialogs.NewWizard; >+import org.eclipse.ui.internal.util.Util; > > /** > * Invoke the resource creation wizard selection Wizard. >@@ -151,7 +152,7 @@ > .getActivePart(); > if (part instanceof IEditorPart) { > IEditorInput input = ((IEditorPart) part).getEditorInput(); >- Object resource = input.getAdapter(resourceClass); >+ Object resource = Util.getAdapter(input, resourceClass); > if (resource != null) { > selectionToPass = new StructuredSelection(resource); > } >Index: Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistry.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistry.java,v >retrieving revision 1.39 >diff -u -r1.39 ViewRegistry.java >--- Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistry.java 8 May 2006 20:55:49 -0000 1.39 >+++ Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistry.java 7 Sep 2006 18:54:00 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.registry; > >-import com.ibm.icu.text.MessageFormat; > import java.util.ArrayList; > import java.util.Comparator; > import java.util.Iterator; >@@ -30,11 +29,14 @@ > import org.eclipse.ui.IPluginContribution; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.internal.WorkbenchPlugin; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.views.IStickyViewDescriptor; > import org.eclipse.ui.views.IViewCategory; > import org.eclipse.ui.views.IViewDescriptor; > import org.eclipse.ui.views.IViewRegistry; > >+import com.ibm.icu.text.MessageFormat; >+ > /** > * The central manager for view descriptors. > */ >@@ -175,7 +177,7 @@ > dirtyViewCategoryMappings = true; > // Mark categories list as dirty > categories.add(desc); >- IConfigurationElement element = (IConfigurationElement) desc.getAdapter(IConfigurationElement.class); >+ IConfigurationElement element = (IConfigurationElement) Util.getAdapter(desc, IConfigurationElement.class); > if (element == null) { > return; > } >Index: Eclipse UI/org/eclipse/ui/internal/registry/ViewDescriptor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewDescriptor.java,v >retrieving revision 1.32 >diff -u -r1.32 ViewDescriptor.java >--- Eclipse UI/org/eclipse/ui/internal/registry/ViewDescriptor.java 8 May 2006 20:55:49 -0000 1.32 >+++ Eclipse UI/org/eclipse/ui/internal/registry/ViewDescriptor.java 7 Sep 2006 18:54:00 -0000 >@@ -27,6 +27,7 @@ > import org.eclipse.ui.handlers.IHandlerActivation; > import org.eclipse.ui.handlers.IHandlerService; > import org.eclipse.ui.internal.WorkbenchPlugin; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.plugin.AbstractUIPlugin; > import org.eclipse.ui.views.IViewDescriptor; > >@@ -251,8 +252,8 @@ > public final void activateHandler() { > if (handlerActivation == null) { > final IHandler handler = new ShowViewHandler(getId()); >- final IHandlerService handlerService = (IHandlerService) PlatformUI >- .getWorkbench().getAdapter(IHandlerService.class); >+ final IHandlerService handlerService = (IHandlerService) Util.getAdapter(PlatformUI >+ .getWorkbench(), IHandlerService.class); > handlerActivation = handlerService > .activateHandler(getId(), handler); > } >@@ -267,8 +268,8 @@ > */ > public final void deactivateHandler() { > if (handlerActivation != null) { >- final IHandlerService handlerService = (IHandlerService) PlatformUI >- .getWorkbench().getAdapter(IHandlerService.class); >+ final IHandlerService handlerService = (IHandlerService) Util.getAdapter(PlatformUI >+ .getWorkbench(), IHandlerService.class); > handlerService.deactivateHandler(handlerActivation); > handlerActivation = null; > } >Index: Eclipse UI/org/eclipse/ui/internal/registry/WizardsRegistryReader.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WizardsRegistryReader.java,v >retrieving revision 1.22 >diff -u -r1.22 WizardsRegistryReader.java >--- Eclipse UI/org/eclipse/ui/internal/registry/WizardsRegistryReader.java 8 May 2006 20:55:49 -0000 1.22 >+++ Eclipse UI/org/eclipse/ui/internal/registry/WizardsRegistryReader.java 7 Sep 2006 18:54:00 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.registry; > >-import com.ibm.icu.text.Collator; > import java.util.ArrayList; > import java.util.Arrays; > import java.util.Collections; >@@ -28,6 +27,9 @@ > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.dialogs.WizardCollectionElement; > import org.eclipse.ui.internal.dialogs.WorkbenchWizardElement; >+import org.eclipse.ui.internal.util.Util; >+ >+import com.ibm.icu.text.Collator; > > /** > * Instances access the registry that is provided at creation time >@@ -268,8 +270,8 @@ > } > > if (parent != null) { >- createCollectionElement(parent, (IConfigurationElement) category >- .getAdapter(IConfigurationElement.class)); >+ createCollectionElement(parent, (IConfigurationElement) Util.getAdapter(category, >+ IConfigurationElement.class)); > } > } > >Index: Eclipse UI/org/eclipse/ui/internal/contexts/WorkbenchContextSupport.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/contexts/WorkbenchContextSupport.java,v >retrieving revision 1.4 >diff -u -r1.4 WorkbenchContextSupport.java >--- Eclipse UI/org/eclipse/ui/internal/contexts/WorkbenchContextSupport.java 1 Dec 2005 21:20:16 -0000 1.4 >+++ Eclipse UI/org/eclipse/ui/internal/contexts/WorkbenchContextSupport.java 7 Sep 2006 18:54:00 -0000 >@@ -25,6 +25,7 @@ > import org.eclipse.ui.contexts.IContextService; > import org.eclipse.ui.contexts.IWorkbenchContextSupport; > import org.eclipse.ui.internal.Workbench; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.keys.IBindingService; > > /** >@@ -80,10 +81,10 @@ > public WorkbenchContextSupport(final Workbench workbenchToSupport, > final ContextManager contextManager) { > workbench = workbenchToSupport; >- contextService = (IContextService) workbench >- .getAdapter(IContextService.class); >- bindingService = (IBindingService) workbench >- .getAdapter(IBindingService.class); >+ contextService = (IContextService) Util.getAdapter(workbench, >+ IContextService.class); >+ bindingService = (IBindingService) Util.getAdapter(workbench, >+ IBindingService.class); > contextManagerWrapper = ContextManagerFactory > .getContextManagerWrapper(contextManager); > } >Index: Eclipse UI/org/eclipse/ui/operations/NonLocalUndoUserApprover.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/operations/NonLocalUndoUserApprover.java,v >retrieving revision 1.17 >diff -u -r1.17 NonLocalUndoUserApprover.java >--- Eclipse UI/org/eclipse/ui/operations/NonLocalUndoUserApprover.java 6 Sep 2006 20:16:47 -0000 1.17 >+++ Eclipse UI/org/eclipse/ui/operations/NonLocalUndoUserApprover.java 7 Sep 2006 18:54:00 -0000 >@@ -26,6 +26,7 @@ > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.internal.Workbench; > import org.eclipse.ui.internal.WorkbenchMessages; >+import org.eclipse.ui.internal.util.Util; > > /** > * <p> >@@ -184,10 +185,9 @@ > // one last try - try to adapt the modified element if a > // preferred > // comparison class has been provided. >- if (affectedObjectsClass != null >- && modifiedElement instanceof IAdaptable) { >- if (elementsContains(((IAdaptable) modifiedElement) >- .getAdapter(affectedObjectsClass))) { >+ if (affectedObjectsClass != null) { >+ if (elementsContains((Util.getAdapter(modifiedElement, >+ affectedObjectsClass)))) { > local = true; > } > } >@@ -248,8 +248,8 @@ > // not originate > // in our context. > if (uiInfo != null) { >- IUndoContext originatingContext = (IUndoContext) uiInfo >- .getAdapter(IUndoContext.class); >+ IUndoContext originatingContext = (IUndoContext) Util.getAdapter(uiInfo, >+ IUndoContext.class); > if (originatingContext != null > && !(originatingContext.matches(context))) { > return false; >@@ -276,10 +276,8 @@ > Object element = elements[i]; > elementsAndAdapters.add(element); > if (affectedObjectsClass != null >- && !affectedObjectsClass.isInstance(element) >- && element instanceof IAdaptable) { >- Object adapter = ((IAdaptable) element) >- .getAdapter(affectedObjectsClass); >+ && !affectedObjectsClass.isInstance(element)) { >+ Object adapter = Util.getAdapter(element, affectedObjectsClass); > if (adapter != null) { > elementsAndAdapters.add(adapter); > } >Index: Eclipse UI/org/eclipse/ui/operations/OperationHistoryActionHandler.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/operations/OperationHistoryActionHandler.java,v >retrieving revision 1.36 >diff -u -r1.36 OperationHistoryActionHandler.java >--- Eclipse UI/org/eclipse/ui/operations/OperationHistoryActionHandler.java 8 May 2006 20:55:52 -0000 1.36 >+++ Eclipse UI/org/eclipse/ui/operations/OperationHistoryActionHandler.java 7 Sep 2006 18:54:00 -0000 >@@ -39,6 +39,7 @@ > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.misc.StatusUtil; > import org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.part.MultiPageEditorSite; > > /** >@@ -330,7 +331,7 @@ > // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=108144 > IWorkbenchPart part = site.getPart(); > if (part != null) { >- return part.getAdapter(adapter); >+ return Util.getAdapter(part, adapter); > } > } > return null; >Index: Eclipse UI/org/eclipse/ui/internal/util/Util.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/util/Util.java,v >retrieving revision 1.37 >diff -u -r1.37 Util.java >--- Eclipse UI/org/eclipse/ui/internal/util/Util.java 8 May 2006 20:55:52 -0000 1.37 >+++ Eclipse UI/org/eclipse/ui/internal/util/Util.java 7 Sep 2006 18:54:00 -0000 >@@ -28,6 +28,10 @@ > import java.util.TreeMap; > import java.util.TreeSet; > >+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.swt.widgets.Shell; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PlatformUI; >@@ -60,6 +64,56 @@ > > return ZERO_LENGTH_STRING; > } >+ >+ /** >+ * 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; >+ } > > public static void assertInstance(Object object, Class c) { > assertInstance(object, c, false); >Index: Eclipse UI/org/eclipse/ui/fieldassist/ContentAssistField.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/fieldassist/ContentAssistField.java,v >retrieving revision 1.9 >diff -u -r1.9 ContentAssistField.java >--- Eclipse UI/org/eclipse/ui/fieldassist/ContentAssistField.java 28 Feb 2006 16:10:54 -0000 1.9 >+++ Eclipse UI/org/eclipse/ui/fieldassist/ContentAssistField.java 7 Sep 2006 18:54:00 -0000 >@@ -22,6 +22,7 @@ > import org.eclipse.swt.widgets.Composite; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.internal.WorkbenchMessages; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.keys.IBindingService; > > /** >@@ -125,8 +126,8 @@ > } > // Always update the decoration text since the key binding may > // have changed since it was last retrieved. >- IBindingService bindingService = (IBindingService) PlatformUI >- .getWorkbench().getAdapter(IBindingService.class); >+ IBindingService bindingService = (IBindingService) Util.getAdapter(PlatformUI >+ .getWorkbench(), IBindingService.class); > dec.setDescription(NLS.bind( > WorkbenchMessages.ContentAssist_Cue_Description_Key, > bindingService.getBestActiveBindingFormattedFor(adapter >Index: Eclipse UI/org/eclipse/ui/fieldassist/ContentAssistCommandAdapter.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/fieldassist/ContentAssistCommandAdapter.java,v >retrieving revision 1.8 >diff -u -r1.8 ContentAssistCommandAdapter.java >--- Eclipse UI/org/eclipse/ui/fieldassist/ContentAssistCommandAdapter.java 15 Mar 2006 22:00:43 -0000 1.8 >+++ Eclipse UI/org/eclipse/ui/fieldassist/ContentAssistCommandAdapter.java 7 Sep 2006 18:54:00 -0000 >@@ -25,6 +25,7 @@ > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.handlers.IHandlerActivation; > import org.eclipse.ui.handlers.IHandlerService; >+import org.eclipse.ui.internal.util.Util; > > /** > * ContentAssistCommandAdapter extends {@link ContentProposalAdapter} to invoke >@@ -115,8 +116,8 @@ > addListeners(control); > > // Cache the handler service so we don't have to retrieve it each time >- this.handlerService = (IHandlerService) PlatformUI.getWorkbench() >- .getAdapter(IHandlerService.class); >+ this.handlerService = (IHandlerService) Util.getAdapter(PlatformUI.getWorkbench(), >+ IHandlerService.class); > } > > /* >Index: Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferencePage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferencePage.java,v >retrieving revision 1.12 >diff -u -r1.12 KeysPreferencePage.java >--- Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferencePage.java 21 Aug 2006 19:39:28 -0000 1.12 >+++ Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferencePage.java 7 Sep 2006 18:54:00 -0000 >@@ -1215,12 +1215,12 @@ > > public final void init(final IWorkbench workbench) { > activityManager = workbench.getActivitySupport().getActivityManager(); >- bindingService = (IBindingService) workbench >- .getAdapter(IBindingService.class); >- commandService = (ICommandService) workbench >- .getAdapter(ICommandService.class); >- contextService = (IContextService) workbench >- .getAdapter(IContextService.class); >+ bindingService = (IBindingService) Util.getAdapter(workbench, >+ IBindingService.class); >+ commandService = (ICommandService) Util.getAdapter(workbench, >+ ICommandService.class); >+ contextService = (IContextService) Util.getAdapter(workbench, >+ IContextService.class); > } > > /** >Index: Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java,v >retrieving revision 1.27 >diff -u -r1.27 NewKeysPreferencePage.java >--- Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java 8 May 2006 20:55:48 -0000 1.27 >+++ Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java 7 Sep 2006 18:54:00 -0000 >@@ -1279,14 +1279,14 @@ > * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) > */ > public final void init(final IWorkbench workbench) { >- bindingService = (IBindingService) workbench >- .getAdapter(IBindingService.class); >- commandImageService = (ICommandImageService) workbench >- .getAdapter(ICommandImageService.class); >- commandService = (ICommandService) workbench >- .getAdapter(ICommandService.class); >- contextService = (IContextService) workbench >- .getAdapter(IContextService.class); >+ bindingService = (IBindingService) Util.getAdapter(workbench, >+ IBindingService.class); >+ commandImageService = (ICommandImageService) Util.getAdapter(workbench, >+ ICommandImageService.class); >+ commandService = (ICommandService) Util.getAdapter(workbench, >+ ICommandService.class); >+ contextService = (IContextService) Util.getAdapter(workbench, >+ IContextService.class); > } > > /** >Index: Eclipse UI/org/eclipse/ui/internal/keys/WorkbenchKeyboard.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/WorkbenchKeyboard.java,v >retrieving revision 1.88 >diff -u -r1.88 WorkbenchKeyboard.java >--- Eclipse UI/org/eclipse/ui/internal/keys/WorkbenchKeyboard.java 8 May 2006 20:55:48 -0000 1.88 >+++ Eclipse UI/org/eclipse/ui/internal/keys/WorkbenchKeyboard.java 7 Sep 2006 18:54:00 -0000 >@@ -461,8 +461,8 @@ > } > > try { >- final IHandlerService handlerService = (IHandlerService) workbench >- .getAdapter(IHandlerService.class); >+ final IHandlerService handlerService = (IHandlerService) Util.getAdapter(workbench, >+ IHandlerService.class); > handlerService.executeCommand(parameterizedCommand, trigger); > } catch (final NotDefinedException e) { > // The command is not defined. Forwarded to the IExecutionListener. >@@ -589,8 +589,8 @@ > */ > private Binding getPerfectMatch(KeySequence keySequence) { > if (bindingService == null) { >- bindingService = (IBindingService) workbench >- .getAdapter(IBindingService.class); >+ bindingService = (IBindingService) Util.getAdapter(workbench, >+ IBindingService.class); > } > return bindingService.getPerfectMatch(keySequence); > } >@@ -643,8 +643,8 @@ > */ > private boolean isPartialMatch(KeySequence keySequence) { > if (bindingService == null) { >- bindingService = (IBindingService) workbench >- .getAdapter(IBindingService.class); >+ bindingService = (IBindingService) Util.getAdapter(workbench, >+ IBindingService.class); > } > return bindingService.isPartialMatch(keySequence); > } >@@ -661,8 +661,8 @@ > */ > private boolean isPerfectMatch(KeySequence keySequence) { > if (bindingService == null) { >- bindingService = (IBindingService) workbench >- .getAdapter(IBindingService.class); >+ bindingService = (IBindingService) Util.getAdapter(workbench, >+ IBindingService.class); > } > return bindingService.isPerfectMatch(keySequence); > } >@@ -764,8 +764,8 @@ > final Widget widget = event.widget; > > // Update the contexts. >- final ContextService contextService = (ContextService) workbench >- .getAdapter(IContextService.class); >+ final ContextService contextService = (ContextService) Util.getAdapter(workbench, >+ IContextService.class); > if ((widget instanceof Control) && (!widget.isDisposed())) { > final Shell shell = ((Control) widget).getShell(); > contextService.updateShellKludge(shell); >@@ -774,8 +774,8 @@ > } > > // Update the handlers. >- final HandlerService handlerService = (HandlerService) workbench >- .getAdapter(IHandlerService.class); >+ final HandlerService handlerService = (HandlerService) Util.getAdapter(workbench, >+ IHandlerService.class); > if ((widget instanceof Control) && (!widget.isDisposed())) { > final Shell shell = ((Control) widget).getShell(); > handlerService.updateShellKludge(shell); >Index: Eclipse UI/org/eclipse/ui/internal/keys/KeyAssistDialog.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/KeyAssistDialog.java,v >retrieving revision 1.26 >diff -u -r1.26 KeyAssistDialog.java >--- Eclipse UI/org/eclipse/ui/internal/keys/KeyAssistDialog.java 8 May 2006 20:55:47 -0000 1.26 >+++ Eclipse UI/org/eclipse/ui/internal/keys/KeyAssistDialog.java 7 Sep 2006 18:54:00 -0000 >@@ -166,10 +166,10 @@ > > this.activityManager = workbench.getActivitySupport() > .getActivityManager(); >- this.bindingService = (IBindingService) workbench >- .getAdapter(IBindingService.class); >- this.commandService = (ICommandService) workbench >- .getAdapter(ICommandService.class); >+ this.bindingService = (IBindingService) Util.getAdapter(workbench, >+ IBindingService.class); >+ this.commandService = (ICommandService) Util.getAdapter(workbench, >+ ICommandService.class); > this.keyBindingState = associatedState; > this.workbenchKeyboard = associatedKeyboard; > >@@ -649,8 +649,8 @@ > */ > private final void registerShellType() { > final Shell shell = getShell(); >- final IContextService contextService = (IContextService) keyBindingState >- .getAssociatedWindow().getWorkbench().getAdapter( >+ final IContextService contextService = (IContextService) Util.getAdapter(keyBindingState >+ .getAssociatedWindow().getWorkbench(), > IContextService.class); > contextService.registerShell(shell, contextService > .getShellType((Shell) shell.getParent())); >Index: Eclipse UI/org/eclipse/ui/model/WorkbenchLabelProvider.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/model/WorkbenchLabelProvider.java,v >retrieving revision 1.19 >diff -u -r1.19 WorkbenchLabelProvider.java >--- Eclipse UI/org/eclipse/ui/model/WorkbenchLabelProvider.java 15 Jun 2005 18:41:21 -0000 1.19 >+++ Eclipse UI/org/eclipse/ui/model/WorkbenchLabelProvider.java 7 Sep 2006 18:54:00 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.ui.model; > >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.DecoratingLabelProvider; > import org.eclipse.jface.viewers.IColorProvider; >@@ -28,6 +27,7 @@ > import org.eclipse.ui.IPropertyListener; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.internal.util.SWTResourceUtil; >+import org.eclipse.ui.internal.util.Util; > > /** > * Provides basic labels for adaptable objects that have the >@@ -121,11 +121,7 @@ > * object is not adaptable. > */ > protected final IWorkbenchAdapter getAdapter(Object o) { >- if (!(o instanceof IAdaptable)) { >- return null; >- } >- return (IWorkbenchAdapter) ((IAdaptable) o) >- .getAdapter(IWorkbenchAdapter.class); >+ return (IWorkbenchAdapter)Util.getAdapter(o, IWorkbenchAdapter.class); > } > > /** >@@ -136,11 +132,7 @@ > * object is not adaptable. > */ > protected final IWorkbenchAdapter2 getAdapter2(Object o) { >- if (!(o instanceof IAdaptable)) { >- return null; >- } >- return (IWorkbenchAdapter2) ((IAdaptable) o) >- .getAdapter(IWorkbenchAdapter2.class); >+ return (IWorkbenchAdapter2)Util.getAdapter(o, IWorkbenchAdapter2.class); > } > > /* (non-Javadoc) >Index: Eclipse UI/org/eclipse/ui/model/BaseWorkbenchContentProvider.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/model/BaseWorkbenchContentProvider.java,v >retrieving revision 1.5 >diff -u -r1.5 BaseWorkbenchContentProvider.java >--- Eclipse UI/org/eclipse/ui/model/BaseWorkbenchContentProvider.java 25 Feb 2005 20:52:37 -0000 1.5 >+++ Eclipse UI/org/eclipse/ui/model/BaseWorkbenchContentProvider.java 7 Sep 2006 18:54:00 -0000 >@@ -10,9 +10,9 @@ > *******************************************************************************/ > package org.eclipse.ui.model; > >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.jface.viewers.ITreeContentProvider; > import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.ui.internal.util.Util; > > /** > * Tree content provider for objects that can be adapted to the interface >@@ -52,11 +52,7 @@ > * @return the corresponding workbench adapter object > */ > protected IWorkbenchAdapter getAdapter(Object element) { >- if (!(element instanceof IAdaptable)) { >- return null; >- } >- return (IWorkbenchAdapter) ((IAdaptable) element) >- .getAdapter(IWorkbenchAdapter.class); >+ return (IWorkbenchAdapter)Util.getAdapter(element, IWorkbenchAdapter.class); > } > > /* (non-Javadoc) >Index: Eclipse UI/org/eclipse/ui/part/MultiPageEditorPart.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiPageEditorPart.java,v >retrieving revision 1.40 >diff -u -r1.40 MultiPageEditorPart.java >--- Eclipse UI/org/eclipse/ui/part/MultiPageEditorPart.java 2 Jun 2006 00:18:08 -0000 1.40 >+++ Eclipse UI/org/eclipse/ui/part/MultiPageEditorPart.java 7 Sep 2006 18:54:00 -0000 >@@ -42,6 +42,7 @@ > import org.eclipse.ui.PartInitException; > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.services.INestable; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.services.IServiceLocator; > > /** >@@ -813,7 +814,7 @@ > IEditorPart innerEditor = getActiveEditor(); > // see bug 138823 - this is a hack > if (innerEditor != null && innerEditor != this) { >- result = innerEditor.getAdapter(adapter); >+ result = Util.getAdapter(innerEditor, adapter); > } > } > return result; >Index: Eclipse UI/org/eclipse/ui/part/PageBookView.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/PageBookView.java,v >retrieving revision 1.32 >diff -u -r1.32 PageBookView.java >--- Eclipse UI/org/eclipse/ui/part/PageBookView.java 8 May 2006 20:55:33 -0000 1.32 >+++ Eclipse UI/org/eclipse/ui/part/PageBookView.java 7 Sep 2006 18:54:00 -0000 >@@ -17,7 +17,6 @@ > import java.util.Set; > > import org.eclipse.core.commands.common.EventManager; >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.util.IPropertyChangeListener; >@@ -39,6 +38,7 @@ > import org.eclipse.ui.PartInitException; > import org.eclipse.ui.SubActionBars; > import org.eclipse.ui.internal.WorkbenchPlugin; >+import org.eclipse.ui.internal.util.Util; > > /** > * Abstract superclass of all multi-page workbench views. >@@ -565,15 +565,13 @@ > public Object getAdapter(Class key) { > // delegate to the current page, if supported > IPage page = getCurrentPage(); >- if (page instanceof IAdaptable) { >- Object adapter = ((IAdaptable) page).getAdapter(key); >- if (adapter != null) { >- return adapter; >- } >+ Object adapter = Util.getAdapter(page, key); >+ if (adapter != null) { >+ return adapter; > } > // if the page did not find the adapter, look for one provided by > // this view before delegating to super. >- Object adapter = getViewAdapter(key); >+ adapter = getViewAdapter(key); > if (adapter != null) { > return adapter; > } >Index: Eclipse UI/org/eclipse/ui/progress/DeferredTreeContentManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/progress/DeferredTreeContentManager.java,v >retrieving revision 1.51 >diff -u -r1.51 DeferredTreeContentManager.java >--- Eclipse UI/org/eclipse/ui/progress/DeferredTreeContentManager.java 8 May 2006 20:55:31 -0000 1.51 >+++ Eclipse UI/org/eclipse/ui/progress/DeferredTreeContentManager.java 7 Sep 2006 18:54:00 -0000 >@@ -11,7 +11,6 @@ > package org.eclipse.ui.progress; > > import org.eclipse.core.runtime.Assert; >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Platform; >@@ -26,6 +25,7 @@ > import org.eclipse.ui.IWorkbenchPartSite; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.internal.progress.ProgressMessages; >+import org.eclipse.ui.internal.util.Util; > import org.eclipse.ui.model.IWorkbenchAdapter; > > /** >@@ -86,8 +86,8 @@ > public DeferredTreeContentManager(ITreeContentProvider provider, > AbstractTreeViewer viewer, IWorkbenchPartSite site) { > this(provider, viewer); >- Object siteService = site >- .getAdapter(IWorkbenchSiteProgressService.class); >+ Object siteService = Util.getAdapter(site, >+ IWorkbenchSiteProgressService.class); > if (siteService != null) { > progressService = (IWorkbenchSiteProgressService) siteService; > } >@@ -163,18 +163,7 @@ > * @return IDeferredWorkbenchAdapter or <code>null</code> > */ > protected IDeferredWorkbenchAdapter getAdapter(Object element) { >- if (element instanceof IDeferredWorkbenchAdapter) { >- return (IDeferredWorkbenchAdapter) element; >- } >- if (!(element instanceof IAdaptable)) { >- return null; >- } >- Object adapter = ((IAdaptable) element) >- .getAdapter(IDeferredWorkbenchAdapter.class); >- if (adapter == null) { >- return null; >- } >- return (IDeferredWorkbenchAdapter) adapter; >+ return (IDeferredWorkbenchAdapter)Util.getAdapter(element, IDeferredWorkbenchAdapter.class); > } > > /** >@@ -260,18 +249,7 @@ > * The object we are adapting to. > */ > private IWorkbenchAdapter getWorkbenchAdapter(Object element) { >- if (element instanceof IWorkbenchAdapter) { >- return (IWorkbenchAdapter) element; >- } >- if (!(element instanceof IAdaptable)) { >- return null; >- } >- Object workbenchAdapter = ((IAdaptable) element) >- .getAdapter(IWorkbenchAdapter.class); >- if (workbenchAdapter == null) { >- return null; >- } >- return (IWorkbenchAdapter) workbenchAdapter; >+ return (IWorkbenchAdapter) Util.getAdapter(element, IWorkbenchAdapter.class); > } > }; > job.addJobChangeListener(new JobChangeAdapter() {
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