|
Re: ItemProviderAdapter implements Interfaces but doesn't declare them [message #429650 is a reply to message #429649] |
Tue, 28 April 2009 18:56 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Felix,
Comments below.
Felix Dorner wrote:
> Hey,
>
> I'm trying to add IColorProvider support to _one_ of my Object types.
> To achieve this I must add IColorItemProvider to the 'supportedTypes'
> collection in my ItemProviderAdapterFactory, and then use one of
> AdapterFactoryLabelProvider's static inner class variations right?
Yes, though it's not generally expected that only one of the object
types supports it...
>
> Now _every_ adapter that the factory returns must implement
> IColorItemProvider or I'll run into a class cast exception in the
> AdapterFactoryLabelProvider.
The factory is allowed to return null, but yes, if it returns an item
provider, it's expected to implement the interface requested.
>
> Now I must declare each of my ItemProviders to implement
> IItemColorProvider. But I don't need to write methods, because they
> inherit the implementation from the base class ItemProviderAdapter.
Yes.
> Now, if ItemProviderAdapter already implements this interface, why
> doesn't it also declare it ('class ItemProviderAdapter implements
> ...') ? I guess you'll have a pretty good reason, I'm curious.
ItemProviderAdapter is intended to be a base and while it provide
default implementations for all the item provider interfaces, it's up to
the client to declare that the item provider should in fact support the
interface via the default implementation.
One thing you've probably not noticed is that you can set the Edit
property Color Providers to true in the GenModel so that everything is
produced for you automatically; note that the registration in the
plugin.xml of the *.edit project will not be regenerated.
>
>
> Thanks,Felix
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03657 seconds