use of com.liferay.ide.core.templates.ITemplateContext in project liferay-ide by liferay.
the class LayoutTplUtil method _createLayoutTplContext.
private static void _createLayoutTplContext(ITemplateOperation op, LayoutTplElement layouttpl) {
ITemplateContext ctx = op.getContext();
ctx.put("root", layouttpl);
ctx.put("stack", new ArrayStack());
}
use of com.liferay.ide.core.templates.ITemplateContext in project liferay-ide by liferay.
the class WizardUtil method createDefaultServiceBuilderFile.
public static void createDefaultServiceBuilderFile(IFile serviceBuilderFile, String descriptorVersion, boolean useSampleTemplate, String packagePath, String namespace, Object author, IProgressMonitor monitor) throws CoreException {
ITemplateOperation templateOp = null;
if (useSampleTemplate) {
templateOp = TemplatesCore.getTemplateOperation("com.liferay.ide.service.core.defaultServiceXmlFile");
} else {
templateOp = TemplatesCore.getTemplateOperation("com.liferay.ide.service.core.emptyServiceXmlFile");
}
ITemplateContext context = templateOp.getContext();
context.put("version", descriptorVersion);
context.put("version_", descriptorVersion.replace('.', '_'));
context.put("package_path", packagePath);
context.put("namespace", namespace);
context.put("author", author);
try {
StringBuffer sb = new StringBuffer();
templateOp.setOutputBuffer(sb);
templateOp.execute(monitor);
CoreUtil.prepareFolder((IFolder) serviceBuilderFile.getParent());
serviceBuilderFile.create(new ByteArrayInputStream(sb.toString().getBytes("UTF-8")), IResource.FORCE, null);
FormatProcessorXML processor = new FormatProcessorXML();
processor.formatFile(serviceBuilderFile);
} catch (Exception e) {
ProjectCore.logError(e);
}
}
Aggregations