Search in sources :

Example 31 with RadContainer

use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.

the class GridChangeUtilTest method testMoveRowUp.

public void testMoveRowUp() throws Exception {
    final RadContainer grid = SampleGrid.create();
    GridChangeUtil.moveCells(grid, true, new int[] { 5 }, 3);
    assertEquals(4, grid.getComponent(3).getConstraints().getRow());
    assertEquals(5, grid.getComponent(4).getConstraints().getRow());
    assertEquals(3, grid.getComponent(5).getConstraints().getRow());
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 32 with RadContainer

use of com.intellij.uiDesigner.radComponents.RadContainer 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());
    }
}
Also used : Insets(java.awt.Insets) GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) LayoutManager(java.awt.LayoutManager) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 33 with RadContainer

use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.

the class GridChangeUtilTest method test_invalid_parameters.

public void test_invalid_parameters() throws Exception {
    final RadContainer grid = SampleGrid.create();
    try {
        // should cause exception
        GridChangeUtil.splitRow(grid, -1);
        assertTrue(false);
    } catch (IllegalArgumentException ok) {
    }
    try {
        // should cause exception
        GridChangeUtil.splitRow(grid, SampleGrid.ORIGINAL_ROWS);
        assertTrue(false);
    } catch (IllegalArgumentException ok) {
    }
    // should be ok
    GridChangeUtil.splitRow(grid, SampleGrid.ORIGINAL_ROWS - 1);
    assertGridDimensions(grid, SampleGrid.ORIGINAL_ROWS + 1, SampleGrid.ORIGINAL_COLUMNS);
    try {
        // should cause exception
        GridChangeUtil.splitColumn(grid, -1);
        assertTrue(false);
    } catch (IllegalArgumentException ok) {
    }
    try {
        // should cause exception
        GridChangeUtil.splitColumn(grid, SampleGrid.ORIGINAL_COLUMNS);
        assertTrue(false);
    } catch (IllegalArgumentException ok) {
    }
    // should be ok
    GridChangeUtil.splitColumn(grid, SampleGrid.ORIGINAL_COLUMNS - 1);
    assertGridDimensions(grid, SampleGrid.ORIGINAL_ROWS + 1, SampleGrid.ORIGINAL_COLUMNS + 1);
    try {
        // should cause exception
        GridChangeUtil.canDeleteCell(grid, -1, false);
        assertTrue(false);
    } catch (IllegalArgumentException ok) {
    }
    try {
        // should cause exception
        GridChangeUtil.canDeleteCell(grid, ((GridLayoutManager) grid.getLayout()).getColumnCount(), false);
        assertTrue(false);
    } catch (IllegalArgumentException ok) {
    }
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 34 with RadContainer

use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.

the class AssignMnemonicFix method fillMnemonicVariants.

private String[] fillMnemonicVariants(final String value) {
    final StringBuffer usedMnemonics = new StringBuffer();
    RadContainer container = myComponent.getParent();
    if (container != null) {
        while (container.getParent() != null) {
            container = container.getParent();
        }
        FormEditingUtil.iterate(container, new FormEditingUtil.ComponentVisitor() {

            public boolean visit(final IComponent component) {
                SupportCode.TextWithMnemonic twm = DuplicateMnemonicInspection.getTextWithMnemonic(myEditor.getModule(), component);
                if (twm != null) {
                    usedMnemonics.append(twm.getMnemonicChar());
                }
                return true;
            }
        });
    }
    ArrayList<String> variants = new ArrayList<>();
    // try upper-case and word start characters
    for (int i = 0; i < value.length(); i++) {
        final char ch = value.charAt(i);
        if (i == 0 || Character.isUpperCase(ch) || (i > 0 && value.charAt(i - 1) == ' ')) {
            if (Character.isLetter(ch) && usedMnemonics.indexOf(String.valueOf(ch).toUpperCase()) < 0) {
                variants.add(value.substring(0, i) + "&" + value.substring(i));
            }
        }
    }
    if (variants.size() == 0) {
        // try any unused characters
        for (int i = 0; i < value.length(); i++) {
            final char ch = value.charAt(i);
            if (Character.isLetter(ch) && usedMnemonics.indexOf(String.valueOf(ch).toUpperCase()) < 0) {
                variants.add(value.substring(0, i) + "&" + value.substring(i));
            }
        }
    }
    if (variants.size() == 0) {
        variants.add(value);
    }
    return ArrayUtil.toStringArray(variants);
}
Also used : IComponent(com.intellij.uiDesigner.lw.IComponent) ArrayList(java.util.ArrayList) FormEditingUtil(com.intellij.uiDesigner.FormEditingUtil) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 35 with RadContainer

use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.

the class GroupSelectionProcessor method markRectangle.

private void markRectangle(final RadComponent component, final Rectangle rectangle, final Component coordinateOriginComponent) {
    if (!(component instanceof RadRootContainer) && !component.equals(myComponent)) {
        final Rectangle bounds = component.getBounds();
        final Point point = SwingUtilities.convertPoint(component.getDelegee().getParent(), bounds.x, bounds.y, coordinateOriginComponent);
        bounds.setLocation(point);
        if (rectangle.intersects(bounds)) {
            component.setSelected(true);
            return;
        }
    }
    if (component instanceof RadContainer) {
        final RadContainer container = (RadContainer) component;
        // [anton] it is very important to iterate through a STORED array because setSelected can
        // change order of components so iteration via getComponent(i) is incorrect 
        final RadComponent[] components = container.getComponents();
        for (RadComponent component1 : components) {
            markRectangle(component1, rectangle, coordinateOriginComponent);
        }
    }
}
Also used : RadRootContainer(com.intellij.uiDesigner.radComponents.RadRootContainer) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Aggregations

RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)51 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)20 RadRootContainer (com.intellij.uiDesigner.radComponents.RadRootContainer)6 ArrayList (java.util.ArrayList)6 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)5 FormEditingUtil (com.intellij.uiDesigner.FormEditingUtil)3 IComponent (com.intellij.uiDesigner.lw.IComponent)3 ComponentTreeBuilder (com.intellij.uiDesigner.componentTree.ComponentTreeBuilder)2 GridLayoutManager (com.intellij.uiDesigner.core.GridLayoutManager)2 GuiEditor (com.intellij.uiDesigner.designSurface.GuiEditor)2 IProperty (com.intellij.uiDesigner.lw.IProperty)2 IncorrectOperationException (com.intellij.util.IncorrectOperationException)2 LayoutManager (java.awt.LayoutManager)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 Ref (com.intellij.openapi.util.Ref)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 SelectionState (com.intellij.uiDesigner.SelectionState)1 ComponentPtr (com.intellij.uiDesigner.componentTree.ComponentPtr)1 ComponentTree (com.intellij.uiDesigner.componentTree.ComponentTree)1