updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PComplexPanel complexPanel1 = get("complexPanel1");
complexPanel1.add(new PAnchor("child1"));
complexPanel1.add(new PAnchor("child3"));
}
});
element = findElementById("complexPanel1");
List<WebElement> anchors = element.findElements(By.tagName("a"));
Assert.assertEquals(2, anchors.size());
Assert.assertEquals(2, complexPanel1.getWidgetCount());
// insert child
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PVerticalPanel complexPanel1 = get("complexPanel1");
final PAnchor child2 = new PAnchor("child2");
child2.ensureDebugId("child2");
complexPanel1.insert(child2, 1);
register(child2);
}
});
element = findElementById("complexPanel1");
anchors = element.findElements(By.tagName("a"));
Assert.assertEquals(3, anchors.size());
Assert.assertEquals("child1", anchors.get(0).getText());
Assert.assertEquals("child2", anchors.get(1).getText());
Assert.assertEquals("child3", anchors.get(2).getText());
Assert.assertEquals(3, complexPanel1.getWidgetCount());
Assert.assertEquals("child1", ((PAnchor) complexPanel1.getWidget(0)).getText());
Assert.assertEquals("child2", ((PAnchor) complexPanel1.getWidget(1)).getText());
Assert.assertEquals("child3", ((PAnchor) complexPanel1.getWidget(2)).getText());
// remove child
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PComplexPanel complexPanel1 = get("complexPanel1");
final PAnchor child2 = get("child2");
complexPanel1.remove(child2);
}
});
element = findElementById("complexPanel1");