Search in sources :

Example 16 with LayoutTplElement

use of com.liferay.ide.layouttpl.core.model.LayoutTplElement in project liferay-ide by liferay.

the class LayoutTplTestsBootstrap method testPorteltColumnWeightValidationService.

@Test
public void testPorteltColumnWeightValidationService() {
    final LayoutTplElement layoutTpl = LayoutTplElement.TYPE.instantiate();
    layoutTpl.setBootstrapStyle(true);
    final PortletLayoutElement row = layoutTpl.getPortletLayouts().insert();
    final PortletColumnElement column = row.getPortletColumns().insert();
    final ValidationService validationService = column.getWeight().service(ValidationService.class);
    column.setWeight(0);
    assertEquals("The weight value is invalid, should be in (0, 12]", validationService.validation().message());
    column.setWeight(-1);
    assertEquals("The weight value is invalid, should be in (0, 12]", validationService.validation().message());
    column.setWeight(13);
    assertEquals("The weight value is invalid, should be in (0, 12]", validationService.validation().message());
    column.setWeight(6);
    assertEquals("ok", validationService.validation().message());
}
Also used : PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) ValidationService(org.eclipse.sapphire.services.ValidationService) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement) Test(org.junit.Test)

Example 17 with LayoutTplElement

use of com.liferay.ide.layouttpl.core.model.LayoutTplElement in project liferay-ide by liferay.

the class LayoutTplTestsBootstrap method testPortletColumnsValidationSerive.

// test sum of column weights
@Test
public void testPortletColumnsValidationSerive() {
    final LayoutTplElement layoutTpl = LayoutTplElement.TYPE.instantiate();
    layoutTpl.setBootstrapStyle(true);
    final PortletLayoutElement row = layoutTpl.getPortletLayouts().insert();
    final ElementList<PortletColumnElement> columns = row.getPortletColumns();
    final PortletColumnElement column = columns.insert();
    final ValidationService validationService = columns.service(ValidationService.class);
    assertEquals("ok", validationService.validation().message());
    column.setWeight(0);
    assertEquals("The sum of weight of columns should be: 12", validationService.validation().message());
    column.setWeight(-1);
    assertEquals("The sum of weight of columns should be: 12", validationService.validation().message());
    column.setWeight(6);
    assertEquals("The sum of weight of columns should be: 12", validationService.validation().message());
    column.setWeight(13);
    assertEquals("The sum of weight of columns should be: 12", validationService.validation().message());
    column.setWeight(12);
    assertEquals("ok", validationService.validation().message());
}
Also used : PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) ValidationService(org.eclipse.sapphire.services.ValidationService) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement) Test(org.junit.Test)

Example 18 with LayoutTplElement

use of com.liferay.ide.layouttpl.core.model.LayoutTplElement in project liferay-ide by liferay.

the class LayoutTplTestsBootstrap method evalTemplateFromChangedModel_1_3_2_nest_columns.

@Test
public void evalTemplateFromChangedModel_1_3_2_nest_columns() throws Exception {
    IFile refTplFile = getFileFromTplName("1_3_2_nest_changed_columns.tpl");
    final String className = convertToTplClassName("1_3_2_nest_changed_columns.tpl");
    final LayoutTplElement layoutTpl = createModel_132_nest(isBootstrapStyle(), className, is62());
    final PortletLayoutElement row1 = (PortletLayoutElement) layoutTpl.getPortletLayouts().get(0);
    final PortletLayoutElement row2 = (PortletLayoutElement) layoutTpl.getPortletLayouts().get(1);
    final PortletLayoutElement row3 = (PortletLayoutElement) layoutTpl.getPortletLayouts().get(2);
    final PortletLayoutElement row311 = row3.getPortletColumns().get(0).getPortletLayouts().get(0);
    final PortletLayoutElement row312 = row3.getPortletColumns().get(0).getPortletLayouts().get(1);
    final PortletLayoutElement row31221 = row312.getPortletColumns().get(1).getPortletLayouts().get(0);
    row1.getPortletColumns().remove(row1.getPortletColumns().get(0));
    layoutTpl.getPortletLayouts().remove(row1);
    PortletColumnElement insertedColumn = row311.getPortletColumns().insert();
    insertedColumn.setWeight(3);
    row311.getPortletColumns().get(0).setWeight(9);
    row2.getPortletColumns().remove(row2.getPortletColumns().get(0));
    row2.getPortletColumns().get(0).setWeight(8);
    insertedColumn = row31221.getPortletColumns().insert();
    insertedColumn.setWeight(2);
    row31221.getPortletColumns().get(0).setWeight(10);
    evalModelWithFile(refTplFile, layoutTpl);
}
Also used : IFile(org.eclipse.core.resources.IFile) PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement) Test(org.junit.Test)

Example 19 with LayoutTplElement

use of com.liferay.ide.layouttpl.core.model.LayoutTplElement in project liferay-ide by liferay.

the class LayoutTplTestsBootstrap method testPortletLayoutClassNameDefaultValueService.

@Test
public void testPortletLayoutClassNameDefaultValueService() throws Exception {
    final LayoutTplElement layoutTpl = LayoutTplElement.TYPE.instantiate();
    layoutTpl.setBootstrapStyle(true);
    layoutTpl.setIs62(true);
    final PortletLayoutElement row = layoutTpl.getPortletLayouts().insert();
    assertEquals("portlet-layout row-fluid", row.getClassName().content(true));
}
Also used : PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement) Test(org.junit.Test)

Example 20 with LayoutTplElement

use of com.liferay.ide.layouttpl.core.model.LayoutTplElement in project liferay-ide by liferay.

the class LayoutTplTestsBootstrap method testPortletColumnFullWeightDefaultValueService.

@Test
public void testPortletColumnFullWeightDefaultValueService() throws Exception {
    final LayoutTplElement layoutTpl = LayoutTplElement.TYPE.instantiate();
    layoutTpl.setBootstrapStyle(true);
    final PortletColumnElement column = layoutTpl.getPortletLayouts().insert().getPortletColumns().insert();
    assertEquals(12, column.getFullWeight().content(true).intValue());
}
Also used : PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement) Test(org.junit.Test)

Aggregations

LayoutTplElement (com.liferay.ide.layouttpl.core.model.LayoutTplElement)21 PortletColumnElement (com.liferay.ide.layouttpl.core.model.PortletColumnElement)10 PortletLayoutElement (com.liferay.ide.layouttpl.core.model.PortletLayoutElement)9 Test (org.junit.Test)7 IFile (org.eclipse.core.resources.IFile)5 Element (org.eclipse.sapphire.Element)3 Status (org.eclipse.sapphire.modeling.Status)2 ValidationService (org.eclipse.sapphire.services.ValidationService)2 LayoutTplDescriptorHelper (com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper)1 IOException (java.io.IOException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Event (org.eclipse.sapphire.Event)1 Listener (org.eclipse.sapphire.Listener)1 Property (org.eclipse.sapphire.Property)1 Value (org.eclipse.sapphire.Value)1 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)1 IModelStateListener (org.eclipse.wst.sse.core.internal.provisional.IModelStateListener)1