IDEA-336134 Rework implementation of ProjectTemplateExportable through ExportableComponent

GitOrigin-RevId: dda70a261e39833aec8e93fe71ddc75502d37593
This commit is contained in:
Elena Shaverdova
2023-10-24 19:03:51 +02:00
committed by intellij-monorepo-bot
parent 9763d26433
commit 92179ae0ad
2 changed files with 28 additions and 10 deletions

View File

@@ -40,7 +40,6 @@
<projectTemplatesFactory implementation="com.intellij.platform.templates.ArchivedTemplatesFactory"/>
<applicationService serviceImplementation="com.intellij.platform.templates.ProjectTemplateExportable"/>
<exportable serviceInterface="com.intellij.platform.templates.ProjectTemplateExportable"/>
<projectTemplateFileProcessor implementation="com.intellij.platform.templates.SystemFileProcessor"/>
<!-- this depends on TemplateLanguageConfigurable which isn't registered in LangExtensions, so it should go here as well -->

View File

@@ -2,21 +2,40 @@
package com.intellij.platform.templates;
import com.intellij.lang.LangBundle;
import com.intellij.openapi.components.ExportableComponent;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.SettingsCategory;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
public final class ProjectTemplateExportable implements ExportableComponent {
@State(name = "ProjectTemplates",
storages = @Storage(value = "ProjectTemplates.xml", exportable = true),//no non-default state, so won't ever be created
additionalExportDirectory = "projectTemplates",
presentableName = ProjectTemplateExportable.NameGetter.class,
category = SettingsCategory.CODE)
public final class ProjectTemplateExportable implements PersistentStateComponent<ProjectTemplateExportable.ProjectTemplateExportableState> {
@Override
public File @NotNull [] getExportFiles() {
return new File[]{new File(ArchivedTemplatesFactory.getCustomTemplatesPath())};
public @Nullable ProjectTemplateExportable.ProjectTemplateExportableState getState() {
return null;
}
@NotNull
@Override
public String getPresentableName() {
return LangBundle.message("project.template.presentable.name");
public void loadState(@NotNull ProjectTemplateExportableState state) {
//ignore
}
public static class ProjectTemplateExportableState {
}
public static class NameGetter extends State.NameGetter {
@Nls
@Override
public String get() {
return LangBundle.message("project.template.presentable.name");
}
}
}