Facets

I have some  questions about facets. Perhaps you can answer them:

1) Where is the best place to register the facet? I used to do that in the plugin.xml under extensions, but it is not recognised anymore since v9. Is my ApplicationComponent the right place using: FacetTypeRegistry.getInstance().registerFacetType(ClickFacetType.INSTANCE);?

2) For my facet I need to create and/or read an XML file in the WEB-INF directory of the WebFacet. How do I find the right directory to create the file in? I have WebFacet as the parent facet.

3) When the user decides to add the facet to his module, when is the right time to create the file mentioned in question #2? Does the facet have some first time initialization point?

Cheers!

WarnerJan

4 comments
Comment actions Permalink

Hello,

I have some  questions about facets. Perhaps you can answer them:

1) Where is the best place to register the facet? I used to do that in the plugin.xml under extensions, but it is not recognised anymore since v9. Is my ApplicationComponent the right place using: FacetTypeRegistry.getInstance().registerFacetType(ClickFacetType.INSTANCE);?

As described in JavaDoc for FacetType the best place to register the facet is plugin.xml. Why do you think what it isn't recognised in v9?

2) For my facet I need to create and/or read an XML file in the WEB-INF directory of the WebFacet. How do I find the right directory to create the file in? I have WebFacet as the parent facet.

You can use webFacet.getWebXmlDescriptor().getVirtualFile() to get location of web.xml. Most likely it will be located in WEB-INF directory. If not
you can examine Web Resource directories by using webFacet.getWebRoots() method.

3) When the user decides to add the facet to his module, when is the right time to create the file mentioned in question #2? Does the facet have some first time initialization point?

If facet is created from FrameworkSupportProvider you can create any additional files in addSupport method. If facet is created in Project Structure
dialog you can override FacetEditorTab#onFacetInitialized method for this (use FacetEditorContext#isNewFacet to check that FacetEditorTab belongs to
just created facet).

--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Thanks for the answers.

1) The xml-tag <facetType.../> is not recognised. See attached screenie.
notes3.png
2) I will look into that.

3) For those of your reading along, your support class needs to extend from com.intellij.openapi.facet.ui.FacetBasedFrameworkSupportProvider in order to find the method addSupport(...)

Cheers all!

WarnerJan

0
Comment actions Permalink

Regarding 2: looks like it's a problem with error highlighting in plugin.xml.

Thanks for the answers.

1) The xml-tag <facetType.../> is not recognised. See attached screenie.
Image:notes3.png
2) I will look into that.

3) For those of your reading along, your support class needs to extend from com.intellij.openapi.facet.ui.FacetBasedFrameworkSupportProvider in order to find the method addSupport(...)

Cheers all!

WarnerJan

---
Original message URL: http://www.jetbrains.net/devnet/message/5252135#5252135



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Perhaps more than that. facetType is not in the list of suggestions when typing the opening bracket <

0

Please sign in to leave a comment.