Why I cannot persist plugin settings (project scope)?


I've created custom PropertiesComponent based on PropertiesComponentImpl.

The differences:

name = "TaskTimer",
storages = {@Storage(StoragePathMacros.WORKSPACE_FILE)}

above class declaraton and:

public void setTogglToken(String token) {
this.setValue("ttoken", token);

public String getTogglToken() {
return this.getValue("ttoken");

public void setTogglProject(String name) {
this.setValue("tproject", name);

public String getTogglProject() {
return this.getValue("tproject");

public String getComponentName() {
return "TaskTimer";

inside class. That's all differences from example implementation.


My Configurable implementation:


private final TaskTimerPropertiesComponent properties = new TaskTimerPropertiesComponent();

public void apply() throws ConfigurationException {

but in createComponent() method getters returns always nulls, so it seems that those values weren't persisted after closing settings window.


What am I doing wrong here?

Comment actions Permalink

`TaskTimerPropertiesComponent` must be registered as a service.

<projectService serviceImplementation="yourPackage.TaskTimerPropertiesComponent"/>

and instead `new`, add `getInstance` method to your class

public static PropertiesComponent getInstance(Project project) {
return ServiceManager.getService(project, TaskTimerPropertiesComponent.class);

Comment actions Permalink

Thanks, one more question how to get Project object in Configurable class for loading PropertiesComponent? (createComponent method exactly)


Please sign in to leave a comment.