コード例 #1
0
  /**
   * @param templateInfo may not be null
   * @throws TemplateInitializationException
   */
  protected TemplateCore(TemplateInfo templateInfo) throws TemplateInitializationException {
    this.templateInfo = templateInfo;
    URL descriptorURL;
    try {
      descriptorURL =
          TemplateEngineHelper.getTemplateResourceURL(
              templateInfo.getPluginId(), templateInfo.getTemplatePath());
    } catch (IOException ioe) {
      String msg =
          MessageFormat.format(
              TemplateEngineMessages.getString("TemplateCore.InitFailed"),
              new Object[] {templateInfo.getTemplatePath()}); // $NON-NLS-1$
      throw new TemplateInitializationException(msg);
    }
    if (descriptorURL == null)
      throw new TemplateInitializationException(
          "Unable to load project template. Location URL is null for "
              + templateInfo.getTemplateId()); // $NON-NLS-1$
    templateDescriptor = new TemplateDescriptor(descriptorURL, templateInfo.getPluginId());
    valueStore = new ValueStore<String>(this);
    valueStore.putAll(templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement()));
    valueStore.putAll(TemplateEngine.getSharedDefaults());
    valueStore.put("projectType", templateInfo.getProjectType()); // $NON-NLS-1$

    processHandler = new TemplateProcessHandler(this);
    allMacrosInProcesses = processHandler.getAllMacros();

    fireDirtyEvents = true;
  }
 private ITemplateDesc addConfig(final IConfigurationElement element) {
   if (element.getName().equals(CodeGeneratorTemplatesRegistry.ATTR_TEMPLATE)) {
     final TemplateDescriptor desc = new TemplateDescriptor(element);
     if (!this.templateMap.containsKey(desc.getId())) {
       this.templateMap.put(desc.getId(), desc);
       final String lang = desc.getCodegenId();
       Set<String> ids = this.codegenToIdMap.get(lang);
       if (ids == null) {
         ids = new HashSet<String>();
         this.codegenToIdMap.put(lang, ids);
       }
       ids.add(desc.getId());
       return desc;
     } else {
       RedhawkCodegenActivator.logError(
           "Duplicate Code Generator registered with an ID of: " + desc.getId(), null);
     }
   }
   return null;
 }
コード例 #3
0
 /** @return String, which contains the Label */
 public String getLabel() {
   if (label == null) {
     label = templateDescriptor.getRootElement().getAttribute(LABEL).trim();
   }
   return TemplateEngineHelper.externalizeTemplateString(templateInfo, label);
 }
コード例 #4
0
 /** @return String, which contains the id of the template */
 public String getTemplateType() {
   if (templateType == null) {
     templateType = templateDescriptor.getRootElement().getAttribute(TYPE).trim();
   }
   return templateType;
 }
コード例 #5
0
 /** @return String, which contains the id of the template */
 public String getTemplateId() {
   if (templateId == null) {
     templateId = templateDescriptor.getRootElement().getAttribute(ID).trim();
   }
   return templateId;
 }
コード例 #6
0
 /** @return String, which contains the description */
 public String getDescription() {
   if (description == null) {
     description = templateDescriptor.getRootElement().getAttribute(DESCRIPTION).trim();
   }
   return TemplateEngineHelper.externalizeTemplateString(templateInfo, description);
 }
コード例 #7
0
 /**
  * This is the List of IDs from TemplateDescriptor with "attribute" Persist as "true"
  *
  * @return Vector of IDs.
  */
 public List<String> getPersistTrueIDs() {
   return templateDescriptor.getPersistTrueIDs();
 }