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);
}
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;
}
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);
}
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);
}
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;
}
Aggregations