public void duplicateSelectedTemplate() {
    TreePath path = getSelectionModel().getSelectionPath();
    Object lastPathComponent = path.getLastPathComponent();
    if (lastPathComponent instanceof PostfixTemplateCheckedTreeNode) {
      PostfixTemplate template = ((PostfixTemplateCheckedTreeNode)lastPathComponent).getTemplate();
      PostfixTemplateProvider provider = ((PostfixTemplateCheckedTreeNode)lastPathComponent).getTemplateProvider();
      String languageId = getProvidersToLanguages().get(provider);
      if (isEditable(template) && languageId != null) {
        PostfixTemplate templateToEdit = template instanceof PostfixChangedBuiltinTemplate
                                         ? ((PostfixChangedBuiltinTemplate)template).getDelegate()
                                         : template;
        PostfixTemplateEditor editor = provider.createEditor(templateToEdit);
        if (editor == null) return;

        String providerName = StringUtil.notNullize(provider.getPresentableName());
        PostfixEditTemplateDialog dialog = new PostfixEditTemplateDialog(this, editor, providerName, templateToEdit);
        if (dialog.showAndGet()) {
          String templateKey = dialog.getTemplateName();
          PostfixTemplate newTemplate = editor.createTemplate(PostfixTemplatesUtils.generateTemplateId(templateKey, provider), templateKey);
          PostfixTemplateCheckedTreeNode createdNode = new PostfixTemplateCheckedTreeNode(newTemplate, provider, true);
          DefaultMutableTreeNode languageNode = findOrCreateLanguageNode(languageId);
          languageNode.insert(createdNode, languageNode.getIndex((PostfixTemplateCheckedTreeNode)lastPathComponent) + 1);
          myModel.nodeStructureChanged(languageNode);
          TreeUtil.selectNode(this, createdNode);
        }
      }
    }
  }
public void duplicateSelectedTemplate()