use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class GridChangeUtilTest method testMoveRowUp.
public void testMoveRowUp() throws Exception {
final RadContainer grid = SampleGrid.create();
GridChangeUtil.moveCells(grid, true, new int[] { 5 }, 3);
assertEquals(4, grid.getComponent(3).getConstraints().getRow());
assertEquals(5, grid.getComponent(4).getConstraints().getRow());
assertEquals(3, grid.getComponent(5).getConstraints().getRow());
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class GridChangeUtilTest method test_margins_and_gaps.
public void test_margins_and_gaps() {
final Insets margin = new Insets(11, 12, 13, 14);
final int hGap = 15;
final int vGap = 16;
final RadContainer grid = createGrid(2, 3, margin, hGap, vGap);
{
final LayoutManager oldLayout = grid.getLayout();
GridChangeUtil.insertRowOrColumn(grid, 1, false, false);
final GridLayoutManager newLayout = (GridLayoutManager) grid.getLayout();
assertGridDimensions(grid, 2, 4);
assertTrue(oldLayout != newLayout);
assertTrue(margin != newLayout.getMargin());
assertEquals(margin, newLayout.getMargin());
assertEquals(hGap, newLayout.getHGap());
assertEquals(vGap, newLayout.getVGap());
}
{
final LayoutManager oldLayout = grid.getLayout();
GridChangeUtil.splitRow(grid, 1);
final GridLayoutManager newLayout = (GridLayoutManager) grid.getLayout();
assertGridDimensions(grid, 3, 4);
assertTrue(oldLayout != newLayout);
assertTrue(margin != newLayout.getMargin());
assertEquals(margin, newLayout.getMargin());
assertEquals(hGap, newLayout.getHGap());
assertEquals(vGap, newLayout.getVGap());
}
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class GridChangeUtilTest method test_invalid_parameters.
public void test_invalid_parameters() throws Exception {
final RadContainer grid = SampleGrid.create();
try {
// should cause exception
GridChangeUtil.splitRow(grid, -1);
assertTrue(false);
} catch (IllegalArgumentException ok) {
}
try {
// should cause exception
GridChangeUtil.splitRow(grid, SampleGrid.ORIGINAL_ROWS);
assertTrue(false);
} catch (IllegalArgumentException ok) {
}
// should be ok
GridChangeUtil.splitRow(grid, SampleGrid.ORIGINAL_ROWS - 1);
assertGridDimensions(grid, SampleGrid.ORIGINAL_ROWS + 1, SampleGrid.ORIGINAL_COLUMNS);
try {
// should cause exception
GridChangeUtil.splitColumn(grid, -1);
assertTrue(false);
} catch (IllegalArgumentException ok) {
}
try {
// should cause exception
GridChangeUtil.splitColumn(grid, SampleGrid.ORIGINAL_COLUMNS);
assertTrue(false);
} catch (IllegalArgumentException ok) {
}
// should be ok
GridChangeUtil.splitColumn(grid, SampleGrid.ORIGINAL_COLUMNS - 1);
assertGridDimensions(grid, SampleGrid.ORIGINAL_ROWS + 1, SampleGrid.ORIGINAL_COLUMNS + 1);
try {
// should cause exception
GridChangeUtil.canDeleteCell(grid, -1, false);
assertTrue(false);
} catch (IllegalArgumentException ok) {
}
try {
// should cause exception
GridChangeUtil.canDeleteCell(grid, ((GridLayoutManager) grid.getLayout()).getColumnCount(), false);
assertTrue(false);
} catch (IllegalArgumentException ok) {
}
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class AssignMnemonicFix method fillMnemonicVariants.
private String[] fillMnemonicVariants(final String value) {
final StringBuffer usedMnemonics = new StringBuffer();
RadContainer container = myComponent.getParent();
if (container != null) {
while (container.getParent() != null) {
container = container.getParent();
}
FormEditingUtil.iterate(container, new FormEditingUtil.ComponentVisitor() {
public boolean visit(final IComponent component) {
SupportCode.TextWithMnemonic twm = DuplicateMnemonicInspection.getTextWithMnemonic(myEditor.getModule(), component);
if (twm != null) {
usedMnemonics.append(twm.getMnemonicChar());
}
return true;
}
});
}
ArrayList<String> variants = new ArrayList<>();
// try upper-case and word start characters
for (int i = 0; i < value.length(); i++) {
final char ch = value.charAt(i);
if (i == 0 || Character.isUpperCase(ch) || (i > 0 && value.charAt(i - 1) == ' ')) {
if (Character.isLetter(ch) && usedMnemonics.indexOf(String.valueOf(ch).toUpperCase()) < 0) {
variants.add(value.substring(0, i) + "&" + value.substring(i));
}
}
}
if (variants.size() == 0) {
// try any unused characters
for (int i = 0; i < value.length(); i++) {
final char ch = value.charAt(i);
if (Character.isLetter(ch) && usedMnemonics.indexOf(String.valueOf(ch).toUpperCase()) < 0) {
variants.add(value.substring(0, i) + "&" + value.substring(i));
}
}
}
if (variants.size() == 0) {
variants.add(value);
}
return ArrayUtil.toStringArray(variants);
}
use of com.intellij.uiDesigner.radComponents.RadContainer 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);
}
}
}
Aggregations