Wednesday Oct 17, 2012

Play in NetBeans IDE (Part 2)

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.

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
« October 2012 »
SunMonTueWedThuFriSat
 
1
2
3
21
   
       
Today