Search in sources :

Example 1 with LayoutTplDescriptorHelper

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>"));
}
Also used : IFile(org.eclipse.core.resources.IFile) IWebProject(com.liferay.ide.core.IWebProject) NewLayoutTplDataModelProvider(com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) LayoutTplDescriptorHelper(com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 2 with LayoutTplDescriptorHelper

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>"));
}
Also used : IFile(org.eclipse.core.resources.IFile) IWebProject(com.liferay.ide.core.IWebProject) NewLayoutTplDataModelProvider(com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) LayoutTplDescriptorHelper(com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 3 with LayoutTplDescriptorHelper

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement) LayoutTplDescriptorHelper(com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper)

Example 4 with LayoutTplDescriptorHelper

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>"));
}
Also used : IFile(org.eclipse.core.resources.IFile) IWebProject(com.liferay.ide.core.IWebProject) NewLayoutTplDataModelProvider(com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) LayoutTplDescriptorHelper(com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Aggregations

LayoutTplDescriptorHelper (com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper)4 IFile (org.eclipse.core.resources.IFile)4 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)4 IWebProject (com.liferay.ide.core.IWebProject)3 NewLayoutTplDataModelProvider (com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider)3 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)3 IFolder (org.eclipse.core.resources.IFolder)3 IProject (org.eclipse.core.resources.IProject)3 Test (org.junit.Test)3 LayoutTplElement (com.liferay.ide.layouttpl.core.model.LayoutTplElement)1 IOException (java.io.IOException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1