@Nullable protected DomElement createElement(final T context, final Editor editor, final PsiFile file, final Project project, PsiClass selectedClass) { final Map<String,String> map = new HashMap<String, String>(); map.put("CLASS_NAME", selectedClass.getQualifiedName()); new WriteCommandAction.Simple(project, file) { @Override protected void run() throws Throwable { DomTemplateRunner.getInstance(project).runTemplate(createElement(context), myTemplate, editor, map); } }.execute(); return null; }