IDEA-129351 Cannot restore deleted live template
[idea/community.git] / platform / lang-impl / src / com / intellij / codeInsight / template / impl / TemplateListPanel.java
index 9a7a724e2d5d21a8199d45794d97af7e573cb6f2..1c0b72a5a454cf8f501c59358b94b5a5c16aae9e 100644 (file)
@@ -19,6 +19,7 @@ package com.intellij.codeInsight.template.impl;
 import com.intellij.application.options.ExportSchemeAction;
 import com.intellij.application.options.SchemesToImportPopup;
 import com.intellij.codeInsight.CodeInsightBundle;
+import com.intellij.icons.AllIcons;
 import com.intellij.ide.DataManager;
 import com.intellij.ide.dnd.*;
 import com.intellij.ide.dnd.aware.DnDAwareTree;
@@ -690,6 +691,17 @@ public class TemplateListPanel extends JPanel implements Disposable {
         public void updateButton(AnActionEvent e) {
           e.getPresentation().setEnabled(getTemplate(getSingleSelectedIndex()) != null);
         }
+      }).addExtraAction(new AnActionButton("Restore deleted defaults", AllIcons.General.TodoDefault) {
+        @Override
+        public void actionPerformed(@NotNull AnActionEvent e) {
+          TemplateSettings.getInstance().reset();
+          reset();
+        }
+
+        @Override
+        public boolean isEnabled() {
+          return super.isEnabled() && !TemplateSettings.getInstance().getDeletedTemplates().isEmpty();
+        }
       });
     if (getSchemesManager().isExportAvailable()) {
       decorator.addExtraAction(new AnActionButton("Share...", PlatformIcons.EXPORT_ICON) {