Search in sources :

Example 21 with GridConstraints

use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.

the class AlignProperty method setValueImpl.

protected void setValueImpl(final RadComponent component, final Integer value) throws Exception {
    int anchorMask = myHorizontal ? 0x0C : 3;
    int fillMask = myHorizontal ? 1 : 2;
    int anchor = 0;
    int fill = 0;
    switch(value.intValue()) {
        case GridConstraints.ALIGN_FILL:
            fill = myHorizontal ? GridConstraints.FILL_HORIZONTAL : GridConstraints.FILL_VERTICAL;
            break;
        case GridConstraints.ALIGN_LEFT:
            anchor = myHorizontal ? GridConstraints.ANCHOR_WEST : GridConstraints.ANCHOR_NORTH;
            break;
        case GridConstraints.ALIGN_RIGHT:
            anchor = myHorizontal ? GridConstraints.ANCHOR_EAST : GridConstraints.ANCHOR_SOUTH;
            break;
    }
    GridConstraints gc = component.getConstraints();
    GridConstraints oldGC = (GridConstraints) gc.clone();
    gc.setAnchor((gc.getAnchor() & ~anchorMask) | anchor);
    gc.setFill((gc.getFill() & ~fillMask) | fill);
    AlignPropertyProvider provider = getAlignPropertyProvider(component);
    if (provider != null) {
        provider.setAlignment(component, myHorizontal, value.intValue());
    }
    component.fireConstraintsChanged(oldGC);
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 22 with GridConstraints

use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.

the class RadFormLayoutManager method gridToCellConstraints.

private static CellConstraints gridToCellConstraints(final RadComponent component) {
    GridConstraints gc = component.getConstraints();
    CellConstraints.Alignment hAlign = ((gc.getHSizePolicy() & GridConstraints.SIZEPOLICY_WANT_GROW) != 0) ? CellConstraints.FILL : CellConstraints.DEFAULT;
    CellConstraints.Alignment vAlign = ((gc.getVSizePolicy() & GridConstraints.SIZEPOLICY_WANT_GROW) != 0) ? CellConstraints.FILL : CellConstraints.DEFAULT;
    if (component.getCustomLayoutConstraints() instanceof CellConstraints) {
        CellConstraints cc = (CellConstraints) component.getCustomLayoutConstraints();
        hAlign = cc.hAlign;
        vAlign = cc.vAlign;
    }
    return new CellConstraints(gc.getColumn() + 1, gc.getRow() + 1, gc.getColSpan(), gc.getRowSpan(), hAlign, vAlign);
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 23 with GridConstraints

use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.

the class RadAbstractGridLayoutManager method moveComponent.

@Override
public void moveComponent(RadComponent c, int rowDelta, int colDelta, final int rowSpanDelta, final int colSpanDelta) {
    GridConstraints constraints = c.getConstraints();
    GridConstraints oldConstraints = (GridConstraints) constraints.clone();
    constraints.setRow(getNewRow(c, rowDelta));
    constraints.setColumn(getNewColumn(c, colDelta));
    constraints.setRowSpan(getNewRowSpan(c, rowSpanDelta));
    constraints.setColSpan(getNewColSpan(c, colSpanDelta));
    c.fireConstraintsChanged(oldConstraints);
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 24 with GridConstraints

use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.

the class RadAbstractGridLayoutManager method getComponentAtGrid.

@Nullable
public static RadComponent getComponentAtGrid(RadContainer container, final int row, final int column) {
    // If the target cell is not empty does not allow drop.
    for (int i = 0; i < container.getComponentCount(); i++) {
        final RadComponent component = container.getComponent(i);
        if (component.isDragging()) {
            continue;
        }
        final GridConstraints constraints = component.getConstraints();
        if (constraints.getRow() <= row && row < constraints.getRow() + constraints.getRowSpan() && constraints.getColumn() <= column && column < constraints.getColumn() + constraints.getColSpan()) {
            return component;
        }
    }
    return null;
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) Nullable(org.jetbrains.annotations.Nullable)

Example 25 with GridConstraints

use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.

the class RadAbstractGridLayoutManager method writeGridConstraints.

protected static void writeGridConstraints(final XmlWriter writer, final RadComponent child) {
    // Constraints in Grid layout
    writer.startElement("grid");
    try {
        final GridConstraints constraints = child.getConstraints();
        writer.addAttribute("row", constraints.getRow());
        writer.addAttribute("column", constraints.getColumn());
        writer.addAttribute("row-span", constraints.getRowSpan());
        writer.addAttribute("col-span", constraints.getColSpan());
        writer.addAttribute("vsize-policy", constraints.getVSizePolicy());
        writer.addAttribute("hsize-policy", constraints.getHSizePolicy());
        writer.addAttribute("anchor", constraints.getAnchor());
        writer.addAttribute("fill", constraints.getFill());
        writer.addAttribute(UIFormXmlConstants.ATTRIBUTE_INDENT, constraints.getIndent());
        writer.addAttribute(UIFormXmlConstants.ATTRIBUTE_USE_PARENT_LAYOUT, constraints.isUseParentLayout());
        // preferred size
        writer.writeDimension(constraints.myMinimumSize, "minimum-size");
        writer.writeDimension(constraints.myPreferredSize, "preferred-size");
        writer.writeDimension(constraints.myMaximumSize, "maximum-size");
    } finally {
        // grid
        writer.endElement();
    }
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

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