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


