@Override
 protected StyledDocument createStyledDocument(EditorKit kit) {
   StyledDocument doc = super.createStyledDocument(kit);
   // Enter the file object in to InputAtrributes. It can be used by lexer.
   InputAttributes attributes = new InputAttributes();
   FileObject fileObject = NbEditorUtilities.getFileObject(doc);
   final GsfLanguage lng = language.getGsfLanguage();
   if (lng != null) {
     attributes.setValue(lng.getLexerLanguage(), FileObject.class, fileObject, false);
   }
   doc.putProperty(InputAttributes.class, attributes);
   return doc;
 }
 protected @Override DataObject handleCreateFromTemplate(DataFolder df, String name)
     throws IOException {
   if (name == null
       && language != null
       && language.getGsfLanguage().getPreferredExtension() != null) {
     // special case: name is null (unspecified or from one-parameter createFromTemplate)
     name =
         FileUtil.findFreeFileName(
             df.getPrimaryFile(),
             getPrimaryFile().getName(),
             language.getGsfLanguage().getPreferredExtension());
   }
   //        else if (!language.getGsfLanguage().isIdentifierChar(c)
   // Utilities.isJavaIdentifier(name)) {
   //            throw new IOException (NbBundle.getMessage(GsfDataObject.class,
   // "FMT_Not_Valid_FileName", language.getDisplayName(), name));
   //        }
   // IndentFileEntry entry = (IndentFileEntry)getPrimaryEntry();
   // entry.initializeIndentEngine();
   try {
     templateLanguage = language;
     DataObject retValue = super.handleCreateFromTemplate(df, name);
     FileObject fo = retValue.getPrimaryFile();
     assert fo != null;
     //        ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE);
     //        String pkgName;
     //        if (cp != null) {
     //            pkgName = cp.getResourceName(fo.getParent(),'.',false);
     //        }
     //        else {
     //            pkgName = "";   //NOI18N
     //        }
     //        renameJDO (retValue, pkgName, name, this.getPrimaryFile().getName());
     return retValue;
   } finally {
     templateLanguage = null;
   }
 }