Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [pde-dev] Setting a listener on the Package Explorer?

Hi Mike!

>I'm writing a plugin that has a view that would like to be notified when 
>the selection in the Package Explorer changes.

This question should be better asked on the newsgroup. This mailinglist is
for discussion of development issues regarding Eclipse PDE.

>After a lot of hunting about I came-up with this:
>
>        viewer.addSelectionChangedListener(this);
>
>Is this the correct/accepted way to do this sort of thing?

Only if it is your viewer and you know what you are doing. The Eclipse
concept is different. The active view regsiters itself as a selection
provider to the workbench (see ISelectionProvider and IWorkbenchSite for
details). You registers as a selection listener (ISelectionListener) to the
currently active workbench page.

This way you should be notified whenever the selection changes in the
Eclipse workbench (whether you it is in the Package Explorer or another
view).

See http://www.eclipse.org/articles/viewArticle/ViewArticle2.html.

>Given the degree of difficulty figuring this out, and having to peek 
>into internal classes, I'm wondering if I'm not on the wrong track here.

You should never use internal API.
See
http://www.eclipse.org/articles/Article-API%20use/eclipse-api-usage-rules.ht
ml.

Cu, Gunnar


Back to the top