Idea Plugin Dev - Component


A plugin is made of one of several components.


There are three kinds of components:

  • Application level components: They are created and initialized when your IDE starts up. They can be acquired from the Application instance by using the getComponent(Class) method.
  • Project level components: They are created for each Project instance in the IDE. Components may be created even for unopened projects. They can be acquired from the Project instance by using the getComponent(Class) method.
  • Module level components: They are created for each Module inside every project loaded in the IDE. Module level components can be acquired from a Module instance with the getComponent(Class) method.



Each component has a unique name which is used for its externalization and other internal needs. The name of a component is returned by its getComponentName() method.

Components naming notation: It is recommended to name components in the form <plugin_name>.<component_name>.

Implementation and configuration

See the following article for specific information about the Implementation and configuration of each component:

Every component should have interface and implementation classes:

  • The interface class will be used for retrieving the component from other components
  • The implementation class will be used for component instantiation.
  • Constructor: You should not request any other components using the getComponent() method in the constructor, otherwise you’ll get an assertion. If you need access to other components when initializing your component, you can:
    • specify them as constructor parameters
    • or access them in the initComponent method.

Note that two components of the same level (Application, Project or Module) cannot have the same interface class. The same class may be specified for both interface and Implementation.

Every component should have interface and implementation classes specified in the configuration file.

State / Settings


The state of every component will be automatically saved and loaded if the component’s class implements the:

  • PersistentStateComponent interface, the component state is saved in an XML file that you can specify using the @State and @Storage annotations in your Java code.
  • JDOMExternalizable (deprecated) interface, the components save their state in the following files:
    • Project level components save their state to the project (.ipr) file. However, if the workspace option in the plugin.xml file is set to true, the component saves its configuration to the workspace (.iws) file instead.
    • Module level components save their state to the module (.iml) file.

For more information and samples, refer to Persisting State of Components


  • The defaults (a component’s predefined settings) should be placed in the <component_name>.xml file.
  • Place this file in the plugin’s classpath in the folder corresponding to the default package.
  • The readExternal() method will be called on the <component> root tag. If a component has defaults, the readExternal() method is called twice:
    • The first time for defaults
    • The second time for saved configuration


The components are loaded in the following order:

  • Creation - constructor is invoked.
  • Initialization - the initComponent method is invoked (if the component implements the ApplicationComponent interface).
  • Configuration
    • if the component implements JDOMExternalizable interface, the readExternal method is invoked,
    • if the component implements PersistentStateComponent and has non-default persisted state, the loadState method is invoked.
  • Registration:
    • For module components, the moduleAdded method of the ModuleComponent interface is invoked to notify that a module has been added to the project.
    • For project components, the projectOpened method of the ProjectComponent interface is invoked to notify that a project has been loaded.

The components are unloaded in the following order:

  • Saving configuration
    • if the component implements the JDOMExternalizable interface, the writeExternal method is invoked ,
    • if the component implements PersistentStateComponent, the getState method is invoked.
  • Disposal - the disposeComponent method is invoked.

Documentation / Reference

Powered by ComboStrap