use of com.intellij.uiDesigner.core.GridLayoutManager 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;
}
use of com.intellij.uiDesigner.core.GridLayoutManager in project intellij-community by JetBrains.
the class GridInsertLocationTest method testGrowComponent.
public void testGrowComponent() {
myContainer.setLayout(new GridLayoutManager(2, 2));
// *|. *** .
//
// *** -> *****
insertComponent(0, 0, 1, 1);
RadComponent c = insertComponent(1, 0, 1, 2);
GridInsertLocation location = new GridInsertLocation(myContainer, 0, 0, GridInsertMode.ColumnAfter);
DraggedComponentList dcl = DraggedComponentList.withComponents(myDropComponent);
assertTrue(location.canDrop(dcl));
doDrop(location);
assertEquals(3, myManager.getGridColumnCount(myContainer));
assertEquals(3, c.getConstraints().getColSpan());
}
use of com.intellij.uiDesigner.core.GridLayoutManager in project intellij-community by JetBrains.
the class GridChangeUtilTest method test_margins_and_gaps.
public void test_margins_and_gaps() {
final Insets margin = new Insets(11, 12, 13, 14);
final int hGap = 15;
final int vGap = 16;
final RadContainer grid = createGrid(2, 3, margin, hGap, vGap);
{
final LayoutManager oldLayout = grid.getLayout();
GridChangeUtil.insertRowOrColumn(grid, 1, false, false);
final GridLayoutManager newLayout = (GridLayoutManager) grid.getLayout();
assertGridDimensions(grid, 2, 4);
assertTrue(oldLayout != newLayout);
assertTrue(margin != newLayout.getMargin());
assertEquals(margin, newLayout.getMargin());
assertEquals(hGap, newLayout.getHGap());
assertEquals(vGap, newLayout.getVGap());
}
{
final LayoutManager oldLayout = grid.getLayout();
GridChangeUtil.splitRow(grid, 1);
final GridLayoutManager newLayout = (GridLayoutManager) grid.getLayout();
assertGridDimensions(grid, 3, 4);
assertTrue(oldLayout != newLayout);
assertTrue(margin != newLayout.getMargin());
assertEquals(margin, newLayout.getMargin());
assertEquals(hGap, newLayout.getHGap());
assertEquals(vGap, newLayout.getVGap());
}
}
use of com.intellij.uiDesigner.core.GridLayoutManager in project intellij-community by JetBrains.
the class GridLayoutSourceGenerator method generateContainerLayout.
@Override
public void generateContainerLayout(final LwContainer container, final FormSourceCodeGenerator generator, final String variable) {
if (container.isXY()) {
if (container.getComponentCount() != 0) {
throw new IllegalStateException("only empty xys are accepted");
}
// no layout needed
} else {
if (container.isGrid()) {
final GridLayoutManager layout = (GridLayoutManager) container.getLayout();
generator.startMethodCall(variable, "setLayout");
generator.startConstructor(GridLayoutManager.class.getName());
generator.push(layout.getRowCount());
generator.push(layout.getColumnCount());
generator.newInsets(layout.getMargin());
generator.push(layout.getHGap());
generator.push(layout.getVGap());
if (layout.isSameSizeHorizontally() || layout.isSameSizeVertically()) {
// values differ from the defaults - use appropriate constructor
generator.push(layout.isSameSizeHorizontally());
generator.push(layout.isSameSizeVertically());
}
// GridLayoutManager
generator.endConstructor();
generator.endMethod();
} else if (container.isXY()) {
throw new IllegalArgumentException("XY is not supported");
} else {
throw new IllegalArgumentException("unknown layout: " + container.getLayout());
}
}
}
use of com.intellij.uiDesigner.core.GridLayoutManager in project intellij-community by JetBrains.
the class GridBuildUtil method createTwoDimensionGrid.
private static GridLayoutManager createTwoDimensionGrid(final RadComponent[] selection) {
final int[] x = new int[selection.length];
final int[] y = new int[selection.length];
final int[] colSpans = new int[selection.length];
final int[] rowSpans = new int[selection.length];
for (int i = selection.length - 1; i >= 0; i--) {
x[i] = selection[i].getX();
y[i] = selection[i].getY();
rowSpans[i] = selection[i].getHeight();
colSpans[i] = selection[i].getWidth();
}
final Couple<Integer> pair = layoutInGrid(x, y, rowSpans, colSpans);
for (int i = 0; i < selection.length; i++) {
final RadComponent component = selection[i];
final GridConstraints constraints = component.getConstraints();
constraints.setRow(y[i]);
constraints.setRowSpan(rowSpans[i]);
constraints.setColumn(x[i]);
constraints.setColSpan(colSpans[i]);
}
return new GridLayoutManager(pair.first.intValue(), pair.second.intValue());
}
Aggregations