Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » [RESOLVED] Adapter not used, caused by plugin not activated.
icon14.gif  [RESOLVED] Adapter not used, caused by plugin not activated. [message #753631] Fri, 28 October 2011 07:09 Go to next message
Matthieu Lentwojt is currently offline Matthieu LentwojtFriend
Messages: 6
Registered: February 2011
Junior Member
Hello,

I created an AdapterFactory (using extension org.eclipse.runtime.adapters) which adapt java.util.List

public class CommonAdapterFactory implements IAdapterFactory {

	private final IWorkbenchAdapter listAdapter = new IWorkbenchAdapter() {

		@Override
		public Object[] getChildren(final Object o) {
			return ((List<?>)o).toArray();
		}

		@Override
		public ImageDescriptor getImageDescriptor(final Object object) {
			return null;
		}

		@Override
		public String getLabel(final Object o) {
			return null;
		}

		@Override
		public Object getParent(final Object o) {
			return null;
		}
	};

	@SuppressWarnings("rawtypes")
	@Override
	public Object getAdapter(final Object adaptableObject, final Class adapterType) {

		if (adapterType == IWorkbenchAdapter.class && adaptableObject instanceof List<?>) {
			return listAdapter;
		}

		return null;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public Class[] getAdapterList() {
		return new Class[] { IWorkbenchAdapter.class };
	}

}


This adapter is declared in a plugin common, because in will be used by many other plugins.


In a second plugin, I define a view which will render a list of object in a TreeViewer.

public class ViewCategories extends ViewPart implements CategorieListener {

	public static final String ID = "GestionComptes-Plugin.ViewCategories";
	TreeViewer viewer = null;

	@Override
	public void createPartControl(final Composite parent) {
		viewer = new TreeViewer(parent);
		getSite().setSelectionProvider(viewer);
		viewer.setLabelProvider(new WorkbenchLabelProvider());
		viewer.setContentProvider(new BaseWorkbenchContentProvider());
		viewer.setInput(CategorieService.INSTANCE.getCategorie());
		CategorieListenerManager.addListener(this);
	}

//...

}



The object categorie has its own adapterFactory ...

The problem is that no categories was displayed in the viewer. After step by step debugging, I found the cause : The common plugin is not loaded so the CommonAdapterFactory is not used to render the List of Categorie.

The only solution I found is to force common plugin activation at start up of the application (using extension org.eclipse.ui.startup)

I don't like activate plugin at start up (because useless if this plugin will not be used ...) so I would like to know if it exist another solution ?

Thx in advance.
Matth.



[Updated on: Fri, 17 February 2012 13:15]

Report message to a moderator

Re: Adapter not used, caused by plugin not activated. [message #753636 is a reply to message #753631] Fri, 28 October 2011 07:28 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 2011-10-28 09:09, mlentwojt wrote:
> Hello,
>
> I created an AdapterFactory (using extension
> org.eclipse.runtime.adapters) which adapt java.util.List

[..]

> This adapter is declared in a plugin common, because in will be used by
> many other plugins.
>
>
> In a second plugin, I define a view which will render a list of object
> in a TreeViewer.

[..]

> The object categorie has its own adapterFactory ...
>
> The problem is that no categories was displayed in the viewer. After
> step by step debugging, I found the cause : The common plugin is not
> loaded so the CommonAdapterFactory is not used to render the List of
> Categorie.
> The only solution I found is to force common plugin activation at start
> up of the application (using extension org.eclipse.ui.startup)
>
> I don't like activate plugin at start up (because useless if this plugin
> will not be used ...) so I would like to know if it exist another
> solution ?

IMO this is a fundamental defect of the org.eclipse.runtime.adapters
extension point. See

https://bugs.eclipse.org/bugs/show_bug.cgi?id=82973

for an old bug about this. There seems to be not much interest in fixing
this, even though there would be a very simple solution (suggested in
the bug report by me) to introduce a new optional attribute to the
extension point, e.g. "force" that has the effect of enforcing
activation of the contributing plugin, if the "pattern" described in the
plugin.xml could match. Given that other extension points do already
have such a flag (usually named "forcePluginActivation", so this should
be the name here as well), this clearly shows the need for sometimes
breaking the lazy-loading strategy.

Examples for other extension points that have such a flag are:

org.eclipse.ui.activities
org.eclipse.core.expressions.definitions
org.eclipse.core.resources.modelProviders
org.eclipse.ltk.core.refactoring.createParticipants

I don't think that it should be too hard to implement
"forcePluginActivation" for org.eclipse.runtime.adapters as well.

Just vote for it ;-)

Greetings from Bremen,

Daniel Krügler
Re: Adapter not used, caused by plugin not activated. [message #800761 is a reply to message #753636] Fri, 17 February 2012 13:14 Go to previous message
Matthieu Lentwojt is currently offline Matthieu LentwojtFriend
Messages: 6
Registered: February 2011
Junior Member
I didn't tell you THX for your answer, so :

THX !!! I resolve it thanks to you.

Bye !
Previous Topic:Change Application text from header/titlebar
Next Topic:How to get annotations of my workspace ?
Goto Forum:
  


Current Time: Fri Dec 04 04:30:30 GMT 2020

Powered by FUDForum. Page generated in 0.02687 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top