예제 #1
0
 private boolean setTemplate(final TemplateToken token, TemplateImpl template) {
   if (template == null) {
     template = myGenerator.createTemplateByKey(token.getKey());
   }
   if (template == null) {
     return false;
   }
   return doSetTemplate(token, template, myCallback);
 }
예제 #2
0
 public static boolean doSetTemplate(
     final TemplateToken token, TemplateImpl template, CustomTemplateCallback callback) {
   token.setTemplate(template);
   final XmlFile xmlFile = parseXmlFileInTemplate(template.getString(), callback, true);
   token.setFile(xmlFile);
   XmlDocument document = xmlFile.getDocument();
   final XmlTag tag = document != null ? document.getRootTag() : null;
   if (token.getAttribute2Value().size() > 0 && tag == null) {
     return false;
   }
   if (tag != null) {
     if (!containsAttrsVar(template) && token.getAttribute2Value().size() > 0) {
       ApplicationManager.getApplication()
           .runWriteAction(
               new Runnable() {
                 public void run() {
                   addMissingAttributes(tag, token.getAttribute2Value());
                 }
               });
     }
   }
   return true;
 }