[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform] Re: TabbedProperty problem when using CommonNavigator with an existing workspace

Hi Joakim,

Can you please file a bug against Platform UI for this?

Thanks,
Boris

"Joakim Althini" <joakim.althini@xxxxxxxxxxx> schrieb im Newsbeitrag 
news:f671ddc623ef849d84256125c85ce65e$1@xxxxxxxxxxxxxxxxxx
> Hi,
> (using eclipse 3.3.1.1)
>
> we're using a CommonNavigator based view and want it to support tabbed 
> properties. So we set up extension points for 
> org.eclipse.ui.views.properties.tabbed.propertyContributor, propertyTabs 
> and propertySections and everything works fine when we run the first time 
> with
> a cleaned workspace.
>
> But when we run it the second time, the properties view does not show the 
> tabbed property view any more, the default property table is shown.
>
> We have an adapter for creating the TabbedPropertySheetPage that is not 
> being called; the extension is declared as:
>
> <extension point="org.eclipse.core.runtime.adapters">
> <factory adaptableType="org.eclipse.ui.navigator.CommonNavigator" 
> class="com.mycompany.mapping.TabbedPropertySheetAdapterFactory">
> <adapter type="org.eclipse.ui.views.properties.IPropertySheetPage"/>
> </factory> </extension>
>
> and a factory class that creates a tabbed property:
>
> public Object getAdapter(Object adaptableObject, Class adapterType) {
> if(adapterType == IPropertySheetPage.class && adaptableObject instanceof 
> CommonNavigator) {
> CommonNavigator cn = (CommonNavigator) adaptableObject; this.contributorId 
> = cn.getViewSite().getId();
> return new TabbedPropertySheetPage(this);
> }
>       return null;
> }
>
> After several hours we found out why it was not called; there was another 
> plugin that had declared an adapter factory for the same types; this was 
> done by the org.eclipse.ui.navigator.resources plugin.
>
> So when debugging what was happening, we saw the following in 
> org.eclipse.core.internal.runtime.AdapterFactoryProxy:
>
> public synchronized IAdapterFactory loadFactory(boolean force) {
>  if (factory != null || factoryLoaded)
>      return factory;
>  String bundleId = element.getContributor().getName();
>  if (!force && Platform.getBundle(bundleId).getState() != Bundle.ACTIVE)
>   return null;   <-- bundleId is 'org.eclipse.ui.navigator.resources'
>  //set to true to prevent repeated attempts to load a broken factory
>  factoryLoaded = true;
>  try {
>    factory = (IAdapterFactory) 
> element.createExecutableExtension("class"); } catch (CoreException e) {
>    InternalPlatform.getDefault().log(e.getStatus());
>  } return factory;
> }
>
> This method returned null beacause it found the navigator.resources bundle 
> (which was not active at that time) instead of our bundle/plugin and this 
> caused the default property table to be displayed instead of the expected 
> tabbed view.
>
> Looking at the JavaDoc for 
> org.eclipse.core.internal.runtime.AdapterManager:
>
> * <li>If multiple installed factories provide the same adapter, only the 
> first found in
> * the search order will be invoked.
>
> makes it look like if two plugins have registered adapter factories for 
> the same types, it takes the first it finds in a non-predictable order.
>
> We have now made a workaround by setting up a dependency to the 
> org.eclipse.ui.navigator.resources plugin from ours and loading a class 
> from it so that it is active and can can create the 
> TabbedPropertySheetPage for us.
>
> But this is a rather dirty solution; it would be better if this could be 
> solved in a more straightforward way.
>
> - So, can this problem be considered being a bug in the eclipse framework?
> - Is there a nice way to solve the problem in the current version?
> - Why is there no error handling when more than one extension registers 
> the same pair of adapter types if one of them will be ignored. It took 
> MANY hours to find out what was the problem; it would have helped with 
> some diagnostic messages...
>
>
> Best Reagards
> /Joakim Althini
>
>
>
>
>
>
>