X

Geertjan's Blog

  • October 13, 2007

First Experiments with the Task List API

Geertjan Wielenga
Product Manager
My first experiments with the Task List API (which is new in NetBeans 6.0) have resulted in a plugin that finds the values of all the HREF attributes in an HTML document and then puts them into the Task List:

The principles of working with this API are straightforward. Begin by registering the task list in the layer file. Task lists are organized in groups, here I create a new one for mine:

<folder name="TaskList">
<folder name="Groups">
<file name="demo.instance">
<attr name="instanceCreate" methodvalue="org.netbeans.spi.tasklist.Task.createGroup"/>
<attr name="localizingBundle" stringvalue="org.yourorghere.mytasklist.Bundle"/>
<attr name="groupName" stringvalue="nb-tasklist-my"/>
<attr name="diplayNameKey" stringvalue="LBL_my_group"/>
<attr name="descriptionKey" stringvalue="HINT_my_group"/>
<attr name="iconKey" stringvalue="ICON_my"/>
<attr name="position" intvalue="50"/>
</file>
</folder>
<folder name="Scanners">
<file name="DemoScanner.instance">
<attr name="instanceOf" stringvalue="org.netbeans.spi.tasklist.FileTaskScanner"/>
<attr name="instanceCreate" methodvalue="org.yourorghere.mytasklist.DemoTaskScanner.create"/>
</file>
</folder>
</folder>

Next, add a dependency on the Task List API and then extend FileTaskScanner. The list returned from FileTaskScanner.scan is what ends up in the Task List. (In this case I use an HTML parser to create the list.) You also need FileTaskScanner.create, which initializes the task list, as you can see from the layer entries above. Other methods include FileTaskScanner.attach, which is called when the Task List is opened, i.e., from the Window menu. By the time 6.0 is released, I plan on providing a full tutorial, which will cover the scenario shown above.

I imagine that this API could be pretty useful for NetBeans Platform applications. For example, there might be a special 'task' item that would be dragged onto the music sheet in the JFugue Music NotePad. Then, a new entry would be added in the Task List, so that you could go back afterwards, click on the line in the Task List, and then the related note would receive focus and the music sheet could scroll to that selected note. That's just one example where the (new!) ability to extend the Task List might be handy for NetBeans Platform developers. Again, one can see how a framework helps—there is no need to create a Task List yourself in your application. Just use the Task List API, at the end of which you provide a list of items to be added to the Task List, and then the NetBeans Platform takes care of everything else. I am now able to sort and organize the HREF attributes that are returned when I click the buttons on the left which, again, I did not need to create. One button lets me search within the current document, another for searching the main project, and the other for searching within all opened projects. The results are put into the Task List table, which I didn't need to create either, with the information magically organized into helpful columns.

Finally, here you see the group view in the Task List, to show you my new group in the context of one of the existing ones:

In other news. Rocket science is not brain surgeory!

Join the discussion

Comments ( 1 )
  • Tim Boudreau Saturday, October 13, 2007

    Would be kind of neat to add a feature that tries to load the page via an http request in the background, and shows if the link is valid. You'd probably want to ignore relative urls and cache known-valid urls rather than fetching them over and over (maybe click the checkbox or whatever shows the url is valid to re-check).


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.