Search in sources :

Example 46 with RadContainer

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

the class GridCaptionPanel method getSelectedGridContainer.

@Nullable
private RadContainer getSelectedGridContainer() {
    final ArrayList<RadComponent> selection = FormEditingUtil.getSelectedComponents(myEditor);
    if (selection.size() == 1 && selection.get(0) instanceof RadContainer) {
        RadContainer container = (RadContainer) selection.get(0);
        if (container.getLayoutManager().isGrid() && (container.getParent() instanceof RadRootContainer || container.getComponentCount() > 0)) {
            return container;
        }
    }
    RadContainer container = FormEditingUtil.getSelectionParent(selection);
    if (container == null && myEditor.getRootContainer().getComponentCount() > 0) {
        final RadComponent topComponent = myEditor.getRootContainer().getComponent(0);
        if (topComponent instanceof RadContainer) {
            container = (RadContainer) topComponent;
        }
    }
    if (container != null && !container.getLayoutManager().isGrid()) {
        return null;
    }
    return container;
}
Also used : RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadRootContainer(com.intellij.uiDesigner.radComponents.RadRootContainer) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer) Nullable(org.jetbrains.annotations.Nullable)

Example 47 with RadContainer

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

the class GridCaptionPanel method paintComponent.

@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    final Rectangle bounds = getBounds();
    final int paintedSize = 8;
    final int paintOffset = 7;
    RadContainer container = getSelectedGridContainer();
    if (container == null) {
        return;
    }
    RadAbstractGridLayoutManager layout = container.getGridLayoutManager();
    int[] coords = layout.getGridCellCoords(container, myIsRow);
    int[] sizes = layout.getGridCellSizes(container, myIsRow);
    int count = myIsRow ? layout.getGridRowCount(container) : layout.getGridColumnCount(container);
    for (int i = 0; i < count; i++) {
        int x = myIsRow ? 0 : coords[i];
        int y = myIsRow ? coords[i] : 0;
        Point pnt = SwingUtilities.convertPoint(container.getDelegee(), x, y, this);
        Rectangle rc = myIsRow ? new Rectangle(bounds.x + paintOffset, pnt.y, paintedSize, sizes[i]) : new Rectangle(pnt.x, bounds.y + paintOffset, sizes[i], paintedSize);
        g.setColor(getCaptionColor(i));
        g.fillRect(rc.x, rc.y, rc.width, rc.height);
        Rectangle rcDecoration = myIsRow ? new Rectangle(bounds.x, pnt.y, bounds.width, sizes[i]) : new Rectangle(pnt.x, bounds.y, sizes[i], bounds.height);
        layout.paintCaptionDecoration(container, myIsRow, i, g2d, rcDecoration);
        Stroke oldStroke = g2d.getStroke();
        int deltaX = 0;
        int deltaY = 0;
        if (isFocusOwner() && i == mySelectionModel.getLeadSelectionIndex()) {
            g.setColor(Color.BLACK);
            g2d.setStroke(new BasicStroke(2.0f));
            deltaX = myIsRow ? 1 : 0;
            deltaY = myIsRow ? 0 : 1;
        } else {
            g.setColor(Color.DARK_GRAY);
        }
        g.drawRect(rc.x + deltaX, rc.y + deltaY, rc.width - deltaX, rc.height - deltaY);
        g2d.setStroke(oldStroke);
    }
    g.setColor(Color.DARK_GRAY);
    if (myIsRow) {
        g.drawLine(paintOffset + paintedSize, 0, paintOffset + paintedSize, bounds.height);
    } else {
        g.drawLine(0, paintOffset + paintedSize, bounds.width, paintOffset + paintedSize);
    }
    if (myDropInsertLine >= 0) {
        int[] lines = myIsRow ? layout.getHorizontalGridLines(container) : layout.getVerticalGridLines(container);
        int coord = lines[myDropInsertLine];
        if (myIsRow) {
            coord = SwingUtilities.convertPoint(container.getDelegee(), 0, coord, this).y;
        } else {
            coord = SwingUtilities.convertPoint(container.getDelegee(), coord, 0, this).x;
        }
        Stroke oldStroke = g2d.getStroke();
        g2d.setStroke(new BasicStroke(2.0f));
        g.setColor(PlatformColors.BLUE);
        if (myIsRow) {
            g.drawLine(bounds.x + 1, coord, bounds.x + bounds.width - 1, coord);
        } else {
            g.drawLine(coord, bounds.y + 1, coord, bounds.y + bounds.height - 1);
        }
        g2d.setStroke(oldStroke);
    }
}
Also used : RadAbstractGridLayoutManager(com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 48 with RadContainer

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

the class GridCaptionPanel method checkSelectionChanged.

private void checkSelectionChanged() {
    RadContainer container = getSelectedGridContainer();
    if (container != mySelectedContainer) {
        mySelectedContainer = container;
        mySelectionModel.clearSelection();
        repaint();
    }
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 49 with RadContainer

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

the class GridInsertLocation method processDrop.

@Override
public void processDrop(final GuiEditor editor, final RadComponent[] components, @Nullable final GridConstraints[] constraintsToAdjust, final ComponentDragObject dragObject) {
    int row = getRow();
    int col = getColumn();
    RadContainer container = getContainer();
    boolean canGrow = isRowInsert() ? dragObject.isVGrow() : dragObject.isHGrow();
    int cell = isRowInsert() ? getRow() : getColumn();
    int cellsToInsert = 1;
    if (components.length > 0) {
        int cellSize = container.getGridCellCount(isRowInsert());
        Rectangle rc = getDragObjectDimensions(dragObject, cell < cellSize - 1);
        int size = isRowInsert() ? rc.height : rc.width;
        if (size > 0) {
            cellsToInsert = size;
        }
    }
    GridSpanInsertProcessor spanInsertProcessor = mySpanInsertMode && dragObject.getComponentCount() == 1 ? new GridSpanInsertProcessor(container, getRow(), getColumn(), myMode, dragObject) : null;
    int newCell = insertGridCells(container, cell, cellsToInsert, canGrow, isRowInsert(), !isInsertAfter(), constraintsToAdjust);
    if (isRowInsert()) {
        row = newCell;
    } else {
        col = newCell;
    }
    if (components.length > 0) {
        if (spanInsertProcessor != null) {
            spanInsertProcessor.doBefore(newCell);
        }
        dropIntoGrid(container, components, row, col, dragObject);
        if (spanInsertProcessor != null) {
            spanInsertProcessor.doAfter(newCell);
        }
    }
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 50 with RadContainer

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

the class FlattenAction method actionPerformed.

protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
    for (RadComponent c : selection) {
        RadContainer container = (RadContainer) c;
        final RadContainer parent = container.getParent();
        if (container.getLayoutManager().isGrid()) {
            flattenGrid(container);
        } else {
            flattenSimple(container);
        }
        parent.revalidate();
    }
}
Also used : 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