use of com.liferay.ide.layouttpl.ui.draw2d.PortletLayoutPanel 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.ui.draw2d.PortletLayoutPanel in project liferay-ide by liferay.
the class PortletLayoutEditPart method createFigure.
@Override
protected IFigure createFigure() {
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.horizontalSpacing = COLUMN_SPACING;
gridLayout.marginHeight = 0;
gridLayout.verticalSpacing = 0;
layoutPanel = new PortletLayoutPanel();
layoutPanel.setOpaque(true);
layoutPanel.setBorder(new MarginBorder(LAYOUT_MARGIN));
layoutPanel.setBackgroundColor(new Color(null, 171, 171, 171));
layoutPanel.setLayoutManager(gridLayout);
return layoutPanel;
}
Aggregations