X

Geertjan's Blog

  • May 27, 2007

Text File Dictionary Project Template

Geertjan Wielenga
Product Manager
In 5.5 (and, possibly 5.5.1, but definitely not 6.0) install this module:

org-netbeans-modules-textfiledictionaryprojecttemplate.nbm

After installing the module, you will find this new sample in the New Project wizard:

When you complete the New Project wizard, you will find a module suite in the Projects window:

Right-click the above and choose Run. A new instance of the IDE starts up, installing the suite's three modules in the newly started IDE. When you open a text file, you will have code completion.

Note: By default, there will be no code completion, because you need to specify a file that contains the words which you want to be displayed in the code completion box. The file containing the words displayed in the code completion box is set in the Options window. For this purpose, the module adds a new section (called "Dictionary File") to the Miscellaneous category. FYI, included in the TextFileDictionaryTemplate sources you will find a file called "English.0", which contains a very long list of English words. You could register that in the Options window. After you click OK, the words in the registered dictionary file will appear in the code completion box.

You may need to specify proxy server settings, if you're behind a firewall, because an on-line web service is accessed, for the definitions of the words, which appear in the documentation section of the popup. However, the web service only defines English words. So, if your dictionary file contains words that are not defined by the web service, such as all non-English words, the documentation popup will not work. When everything is working, i.e., you've defined a dictionary file in the Options window and the web service is responsive, you will be able to use code completion in text files, as shown below:

To get the tooltip shown in the screenshot above, press Alt-P.

Why would you want to make use of this sample? Two reasons. First, you're learning about code completion. The TextFileDictionaryTemplate module provides a complete implementation of the Editor Code Completion API. So inspect the sources to learn from them and discover how they work. One of the tutorials on http://platform.netbeans.org (here) should be of some help in understanding the code. Second, maybe you would like to make use of the functionality when editing text files. Pretty useful, I've found. Be aware that there might be a slight delay, depending on your connection, because of the time taken to retrieve the definitions from the web service.

I have a semi-working version of this module for 6.0, but want to work on it a bit more and want to make it available once 6.0 is released. The 5.5 version, i.e., provided and described above, has one or two imperfections, but they're quite small. There's enough there to show you how code completion works under the hood.

Join the discussion

Comments ( 4 )
  • Vladimir Voskresensky Sunday, May 27, 2007
    Hello, Geertjan!
    Sorry for posting here, but I've sent you 2 mails (replay and test mail), have you received any?
    Thanks,
    Vladimir.
  • Geertjan Sunday, May 27, 2007
    Thanks for the note Vladimir, I've responded to your e-mails now.
  • R.Thangaprakash Saturday, June 23, 2007
    I need a program for Keyboard dictionary shortkeys in Java program just like Mobile keypad.
  • adam Thursday, February 28, 2008

    I would appreciate it if you would complete a working version of this module for 6.0 now that netbeans 6.0 has been released, as I found the one you posted here very useful. Thank you for the code.


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