Search in sources :

Example 41 with GridConstraints

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

the class ValidationConfigurable method createComponent.

public JComponent createComponent() {
    final GridConstraints constraints = new GridConstraints();
    constraints.setFill(GridConstraints.FILL_BOTH);
    myExcludedEntriesPanel.add(myExcludedConfigurable.createComponent(), constraints);
    return myPanel;
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 42 with GridConstraints

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

the class KeyValuePane method init.

public void init(GradleBuildFile gradleBuildFile, Collection<BuildFileKey> properties) {
    GridLayoutManager layout = new GridLayoutManager(properties.size() + 1, 2);
    setLayout(layout);
    GridConstraints constraints = new GridConstraints();
    constraints.setAnchor(GridConstraints.ANCHOR_WEST);
    constraints.setVSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
    for (BuildFileKey property : properties) {
        constraints.setColumn(0);
        constraints.setFill(GridConstraints.FILL_NONE);
        constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
        JBLabel label = new JBLabel(property.getDisplayName());
        add(label, constraints);
        constraints.setColumn(1);
        constraints.setFill(GridConstraints.FILL_HORIZONTAL);
        constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_WANT_GROW);
        JComponent component;
        switch(property.getType()) {
            case BOOLEAN:
                {
                    constraints.setFill(GridConstraints.FILL_NONE);
                    ComboBox comboBox = createComboBox(false);
                    comboBox.addItem("");
                    comboBox.addItem("true");
                    comboBox.addItem("false");
                    comboBox.setPrototypeDisplayValue("(false) ");
                    component = comboBox;
                    break;
                }
            case FILE:
            case FILE_AS_STRING:
                {
                    JBTextField textField = new JBTextField();
                    TextFieldWithBrowseButton fileField = new TextFieldWithBrowseButton(textField);
                    FileChooserDescriptor d = new FileChooserDescriptor(true, false, false, true, false, false);
                    d.setShowFileSystemRoots(true);
                    fileField.addBrowseFolderListener(new TextBrowseFolderListener(d));
                    fileField.getTextField().getDocument().addDocumentListener(this);
                    component = fileField;
                    break;
                }
            case REFERENCE:
                {
                    constraints.setFill(GridConstraints.FILL_NONE);
                    ComboBox comboBox = createComboBox(true);
                    if (hasKnownValues(property)) {
                        for (String s : myKeysWithKnownValues.get(property).values()) {
                            comboBox.addItem(s);
                        }
                    }
                    // If there are no hardcoded values, the combo box's values will get populated later when the panel for the container reference
                    // type wakes up and notifies us of its current values.
                    component = comboBox;
                    break;
                }
            case CLOSURE:
            case STRING:
            case INTEGER:
            default:
                {
                    if (hasKnownValues(property)) {
                        constraints.setFill(GridConstraints.FILL_NONE);
                        ComboBox comboBox = createComboBox(true);
                        for (String s : myKeysWithKnownValues.get(property).values()) {
                            comboBox.addItem(s);
                        }
                        component = comboBox;
                    } else {
                        JBTextField textField = new JBTextField();
                        textField.getDocument().addDocumentListener(this);
                        component = textField;
                    }
                    break;
                }
        }
        add(component, constraints);
        label.setLabelFor(component);
        myProperties.put(property, component);
        constraints.setRow(constraints.getRow() + 1);
    }
    constraints.setColumn(0);
    constraints.setVSizePolicy(GridConstraints.FILL_VERTICAL);
    constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
    add(new JBLabel(""), constraints);
    updateUiFromCurrentObject();
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) JBLabel(com.intellij.ui.components.JBLabel) ComboBox(com.intellij.openapi.ui.ComboBox) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) TextBrowseFolderListener(com.intellij.openapi.ui.TextBrowseFolderListener) JBTextField(com.intellij.ui.components.JBTextField) AndroidTargetHash.getAddonHashString(com.android.sdklib.AndroidTargetHash.getAddonHashString) BuildFileKey(com.android.tools.idea.gradle.parser.BuildFileKey)

Example 43 with GridConstraints

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

the class FormScalingUtil method scaleComponent.

private void scaleComponent(Component c) {
    if (c instanceof Container) {
        Container container = (Container) c;
        scaleLayoutManager(container.getLayout());
    }
    if (c instanceof JTable) {
        JTable table = (JTable) c;
        Dimension size = table.getPreferredScrollableViewportSize();
        if (size != null) {
            table.setPreferredScrollableViewportSize(scale(size, "preferredScrollableViewportSize"));
        }
    }
    if (c instanceof JSlider) {
        JSlider slider = (JSlider) c;
        // force the default size to be computed. It will then be scaled in this method below.
        if (!slider.isPreferredSizeSet()) {
            slider.setPreferredSize(slider.getPreferredSize());
        }
    }
    if (c instanceof JBLabel) {
        JBLabel label = (JBLabel) c;
        label.setIconTextGap(scale(label.getIconTextGap(), "IconTextGap"));
    }
    if (c instanceof JComponent) {
        JComponent component = (JComponent) c;
        Border scaledBorder = getScaledBorder(component, component.getBorder());
        if (scaledBorder != null) {
            component.setBorder(scaledBorder);
        }
    }
    if (c.isFontSet()) {
        // Special case: If we have a font smaller than the threshold for the given
        // scale factor, scale the font size.
        // This heuristics only handle a subset of font sizing, where the intent was
        // do set the font size to "small" in the .form file.
        float fontSize = c.getFont().getSize2D();
        // We assume a size < 9 would be too small at any dpi setting.
        float minFontSize = 9f * myScaleFactor;
        if (fontSize <= minFontSize) {
            c.setFont(c.getFont().deriveFont(scale(fontSize, "FontSize")));
        }
    }
    scaleMinimumSize(c);
    scaleMaximumSize(c);
    scalePreferredSize(c);
    if (c.getParent() != null && c.getParent().getLayout() != null && c.getParent().getLayout() instanceof AbstractLayout) {
        AbstractLayout abstractLayout = (AbstractLayout) c.getParent().getLayout();
        GridConstraints constraint = abstractLayout.getConstraintsForComponent(c);
        constraint.myPreferredSize.width = scale(constraint.myPreferredSize.width, "constraint.myPreferredSize.width");
        constraint.myPreferredSize.height = scale(constraint.myPreferredSize.height, "constraint.myPreferredSize.height");
        constraint.myMinimumSize.width = scale(constraint.myMinimumSize.width, "constraint.myMinimumSize.width");
        constraint.myMinimumSize.height = scale(constraint.myMinimumSize.height, "constraint.myMinimumSize.height");
        constraint.myMaximumSize.width = scale(constraint.myMaximumSize.width, "constraint.myMaximumSize.width");
        constraint.myMaximumSize.height = scale(constraint.myMaximumSize.height, "constraint.myMaximumSize.height");
    }
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) AbstractLayout(com.intellij.uiDesigner.core.AbstractLayout) EmptyBorder(javax.swing.border.EmptyBorder) TitledBorder(javax.swing.border.TitledBorder) Border(javax.swing.border.Border)

Example 44 with GridConstraints

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

the class WizardStepHeaderPanel method addIconIfExists.

private boolean addIconIfExists(@Nullable ImageComponent iconComponent, int column, int spanningRows) {
    if (iconComponent != null) {
        GridConstraints imageConstraints = new GridConstraints(0, column, spanningRows, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, JBUI.size(60, 60), null);
        add(iconComponent, imageConstraints);
        return true;
    } else {
        return false;
    }
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 45 with GridConstraints

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

the class ModulesTable method createGridConstraints.

private static GridConstraints createGridConstraints(int row, boolean growVertically) {
    GridConstraints constraints = new GridConstraints();
    constraints.setRow(row);
    constraints.setFill(GridConstraints.FILL_HORIZONTAL);
    constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_WANT_GROW);
    if (growVertically) {
        constraints.setVSizePolicy(GridConstraints.SIZEPOLICY_WANT_GROW | GridConstraints.SIZEPOLICY_CAN_GROW);
    }
    return constraints;
}
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