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;
}
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);
}
}
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();
}
}
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);
}
}
}
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();
}
}
Aggregations