Search in sources :

Example 1 with PortletLayoutElement

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

the class PortletColumnsListener method updateColumns.

protected int updateColumns(CanAddPortletLayouts columnsParent, int numId) {
    for (PortletLayoutElement portletLayout : columnsParent.getPortletLayouts()) {
        ElementList<PortletColumnElement> columns = portletLayout.getPortletColumns();
        int size = columns.size();
        for (int i = 0; i < size; i++) {
            PortletColumnElement column = columns.get(i);
            if (column.getPortletLayouts().size() == 0) {
                column.setNumId(String.valueOf(numId++));
            } else if (column.getPortletLayouts().size() > 0) {
                // when new child is added, the parent column will have no numId
                column.setNumId("N/A");
                numId = updateColumns(column, numId++);
            }
            column.setOnly(false);
            column.setFirst(false);
            column.setLast(false);
            column.setColumnDescriptor("");
            column.setColumnContentDescriptor("");
            if (size == 1) {
                column.setOnly(true);
                column.setColumnDescriptor("portlet-column-only");
                column.setColumnContentDescriptor("portlet-column-content-only");
            } else if (size > 1) {
                if (i == 0) {
                    column.setFirst(true);
                    column.setColumnDescriptor("portlet-column-first");
                    column.setColumnContentDescriptor("portlet-column-content-first");
                } else if (i == (size - 1)) {
                    column.setLast(true);
                    column.setColumnDescriptor("portlet-column-last");
                    column.setColumnContentDescriptor("portlet-column-content-last");
                }
            }
        }
    }
    return numId;
}
Also used : PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement)

Example 2 with PortletLayoutElement

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

the class LayoutTemplatesFactory method add_Row_2_I.

public static void add_Row_2_I(CanAddPortletLayouts element) {
    PortletLayoutElement row = element.getPortletLayouts().insert();
    PortletColumnElement column1 = row.getPortletColumns().insert();
    PortletColumnElement column2 = row.getPortletColumns().insert();
    int fullWeight = column1.getFullWeight().content();
    column1.setWeight(fullWeight / 2);
    column2.setWeight(fullWeight / 2);
}
Also used : PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement)

Example 3 with PortletLayoutElement

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

the class LayoutTemplatesFactory method add_Layout_1_2_1.

public static void add_Layout_1_2_1(LayoutTplElement layoutTpl) {
    PortletLayoutElement row1 = layoutTpl.getPortletLayouts().insert();
    PortletColumnElement column11 = row1.getPortletColumns().insert();
    int fullWeight = column11.getFullWeight().content();
    column11.setWeight(fullWeight);
    PortletLayoutElement row2 = layoutTpl.getPortletLayouts().insert();
    PortletColumnElement column21 = row2.getPortletColumns().insert();
    column21.setWeight(fullWeight / 2);
    PortletColumnElement column22 = row2.getPortletColumns().insert();
    column22.setWeight(fullWeight / 2);
    PortletLayoutElement row3 = layoutTpl.getPortletLayouts().insert();
    PortletColumnElement column31 = row3.getPortletColumns().insert();
    column31.setWeight(fullWeight);
}
Also used : PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement)

Example 4 with PortletLayoutElement

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

the class LayoutTemplatesFactory method add_Row_1.

public static void add_Row_1(CanAddPortletLayouts element) {
    PortletLayoutElement row = element.getPortletLayouts().insert();
    PortletColumnElement column = row.getPortletColumns().insert();
    column.setWeight(column.getFullWeight().content());
}
Also used : PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement)

Example 5 with PortletLayoutElement

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

the class LayoutTemplatesFactory method add_Layout_1_2_II.

public static void add_Layout_1_2_II(LayoutTplElement layoutTpl) {
    PortletLayoutElement row1 = layoutTpl.getPortletLayouts().insert();
    PortletColumnElement column11 = row1.getPortletColumns().insert();
    column11.setWeight(column11.getFullWeight().content());
    PortletLayoutElement row2 = layoutTpl.getPortletLayouts().insert();
    PortletColumnElement column21 = row2.getPortletColumns().insert();
    PortletColumnElement column22 = row2.getPortletColumns().insert();
    if (_isBootstrapStyle(layoutTpl)) {
        column21.setWeight(8);
        column22.setWeight(4);
    } else {
        column21.setWeight(70);
        column22.setWeight(30);
    }
}
Also used : PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement)

Aggregations

PortletLayoutElement (com.liferay.ide.layouttpl.core.model.PortletLayoutElement)19 PortletColumnElement (com.liferay.ide.layouttpl.core.model.PortletColumnElement)18 LayoutTplElement (com.liferay.ide.layouttpl.core.model.LayoutTplElement)8 Test (org.junit.Test)5 ValidationService (org.eclipse.sapphire.services.ValidationService)2 IFile (org.eclipse.core.resources.IFile)1 Element (org.eclipse.sapphire.Element)1 Value (org.eclipse.sapphire.Value)1 Status (org.eclipse.sapphire.modeling.Status)1