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.

Comments:

thank you for imformation !!!

good luck

Posted by tattoo on July 19, 2008 at 10:46 PM PDT #

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 12:04 PM PDT #

Uh, meant to say it DOESNT seem to work

Posted by Bill Snyder on July 31, 2008 at 12:04 PM PDT #

What do you mean?

Posted by Geertjan on July 31, 2008 at 04: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 12: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.

Posted by mbien on August 11, 2008 at 03:07 AM PDT #

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!!!

Posted by Alejo Ceballos on November 01, 2008 at 08:06 AM PDT #

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

Posted by Bhavik Patel on November 10, 2008 at 05:50 PM PST #

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.

Posted by Aljoscha Rittner on November 24, 2008 at 06:06 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

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.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today