use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class FormEditingUtil method selectSingleComponent.
public static void selectSingleComponent(final GuiEditor editor, final RadComponent component) {
final RadContainer root = (RadContainer) getRoot(component);
if (root == null)
return;
ComponentTreeBuilder builder = DesignerToolWindowManager.getInstance(editor).getComponentTreeBuilder();
// the component tree will be instantiated after the event has been processed completely
if (builder != null) {
builder.beginUpdateSelection();
}
try {
clearSelection(root);
selectComponent(editor, component);
editor.setSelectionAnchor(component);
editor.scrollComponentInView(component);
} finally {
if (builder != null) {
builder.endUpdateSelection();
}
}
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class FormEditingUtil method deleteComponents.
public static void deleteComponents(final Collection<? extends RadComponent> selection, boolean deleteEmptyCells) {
if (selection.size() == 0) {
return;
}
final RadRootContainer rootContainer = (RadRootContainer) getRoot(selection.iterator().next());
final Set<String> deletedComponentIds = new HashSet<>();
for (final RadComponent component : selection) {
boolean wasSelected = component.isSelected();
final RadContainer parent = component.getParent();
boolean wasPackedHorz = false;
boolean wasPackedVert = false;
if (parent.getParent() != null && parent.getParent().isXY()) {
final Dimension minSize = parent.getMinimumSize();
wasPackedHorz = parent.getWidth() == minSize.width;
wasPackedVert = parent.getHeight() == minSize.height;
}
iterate(component, new ComponentVisitor() {
public boolean visit(final IComponent c) {
RadComponent rc = (RadComponent) c;
BindingProperty.checkRemoveUnusedField(rootContainer, rc.getBinding(), null);
deletedComponentIds.add(rc.getId());
return true;
}
});
GridConstraints delConstraints = parent.getLayoutManager().isGrid() ? component.getConstraints() : null;
int index = parent.indexOfComponent(component);
parent.removeComponent(component);
if (wasSelected) {
if (parent.getComponentCount() > index) {
parent.getComponent(index).setSelected(true);
} else if (index > 0 && parent.getComponentCount() == index) {
parent.getComponent(index - 1).setSelected(true);
} else {
parent.setSelected(true);
}
}
if (delConstraints != null && deleteEmptyCells) {
deleteEmptyGridCells(parent, delConstraints);
}
if (wasPackedHorz || wasPackedVert) {
final Dimension minSize = parent.getMinimumSize();
Dimension newSize = new Dimension(parent.getWidth(), parent.getHeight());
if (wasPackedHorz) {
newSize.width = minSize.width;
}
if (wasPackedVert) {
newSize.height = minSize.height;
}
parent.setSize(newSize);
}
}
iterate(rootContainer, new ComponentVisitor() {
public boolean visit(final IComponent component) {
RadComponent rc = (RadComponent) component;
for (IProperty p : component.getModifiedProperties()) {
if (p instanceof IntroComponentProperty) {
IntroComponentProperty icp = (IntroComponentProperty) p;
final String value = icp.getValue(rc);
if (deletedComponentIds.contains(value)) {
try {
icp.resetValue(rc);
} catch (Exception e) {
// ignore
}
}
}
}
return true;
}
});
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class GridChangeUtilTest method testMoveDisjointRowsDown.
public void testMoveDisjointRowsDown() throws Exception {
final RadContainer grid = SampleGrid.create();
GridChangeUtil.moveCells(grid, true, new int[] { 0, 2 }, 5);
assertEquals(3, grid.getComponent(0).getConstraints().getRow());
assertEquals(4, grid.getComponent(2).getConstraints().getRow());
assertEquals(1, grid.getComponent(3).getConstraints().getRow());
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class GridChangeUtilTest method testMoveAdjacentRowsUp.
public void testMoveAdjacentRowsUp() throws Exception {
final RadContainer grid = SampleGrid.create();
GridChangeUtil.moveCells(grid, true, new int[] { 4, 5 }, 3);
assertEquals(5, grid.getComponent(3).getConstraints().getRow());
assertEquals(3, grid.getComponent(4).getConstraints().getRow());
assertEquals(4, grid.getComponent(5).getConstraints().getRow());
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class GridChangeUtilTest method test_insert_first.
@SuppressWarnings({ "PointlessArithmeticExpression" })
public void test_insert_first() throws Exception {
final RadContainer grid = SampleGrid.create();
GridChangeUtil.insertRowOrColumn(grid, 0, false, true);
assertGridDimensions(grid, SampleGrid.ORIGINAL_ROWS, SampleGrid.ORIGINAL_COLUMNS + 1);
// all must be shifted one cell right
assertComponentCellAndSpan(grid, 0, SampleGrid.C0 + 1, SampleGrid.S0);
assertComponentCellAndSpan(grid, 1, SampleGrid.C1 + 1, SampleGrid.S1);
assertComponentCellAndSpan(grid, 2, SampleGrid.C2 + 1, SampleGrid.S2);
assertComponentCellAndSpan(grid, 3, SampleGrid.C3 + 1, SampleGrid.S3);
assertComponentCellAndSpan(grid, 4, SampleGrid.C4 + 1, SampleGrid.S4);
assertComponentCellAndSpan(grid, 5, SampleGrid.C5 + 1, SampleGrid.S5);
}
Aggregations