use of com.liferay.ide.layouttpl.core.model.PortletColumnElement in project liferay-ide by liferay.
the class PortletColumnEditPart method createFigureForModel.
protected Figure createFigureForModel() {
if (getModel() instanceof PortletColumnElement) {
RoundedRectangle rect = new ColumnFigure();
rect.setCornerDimensions(new Dimension(10, 10));
return rect;
} else {
throw new IllegalArgumentException();
}
}
use of com.liferay.ide.layouttpl.core.model.PortletColumnElement in project liferay-ide by liferay.
the class PortletLayoutEditPart method refreshVisuals.
@Override
@SuppressWarnings("rawtypes")
protected void refreshVisuals() {
super.refreshVisuals();
GridData gd = createGridData();
((GraphicalEditPart) getParent()).setLayoutConstraint(this, layoutPanel, gd);
List rows = getParent().getChildren();
if (rows.size() == 1) {
layoutPanel.setTop(true);
layoutPanel.setBottom(true);
} else if (equals(rows.get(0))) {
layoutPanel.setTop(true);
layoutPanel.setBottom(false);
} else if (equals(rows.get(rows.size() - 1))) {
layoutPanel.setTop(false);
layoutPanel.setBottom(true);
} else {
layoutPanel.setTop(false);
layoutPanel.setBottom(false);
}
PortletLayoutPanel panel = getCastedFigure();
GridLayout gridLayout = (GridLayout) panel.getLayoutManager();
List columns = getChildren();
int numColumns = columns.size();
if (numColumns > 0) {
/*
* get width of our own part to calculate new width this method is
* invoked recursively, so it's complicated to compute the very
* exact width, sometimes minus 2 times of margin causes sidelines
* cannot be shown, minus 3 times of margin looks better
*/
IFigure parentFigure = getFigure().getParent();
Dimension size = parentFigure.getSize();
int rowWidth = size.width - (PortletLayoutEditPart.LAYOUT_MARGIN * 3);
if (rowWidth > 0) {
for (Object col : columns) {
PortletColumnEditPart portletColumnPart = (PortletColumnEditPart) col;
PortletColumnElement column = (PortletColumnElement) portletColumnPart.getModel();
GridData rowData = portletColumnPart.createGridData();
Value<Integer> weight = column.getWeight();
Integer weightValue = weight.content();
Value<Integer> fullWeight = column.getFullWeight();
Integer fullWeightValue = fullWeight.content();
double percent = weightValue.doubleValue() / fullWeightValue.doubleValue();
int standardRowWidth = (int) (percent * rowWidth);
rowData.widthHint = standardRowWidth - COLUMN_SPACING * 2;
IFigure columnFigure = portletColumnPart.getFigure();
columnFigure.setSize(rowData.widthHint, columnFigure.getSize().height);
/*
* this.setLayoutConstraint( portletColumnPart,
* columnFigure, rowData );
*/
portletColumnPart.refresh();
}
}
gridLayout.numColumns = numColumns;
getFigure().repaint();
}
}
use of com.liferay.ide.layouttpl.core.model.PortletColumnElement 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;
}
use of com.liferay.ide.layouttpl.core.model.PortletColumnElement in project liferay-ide by liferay.
the class PortletColumnsValidtionSerivce method dispose.
@Override
public void dispose() {
for (PortletColumnElement column : _columnsAttachedListener) {
if ((column != null) && !column.disposed()) {
column.detach(_listener);
}
}
_listener = null;
super.dispose();
}
use of com.liferay.ide.layouttpl.core.model.PortletColumnElement 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);
}
Aggregations