Search in sources :

Example 11 with PortletColumnElement

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

the class LayoutTemplatesFactory method add_Layout_1.

public static void add_Layout_1(LayoutTplElement layoutTpl) {
    PortletLayoutElement row = layoutTpl.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 12 with PortletColumnElement

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

the class LayoutTemplatesFactory method add_Row_2_III.

public static void add_Row_2_III(CanAddPortletLayouts element) {
    PortletLayoutElement row = element.getPortletLayouts().insert();
    PortletColumnElement column1 = row.getPortletColumns().insert();
    PortletColumnElement column2 = row.getPortletColumns().insert();
    if (_isBootstrapStyle(element)) {
        column1.setWeight(8);
        column2.setWeight(4);
    } else {
        column1.setWeight(70);
        column2.setWeight(30);
    }
}
Also used : PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement)

Example 13 with PortletColumnElement

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

the class LayoutTemplatesFactory method add_Layout_2_2.

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

Example 14 with PortletColumnElement

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

the class LayoutTemplatesFactory method add_Layout_1_2_I.

public static void add_Layout_1_2_I(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(4);
        column22.setWeight(8);
    } else {
        column21.setWeight(30);
        column22.setWeight(70);
    }
}
Also used : PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement)

Example 15 with PortletColumnElement

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

the class PortletColumnWeightInitialValueService method compute.

@Override
protected String compute() {
    PortletColumnElement column = (PortletColumnElement) context(Element.class);
    PortletLayoutElement parentLayout = column.nearest(PortletLayoutElement.class);
    LayoutTplElement layoutTpl = column.nearest(LayoutTplElement.class);
    int weightSum = 0;
    ElementList<PortletColumnElement> portletColumns = parentLayout.getPortletColumns();
    for (PortletColumnElement col : portletColumns) {
        if (col != column) {
            Value<Integer> colWeight = col.getWeight();
            Integer colWeightContent = colWeight.content();
            weightSum += colWeightContent.intValue();
        }
    }
    Value<Integer> columnFullWeight = column.getFullWeight();
    Integer fullWeightContent = columnFullWeight.content();
    int fullWeight = fullWeightContent.intValue();
    int initialWeight = layoutTpl.getBootstrapStyle().content() ? 3 : 25;
    if ((weightSum >= 0) && (weightSum < fullWeight)) {
        initialWeight = fullWeight - weightSum;
    } else if (weightSum == fullWeight) {
        /*
			 * the index of last valid column is portletColumns.size() - 2, because
			 * portletColumns().size() -1 is the new inserted column
			 */
        PortletColumnElement lastValidColumn = portletColumns.get(portletColumns.size() - 2);
        Value<Integer> lvColumnWeight = lastValidColumn.getWeight();
        Integer lvWeightContent = lvColumnWeight.content();
        int lastValidWeight = lvWeightContent.intValue();
        if (lastValidWeight > 1) {
            initialWeight = lastValidWeight / 2;
            lastValidWeight = lastValidWeight - initialWeight;
            lastValidColumn.setWeight(lastValidWeight);
        }
    }
    return String.valueOf(initialWeight);
}
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) PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) Element(org.eclipse.sapphire.Element) PortletLayoutElement(com.liferay.ide.layouttpl.core.model.PortletLayoutElement) Value(org.eclipse.sapphire.Value) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement)

Aggregations

PortletColumnElement (com.liferay.ide.layouttpl.core.model.PortletColumnElement)23 PortletLayoutElement (com.liferay.ide.layouttpl.core.model.PortletLayoutElement)18 LayoutTplElement (com.liferay.ide.layouttpl.core.model.LayoutTplElement)9 Test (org.junit.Test)5 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Status (org.eclipse.sapphire.modeling.Status)2 ValidationService (org.eclipse.sapphire.services.ValidationService)2 ColumnFigure (com.liferay.ide.layouttpl.ui.draw2d.ColumnFigure)1 PortletLayoutPanel (com.liferay.ide.layouttpl.ui.draw2d.PortletLayoutPanel)1 List (java.util.List)1 IFile (org.eclipse.core.resources.IFile)1 GridData (org.eclipse.draw2d.GridData)1 GridLayout (org.eclipse.draw2d.GridLayout)1 IFigure (org.eclipse.draw2d.IFigure)1 RoundedRectangle (org.eclipse.draw2d.RoundedRectangle)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 Element (org.eclipse.sapphire.Element)1 ElementList (org.eclipse.sapphire.ElementList)1 Value (org.eclipse.sapphire.Value)1