Search in sources :

Example 16 with GridLayoutManager

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

the class GridLayoutCodeGenerator method generateContainerLayout.

public void generateContainerLayout(final LwContainer lwContainer, final GeneratorAdapter generator, final int componentLocal) {
    if (lwContainer.isGrid()) {
        // arg 0: object
        generator.loadLocal(componentLocal);
        // arg 1: layout
        final GridLayoutManager layout = (GridLayoutManager) lwContainer.getLayout();
        generator.newInstance(myGridLayoutManagerType);
        generator.dup();
        generator.push(layout.getRowCount());
        generator.push(layout.getColumnCount());
        AsmCodeGenerator.pushPropValue(generator, "java.awt.Insets", layout.getMargin());
        generator.push(layout.getHGap());
        generator.push(layout.getVGap());
        generator.push(layout.isSameSizeHorizontally());
        generator.push(layout.isSameSizeVertically());
        generator.invokeConstructor(myGridLayoutManagerType, ourGridLayoutManagerConstructor);
        generator.invokeVirtual(ourContainerType, ourSetLayoutMethod);
    }
}
Also used : GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager)

Example 17 with GridLayoutManager

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

the class GridLayoutSerializer method readLayout.

void readLayout(Element element, LwContainer container) {
    final int rowCount = LwXmlReader.getRequiredInt(element, UIFormXmlConstants.ATTRIBUTE_ROW_COUNT);
    final int columnCount = LwXmlReader.getRequiredInt(element, UIFormXmlConstants.ATTRIBUTE_COLUMN_COUNT);
    final int hGap = LwXmlReader.getOptionalInt(element, UIFormXmlConstants.ATTRIBUTE_HGAP, -1);
    final int vGap = LwXmlReader.getOptionalInt(element, UIFormXmlConstants.ATTRIBUTE_VGAP, -1);
    // attribute is optional for compatibility with IDEA 4.0 forms
    final boolean sameSizeHorizontally = LwXmlReader.getOptionalBoolean(element, UIFormXmlConstants.ATTRIBUTE_SAME_SIZE_HORIZONTALLY, false);
    final boolean sameSizeVertically = LwXmlReader.getOptionalBoolean(element, UIFormXmlConstants.ATTRIBUTE_SAME_SIZE_VERTICALLY, false);
    final Element marginElement = LwXmlReader.getRequiredChild(element, "margin");
    final Insets margin = new Insets(LwXmlReader.getRequiredInt(marginElement, "top"), LwXmlReader.getRequiredInt(marginElement, "left"), LwXmlReader.getRequiredInt(marginElement, "bottom"), LwXmlReader.getRequiredInt(marginElement, "right"));
    final GridLayoutManager layout = new GridLayoutManager(rowCount, columnCount);
    layout.setMargin(margin);
    layout.setVGap(vGap);
    layout.setHGap(hGap);
    layout.setSameSizeHorizontally(sameSizeHorizontally);
    layout.setSameSizeVertically(sameSizeVertically);
    container.setLayout(layout);
}
Also used : GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) Element(org.jdom.Element)

Example 18 with GridLayoutManager

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

the class TemplateParameterStep2 method addParameterComponents.

private int addParameterComponents(final int rowCount, final Set<Parameter> parameters) {
    CellLocation location = new CellLocation();
    myTemplateParameters.removeAll();
    GridLayoutManager layout = new GridLayoutManager(rowCount + 1, COLUMN_COUNT);
    layout.setSameSizeHorizontally(false);
    myTemplateParameters.setLayout(layout);
    for (final Parameter parameter : parameters) {
        addComponents(parameter, location);
    }
    if (location.column > 0) {
        //add spacers before moving to the next row.
        if (location.column < COLUMN_COUNT) {
            addComponent(myTemplateParameters, new Spacer(), location.row, location.column, true);
        }
        location.row++;
    }
    return location.row;
}
Also used : GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) Spacer(com.intellij.uiDesigner.core.Spacer)

Example 19 with GridLayoutManager

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

the class WizardStepHeaderPanel method updateHeader.

private void updateHeader() {
    boolean updateLayout = false;
    if (myTitleLabel == null) {
        myTitleLabel = new JLabel(myTitle);
        updateLayout = true;
    }
    myTitleLabel.setText(myTitle);
    updateLayout |= myDescriptionLabel.updateValue(StringUtil.nullize(myDescription, true)) || myWizardIconComponent.updateValue(myWizardIcon) || myStepIconComponent.updateValue(myStepIcon);
    if (updateLayout) {
        final int rows = myDescriptionLabel.getComponent() == null ? 1 : 2;
        final int columns = 1 + (myWizardIconComponent.getComponent() == null ? 0 : 1) + (myStepIconComponent.getComponent() == null ? 0 : 1);
        for (Component component : getComponents()) {
            remove(component);
        }
        setLayout(new GridLayoutManager(rows, columns, new Insets(18, 0, 12, 0), 2, 2));
        int currentColumn = addIconIfExists(myWizardIconComponent.getComponent(), 0, rows) ? 1 : 0;
        addLabels(myTitleLabel, myDescriptionLabel.getComponent(), currentColumn);
        addIconIfExists(myStepIconComponent.getComponent(), currentColumn + 1, rows);
    }
}
Also used : GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) ImageComponent(com.android.tools.idea.ui.ImageComponent)

Example 20 with GridLayoutManager

use of com.intellij.uiDesigner.core.GridLayoutManager 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

GridLayoutManager (com.intellij.uiDesigner.core.GridLayoutManager)40 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)17 Spacer (com.intellij.uiDesigner.core.Spacer)5 Module (com.intellij.openapi.module.Module)2 JBTextField (com.intellij.ui.components.JBTextField)2 DraggedComponentList (com.intellij.uiDesigner.designSurface.DraggedComponentList)2 GridInsertLocation (com.intellij.uiDesigner.designSurface.GridInsertLocation)2 ComponentItem (com.intellij.uiDesigner.palette.ComponentItem)2 RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)2 XYLayoutManager (com.intellij.uiDesigner.shared.XYLayoutManager)2 Insets (java.awt.Insets)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 AndroidTargetHash.getAddonHashString (com.android.sdklib.AndroidTargetHash.getAddonHashString)1 BuildFileKey (com.android.tools.idea.gradle.parser.BuildFileKey)1 TemplateManager (com.android.tools.idea.templates.TemplateManager)1 TemplateMetadata (com.android.tools.idea.templates.TemplateMetadata)1 ImageComponent (com.android.tools.idea.ui.ImageComponent)1 NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)1 LineMarginBorder (com.intellij.designer.designSurface.feedbacks.LineMarginBorder)1