Search in sources :

Example 11 with GridConstraints

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;
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) Element(org.jdom.Element)

Example 12 with GridConstraints

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());
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 13 with GridConstraints

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;
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 14 with GridConstraints

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;
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 15 with GridConstraints

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();
    }
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) ArrayList(java.util.ArrayList) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Aggregations

GridConstraints (com.intellij.uiDesigner.core.GridConstraints)73 GridLayoutManager (com.intellij.uiDesigner.core.GridLayoutManager)17 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)14 Spacer (com.intellij.uiDesigner.core.Spacer)6 RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)5 ComponentItem (com.intellij.uiDesigner.palette.ComponentItem)3 CellConstraints (com.jgoodies.forms.layout.CellConstraints)3 ArrayList (java.util.ArrayList)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 JBLabel (com.intellij.ui.components.JBLabel)2 JBTextField (com.intellij.ui.components.JBTextField)2 GuiEditor (com.intellij.uiDesigner.designSurface.GuiEditor)2 IComponent (com.intellij.uiDesigner.lw.IComponent)2 Palette (com.intellij.uiDesigner.palette.Palette)2 QuickFix (com.intellij.uiDesigner.quickFixes.QuickFix)2 RadAbstractGridLayoutManager (com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager)2 RadRootContainer (com.intellij.uiDesigner.radComponents.RadRootContainer)2 XYLayoutManager (com.intellij.uiDesigner.shared.XYLayoutManager)2 IncorrectOperationException (com.intellij.util.IncorrectOperationException)2 Element (org.jdom.Element)2