Search in sources :

Example 11 with LayoutTplElement

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

the class PortletColumnsListener method handleTypedEvent.

@Override
protected void handleTypedEvent(PropertyContentEvent event) {
    Property property = event.property();
    Element element = property.element();
    LayoutTplElement layouttpl = element.nearest(LayoutTplElement.class);
    updateColumns(layouttpl, 1);
}
Also used : LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) Element(org.eclipse.sapphire.Element) PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) Property(org.eclipse.sapphire.Property) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement)

Example 12 with LayoutTplElement

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

the class PortletColumnsValidtionSerivce method compute.

// store PortletColumns who have attached the listener
@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    PortletLayoutElement portletLayout = context(PortletLayoutElement.class);
    LayoutTplElement layoutTpl = portletLayout.nearest(LayoutTplElement.class);
    int actualWeightSum = 0;
    int exceptedweightSum = layoutTpl.getBootstrapStyle().content() ? 12 : 100;
    for (PortletColumnElement col : portletLayout.getPortletColumns()) {
        /*
			 * attach listener for the newly added PortletColumn there should be a better
			 * way to do this which makes more sense
			 */
        if (!_columnsAttachedListener.contains(col)) {
            col.getWeight().attach(_listener);
            _columnsAttachedListener.add(col);
        }
        Value<Integer> weight = col.getWeight();
        Integer content = weight.content();
        actualWeightSum += content.intValue();
    }
    if (!((actualWeightSum == exceptedweightSum) || ((exceptedweightSum == 100) && (actualWeightSum == 99)))) {
        retval = Status.createErrorStatus("The sum of weight of columns should be: " + exceptedweightSum);
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement)

Example 13 with LayoutTplElement

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

the class LayoutTplCoreTests method evalTemplateFromFile_0_columns.

@Test
public void evalTemplateFromFile_0_columns() throws Exception {
    IFile refTplFile = getFileFromTplName("0_columns.tpl");
    LayoutTplElement layoutTpl = LayoutTplElement.TYPE.instantiate();
    layoutTpl.setClassName(convertToTplClassName("0_columns.tpl"));
    layoutTpl.setBootstrapStyle(isBootstrapStyle());
    layoutTpl.setIs62(is62());
    evalModelWithFile(refTplFile, layoutTpl);
}
Also used : IFile(org.eclipse.core.resources.IFile) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement) Test(org.junit.Test)

Example 14 with LayoutTplElement

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

the class LayoutTplCoreTests method evalTemplateFromFile.

protected void evalTemplateFromFile(String tplName) throws Exception {
    IFile tplFile = getFileFromTplName(tplName);
    LayoutTplElement layoutTpl = LayoutTplElementsFactory.INSTANCE.newLayoutTplFromFile(tplFile, isBootstrapStyle(), is62());
    evalModelWithFile(tplFile, layoutTpl);
}
Also used : IFile(org.eclipse.core.resources.IFile) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement)

Example 15 with LayoutTplElement

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

the class LayoutTplTestsBootstrap method createModel_132_nest.

protected LayoutTplElement createModel_132_nest(boolean isBootstrapStyle, String className, boolean is62) {
    final LayoutTplElement layoutTpl = LayoutTplElement.TYPE.instantiate();
    layoutTpl.setBootstrapStyle(isBootstrapStyle);
    layoutTpl.setClassName(className);
    layoutTpl.setIs62(is62);
    final PortletLayoutElement row1 = layoutTpl.getPortletLayouts().insert();
    final PortletColumnElement column11 = row1.getPortletColumns().insert();
    column11.setWeight(12);
    final PortletLayoutElement row2 = layoutTpl.getPortletLayouts().insert();
    final PortletColumnElement column21 = row2.getPortletColumns().insert();
    column21.setWeight(4);
    final PortletColumnElement column22 = row2.getPortletColumns().insert();
    column22.setWeight(4);
    final PortletColumnElement column23 = row2.getPortletColumns().insert();
    column23.setWeight(4);
    final PortletLayoutElement row3 = layoutTpl.getPortletLayouts().insert();
    final PortletColumnElement column31 = row3.getPortletColumns().insert();
    column31.setWeight(8);
    final PortletLayoutElement row311 = column31.getPortletLayouts().insert();
    final PortletColumnElement column3111 = row311.getPortletColumns().insert();
    column3111.setWeight(12);
    final PortletLayoutElement row312 = column31.getPortletLayouts().insert();
    final PortletColumnElement column3121 = row312.getPortletColumns().insert();
    column3121.setWeight(6);
    final PortletColumnElement column3122 = row312.getPortletColumns().insert();
    column3122.setWeight(6);
    final PortletLayoutElement row31221 = column3122.getPortletLayouts().insert();
    final PortletColumnElement column312211 = row31221.getPortletColumns().insert();
    column312211.setWeight(12);
    final PortletColumnElement column32 = row3.getPortletColumns().insert();
    column32.setWeight(4);
    return layoutTpl;
}
Also used : PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement)

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