Search in sources :

Example 16 with RadContainer

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

the class PackAction method actionPerformed.

protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
    RadContainer container = getContainerToPack(selection);
    if (container != null) {
        container.getDelegee().setSize(container.getMinimumSize());
        container.getDelegee().revalidate();
    }
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 17 with RadContainer

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

the class DuplicateComponentsAction method actionPerformed.

protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
    FormEditingUtil.remapToActionTargets(selection);
    RadContainer parent = FormEditingUtil.getSelectionParent(selection);
    assert parent != null;
    List<RadComponent> duplicates = new ArrayList<>();
    Map<RadComponent, RadComponent> duplicateMap = new HashMap<>();
    TIntHashSet insertedRows = new TIntHashSet();
    boolean incrementRow = true;
    if (selection.size() > 1 && canDuplicate(selection, false) && FormEditingUtil.getSelectionBounds(selection).width == 1) {
        incrementRow = false;
    }
    for (RadComponent c : selection) {
        final int row = c.getConstraints().getCell(incrementRow);
        int rowSpan = c.getConstraints().getSpan(incrementRow);
        int insertIndex = parent.indexOfComponent(c);
        if (parent.getLayoutManager().isGrid()) {
            if (!insertedRows.contains(row) && !isSpaceBelowEmpty(c, incrementRow)) {
                insertedRows.add(row);
                parent.getGridLayoutManager().copyGridCells(parent, parent, incrementRow, row, rowSpan, row + rowSpan);
            }
        }
        List<RadComponent> copyList = CutCopyPasteSupport.copyComponents(editor, Collections.singletonList(c));
        if (copyList != null) {
            RadComponent copy = copyList.get(0);
            if (parent.getLayoutManager().isGrid()) {
                copy.getConstraints().setCell(incrementRow, row + rowSpan + parent.getGridLayoutManager().getGapCellCount());
                copy.getConstraints().setSpan(incrementRow, rowSpan);
            }
            parent.addComponent(copy, insertIndex + 1);
            fillDuplicateMap(duplicateMap, c, copy);
            duplicates.add(copy);
        }
    }
    adjustDuplicates(duplicateMap);
    FormEditingUtil.selectComponents(editor, duplicates);
}
Also used : RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer) TIntHashSet(gnu.trove.TIntHashSet)

Example 18 with RadContainer

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

the class DuplicateComponentsAction method fillDuplicateMap.

private static void fillDuplicateMap(Map<RadComponent, RadComponent> duplicates, final RadComponent c, final RadComponent copy) {
    duplicates.put(c, copy);
    if (c instanceof RadContainer) {
        LOG.assertTrue(copy instanceof RadContainer);
        final RadContainer container = (RadContainer) c;
        final RadContainer containerCopy = (RadContainer) copy;
        for (int i = 0; i < container.getComponentCount(); i++) {
            fillDuplicateMap(duplicates, container.getComponent(i), containerCopy.getComponent(i));
        }
    }
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 19 with RadContainer

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

the class FlattenAction method flattenGrid.

private static void flattenGrid(final RadContainer container) {
    RadContainer parent = container.getParent();
    GridConstraints containerConstraints = (GridConstraints) container.getConstraints().clone();
    // ensure there will be enough rows and columns to fit the container contents
    for (int i = containerConstraints.getRowSpan(); i < container.getGridRowCount(); i++) {
        GridChangeUtil.splitRow(parent, containerConstraints.getRow());
    }
    for (int i = containerConstraints.getColSpan(); i < container.getGridColumnCount(); i++) {
        GridChangeUtil.splitColumn(parent, containerConstraints.getColumn());
    }
    ArrayList<RadComponent> contents = new ArrayList<>();
    for (int i = container.getComponentCount() - 1; i >= 0; i--) {
        contents.add(0, container.getComponent(i));
        container.removeComponent(container.getComponent(i));
    }
    if (contents.size() == 1) {
        contents.get(0).setCustomLayoutConstraints(container.getCustomLayoutConstraints());
    }
    FormEditingUtil.deleteComponents(Collections.singletonList(container), false);
    for (RadComponent child : contents) {
        final GridConstraints childConstraints = child.getConstraints();
        childConstraints.setRow(childConstraints.getRow() + containerConstraints.getRow());
        childConstraints.setColumn(childConstraints.getColumn() + containerConstraints.getColumn());
        parent.addComponent(child);
        child.revalidate();
    }
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) ArrayList(java.util.ArrayList) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 20 with RadContainer

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

the class InsertAfterAction method actionPerformed.

protected void actionPerformed(final CaptionSelection selection) {
    final RadContainer container = selection.getContainer();
    container.getGridLayoutManager().insertGridCells(container, selection.getFocusedIndex(), selection.isRow(), false, false);
}
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