Geertjan's Blog

  • March 8, 2009

Getting Started with VisualVM Plugin Facet

Geertjan Wielenga
Product Manager
Not everyone uses NetBeans IDE, but should still be able to extend NetBeans Platform applications, such as Java VisualVM. Here's a first step, getting "VisualVM Plugin" into the IntelliJ New Module dialog (look at the final entry below):

Ultimately, the user will create a new Java project, click the "VisualVM Plugin" checkbox above, and then all the files that define a VisualVM plugin will be added to the Java project (i.e., VisualVM API libraries on the classpath, new entries in the manifest, together with a layer and a module installer, as well as a build.xml that contains targets for creating a NBM file), with some additional Java stubs for some VisualVM API or other.

All this requires the creation of a Facet, which is comparable to a 'perspective' in Eclipse. Once you have that, you need to create a FacetTypeFrameworkSupportProvider and register it in the plugin.xml. Here's how:

package demo1;
import com.intellij.facet.Facet;
import com.intellij.facet.FacetType;
import com.intellij.facet.FacetConfiguration;
import com.intellij.openapi.module.Module;
public class DemoFacet extends Facet {
public DemoFacet(@org.jetbrains.annotations.NotNull FacetType facetType,
@org.jetbrains.annotations.NotNull Module module,
String s, @org.jetbrains.annotations.NotNull FacetConfiguration
facetConfiguration, Facet facet) {
super(facetType, module, s, facetConfiguration, facet);

package demo1;
import com.intellij.facet.FacetConfiguration;
import com.intellij.facet.ui.FacetEditorTab;
import com.intellij.facet.ui.FacetEditorContext;
import com.intellij.facet.ui.FacetValidatorsManager;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import org.jdom.Element;
public class DemoFacetConfiguration implements FacetConfiguration {
public FacetEditorTab[] createEditorTabs(FacetEditorContext
facetEditorContext, FacetValidatorsManager facetValidatorsManager) {
return new FacetEditorTab[0];
public void readExternal(Element element) throws InvalidDataException {
public void writeExternal(Element element) throws WriteExternalException {

Once you have the basic Facet class and the FacetConfiguration class, you can create the FacetType:

package demo1;
import com.intellij.facet.FacetType;
import com.intellij.facet.Facet;
import com.intellij.facet.FacetTypeId;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.JavaModuleType;
import com.intellij.javaee.web.facet.WebFacet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class DemoFacetType extends FacetType<DemoFacet, DemoFacetConfiguration> {
public static final FacetTypeId<DemoFacet> ID = new FacetTypeId("demo");
public static final DemoFacetType INSTANCE = new DemoFacetType();
public DemoFacetType() {
super(ID, "demo", "Demo");
public DemoFacetConfiguration createDefaultConfiguration() {
return new DemoFacetConfiguration();
public DemoFacet createFacet(@NotNull Module module, String name,
@NotNull DemoFacetConfiguration configuration,
@Nullable Facet underlyingFacet) {
return new DemoFacet(this, module, name, configuration, underlyingFacet);
public boolean isSuitableModuleType(ModuleType moduleType) {
return moduleType instanceof JavaModuleType;

Finally, extend FacetTypeFrameworkSupportProvider<DemoFacet> so that the Facet will be displayed in the New Module dialog when the user creates a new Java project:

package demo1;
import com.intellij.ide.util.newProjectWizard.FrameworkSupportProvider;
import com.intellij.facet.impl.ui.FacetTypeFrameworkSupportProvider;
import com.intellij.facet.Facet;
import com.intellij.facet.FacetType;
import com.intellij.openapi.roots.ModifiableRootModel;
public class DemoFacetTypeFrameworkSupportProvider extends
FacetTypeFrameworkSupportProvider<DemoFacet> {
protected DemoFacetTypeFrameworkSupportProvider() {
public String getTitle() {
return "VisualVM Plugin";
protected void setupConfiguration(DemoFacet demoFacet,
ModifiableRootModel modifiableRootModel, String s) {

Fill out the plugin.xml as follows:

<idea-plugin version="2">
<name>Plugin name here</name>
<description>short description of the plugin</description>
<idea-version since-build="8000"/>
<extensions defaultExtensionNs="com.intellij">
<frameworkSupport implementation="demo1.DemoFacetTypeFrameworkSupportProvider"/>

Source structure:

That's it. Now the title is displayed in the New Module dialog. The Facet doesn't do anything yet, but a start has been made.

Join the discussion

Comments ( 4 )
  • Tom Wheeler Monday, March 9, 2009

    There are a lot of people who want a general purpose framework for building Swing applications, but who are not interested in switching IDEs.

    I'm glad to see you make the point that you can achieve this with the NetBeans Platform and IntelliJ IDE. I've also built platform applications while using the Eclipse IDE.

  • Geertjan Wielenga Monday, March 9, 2009

    Thanks Tom! Hopefully at the other end of this blog series we'll be able to use IntelliJ to extend VisualVM (for example).

  • Kris Monday, March 16, 2009


    Please add your site at http://www.sweebs.com. Sweebs.com is a place where other people can find you among the best sites on the internet!

    Its just started and we are collecting the best found on the net! We will be delighted to have you in the sweebs listings.



  • guest Tuesday, October 11, 2011

    FrameworkSupportProvider staff was moved to open api in IDEA 9. The class mentioned by you was renamed to



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