use of com.liferay.ide.core.templates.ITemplateOperation in project liferay-ide by liferay.
the class LayoutTplUtil method getTemplateSource.
public static String getTemplateSource(LayoutTplElement layouttpl) {
StringBuffer buffer = new StringBuffer();
try {
ITemplateOperation templateOperation = null;
if (layouttpl.getBootstrapStyle().content()) {
templateOperation = TemplatesCore.getTemplateOperation("com.liferay.ide.layouttpl.core.layoutTemplate.bootstrap");
} else {
templateOperation = TemplatesCore.getTemplateOperation("com.liferay.ide.layouttpl.core.layoutTemplate.legacy");
}
_createLayoutTplContext(templateOperation, layouttpl);
templateOperation.setOutputBuffer(buffer);
templateOperation.execute(new NullProgressMonitor());
} catch (Exception ex) {
LayoutTplCore.logError("Error getting template source.", ex);
}
return buffer.toString();
}
use of com.liferay.ide.core.templates.ITemplateOperation in project liferay-ide by liferay.
the class LayoutTplUtil method saveToFile.
public static void saveToFile(LayoutTplElement diagramElement, IFile file, IProgressMonitor monitor) {
try {
ITemplateOperation op = null;
if (diagramElement.getBootstrapStyle().content()) {
op = TemplatesCore.getTemplateOperation("com.liferay.ide.layouttpl.core.layoutTemplate.bootstrap");
} else {
op = TemplatesCore.getTemplateOperation("com.liferay.ide.layouttpl.core.layoutTemplate.legacy");
}
_createLayoutTplContext(op, diagramElement);
op.setOutputFile(file);
op.execute(monitor);
} catch (Exception e) {
LayoutTplCore.logError(e);
}
}
use of com.liferay.ide.core.templates.ITemplateOperation 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