Question

How can I override the default service implementation of, say, FrameTitleBuilder in my intellij plugin?

I am using IntelliJ 12.1.4, I have set up the environment properly for building plugins.

Now I have tried adding this to my plugin.xml in a fresh plugin project:

<extensions defaultExtensionNs="com.intellij">
    <applicationService serviceInterface="com.intellij.openapi.wm.impl.FrameTitleBuilder"
         serviceImplementation="com.my.package.MyFrameTitleBuilder"
         overrides="com.intellij.openapi.wm.impl.FrameTitleBuilder"
     />
</extensions>

However it fails like this:

org.picocontainer.defaults.DuplicateComponentKeyRegistrationException: Key com.intellij.openapi.wm.impl.FrameTitleBuilder duplicated

Can anyone offer some tips please?

Thank you very much in advance!!

Was it helpful?

Solution

The "overrides" attribute is a boolean (In IntelliJ 13 anyway), set it to true and the old Implementation will be removed first

<extensions defaultExtensionNs="com.intellij">
    <applicationService 
         serviceInterface="com.intellij.openapi.wm.impl.FrameTitleBuilder"
         serviceImplementation="com.my.package.MyFrameTitleBuilder"
         overrides="true" />
 </extensions>

OTHER TIPS

Since I couldn't find a way in the plugin.xml to make my plugin override the service implementation, I had to "replace" it manually via PicoContainer.

Take ApplicationManager.getApplication().getPicoContainer() and cast it to MutablePicoContainer and you are then able to unregister / reregister a component.

I'd still like to know the proper format for doing this via the plugin.xml, if possible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top