Saturday July 19, 2008
Search the Guardian from a NetBeans Platform Application without Coding At All
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.
Jul 19 2008, 02:04:36 PM PDT Permalink
What about searching wikis? Or sites where there is no extension to the page? It does seem to work....
Posted by Bill Snyder on July 31, 2008 at 07:04 PM PDT #
Uh, meant to say it DOESNT seem to work
Posted by Bill Snyder on July 31, 2008 at 07:04 PM PDT #
What do you mean?
Posted by Geertjan on July 31, 2008 at 11:10 PM PDT #
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?
Posted by Bill Snyder on August 02, 2008 at 07:51 AM PDT #
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.


