Method to disable plugin when requirements aren't met

Answered

I have a plugin that only makes sense when working within a specific architecture at my company. If you're working in a different system, it is misleading and annoying. 

 

Is there a way on startup, once I've detected that we're not within the architecture, to shutdown the plugin for that project?

0
8 comments

I'd suggest declaring an application service which will do such check and contain information that conditions are met - and then provide it for the other parts of your plugin.

You may also try to register ProjectManagerListener or ApplicationLoadListener to do such checks

There is a PluginManagerCore.disablePlugin(String id) method available but it may require a restart of the IDE.

0

Would I then need to call out to the application service in all the inspections, toolboxes etc, to see if it's disabled for that project and end the operations if it is?

0

If the condition check result will be performed once and cached, that'd be not a problem.

I assume that such conditions may be fulfilled in the next IDE run or when another project will be opened, right?

0

Yes, it's possible that across the projects opened, some will fulfil the conditions and some won't. Great, I'll implement like that then, thanks.

0

So if conditions are project dependent, use projectService instead of applicationService.

0

I currently have a project component, as per 

 

<project-components>
<component>
<implementation-class>

Should I migrate this to a project service?

0

Plugin components are deprecated now - check our docs about Plugin Components. The proper way of the implementation is linked in my first answer.

0

Cool, I'll do that, thanks.

0

Please sign in to leave a comment.