Set Default Facet and Add Options in Wizard

I've added framework support for my Facet that I've created so you can check the frameworks box in the project wizard and it will add the framework to the project. However I can't figure out how to add the settings panel below the additional frameworks box in the project wizard. I would also like to make the facet checked by default for that particular module I'm using.

Here's a screenshot of the spring module with the default facet selected and with the options displayed below the additional frameworks so you can get a better idea of what I'm talking about. I've looked through a bunch of other plugins, but I'm having a hard time finding an example.

Screen Shot 2015-06-30 at 7.10.42 AM.png

1 comment
Comment actions Permalink

I figured out how to do this. In addition to created a class that extends FrameworkSupportProvider you also need to add a FrameworkSupportConfigurable class.

The class looks like this.

public class MyrameworkSupportConfigurable extends FrameworkSupportConfigurable {
    MyFrameworkSupportConfigurablePanel myFrameworkSupportConfigurablePanel;

    public DWFrameworkSupportConfigurable(FrameworkSupportModel model) {
        // This line enabled the framework by default
        model.setFrameworkComponentEnabled("myFrameworkID", true);

        myFrameworkSupportConfigurablePanel = new MyFrameworkSupportConfigurablePanel();
    }

    @Nullable
    @Override
    public JComponent getComponent() {
        return MyFrameworkSupportConfigurablePanel.createPanel();
    }

    @Override
    public void addSupport(@NotNull Module module, @NotNull ModifiableRootModel modifiableRootModel, @Nullable Library library) {
        final FacetManager facetManager = FacetManager.getInstance(module);
        ModifiableFacetModel facetModel = facetManager.createModifiableModel();

        // UI Stuff with your JComponent, Settings updates... 

        Facet facet = FacetManager.getInstance(modifiableRootModel.getModule()).addFacet(MyFacetType.INSTANCE, "FacetTypeID", null);
        facetModel.addFacet(facet);
        facetModel.commit();
    }
}


In your FrameworkSupportProvider overide the following method

 
@NotNull
@Override
public FrameworkSupportConfigurable createConfigurable(@NotNull FrameworkSupportModel model) {
    return new MyFrameworkSupportConfigurable(model);
}
0

Please sign in to leave a comment.