[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipse-dev] Why should the listener be model-specific

Hi,

Iam just starting to work with Eclipse. My first attempt was the Readme view
example and the Wordview article example.

One thing which struck me while reading the article is, why should the
listener which is being registered in the IContentProvider be
model-specific?

To explain it further, in 'createPartControl()' method in objects of type
ViewPart when we set the input on the viewer using the method
'viewer.setInput()' the viewer calls the 'inputChanged(..)' method on the
ContentProvider.

The doc for the method 'inputChanged()' on the ContentProvider states that,

Notifies this content provider that the given viewer's input has been
switched to a different element.
A typical use for this method is registering the content provider as a
listener to changes on the new input (using model-specific means), and
deregistering the viewer from the old input. In response to these change
notifications, the content provider propagates the changes to the viewer.

If i have got it right the listener is a model-specific listener. In the
WordView article example theres a custom listner declared inside the class
WordFile.

And in the WordContentProvider's 'inputChanged()' method the
WordContentProvider is registered as a listner.  (WordContentProvider
implements the model-specific listner)

My question is why should the listener interface be model-specific, why cant
it be a specific fixed interface if its job is to just add and remove
elements?

hope iam clear

gover