Search in sources :

Example 1 with ITemplateContext

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());
}
Also used : ArrayStack(org.apache.commons.collections.ArrayStack) ITemplateContext(com.liferay.ide.core.templates.ITemplateContext)

Example 2 with ITemplateContext

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);
    }
}
Also used : ITemplateOperation(com.liferay.ide.core.templates.ITemplateOperation) ByteArrayInputStream(java.io.ByteArrayInputStream) FormatProcessorXML(org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML) ITemplateContext(com.liferay.ide.core.templates.ITemplateContext) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

ITemplateContext (com.liferay.ide.core.templates.ITemplateContext)2 ITemplateOperation (com.liferay.ide.core.templates.ITemplateOperation)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayStack (org.apache.commons.collections.ArrayStack)1 CoreException (org.eclipse.core.runtime.CoreException)1 FormatProcessorXML (org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML)1