use of org.eclipse.wb.internal.xwt.model.layout.grid.GridLayoutInfo in project windowbuilder by eclipse.
the class GridLayoutTest method test_normalizeSpanning_4.
/**
* Test for {@link GridLayoutInfo#command_normalizeSpanning()}.<br>
* Do normalize: no control for second column.
*/
public void test_normalizeSpanning_4() throws Exception {
parse("// filler filler filler filler filler", "<Shell>", " <Shell.layout>", " <GridLayout wbp:name='layout' numColumns='2'/>", " </Shell.layout>", " <Button wbp:name='button_1'>", " <Button.layoutData>", " <GridData horizontalSpan='2'/>", " </Button.layoutData>", " </Button>", " <Button wbp:name='button_2'/>", " <Label/>", "</Shell>");
refresh();
GridLayoutInfo layout = getObjectByName("layout");
//
layout.command_normalizeSpanning();
assertXML("// filler filler filler filler filler", "<Shell>", " <Shell.layout>", " <GridLayout wbp:name='layout'/>", " </Shell.layout>", " <Button wbp:name='button_1'/>", " <Button wbp:name='button_2'/>", "</Shell>");
}
use of org.eclipse.wb.internal.xwt.model.layout.grid.GridLayoutInfo in project windowbuilder by eclipse.
the class GridLayoutTest method test_CREATE_appendColumnRow.
public void test_CREATE_appendColumnRow() throws Exception {
parse("// filler filler filler filler filler", "<Shell>", " <Shell.layout>", " <GridLayout wbp:name='layout'/>", " </Shell.layout>", " <Button text='0'/>", "</Shell>");
refresh();
GridLayoutInfo layout = getObjectByName("layout");
//
ControlInfo newButton = createButton();
layout.command_CREATE(newButton, 1, false, 1, false);
assertXML("// filler filler filler filler filler", "<Shell>", " <Shell.layout>", " <GridLayout wbp:name='layout' numColumns='2'/>", " </Shell.layout>", " <Button text='0'/>", " <Label/>", " <Label/>", " <Button/>", "</Shell>");
}
use of org.eclipse.wb.internal.xwt.model.layout.grid.GridLayoutInfo in project windowbuilder by eclipse.
the class GridLayoutTest method test_fixGrid_leadingImplicitControls.
/**
* It is possible that there are existing {@link Control}-s created in superclass. We should not
* try to "fix" this by adding fillers.
*/
public void test_fixGrid_leadingImplicitControls() throws Exception {
setFileContentSrc("test/MyShell.java", getJavaSource("public class MyShell extends Shell {", " public MyShell() {", " setLayout(new GridLayout());", " new Text(this, SWT.NONE);", " }", " protected void checkSubclass() {", " }", "}"));
waitForAutoBuild();
//
CompositeInfo shell = parse("// filler filler filler filler filler", "// filler filler filler filler filler", "<t:MyShell>", " <Button/>", "</t:MyShell>");
refresh();
GridLayoutInfo layout = (GridLayoutInfo) shell.getLayout();
// do "fix"
ReflectionUtils.invokeMethod(layout, "fixGrid()");
assertXML("// filler filler filler filler filler", "// filler filler filler filler filler", "<t:MyShell>", " <Button/>", "</t:MyShell>");
}
use of org.eclipse.wb.internal.xwt.model.layout.grid.GridLayoutInfo in project windowbuilder by eclipse.
the class GridLayoutTest method test_CREATE_insertColumn.
public void test_CREATE_insertColumn() throws Exception {
parse("// filler filler filler filler filler", "<Shell>", " <Shell.layout>", " <GridLayout wbp:name='layout' numColumns='2'/>", " </Shell.layout>", " <Button text='0'/>", " <Label />", " <Label />", " <Button text='1'/>", "</Shell>");
refresh();
GridLayoutInfo layout = getObjectByName("layout");
//
ControlInfo newButton = createButton();
layout.command_CREATE(newButton, 1, true, 0, false);
assertXML("// filler filler filler filler filler", "<Shell>", " <Shell.layout>", " <GridLayout wbp:name='layout' numColumns='3'/>", " </Shell.layout>", " <Button text='0'/>", " <Button/>", " <Label />", " <Label />", " <Label/>", " <Button text='1'/>", "</Shell>");
}
use of org.eclipse.wb.internal.xwt.model.layout.grid.GridLayoutInfo in project windowbuilder by eclipse.
the class GridLayoutTest method test_gridInfo.
// //////////////////////////////////////////////////////////////////////////
//
// IGridInfo
//
// //////////////////////////////////////////////////////////////////////////
/**
* Test for {@link IGridInfo}.
*/
public void test_gridInfo() throws Exception {
parse("// filler filler filler filler filler", "<Shell>", " <Shell.layout>", " <GridLayout wbp:name='layout' numColumns='2'/>", " </Shell.layout>", " <Button wbp:name='button_0'/>", " <Label/>", " <Label/>", " <Button wbp:name='button_1'/>", " <Button wbp:name='button_2'>", " <Button.layoutData>", " <GridData horizontalSpan='2'/>", " </Button.layoutData>", " </Button>", "</Shell>");
refresh();
GridLayoutInfo layout = getObjectByName("layout");
ControlInfo button_0 = getObjectByName("button_0");
ControlInfo button_1 = getObjectByName("button_1");
ControlInfo button_2 = getObjectByName("button_2");
//
IGridInfo gridInfo = layout.getGridInfo();
assertNotNull(gridInfo);
// check count of column/row
assertEquals(2, gridInfo.getColumnCount());
assertEquals(3, gridInfo.getRowCount());
// check column intervals
{
int[] columnOrigins = layout.getColumnOrigins();
Interval[] columnIntervals = gridInfo.getColumnIntervals();
assertEquals(columnOrigins.length, columnIntervals.length);
for (int i = 0; i < columnOrigins.length; i++) {
int origin = columnOrigins[i];
Interval interval = columnIntervals[i];
assertEquals(origin, interval.begin);
}
}
// check row intervals
{
int[] rowOrigins = layout.getRowOrigins();
Interval[] rowIntervals = gridInfo.getRowIntervals();
assertEquals(rowOrigins.length, rowIntervals.length);
}
// check component cells
{
assertEquals(new Rectangle(0, 0, 1, 1), gridInfo.getComponentCells(button_0));
assertEquals(new Rectangle(1, 1, 1, 1), gridInfo.getComponentCells(button_1));
assertEquals(new Rectangle(0, 2, 2, 1), gridInfo.getComponentCells(button_2));
}
// check cells rectangle
{
Rectangle rectangle = gridInfo.getCellsRectangle(new Rectangle(0, 0, 1, 1));
assertEquals(5, rectangle.x);
assertEquals(5, rectangle.y);
}
// not RTL
assertFalse(gridInfo.isRTL());
// insets
assertEquals(new Insets(0, 0, 0, 0), gridInfo.getInsets());
// check "virtual" feedback sizes
{
assertTrue(gridInfo.hasVirtualColumns());
assertTrue(gridInfo.hasVirtualRows());
assertEquals(25, gridInfo.getVirtualColumnSize());
assertEquals(5, gridInfo.getVirtualColumnGap());
assertEquals(25, gridInfo.getVirtualRowSize());
assertEquals(5, gridInfo.getVirtualRowGap());
}
// check occupied cells
{
assertSame(button_0, gridInfo.getOccupied(0, 0));
assertSame(button_1, gridInfo.getOccupied(1, 1));
assertSame(button_2, gridInfo.getOccupied(0, 2));
assertSame(button_2, gridInfo.getOccupied(1, 2));
assertNull(gridInfo.getOccupied(1, 0));
assertNull(gridInfo.getOccupied(0, 1));
}
}
Aggregations