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;
}
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();
}
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");
}
}
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;
}
}
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;
}
Aggregations