Geertjan's Blog

  • June 27, 2008

User FAQ Search Inside NetBeans IDE

Geertjan Wielenga
Product Manager
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.

Join the discussion

Comments ( 2 )
  • Jesse Glick Friday, June 27, 2008

    Trunk builds already have a search provider which searches netbeans.org via Google, including wiki.netbeans.org.

  • Denis Friday, June 27, 2008

    It seems to be a little buggy when searching for \*,+ etc

    BTW What about adding a calculator support? :) Its really easy to do it with groovy just using groovy.lang.GroovyShell#evaluate.

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