Wednesday, July 19, 2006

Label Decorators in a Common Navigator Framework viewer

I just posted these comments elsewhere on label decorators, and thought they might be useful to the general audience for the Common Navigator Framework.

If you check out the org.eclipse.ui.tests.navigator plugin from Eclipse CVS repository, there's a simple example of using a lightweight decorator there. (There are instructions on using Eclipse with CVS, which also documents the repository paths.)

The extension looks like:
<!-- Verify decorator extension: Adds ">>" to Test Items that end in "3" -->
<extension point="org.eclipse.ui.decorators">
<decorator class="org.eclipse.ui.tests.navigator.extension.TestLabelDecorator"
label="Items that end in 3 decorator"
name="org.eclipse.ui.tests.navigator.extension.TestExtensionTreeData" />
And the type must implement ILabelDecorator:

import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProviderListener;

public class TestLabelDecorator implements ILabelDecorator
There's an FAQ on label decorators, as well as an article with more detail. Right off, I don't think this topic would merit a full article in this series on contributing label decorators to Common Navigator Framework viewers, so if you think there's enough need out there, chime in!

Sunday, July 16, 2006

PDF versions now available!

Some readers have requested PDF versions of the CNF articles. After some investigation of some pointers from Brian Fitzpatrick, I decided to go with PrimoPDF. The content of each article is roughly unchanged, excluding some minor formatting adjustments.

I have attached versions of the existing articles below, as well as comments to the original posts.

Building a Common Navigator Framework Viewer
What does the Common Navigator Framework help me do? (*.pdf) (original post)

Once a few more of the foundations of building CNF viewers are covered, I will integrate these articles into a more coherent organization and prepose them as Eclipse Corner articles. The links above point to attachments on Bug 143127: [CommonNavigator] Examples.

Thursday, July 13, 2006

It takes a village

With some great help from the community, part of the series is no longer necessary. Aashish Patil has prepared an article on rendering Non-Resource content in a Common Navigator Framework viewer.

Anybody else want to step in to help?

For anyone that decides to jump in, feel free to either build the example in the org.eclipse.ui.examples.navigator plugin in the Eclipse CVS repository (check out as anonymous, generate a patch, and attach it to bug 143127). There are also some instructions on using Eclipse with CVS, which also documents the repository paths.

Or you can just build a complete example as Aashish did, and then attach it to bug 143127: [CommonNavigator] Examples as a zip file to make it available to the community.

Thanks Aashish!

Wednesday, July 12, 2006

Response to comments and status on upcoming articles

When responding to a few of the latest comments on Part IV, it seemed like it made the most sense to just write a quick post. I hope to have Part V ready by the end of the week -- Monday at the latest.

I've been busy with a few other activities over the last few weeks -- one of which was a great vacation, and now I'm back.

The following quotes are snippets of comments from Part IV, I've copied them here for context.

"You may want to mention (or show an example implementing) IObjectActionDelegate."

I'll make a note for a short example of using IObjectActionDelegate just after Part V. My guess is there are other tutorials around for that topic (outside of the CNF context), so I may be able to find them and just post a link.

"It looks to be a simple task to hook up the CNF to our virtual file system that accesses about 33 TB of disk. I had a prototype up and running in less than an hour."

The filesystem example sounds pretty cool. I would hate to see how long an "expand all" type operation would take for 33TB though. Are you planning to use or provide "Go Into" support? (Which is not supported by the base framework, but I know of other clients that have implemented it).

"How do I sort the root nodes?"

I'll make sorting the topic of the next article in the series. The algorithm for sorting in a generic context is kind of interesting, so it would merit an explanation better than the one available in the slides anyway.

"At what point should I starting doing the work of building my nodes for my common navigator? I wanted to tie in the IProgress monitor and jobs to prevent blocking."

I have an article and example prepared for deferred loading of model data. For various reasons, the base framework doesn't support this natively. For clients that want to roll your own solution, there are a couple of points to be aware of, but it's not too complex. Deferred model loading can be used to offload expensive calculation out of the UI thread -- you could choose to pop a progress service dialog (which I would tend to discourage), but running the model loading operation in a Job, which shows progress in the Progress View is a great way to keep the UI responsive for the user. Would there be enough interest to make deferred model loading Part VII of the series?

"Secondly at what points are the methods in the content provider called? ... Will I need to refresh parts of my navigator during runtime?"

You have to call refresh() or update() on the viewer as necessary. You can implement fine-grained calls to add()/remove() to update the viewer; it's up to you to decide what makes the most sense for your scenario. You will have a reference to the viewer in the inputChanged() method on the content provider. You can remember the reference and generate events as necessary. Take a look at the org.eclipse.ui.examples.navigator plugin and specifically at the PropertiesContentProvider's implementation of inputChanged() and it's visit() method to refresh files as they change.

So in summary, I'm tentatively planning the following articles:

  • Part V : Action Providers
  • Part VI: Sorting
  • Part VII: Deferred model loading
  • Part VIII: Non-resource content