Search in sources :

Example 1 with NewLayoutTplDataModelProvider

use of com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider in project liferay-ide by liferay.

the class NewLayoutTplWizard method getDefaultProvider.

@Override
protected IDataModelProvider getDefaultProvider() {
    LayoutTplUI defaultUI = LayoutTplUI.getDefault();
    TemplateStore templateStore = defaultUI.getTemplateStore();
    ContextTypeRegistry contextTypeRegistry = defaultUI.getTemplateContextRegistry();
    TemplateContextType contextType = contextTypeRegistry.getContextType(LayoutTplTemplateContextTypeIds.NEW);
    return new NewLayoutTplDataModelProvider() {

        @Override
        public IDataModelOperation getDefaultOperation() {
            return new AddLayoutTplOperation(getDataModel(), templateStore, contextType);
        }
    };
}
Also used : NewLayoutTplDataModelProvider(com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider) LayoutTplUI(com.liferay.ide.layouttpl.ui.LayoutTplUI) ContextTypeRegistry(org.eclipse.jface.text.templates.ContextTypeRegistry) TemplateStore(org.eclipse.jface.text.templates.persistence.TemplateStore) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType)

Example 2 with NewLayoutTplDataModelProvider

use of com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider 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 3 with NewLayoutTplDataModelProvider

use of com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider 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 4 with NewLayoutTplDataModelProvider

use of com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider 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

NewLayoutTplDataModelProvider (com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider)4 IWebProject (com.liferay.ide.core.IWebProject)3 LayoutTplDescriptorHelper (com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper)3 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)3 IFile (org.eclipse.core.resources.IFile)3 IFolder (org.eclipse.core.resources.IFolder)3 IProject (org.eclipse.core.resources.IProject)3 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)3 Test (org.junit.Test)3 LayoutTplUI (com.liferay.ide.layouttpl.ui.LayoutTplUI)1 ContextTypeRegistry (org.eclipse.jface.text.templates.ContextTypeRegistry)1 TemplateContextType (org.eclipse.jface.text.templates.TemplateContextType)1 TemplateStore (org.eclipse.jface.text.templates.persistence.TemplateStore)1