Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[buckminster-dev] Re: Problems getting started with Headless Buckminster

Thomas Hallgren wrote:
Hi Eugene,
I've seen the concept of adaptable used in many places in Eclipse but I'm not sure I fully understand the semantics of it. In particular, when and how will the adapter factory be utilized?

For instance, how do you make sure the adapter factory comes into play prior to situations like this:

if (sa instanceof IEncodedStreamContentAccessor) {
    try {
        encoding= ((IEncodedStreamContentAccessor) sa).getCharset();
    } catch (Exception e) {
    }
}

I see this type of construct in a number of places in Eclipse.
This is how Adaptable.getAdapter() method is usually implemented. That won't help in your case. Though could eliminate direct dependencies at the class initialization time (because resource won't implement IEncodedStreamContentAccessor interface anymore).

To make it even more decoupled and allow adapter to be in a different plugin then adapable you would need to register factory Platform.getAdapterManager().registerAdapters(factory, IEncodedStreamContentAccessor.class);

Then you can use Platform.getAdapterManager().getAdapter(adaptable, IEncodedStreamContentAccessor.class)

You can see that Subclipse is registering adapter factory for a few classes in CVSUIPlugin.start

 regards,
 Eugene



Back to the top