Search in sources :

Example 46 with GridConstraints

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

the class ModuleImportSettingsPane method createGridConstraints.

private GridConstraints createGridConstraints(boolean grab, int columnSpan) {
    GridConstraints gridConstraints = new GridConstraints();
    gridConstraints.setRow(componentNumber / COLUMN_COUNT);
    final int column = componentNumber % COLUMN_COUNT;
    gridConstraints.setColumn(column);
    if (grab) {
        gridConstraints.setHSizePolicy(GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_WANT_GROW);
    }
    gridConstraints.setFill(GridConstraints.FILL_HORIZONTAL);
    gridConstraints.setColSpan(columnSpan);
    componentNumber += columnSpan;
    return gridConstraints;
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 47 with GridConstraints

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

the class ConfigureFormFactorStep method populateAdditionalFormFactors.

private void populateAdditionalFormFactors() {
    TemplateManager manager = TemplateManager.getInstance();
    List<File> applicationTemplates = manager.getTemplatesInCategory(Template.CATEGORY_APPLICATION);
    myFormFactors.clear();
    myFormFactorPanel.removeAll();
    int row = 0;
    for (File templateFile : applicationTemplates) {
        TemplateMetadata metadata = manager.getTemplateMetadata(templateFile);
        if (metadata == null || metadata.getFormFactor() == null) {
            continue;
        }
        FormFactor formFactor = FormFactor.get(metadata.getFormFactor());
        if (formFactor == FormFactor.GLASS && !AndroidSdkUtils.isGlassInstalled()) {
            // Only show Glass if you've already installed the SDK
            continue;
        }
        Integer prevMinSdk = myFormFactors.get(formFactor);
        int templateMinSdk = metadata.getMinSdk();
        if (prevMinSdk == null) {
            myFormFactors.put(formFactor, Math.max(templateMinSdk, formFactor.getMinOfflineApiLevel()));
        } else if (templateMinSdk > prevMinSdk) {
            myFormFactors.put(formFactor, templateMinSdk);
        }
    }
    // One row for each form factor
    GridLayoutManager gridLayoutManager = new GridLayoutManager(myFormFactors.size(), 1);
    gridLayoutManager.setVGap(5);
    gridLayoutManager.setHGap(10);
    myFormFactorPanel.setLayout(gridLayoutManager);
    for (final FormFactor formFactor : myFormFactors.keySet()) {
        GridConstraints c = new GridConstraints();
        c.setRow(row);
        c.setColumn(0);
        c.setFill(GridConstraints.FILL_HORIZONTAL);
        c.setAnchor(GridConstraints.ANCHOR_WEST);
        FormFactorSdkControls controls = new FormFactorSdkControls(formFactor, myFormFactors.get(formFactor), myDisposable, this);
        myControls.add(controls);
        myFormFactorPanel.add(controls.getComponent(), c);
        myFormFactorApiSelectors.put(formFactor, controls);
        row++;
    }
}
Also used : GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) TemplateManager(com.android.tools.idea.templates.TemplateManager) File(java.io.File) TemplateMetadata(com.android.tools.idea.templates.TemplateMetadata)

Example 48 with GridConstraints

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

the class InspectorPanel method setComponent.

public void setComponent(@NotNull List<NlComponent> components, @NotNull Table<String, String, ? extends NlProperty> properties, @NotNull NlPropertiesManager propertiesManager) {
    myInspector.setLayout(null);
    myInspector.removeAll();
    mySource2GroupMap.clear();
    myLabel2GroupMap.clear();
    myLabel2ComponentMap.clear();
    myRow = 0;
    if (!components.isEmpty()) {
        Map<String, NlProperty> propertiesByName = Maps.newHashMapWithExpectedSize(properties.size());
        for (NlProperty property : properties.row(ANDROID_URI).values()) {
            propertiesByName.put(property.getName(), property);
        }
        for (NlProperty property : properties.row(AUTO_URI).values()) {
            propertiesByName.put(property.getName(), property);
        }
        for (NlProperty property : properties.row("").values()) {
            propertiesByName.put(property.getName(), property);
        }
        // Add access to known design properties
        for (NlProperty property : myDesignProperties.getKnownProperties(components)) {
            propertiesByName.putIfAbsent(property.getName(), property);
        }
        myInspectors = myProviders.createInspectorComponents(components, propertiesByName, propertiesManager);
        int rows = 0;
        for (InspectorComponent inspector : myInspectors) {
            rows += inspector.getMaxNumberOfRows();
        }
        // 1 row for each divider (including 1 after the last property)
        rows += myInspectors.size();
        // 1 Line with a link to all properties + 1 row with a spacer on the bottom
        rows += 2;
        myInspector.setLayout(createLayoutManager(rows, 2));
        for (InspectorComponent inspector : myInspectors) {
            addSeparator();
            inspector.attachToInspector(this);
        }
        endGroup();
        addSeparator();
        // Add a vertical spacer
        myInspector.add(new Spacer(), new GridConstraints(myRow++, 0, 1, 2, ANCHOR_CENTER, FILL_HORIZONTAL, SIZEPOLICY_CAN_GROW, SIZEPOLICY_CAN_GROW | SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
        // Add link to all properties table
        addLineComponent(myAllPropertiesLink, myRow++);
    }
    // These are both important to render the controls correctly the first time:
    ApplicationManager.getApplication().invokeLater(() -> {
        updateAfterFilterChange();
        if (myActivateEditorAfterLoad) {
            activatePreferredEditor(myPropertyNameForActivation);
        }
    });
}
Also used : NlProperty(com.android.tools.idea.uibuilder.property.NlProperty) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) Spacer(com.intellij.uiDesigner.core.Spacer)

Example 49 with GridConstraints

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

the class ContentRootPanel method createFolderGroupComponent.

protected JComponent createFolderGroupComponent(String title, ContentFolder[] folders, Color foregroundColor, @Nullable ModuleSourceRootEditHandler<?> editor) {
    final JPanel panel = new JPanel(new GridLayoutManager(folders.length, 3, JBUI.insets(1, 17, 0, 5), 0, 1));
    panel.setOpaque(false);
    for (int idx = 0; idx < folders.length; idx++) {
        final ContentFolder folder = folders[idx];
        final int verticalPolicy = idx == folders.length - 1 ? GridConstraints.SIZEPOLICY_CAN_GROW : GridConstraints.SIZEPOLICY_FIXED;
        panel.add(createFolderComponent(folder, foregroundColor, editor), new GridConstraints(idx, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK, verticalPolicy, null, null, null));
        int column = 1;
        int colspan = 2;
        if (editor != null) {
            JComponent additionalComponent = createRootPropertiesEditor(editor, (SourceFolder) folder);
            if (additionalComponent != null) {
                panel.add(additionalComponent, new GridConstraints(idx, column++, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, verticalPolicy, null, null, null));
                colspan = 1;
            }
        }
        panel.add(createFolderDeleteComponent(folder, editor), new GridConstraints(idx, column, 1, colspan, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, verticalPolicy, null, null, null));
    }
    final JLabel titleLabel = new JLabel(title);
    final Font labelFont = UIUtil.getLabelFont();
    titleLabel.setFont(labelFont.deriveFont(Font.BOLD));
    titleLabel.setOpaque(false);
    titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
    registerTextComponent(titleLabel, foregroundColor);
    final JPanel groupPanel = new JPanel(new BorderLayout());
    groupPanel.setOpaque(false);
    groupPanel.add(titleLabel, BorderLayout.NORTH);
    groupPanel.add(panel, BorderLayout.CENTER);
    return groupPanel;
}
Also used : GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) ContentFolder(com.intellij.openapi.roots.ContentFolder) GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 50 with GridConstraints

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

the class GridChangeUtilTest method assertGridsEqual.

private static void assertGridsEqual(final RadContainer gridA, final RadContainer gridB) {
    final int count = gridA.getComponentCount();
    assertEquals(count, gridB.getComponentCount());
    for (int j = 0; j < count; j++) {
        final GridConstraints aConstraints = gridA.getComponent(j).getConstraints();
        final GridConstraints bConstraints = gridB.getComponent(j).getConstraints();
        assertEquals(aConstraints.getColumn(), bConstraints.getColumn());
        assertEquals(aConstraints.getColSpan(), bConstraints.getColSpan());
    }
}
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