private void onClone() {
    try {
      editor.apply();
    }
    catch (ConfigurationException ignore) {
    }

    FileTemplate selected = getSelectedTemplate();
    if (selected == null) {
      return;
    }

    List<FileTemplate> templates = currentTab.getTemplates();
    Set<String> names = new HashSet<>(templates.size());
    for (FileTemplate template : templates) {
      names.add(template.getName());
    }
    @SuppressWarnings("UnresolvedPropertyKey")
    final String nameTemplate = IdeBundle.message("template.copy.N.of.T");

    String name = FileTemplateBase.isChild(selected) && selected instanceof FileTemplateBase 
                  ? ((FileTemplateBase)selected).getChildName(selected.getChildren().length)
                  : MessageFormat.format(nameTemplate, "", selected.getName());
    int i = 0;
    while (names.contains(name)) {
      name = MessageFormat.format(nameTemplate, ++i + " ", selected.getName());
    }
    final FileTemplateBase newTemplate = new CustomFileTemplate(name, selected.getExtension());
    newTemplate.setText(selected.getText());
    newTemplate.setFileName(selected.getFileName());
    newTemplate.setReformatCode(selected.isReformatCode());
    newTemplate.setLiveTemplateEnabled(selected.isLiveTemplateEnabled());
    newTemplate.setChildren(ContainerUtil.map2Array(selected.getChildren(), FileTemplate.class, template -> template.clone()));
    newTemplate.updateChildrenNames();
    currentTab.addTemplate(newTemplate);
    for (FileTemplate child : newTemplate.getChildren()) {
      currentTab.addTemplate(child);
    }
    isModified = true;
    currentTab.selectTemplate(newTemplate);
    fireListChanged();
  }
private void onClone()