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