Search in sources :

Example 51 with RadComponent

use of com.intellij.uiDesigner.radComponents.RadComponent 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)

Example 52 with RadComponent

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

the class GroupSelectionProcessor method selectComponentsInRange.

private static void selectComponentsInRange(final RadComponent component, final RadComponent anchor) {
    final GridConstraints c1 = component.getConstraints();
    final GridConstraints c2 = anchor.getConstraints();
    int startRow = Math.min(c1.getRow(), c2.getRow());
    int startCol = Math.min(c1.getColumn(), c2.getColumn());
    int endRow = Math.max(c1.getRow() + c1.getRowSpan(), c2.getRow() + c2.getRowSpan());
    int endCol = Math.max(c1.getColumn() + c1.getColSpan(), c2.getColumn() + c2.getColSpan());
    for (int row = startRow; row < endRow; row++) {
        for (int col = startCol; col < endCol; col++) {
            RadComponent c = anchor.getParent().getComponentAtGrid(row, col);
            if (c != null) {
                c.setSelected(true);
            }
        }
    }
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent)

Example 53 with RadComponent

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

the class GuiEditor method refreshProperties.

private void refreshProperties() {
    final Ref<Boolean> anythingModified = new Ref<>();
    FormEditingUtil.iterate(myRootContainer, new FormEditingUtil.ComponentVisitor() {

        public boolean visit(final IComponent component) {
            final RadComponent radComponent = (RadComponent) component;
            boolean componentModified = false;
            for (IProperty prop : component.getModifiedProperties()) {
                if (prop instanceof IntroStringProperty) {
                    IntroStringProperty strProp = (IntroStringProperty) prop;
                    componentModified = strProp.refreshValue(radComponent) || componentModified;
                }
            }
            if (component instanceof RadContainer) {
                componentModified = ((RadContainer) component).updateBorder() || componentModified;
            }
            if (component.getParentContainer() instanceof RadTabbedPane) {
                componentModified = ((RadTabbedPane) component.getParentContainer()).refreshChildTitle(radComponent) || componentModified;
            }
            if (componentModified) {
                anythingModified.set(Boolean.TRUE);
            }
            return true;
        }
    });
    if (!anythingModified.isNull()) {
        refresh();
        DesignerToolWindow designerToolWindow = DesignerToolWindowManager.getInstance(this);
        ComponentTree tree = designerToolWindow.getComponentTree();
        if (tree != null)
            tree.repaint();
        PropertyInspector inspector = designerToolWindow.getPropertyInspector();
        if (inspector != null)
            inspector.synchWithTree(true);
    }
}
Also used : IComponent(com.intellij.uiDesigner.lw.IComponent) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) DesignerToolWindow(com.intellij.uiDesigner.propertyInspector.DesignerToolWindow) PropertyInspector(com.intellij.uiDesigner.propertyInspector.PropertyInspector) ComponentTree(com.intellij.uiDesigner.componentTree.ComponentTree) Ref(com.intellij.openapi.util.Ref) RadTabbedPane(com.intellij.uiDesigner.radComponents.RadTabbedPane) IProperty(com.intellij.uiDesigner.lw.IProperty) IntroStringProperty(com.intellij.uiDesigner.propertyInspector.properties.IntroStringProperty) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 54 with RadComponent

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

the class GridChangeUtil method splitCell.

/**
   * @param cellIndex column or row index, depending on isRow parameter; must be in the range 0..grid.get{Row|Column}Count()-1
   * @param isRow if true, row is splitted, otherwise column
   */
public static void splitCell(final RadContainer grid, final int cellIndex, final boolean isRow) {
    check(grid, isRow, cellIndex);
    int insertedCells = grid.getGridLayoutManager().insertGridCells(grid, cellIndex, isRow, false, false);
    for (int i = grid.getComponentCount() - 1; i >= 0; i--) {
        final RadComponent component = grid.getComponent(i);
        final GridConstraints constraints = component.getConstraints();
        if (constraints.getCell(isRow) + constraints.getSpan(isRow) - 1 == cellIndex) {
            // component belongs to the cell being resized - increment component's span
            GridConstraints oldConstraints = (GridConstraints) constraints.clone();
            constraints.setSpan(isRow, constraints.getSpan(isRow) + insertedCells);
            component.fireConstraintsChanged(oldConstraints);
        }
    }
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent)

Example 55 with RadComponent

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

the class GridChangeUtil method moveCell.

public static void moveCell(final RadContainer container, final boolean isRow, final int sourceCell, int targetCell) {
    if (targetCell == sourceCell || targetCell == sourceCell + 1)
        return;
    // if column moved to left - components inbetween move to right, and vice versa
    int delta = (sourceCell > targetCell) ? 1 : -1;
    int startCell = Math.min(sourceCell, targetCell);
    int endCell = Math.max(sourceCell, targetCell);
    if (sourceCell < targetCell)
        targetCell--;
    for (RadComponent c : container.getComponents()) {
        GridConstraints constraints = c.getConstraints();
        GridConstraints oldConstraints = (GridConstraints) constraints.clone();
        final int aCell = constraints.getCell(isRow);
        if (aCell == sourceCell) {
            constraints.setCell(isRow, targetCell);
        } else if (aCell >= startCell && aCell < endCell) {
            constraints.setCell(isRow, aCell + delta);
        }
        c.fireConstraintsChanged(oldConstraints);
    }
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent)

Aggregations

RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)86 RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)22 RadRootContainer (com.intellij.uiDesigner.radComponents.RadRootContainer)18 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)15 ArrayList (java.util.ArrayList)12 FormEditingUtil (com.intellij.uiDesigner.FormEditingUtil)8 GuiEditor (com.intellij.uiDesigner.designSurface.GuiEditor)8 IComponent (com.intellij.uiDesigner.lw.IComponent)7 IProperty (com.intellij.uiDesigner.lw.IProperty)6 ComponentItem (com.intellij.uiDesigner.palette.ComponentItem)5 RadButtonGroup (com.intellij.uiDesigner.radComponents.RadButtonGroup)5 ListPopup (com.intellij.openapi.ui.popup.ListPopup)4 ComponentTree (com.intellij.uiDesigner.componentTree.ComponentTree)4 IntrospectedProperty (com.intellij.uiDesigner.propertyInspector.IntrospectedProperty)4 IntroComponentProperty (com.intellij.uiDesigner.propertyInspector.properties.IntroComponentProperty)4 QuickFix (com.intellij.uiDesigner.quickFixes.QuickFix)4 Nullable (org.jetbrains.annotations.Nullable)4 RelativePoint (com.intellij.ui.awt.RelativePoint)3 Palette (com.intellij.uiDesigner.palette.Palette)3 IncorrectOperationException (com.intellij.util.IncorrectOperationException)3