Search in sources :

Example 11 with RadContainer

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

the class GridChangeUtilTest method test_insert_1.

public void test_insert_1() throws Exception {
    final RadContainer grid = SampleGrid.create();
    GridChangeUtil.insertRowOrColumn(grid, 1, false, false);
    assertGridDimensions(grid, SampleGrid.ORIGINAL_ROWS, SampleGrid.ORIGINAL_COLUMNS + 1);
    assertComponentCellAndSpan(grid, 0, 0, 4);
    assertComponentCellAndSpan(grid, 1, 1, 4);
    assertComponentCellAndSpan(grid, 2, 0, 5);
    assertComponentCellAndSpan(grid, 3, 1, 1);
    assertComponentCellAndSpan(grid, 4, 3, 3);
    assertComponentCellAndSpan(grid, 5, 0, 1);
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 12 with RadContainer

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

the class GridChangeUtilTest method test_delete.

public void test_delete() throws Exception {
    {
        final RadContainer grid = SampleGrid.create();
        assertEquals(GridChangeUtil.CellStatus.Required, GridChangeUtil.canDeleteCell(grid, 0, false));
        assertEquals(GridChangeUtil.CellStatus.Required, GridChangeUtil.canDeleteCell(grid, 1, false));
        assertEquals(GridChangeUtil.CellStatus.CanShift, GridChangeUtil.canDeleteCell(grid, 2, false));
        assertEquals(GridChangeUtil.CellStatus.Redundant, GridChangeUtil.canDeleteCell(grid, 3, false));
        assertEquals(GridChangeUtil.CellStatus.Redundant, GridChangeUtil.canDeleteCell(grid, 4, false));
    }
    for (int i = 0; i < SampleGrid.ORIGINAL_COLUMNS; i++) {
        final RadContainer grid = SampleGrid.create();
        if (GridChangeUtil.canDeleteCell(grid, i, false) != GridChangeUtil.CellStatus.Required) {
            GridChangeUtil.deleteCell(grid, i, false);
            assertGridDimensions(grid, SampleGrid.ORIGINAL_ROWS, SampleGrid.ORIGINAL_COLUMNS - 1);
        } else {
            // exception should be thrown
            try {
                GridChangeUtil.deleteCell(grid, i, false);
                assertTrue(false);
            } catch (IllegalArgumentException ok) {
            }
        }
    }
    // no rows in SampleGrid should be deletable...
    {
        final RadContainer grid = SampleGrid.create();
        for (int i = 0; i < SampleGrid.ORIGINAL_ROWS; i++) {
            assertEquals(GridChangeUtil.CellStatus.Required, GridChangeUtil.canDeleteCell(grid, i, true));
        }
    }
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 13 with RadContainer

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

the class GridChangeUtilTest method test_insert_after_and_before.

public void test_insert_after_and_before() throws Exception {
    for (int i = 0; i < SampleGrid.ORIGINAL_COLUMNS - 1; i++) {
        final RadContainer afterCurrent = SampleGrid.create();
        GridChangeUtil.insertRowOrColumn(afterCurrent, i, false, false);
        assertGridDimensions(afterCurrent, SampleGrid.ORIGINAL_ROWS, SampleGrid.ORIGINAL_COLUMNS + 1);
        final RadContainer beforeNext = SampleGrid.create();
        GridChangeUtil.insertRowOrColumn(beforeNext, i + 1, false, true);
        assertGridDimensions(beforeNext, SampleGrid.ORIGINAL_ROWS, SampleGrid.ORIGINAL_COLUMNS + 1);
        // afterCurrent and beforeNext grids should be same 
        assertGridsEqual(afterCurrent, beforeNext);
    }
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 14 with RadContainer

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

the class GridChangeUtilTest method testMoveDisjointRowsUp.

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

Example 15 with RadContainer

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

the class GridChangeUtilTest method testMoveAdjacentRowsDown.

public void testMoveAdjacentRowsDown() throws Exception {
    final RadContainer grid = SampleGrid.create();
    GridChangeUtil.moveCells(grid, true, new int[] { 3, 4 }, 6);
    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)

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