Snippets and Extended Code Recommendations for Vaadin: Thinking of U and I and All of Us

If you are developing Java applications for the Web, chances are that you have tried Vaadin, an open source Web framework with a great, modern look and feel. Vaadin not only has excellent documentation but also a tight integration with the Eclipse IDE.

Still, Vaadin’s documentation sits on the Web, and you are working in your IDE. At Codetrails we asked ourselves, “Wouldn’t it be great if the IDE itself could help you learn the Vaadin framework?” We came up with a two part answer: Eclipse Code Recommenders and Snipmatch.

Eclipse Code Recommenders offers you recommendations on how to use the Vaadin framework based on how others have used it before, both in the form of intelligent code completion and API Docs. Snipmatch gives you instantaneous access to a collection of common code snippets supplied by the Vaadin Sampler. In either case, you never have to leave the comfort of your IDE.

To make setup as easy as possible, we bundled Eclipse Code Recommenders, Snipmatch, and all the recommendation models and code snippets created with our [ctrl]flow Miner in an easy-to-install package: Codetrails Vaadin Support. So here’s how to get recommendations and snippets for Vaadin:

First, make sure that you are using Eclipse 4.3 (Kepler); Eclipse 4.2 (Juno) or older won’t work with this package. Then, navigate to Help > Install New Software... and configure this update site: http://download.codetrails.com/updates/vaadin/releases/.

Click Next twice, accept the terms of the license agreement, and click Finish. Now the required plugins will be downloaded. After the download and installation are finished, restart your Eclipse IDE as suggested.

All you need to do now is to enable support for the Vaadin framework. Head over to the Codetrails Connect > Vaadin Support preference page and click Enable Vaadin Support. This automatically switches to Eclipse Code Recommenders’ intelligent code-completion engine and configures a Snipmatch repository with code snippets for Vaadin.

To search for these code snippets, just hit Ctrl+Enter (Cmd+Enter under Mac OS X) in your Eclipse Java editor. This opens a small popup where you can search for snippets by keyword. Using the keyword “Vaadin” gives you a list of all Vaadin-related snippets currently in the repository:

Of course, you can also search for other, more specific keywords. If for example, you want to know how to to embed a video into your page, there’s a helpful snippet for that:

But code snippets aren't the only thing Codetrails’ tools for Vaadin have to offer. You also get intelligent code completion, which suggests to you those methods that others have found most useful in a similar situation.

Moreover, the API Docs view offers you extended documentation on frequently used framework classes. If you want to know, for example, which methods you typically have to override when extending an AbstractComponentContainer, the API Docs view knows the answer:

Do you want to find out more about the data-mining tools and techniques behind the above recommendations? Or do you have a framework of your own that could benefit from such support? Then why not become a data-miner yourself?

Learn More Download [ctrl]flow Miner

Comments

Thomas Hoenen's picture

Very useful, but here ctrl+enter and "vaadin" or "video" gives no results. Code completion works as expected. Kepler SP1 win64 and vaadin 7.1.7.

Johannes Dorn's picture

Did you perhaps try ctrl+enter before enabling vaadin support in the preferences?

If so, please delete the ".snipmatch" project in your workspace (you may have to disable the filter for hidden ".*" resources. Then restart Eclipse and try again.

Keep in mind that when you first trigger Snipmatch with ctrl+enter, the data is downloaded while the completion window shows no results. In that case, simply try again in a minute or so. You can check Eclipse's progress view to see when it is done.

If it still doesn't work, do you find any other snippets, e. g. when searching for "a"?

Add new comment