/** * @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; }
@Override public String put(K key, String value) { value = TemplateEngineHelper.externalizeTemplateString(template.getTemplateInfo(), value); String v = super.put(key, value); template.setDirty(); return v; }
@Override public void putAll(Map<? extends K, ? extends String> map) { for (K key : map.keySet()) { String value = map.get(key); value = TemplateEngineHelper.externalizeTemplateString(template.getTemplateInfo(), value); super.put(key, value); } template.setDirty(); }
/** @return String, which contains the Label */ public String getLabel() { if (label == null) { label = templateDescriptor.getRootElement().getAttribute(LABEL).trim(); } return TemplateEngineHelper.externalizeTemplateString(templateInfo, label); }
/** @return String, which contains the description */ public String getDescription() { if (description == null) { description = templateDescriptor.getRootElement().getAttribute(DESCRIPTION).trim(); } return TemplateEngineHelper.externalizeTemplateString(templateInfo, description); }