Search in sources :

Example 31 with GridConstraints

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

the class FormLayoutCodeGenerator method addNewCellConstraints.

private static void addNewCellConstraints(final GeneratorAdapter generator, final LwComponent lwComponent) {
    final GridConstraints constraints = lwComponent.getConstraints();
    final CellConstraints cc = (CellConstraints) lwComponent.getCustomLayoutConstraints();
    generator.newInstance(ourCellConstraintsType);
    generator.dup();
    generator.push(constraints.getColumn() + 1);
    generator.push(constraints.getRow() + 1);
    generator.push(constraints.getColSpan());
    generator.push(constraints.getRowSpan());
    if (cc.hAlign == CellConstraints.DEFAULT) {
        generator.getStatic(ourCellConstraintsType, "DEFAULT", ourCellAlignmentType);
    } else {
        int hAlign = Utils.alignFromConstraints(constraints, true);
        generator.getStatic(ourCellConstraintsType, HORZ_ALIGN_FIELDS[hAlign], ourCellAlignmentType);
    }
    if (cc.vAlign == CellConstraints.DEFAULT) {
        generator.getStatic(ourCellConstraintsType, "DEFAULT", ourCellAlignmentType);
    } else {
        int vAlign = Utils.alignFromConstraints(constraints, false);
        generator.getStatic(ourCellConstraintsType, VERT_ALIGN_FIELDS[vAlign], ourCellAlignmentType);
    }
    AsmCodeGenerator.pushPropValue(generator, Insets.class.getName(), cc.insets);
    generator.invokeConstructor(ourCellConstraintsType, ourCellConstraintsConstructor);
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 32 with GridConstraints

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

the class GridBagConverter method prepareConstraints.

public static void prepareConstraints(final LwContainer container, final Map idToConstraintsMap) {
    GridLayoutManager gridLayout = (GridLayoutManager) container.getLayout();
    GridBagConverter converter = new GridBagConverter(gridLayout.getMargin(), getGap(container, true), getGap(container, false), gridLayout.isSameSizeHorizontally(), gridLayout.isSameSizeVertically());
    for (int i = 0; i < container.getComponentCount(); i++) {
        final LwComponent component = (LwComponent) container.getComponent(i);
        if (component instanceof LwHSpacer || component instanceof LwVSpacer) {
            GridConstraints constraints = component.getConstraints().store();
            constraints.setHSizePolicy(constraints.getHSizePolicy() & ~GridConstraints.SIZEPOLICY_WANT_GROW);
            constraints.setVSizePolicy(constraints.getVSizePolicy() & ~GridConstraints.SIZEPOLICY_WANT_GROW);
            converter.addComponent(null, constraints);
        } else {
            converter.addComponent(null, component.getConstraints());
        }
    }
    Result[] results = converter.convert();
    int componentIndex = 0;
    for (int i = 0; i < results.length; i++) {
        if (!results[i].isFillerPanel) {
            final LwComponent component = (LwComponent) container.getComponent(componentIndex++);
            idToConstraintsMap.put(component.getId(), results[i]);
        }
    // else generateFillerPanel(generator, componentLocal, results [i]);
    }
}
Also used : GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 33 with GridConstraints

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

the class GridLayoutCodeGenerator method addNewGridConstraints.

private static void addNewGridConstraints(final GeneratorAdapter generator, final LwComponent lwComponent) {
    final GridConstraints constraints = lwComponent.getConstraints();
    generator.newInstance(myGridConstraintsType);
    generator.dup();
    generator.push(constraints.getRow());
    generator.push(constraints.getColumn());
    generator.push(constraints.getRowSpan());
    generator.push(constraints.getColSpan());
    generator.push(constraints.getAnchor());
    generator.push(constraints.getFill());
    generator.push(constraints.getHSizePolicy());
    generator.push(constraints.getVSizePolicy());
    newDimensionOrNull(generator, constraints.myMinimumSize);
    newDimensionOrNull(generator, constraints.myPreferredSize);
    newDimensionOrNull(generator, constraints.myMaximumSize);
    if (constraints.isUseParentLayout()) {
        generator.push(constraints.getIndent());
        generator.push(constraints.isUseParentLayout());
        generator.invokeConstructor(myGridConstraintsType, myInitConstraintsIndentParentMethod);
    } else if (constraints.getIndent() != 0) {
        generator.push(constraints.getIndent());
        generator.invokeConstructor(myGridConstraintsType, myInitConstraintsIndentMethod);
    } else {
        generator.invokeConstructor(myGridConstraintsType, myInitConstraintsMethod);
    }
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 34 with GridConstraints

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

the class DartGeneratorPeer method startLoadingTemplates.

private void startLoadingTemplates() {
    myLoadingTemplatesPanel.setVisible(true);
    myLoadingTemplatesPanel.setPreferredSize(myLoadedTemplatesPanel.getPreferredSize());
    myLoadedTemplatesPanel.setVisible(false);
    // until loaded
    myCreateSampleProjectCheckBox.setSelected(false);
    final AsyncProcessIcon asyncProcessIcon = new AsyncProcessIcon("Dart project templates loading");
    // defaults are ok: row = 0, column = 0
    myLoadingTemplatesPanel.add(asyncProcessIcon, new GridConstraints());
    asyncProcessIcon.resume();
    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        final String sdkPath = mySdkPathComboWithBrowse.getComboBox().getEditor().getItem().toString().trim();
        DartProjectTemplate.loadTemplatesAsync(sdkPath, templates -> {
            asyncProcessIcon.suspend();
            Disposer.dispose(asyncProcessIcon);
            onTemplatesLoaded(templates);
        });
    });
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon)

Example 35 with GridConstraints

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

the class InspectorPanelTest method findComponents.

@NotNull
private static Multimap<Integer, Component> findComponents(@NotNull InspectorPanel inspector) {
    Multimap<Integer, Component> components = ArrayListMultimap.create();
    JPanel panel = (JPanel) inspector.getComponent(0);
    GridLayoutManager layout = (GridLayoutManager) panel.getLayout();
    for (Component component : panel.getComponents()) {
        GridConstraints constraints = layout.getConstraintsForComponent(component);
        int row = constraints.getRow();
        components.put(row, component);
    }
    return components;
}
Also used : GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) NotNull(org.jetbrains.annotations.NotNull)

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