The power of a community

Last week I posted an entry about Eclipse selection and when a view part should or should not process the selection.  I showed a pattern to use the IPartListener2 model as described in my post.  James Fry (no link provided) showed what now believe to be a much cleaner way to do this.  The reason its cleaner is because you are not on the part listener list and called every time and its a one liner!  No overhead of a boolean and your code to evaluate in the listener callback is now gone.  Much nicer!

Here was the code I ended up using:

if (viewer.getSite().getPage().isPartVisible(viewer) == false)
     return;

You should see this in the next release of the Attachment Viewer on OpenNTF.

Thanks James for being a reader and more importantly adding value to my blog!

One thing you may want to consider is when your view is re-opened or maximized you might want to restore the last selection so having a listener may be your only option in the end.

3 thoughts on “The power of a community

  1. Hi Bob

    just wanted to mention that the Attachment Viewer is getting better from release to release. Using a large screen there is plenty of space for the sidebar and even reading a multi page PDF file is very smoothly. Especially using the new “Pin” feature.
    Thanks a lot for the efforts. It is highly appreciated 🙂

    Best wishes, Michael

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s