X

Geertjan's Blog

  • July 19, 2008

Search the Guardian from a NetBeans Platform Application without Coding At All

Geertjan Wielenga
Product Manager
By default, the Quick Search feature is hidden in NetBeans Platform applications. Below, I show how to enable it in the layer.xml file and also how to enable the web search provider (this provider searches Google and returns pages that match your search string), which is defined in the NetBeans sources but not declared by default in the NetBeans Platform:
<folder name="QuickSearch">
<!-- Optionally, we've hidden the existing quick search providers: -->
<file name="Actions_hidden"/>
<file name="GoToOption_hidden"/>
<file name="Help_hidden"/>
<!-- Enabling the WebQuickSearchProviderImpl: -->
<folder name="Guardian">
<file name="org-netbeans-modules-quicksearch-web-WebQuickSearchProviderImpl.instance"/>
</folder>
</folder>
<!-- Showing the Quick Search feature: -->
<folder name="Toolbars">
<folder name="QuickSearch">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.guardiansearch.Bundle"/>
<file name="org-netbeans-modules-quicksearch-QuickSearchAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-quicksearch-QuickSearchAction.instance"/>
</file>
</folder>
</folder>

Finally, in our branding folder, we create the folder hierarchy below and set the two properties that you see there (read about these properties at the bottom of this page):

In the IDE, the above properties are hardcoded to the following, but for the NetBeans Platform they are undefined and hence need to be branded as the above:

quicksearch.web.site=netbeans.org
quicksearch.web.url_patterns=.\*netbeans\\.org/kb.\*,.\*wiki\\.netbeans\\.org/.\*faq.\*,.\*wiki\\.netbeans\\.org/.\*howto.\*,.\*platform\\.netbeans\\.org/tutorials.\*

You've done no coding at all, right? So now run the application and you'll be able to search the Guardian (or whatever you set in the branded Bundle file that you see above):

When you click an item above, the related article opens in your browser.

So here's all I did to be able to search Jon Stewart's show:

quicksearch.web.site=thedailyshow.com
quicksearch.web.url_patterns=.\*

And here's the result:

All of the above is possible from 6.5 Milestone 1 onwards.

Join the discussion

Comments ( 9 )
  • tattoo Sunday, July 20, 2008

    thank you for imformation !!!

    good luck


  • Bill Snyder Thursday, July 31, 2008

    What about searching wikis? Or sites where there is no extension to the page? It does seem to work....


  • Bill Snyder Thursday, July 31, 2008

    Uh, meant to say it DOESNT seem to work


  • Geertjan Thursday, July 31, 2008

    What do you mean?


  • Bill Snyder Saturday, August 2, 2008

    quicksearch.web.site=http://code.google.com/p/cashforward/wiki

    quicksearch.web.url_patterns=.\*,\*

    doesn't seem to work. Though if you google this :

    site:http://code.google.com/p/cashforward/wiki icon

    it brings up a result.

    Am I missing something?


  • mbien Monday, August 11, 2008

    Is it possible to use the Websearch provider in a IDE module? I haven't figured out how to set the quicksearch.web.\* properties (IDE plugins have no branding folder...). (Custom search providers work perfectly of course)

    Thank you for the great blog entries.


  • Alejo Ceballos Saturday, November 1, 2008

    Geertjan

    I'm quite a fan of your work. But there is something that's making me loose a lot of time: How do I use netbeans API to search for java files inside the project and get information about these files? I mean, when the user presses some action (code completer, code generator, etc) I need to look inside his project's java files and inform him about this class' methods, annotaions, etc. I can't figure the right API and its usage!!!


  • Bhavik Patel Tuesday, November 11, 2008

    Hello,

    We are migrating from NetBeans6M10 to NetBeans6.5.

    The problem I an facing is that, our application shows QuickSearch on the corner. It is not enable from our layer.xml. WSe want to hide the QuickSearch. any help.

    Bhavik


  • Aljoscha Rittner Tuesday, November 25, 2008

    Hello Bhavik Patel!

    The Quick Search is a simple toolbar. You can disable the quick search toolbar with this few lines in your layer.xml:

    <folder name="Toolbars">

    <folder name="QuickSearch_hidden"/>

    </folder>

    best regards,

    josh.


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