Search in sources :

Example 1 with RadContainer

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

the class GridCaptionPanel method getSelectedCells.

public int[] getSelectedCells(@Nullable final Point dragOrigin) {
    ArrayList<Integer> selection = new ArrayList<>();
    RadContainer container = getSelectedGridContainer();
    if (container == null) {
        return ArrayUtil.EMPTY_INT_ARRAY;
    }
    int size = getCellCount();
    for (int i = 0; i < size; i++) {
        if (mySelectionModel.isSelectedIndex(i)) {
            selection.add(i);
        }
    }
    if (selection.size() == 0 && dragOrigin != null) {
        int cell = getCellAt(dragOrigin);
        if (cell >= 0) {
            return new int[] { cell };
        }
    }
    int[] result = new int[selection.size()];
    for (int i = 0; i < selection.size(); i++) {
        result[i] = selection.get(i).intValue();
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 2 with RadContainer

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

the class GridDropLocation method dropIntoGrid.

protected static void dropIntoGrid(final RadContainer container, final RadComponent[] components, int row, int column, final ComponentDragObject dragObject) {
    assert components.length > 0;
    for (int i = 0; i < components.length; i++) {
        RadComponent c = components[i];
        if (c instanceof RadContainer) {
            final LayoutManager layout = ((RadContainer) c).getLayout();
            if (layout instanceof XYLayoutManager) {
                ((XYLayoutManager) layout).setPreferredSize(c.getSize());
            }
        }
        int relativeCol = dragObject.getRelativeCol(i);
        int relativeRow = dragObject.getRelativeRow(i);
        LOG.debug("dropIntoGrid: relativeRow=" + relativeRow + ", relativeCol=" + relativeCol);
        int colSpan = dragObject.getColSpan(i);
        int rowSpan = dragObject.getRowSpan(i);
        assert row + relativeRow >= 0;
        assert column + relativeCol >= 0;
        if (rowSpan > 1 || colSpan > 1) {
            if ((row + relativeRow + rowSpan > container.getGridRowCount() && rowSpan > 1) || (column + relativeCol + colSpan > container.getGridColumnCount() && colSpan > 1) || container.findComponentInRect(row + relativeRow, column + relativeCol, rowSpan, colSpan) != null) {
                rowSpan = 1;
                colSpan = 1;
            }
        }
        if (!container.getGridLayoutManager().isGridDefinedByComponents()) {
            assert relativeRow + rowSpan <= container.getGridRowCount();
            assert relativeCol + colSpan <= container.getGridColumnCount();
        }
        RadComponent old = container.findComponentInRect(row + relativeRow, column + relativeCol, rowSpan, colSpan);
        if (old != null) {
            LOG.error("Drop rectangle not empty: (" + (row + relativeRow) + ", " + (column + relativeCol) + ", " + rowSpan + ", " + colSpan + "), component ID=" + old.getId());
        }
        final GridConstraints constraints = c.getConstraints();
        constraints.setRow(row + relativeRow);
        constraints.setColumn(column + relativeCol);
        constraints.setRowSpan(rowSpan);
        constraints.setColSpan(colSpan);
        LOG.info("GridDropLocation.dropIntoGrid() constraints=" + constraints);
        container.addComponent(c);
        // Fill DropInfo
        c.revalidate();
    }
    container.revalidate();
    LOG.info("GridDropLocation.dropIntoGrid() done");
}
Also used : LayoutManager(java.awt.LayoutManager) XYLayoutManager(com.intellij.uiDesigner.shared.XYLayoutManager) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) XYLayoutManager(com.intellij.uiDesigner.shared.XYLayoutManager) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 3 with RadContainer

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

the class GridInsertProcessor method getDropTargetContainer.

public static RadContainer getDropTargetContainer(final RadRootContainer rootContainer, final Point aPoint) {
    int EPSILON = 4;
    RadContainer container = FormEditingUtil.getRadContainerAt(rootContainer, aPoint.x, aPoint.y, EPSILON);
    // to facilitate initial component adding, increase stickiness if there is one container at top level
    if (container instanceof RadRootContainer && rootContainer.getComponentCount() == 1) {
        final RadComponent singleComponent = rootContainer.getComponents()[0];
        if (singleComponent instanceof RadContainer) {
            Rectangle rc = singleComponent.getDelegee().getBounds();
            rc.grow(EPSILON * 2, EPSILON * 2);
            if (rc.contains(aPoint)) {
                container = (RadContainer) singleComponent;
                EPSILON *= 2;
            }
        }
    }
    return container;
}
Also used : RadRootContainer(com.intellij.uiDesigner.radComponents.RadRootContainer) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 4 with RadContainer

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

the class GridInsertProcessor method getDropLocation.

@NotNull
public static ComponentDropLocation getDropLocation(RadRootContainer rootContainer, Point aPoint) {
    RadContainer container = getDropTargetContainer(rootContainer, aPoint);
    if (container == null) {
        return NoDropLocation.INSTANCE;
    }
    final Point targetPoint = SwingUtilities.convertPoint(rootContainer.getDelegee(), aPoint, container.getDelegee());
    return container.getDropLocation(targetPoint);
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with RadContainer

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

the class GuiEditor method refreshImpl.

private static void refreshImpl(final RadComponent component) {
    if (component.getParent() != null) {
        final Dimension size = component.getSize();
        final int oldWidth = size.width;
        final int oldHeight = size.height;
        Util.adjustSize(component.getDelegee(), component.getConstraints(), size);
        if (oldWidth != size.width || oldHeight != size.height) {
            if (component.getParent().isXY()) {
                component.setSize(size);
            }
            component.getDelegee().invalidate();
        }
    }
    if (component instanceof RadContainer) {
        component.refresh();
        final RadContainer container = (RadContainer) component;
        for (int i = container.getComponentCount() - 1; i >= 0; i--) {
            refreshImpl(container.getComponent(i));
        }
    }
}
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