use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.
the class Palette method processDefaultConstraintsElement.
/**
* Helper method.
*/
private static GridConstraints processDefaultConstraintsElement(@NotNull final Element element) {
final GridConstraints constraints = new GridConstraints();
// grid related attributes
constraints.setVSizePolicy(LwXmlReader.getRequiredInt(element, ATTRIBUTE_VSIZE_POLICY));
constraints.setHSizePolicy(LwXmlReader.getRequiredInt(element, ATTRIBUTE_HSIZE_POLICY));
constraints.setAnchor(LwXmlReader.getRequiredInt(element, ATTRIBUTE_ANCHOR));
constraints.setFill(LwXmlReader.getRequiredInt(element, ATTRIBUTE_FILL));
// minimum size
final Element minSizeElement = element.getChild(ELEMENT_MINIMUM_SIZE);
if (minSizeElement != null) {
constraints.myMinimumSize.width = LwXmlReader.getRequiredInt(minSizeElement, ATTRIBUTE_WIDTH);
constraints.myMinimumSize.height = LwXmlReader.getRequiredInt(minSizeElement, ATTRIBUTE_HEIGHT);
}
// preferred size
final Element prefSizeElement = element.getChild(ELEMENT_PREFERRED_SIZE);
if (prefSizeElement != null) {
constraints.myPreferredSize.width = LwXmlReader.getRequiredInt(prefSizeElement, ATTRIBUTE_WIDTH);
constraints.myPreferredSize.height = LwXmlReader.getRequiredInt(prefSizeElement, ATTRIBUTE_HEIGHT);
}
// maximum size
final Element maxSizeElement = element.getChild(ELEMENT_MAXIMUM_SIZE);
if (maxSizeElement != null) {
constraints.myMaximumSize.width = LwXmlReader.getRequiredInt(maxSizeElement, ATTRIBUTE_WIDTH);
constraints.myMaximumSize.height = LwXmlReader.getRequiredInt(maxSizeElement, ATTRIBUTE_HEIGHT);
}
return constraints;
}
use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.
the class GridChangeUtilTest method assertComponentCellAndSpan.
private static void assertComponentCellAndSpan(final RadContainer grid, final int idx, final int cell, final int span) {
final GridConstraints constraints = grid.getComponent(idx).getConstraints();
assertEquals(cell, constraints.getColumn());
assertEquals(span, constraints.getColSpan());
}
use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.
the class RadFormLayoutManagerTest method newComponent.
private RadComponent newComponent(final int row, final int column, final int rowSpan, final int colSpan) {
RadComponent c = new RadAtomicComponent(null, JLabel.class, "1");
c.setCustomLayoutConstraints(new CellConstraints(1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT));
c.getConstraints().restore(new GridConstraints(row, column, rowSpan, colSpan, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null));
return c;
}
use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.
the class DuplicateComponentsAction method isSpaceBelowEmpty.
private static boolean isSpaceBelowEmpty(final RadComponent component, boolean incrementRow) {
final GridConstraints constraints = component.getConstraints();
int startRow = constraints.getCell(incrementRow) + constraints.getSpan(incrementRow);
int endRow = constraints.getCell(incrementRow) + constraints.getSpan(incrementRow) * 2 + component.getParent().getGridLayoutManager().getGapCellCount();
if (endRow > component.getParent().getGridCellCount(incrementRow)) {
return false;
}
for (int row = startRow; row < endRow; row++) {
for (int col = constraints.getCell(!incrementRow); col < constraints.getCell(!incrementRow) + constraints.getSpan(!incrementRow); col++) {
if (component.getParent().getComponentAtGrid(incrementRow, row, col) != null) {
return false;
}
}
}
return true;
}
use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.
the class FlattenAction method flattenGrid.
private static void flattenGrid(final RadContainer container) {
RadContainer parent = container.getParent();
GridConstraints containerConstraints = (GridConstraints) container.getConstraints().clone();
// ensure there will be enough rows and columns to fit the container contents
for (int i = containerConstraints.getRowSpan(); i < container.getGridRowCount(); i++) {
GridChangeUtil.splitRow(parent, containerConstraints.getRow());
}
for (int i = containerConstraints.getColSpan(); i < container.getGridColumnCount(); i++) {
GridChangeUtil.splitColumn(parent, containerConstraints.getColumn());
}
ArrayList<RadComponent> contents = new ArrayList<>();
for (int i = container.getComponentCount() - 1; i >= 0; i--) {
contents.add(0, container.getComponent(i));
container.removeComponent(container.getComponent(i));
}
if (contents.size() == 1) {
contents.get(0).setCustomLayoutConstraints(container.getCustomLayoutConstraints());
}
FormEditingUtil.deleteComponents(Collections.singletonList(container), false);
for (RadComponent child : contents) {
final GridConstraints childConstraints = child.getConstraints();
childConstraints.setRow(childConstraints.getRow() + containerConstraints.getRow());
childConstraints.setColumn(childConstraints.getColumn() + containerConstraints.getColumn());
parent.addComponent(child);
child.revalidate();
}
}
Aggregations