use of com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper in project liferay-ide by liferay.
the class NewLiferayPluginProjectOp625Tests method testNewLayoutAntProject.
@Override
@Test
public void testNewLayoutAntProject() throws Exception {
if (shouldSkipBundleTests())
return;
String projectName = "test-layouttpl-project-sdk";
NewLiferayPluginProjectOp op = newProjectOp(projectName);
op.setPluginType(PluginType.layouttpl);
IProject layouttplProject = createAntProject(op);
IFolder webappRoot = LiferayCore.create(IWebProject.class, layouttplProject).getDefaultDocrootFolder();
assertNotNull(webappRoot);
IFile layoutXml = webappRoot.getFile("WEB-INF/liferay-layout-templates.xml");
assertEquals(true, layoutXml.exists());
IFile wapTpl = webappRoot.getFile("test_layouttpl_project_sdk_6.2.5.wap.tpl");
assertTrue(wapTpl.exists());
IDataModel model = DataModelFactory.createDataModel(new NewLayoutTplDataModelProvider());
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_ID, "newtemplate");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_NAME, "New Template");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_THUMBNAIL_FILE, "/newtemplate.png");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_WAP_TEMPLATE_FILE, "/newtemplate.wap.tpl");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_FILE, "/newtemplate.tpl");
LayoutTplDescriptorHelper layoutHelper = new LayoutTplDescriptorHelper(layouttplProject);
layoutHelper.addNewLayoutTemplate(model);
String contents = CoreUtil.readStreamToString(layoutXml.getContents(true));
assertTrue(contents.contains("<wap-template-path>"));
}
use of com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper in project liferay-ide by liferay.
the class NewLiferayPluginProjectOp7sp3Tests method testNewLayoutAntProject.
@Override
@Test
public void testNewLayoutAntProject() throws Exception {
String projectName = "test-layouttpl-project-sdk";
NewLiferayPluginProjectOp op = newProjectOp(projectName);
op.setPluginType(PluginType.layouttpl);
IProject layouttplProject = createAntProject(op);
IFolder webappRoot = LiferayCore.create(IWebProject.class, layouttplProject).getDefaultDocrootFolder();
assertNotNull(webappRoot);
IFile layoutXml = webappRoot.getFile("WEB-INF/liferay-layout-templates.xml");
assertEquals(true, layoutXml.exists());
IFile wapTpl = webappRoot.getFile("test_layouttpl_project_sdk_7.0.2.wap.tpl");
assertFalse(wapTpl.exists());
IDataModel model = DataModelFactory.createDataModel(new NewLayoutTplDataModelProvider());
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_ID, "newtemplate");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_NAME, "New Template");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_THUMBNAIL_FILE, "/newtemplate.png");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_WAP_TEMPLATE_FILE, "/newtemplate.wap.tpl");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_FILE, "/newtemplate.tpl");
LayoutTplDescriptorHelper layoutHelper = new LayoutTplDescriptorHelper(layouttplProject);
layoutHelper.addNewLayoutTemplate(model);
String contents = CoreUtil.readStreamToString(layoutXml.getContents(true));
assertFalse(contents.contains("<wap-template-path>"));
}
use of com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper in project liferay-ide by liferay.
the class AddLayoutTplOperation method execute.
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
IStatus retval = null;
IDataModel dm = getDataModel();
String diagramClassName = dm.getStringProperty(LAYOUT_TEMPLATE_ID);
LayoutTplElement diagramModel = createLayoutTplDigram(dm, _isBootstrapStyle(), _is62(), diagramClassName);
try {
IFile templateFile = null;
String templateFileName = getDataModel().getStringProperty(LAYOUT_TEMPLATE_FILE);
if (!CoreUtil.isNullOrEmpty(templateFileName)) {
templateFile = createTemplateFile(templateFileName, diagramModel);
}
getDataModel().setProperty(LAYOUT_TPL_FILE_CREATED, templateFile);
String wapTemplateFileName = getDataModel().getStringProperty(LAYOUT_WAP_TEMPLATE_FILE);
diagramModel.setClassName(diagramClassName + ".wap");
if (!CoreUtil.isNullOrEmpty(wapTemplateFileName) && _is62()) {
createTemplateFile(wapTemplateFileName, diagramModel);
}
String thumbnailFileName = getDataModel().getStringProperty(LAYOUT_THUMBNAIL_FILE);
if (!CoreUtil.isNullOrEmpty(thumbnailFileName)) {
createThumbnailFile(thumbnailFileName);
}
} catch (CoreException ce) {
LayoutTplUI.logError(ce);
return LayoutTplUI.createErrorStatus(ce);
} catch (IOException ioe) {
LayoutTplUI.logError(ioe);
return LayoutTplUI.createErrorStatus(ioe);
}
LayoutTplDescriptorHelper layoutTplDescHelper = new LayoutTplDescriptorHelper(getTargetProject());
retval = layoutTplDescHelper.addNewLayoutTemplate(dm);
return retval;
}
use of com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper in project liferay-ide by liferay.
the class NewLiferayPluginProjectOp701Tests method testNewLayoutAntProject.
@Override
@Test
public void testNewLayoutAntProject() throws Exception {
String projectName = "test-layouttpl-project-sdk";
NewLiferayPluginProjectOp op = newProjectOp(projectName);
op.setPluginType(PluginType.layouttpl);
IProject layouttplProject = createAntProject(op);
IFolder webappRoot = LiferayCore.create(IWebProject.class, layouttplProject).getDefaultDocrootFolder();
assertNotNull(webappRoot);
IFile layoutXml = webappRoot.getFile("WEB-INF/liferay-layout-templates.xml");
assertEquals(true, layoutXml.exists());
IFile wapTpl = webappRoot.getFile("test_layouttpl_project_sdk_7.0.2.wap.tpl");
assertFalse(wapTpl.exists());
IDataModel model = DataModelFactory.createDataModel(new NewLayoutTplDataModelProvider());
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_ID, "newtemplate");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_NAME, "New Template");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_THUMBNAIL_FILE, "/newtemplate.png");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_WAP_TEMPLATE_FILE, "/newtemplate.wap.tpl");
model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_FILE, "/newtemplate.tpl");
LayoutTplDescriptorHelper layoutHelper = new LayoutTplDescriptorHelper(layouttplProject);
layoutHelper.addNewLayoutTemplate(model);
String contents = CoreUtil.readStreamToString(layoutXml.getContents(true));
assertFalse(contents.contains("<wap-template-path>"));
}
Aggregations