// creation
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PDisclosurePanel disclosurePanel1 = new PDisclosurePanel("A disclosure panel");
disclosurePanel1.ensureDebugId("disclosurePanel1");
PRootPanel.get().add(disclosurePanel1);
register(disclosurePanel1);
}
});
WebElement disclosure = findElementById("disclosurePanel1");
Assert.assertTrue(disclosure.getAttribute("class").contains("gwt-DisclosurePanel-closed"));
final PDisclosurePanel disclosurePanel1 = get("disclosurePanel1");
Assert.assertEquals(false, disclosurePanel1.isOpen());
WebElement disclosureHeader = findElementById("disclosurePanel1-header");
Assert.assertEquals("A disclosure panel", disclosureHeader.getText());
// set content
// open / close
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PDisclosurePanel disclosurePanel1 = get("disclosurePanel1");
final PLabel label = new PLabel("Text");
label.ensureDebugId("label1");
disclosurePanel1.setContent(label);
disclosurePanel1.addOpenHandler(eventsListener);
disclosurePanel1.addCloseHandler(eventsListener);
register(disclosurePanel1);
}
});
disclosureHeader = findElementById("disclosurePanel1-header");
disclosureHeader.click();
final POpenEvent e2 = eventsListener.poll();
Assert.assertNotNull(e2);
Assert.assertTrue(disclosurePanel1.isOpen());
disclosure = findElementById("disclosurePanel1");
final WebElement content = findElementById(disclosure, "label1");
Assert.assertEquals("Text", content.getText());
disclosureHeader.click();
final PCloseEvent e1 = eventsListener.poll();
Assert.assertNotNull(e1);
Assert.assertTrue(!disclosurePanel1.isOpen());
// server side open
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PDisclosurePanel disclosurePanel1 = get("disclosurePanel1");
disclosurePanel1.setOpen(true);
}
});
disclosure = findElementById("disclosurePanel1");
Assert.assertTrue(disclosure.getAttribute("class").contains("gwt-DisclosurePanel-open"));
// server side close
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PDisclosurePanel disclosurePanel1 = get("disclosurePanel1");
disclosurePanel1.setOpen(false);
}
});
disclosure = findElementById("disclosurePanel1");
Assert.assertTrue(disclosure.getAttribute("class").contains("gwt-DisclosurePanel-closed"));