void () { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { try { final String newFileNameWithExtension = newFileName.endsWith('.' + fileType.getDefaultExtension()) ? newFileName : newFileName + '.' + fileType.getDefaultExtension(); final VirtualFile file = parentDirectory.createChildData(this, newFileNameWithExtension); VfsUtil.saveText(file, initialContent != null ? initialContent : ""); updateTree(); select(file, null); } catch (IOException e) { failReason[0] = e; } } }); }