Friday Jun 27, 2008

User FAQ Search Inside NetBeans IDE

Over on NetBeans Zone today, I speculated about one interesting scenario that is possible in relation to the new Quick Search feature—plugging the NetBeans User FAQs into the Quick Search. Well, I figured out how to do it and this would be the result:

So, the user would be curious about CVS in NetBeans IDE. The user would then type "CVS" and get (1) all the related FAQs, as well as (2) the action for opening the CVS window. Many similar results could be imagined, combining actions (and types) in the IDE with FAQs which, when clicked, would open in the browser.

The parsing code is very slightly different, i.e., just the code in bold below is different to that found on NetBeans Zone:

Document doc = tidy.parseDOM(url.openStream(), null);
//Get all "a" elements:
NodeList list = doc.getElementsByTagName("a");
//Get the number of elements:
int length = list.getLength();
//Loop through all the "a" elements:
for (int i = 0; i < length; i++) {
    String href = null;
    if (null != list.item(i).getAttributes().getNamedItem("href")) {
        //Get the "href" attribute from the current "a" element:
        href = list.item(i).getAttributes().getNamedItem("href").getNodeValue();
    //Get the the node value, i.e., <a href="foo">value</a>:
    if (null != list.item(i).getChildNodes().item(0)) {
        String title = list.item(i).getChildNodes().item(0).getNodeValue();
        //If the node value matches the requested text:
        if (title.toLowerCase().indexOf(request.getText().toLowerCase()) != -1) {
            //Add the runnable and the title to the response
            //and return if nothing is added:
            if (!response.addResult(new OpenFoundArticle(href), title)) {

Now imagine if we plugged the NetBeans Developer FAQ into the Quick Search feature too. You'd be able to get a lot of information from searches that combined both these FAQs. Then add tutorials, community docs, and NetBeans Zone. For very little work the user would end up with an incredibly powerful search mechanism across all our documentation... and all of it right inside the IDE, with the Quick Search constantly only a Ctrl-I click away.


Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« June 2008 »