Contributed adapter not available [message #987905] |
Wed, 28 November 2012 15:54 |
Steve Biggs Messages: 5 Registered: November 2012 |
Junior Member |
|
|
I'm contributing two adapters to a plugin I'm writing via the org.eclipse.core.runtime.adapters extension point, but the adapters are not accessible when I start the plugin. The adapters are used to convert my model objects to IWorkbenchAdapter for display in a TreeViewer.
The source of the problem occurs in BaseWorkbenchContentProvider.getChildren() where the call the getAdapter(element) returns null instead of the expected adapter. I've traced this call down to method AdapterFactoryProxy.loadFactory(). This returns null because the call to org.eclipse.core.internal.registry.osgi.EquinoxUtils.isActive() returns false and loadFactory() has been called with the force argument set to false. The isActive() method is returning false because the bundle getState() method is returning Bundle.RESOLVED instead of Bundle.ACTIVE.
Any idea why the bundle state is resolved and not ACTIVE, and how do I access contributed adapters if the contributing bundle state is not Bundle.ACTIVE? Since the contributing bundle is the main plugin associated with the application, it's not clear to me why the state isn't Bundle.ACTIVE, since presumably it would have to be ACTIVE to be executing.
I know the adapters work because if I register them manually using Platform.getAdapterManager().registerAdapters() everything works fine.
Extract from plugin.xml where I declare adapters:
<extension
point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="com.ibm.ccoet.model.managers.ProjectsManager"
class="com.ibm.ccoet.ui.adapters.ApplicationAdapterFactory">
<adapter
type="org.eclipse.ui.model.IWorkbenchAdapter">
</adapter>
</factory>
<factory
adaptableType="com.ibm.ccoet.ui.adapters.ApplicationAdapterFactory$ObjectWrapper"
class="com.ibm.ccoet.ui.adapters.ApplicationAdapterFactory">
<adapter
type="org.eclipse.ui.model.IWorkbenchAdapter">
</adapter>
</factory>
</extension>
createPartControl() method from the View that displays the TreeViewer
@Override
public void createPartControl(Composite parent) {
// Create a TreeViewer to display the managed projects
treeViewer = new TreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
// Configure the TreeViewer to be the selection provider for the view
getSite().setSelectionProvider(treeViewer);
// Hook up the ProjectsManager to the TreeViewer
DecoratingLabelProvider decorator=new DecoratingLabelProvider(new WorkbenchLabelProvider(),new ArtifactsDecorator());
treeViewer.setLabelProvider(decorator);
treeViewer.setContentProvider(new BaseWorkbenchContentProvider());
treeViewer.setInput(pm);
// Setup drag and drop for artifacts
initDragAndDrop(treeViewer);
// Listen for artifact editors to open and close
getSite().getWorkbenchWindow().getPartService().addPartListener(partListener);
// Link to context sensitive help
PlatformUI.getWorkbench().getHelpSystem().setHelp(treeViewer.getControl(),"com.ibm.CCoET.help.project_explorer");
// Perform the rest of the view setup
createActions();
initializeToolBar();
initializeMenu();
}
Thanks.
Steve Biggs
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Contributed adapter not available [message #989867 is a reply to message #988014] |
Sat, 08 December 2012 19:12 |
Steve Biggs Messages: 5 Registered: November 2012 |
Junior Member |
|
|
Thanks for the suggestion. Selecting "Activate this plug-in when one of it's classes is loaded" in the General Information section of the Overview tab of the plug-in's manifest editor fixed the problem.
Steve Biggs
|
|
|
Powered by
FUDForum. Page generated in 0.07328 seconds