Play in NetBeans IDE (Part 2)

Posted by Geertjan on Oracle Blogs See other posts from Oracle Blogs or by Geertjan
Published on Wed, 17 Oct 2012 18:17:09 +0000 Indexed on 2012/10/17 23:12 UTC
Read the original article Hit count: 194

Filed under:

Peter Hilton was one of many nice people I met for the first time during the last few days constituting JAX London. He did a session today on the Play framework which, if I understand it correctly, is an HTML5 framework. It doesn't use web.xml, Java EE, etc. It uses Scala internally, as well as in its templating language. 

Support for Play would, I guess, based on the little I know about it right now, consist of extending the HTML5 application project, which is new in NetBeans IDE 7.3. The workflow I imagine goes as follows. You'd create a new HTML5 application project, at which point you can choose a variety of frameworks and templates (Coffee Script, Angular, etc), which comes out of the box with the HTML5 support (i.e., Project Easel) in NetBeans IDE 7.3.

Then, once the project is created, you'll right-click it and go to the Project Properties dialog, where you'll be able to enable Play support:

At this stage, i.e., when you've checked the checkbox above and then clicked OK, all the necessary Play files will be added to your project, e.g., the routes file and the application.conf, for example. And then you have a Play application.

Creating support in this way entails nothing more than creating a module that looks like this, i.e., with one Java class, where even the layer.xml file below is superfluous:

All the code in the PlayEnablerPlanel.java that you see above is as follows:

import java.awt.BorderLayout;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JPanel;
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category;
import org.openide.util.Lookup;

public class PlayEnablerPanel implements ProjectCustomizer.CompositeCategoryProvider {

    @ProjectCustomizer.CompositeCategoryProvider.Registration(
            projectType = "org.netbeans.modules.web.clientproject", 
            position = 1000)
    public static PlayEnablerPanel enablePlay() {
        return new PlayEnablerPanel();
    }
 
    @Override
    public Category createCategory(Lookup lkp) {
        return ProjectCustomizer.Category.create("Play Framework", "Configure Play", null);
    }

    @Override
    public JComponent createComponent(Category ctgr, Lookup lkp) {
        JPanel playPanel = new JPanel(new BorderLayout());
        playPanel.add(new JCheckBox("Enable Play"), BorderLayout.NORTH);
        return playPanel;
    }
 
} 

Looking forward to having a beer with Peter soon (he lives not far away, in Rotterdam) to discuss this! Also read Part 1 of this series, which I wrote some time ago, and which has other ideas and considerations.

© Oracle Blogs or respective owner

Related posts about /NetBeans IDE