@Override
protected void onFirstShowPage() {
super.onFirstShowPage();
final PVerticalPanel verticalPanel = new PVerticalPanel();
verticalPanel.setSpacing(10);
// Open popup with custom URL
final PFlexTable table = new PFlexTable();
table.setWidget(0, 0, new PLabel("URL"));
table.setWidget(0, 1, urlTextBox = new PTextBox("https://github.com/PonySDK/PonySDK"));
table.setWidget(1, 0, new PLabel("Name"));
table.setWidget(1, 1, nameTextBox = new PTextBox("PonySDK"));
table.setWidget(2, 0, new PLabel("Features"));
table.setWidget(2, 1, featuresTextBox = new PTextBox("width=1280,height=800,resizable,status=1"));
final PButton open = new PButton("Open new window");
open.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent event) {
final String url = urlTextBox.getText();
final String name = nameTextBox.getText();
final String features = featuresTextBox.getText();
final PWindow w = new PWindow(url, name, features);
w.open();
}
});
// Open popup that communicate with server
final PFlexTable table2 = new PFlexTable();
table2.setWidget(0, 0, new PLabel("Name"));
table2.setWidget(0, 1, popNameTextBox = new PTextBox("Popup"));
table2.setWidget(1, 0, new PLabel("Features"));
table2.setWidget(1, 1, popFeaturesTextBox = new PTextBox("width=500,height=300,resizable"));
final PButton open2 = new PButton("Open new window");
open2.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent event) {
final String disc = windows.size() == 0 ? "" : Integer.toString(windows.size());
final String name = popNameTextBox.getText();
final String features = popFeaturesTextBox.getText();
final MyWindow window = new MyWindow(name + disc, features);
window.open();
window.addCloseHandler(WindowPageActivity.this);
windows.add(window);
}
});
final PButton postHello = new PButton("Post message");
postHello.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent event) {
for (final PWindow window : windows) {
window.acquire();
try {
PNotificationManager.showHumanizedNotification("Hello from opener");
window.flush();
} finally {
window.release();
}
}
}
});
final PButton closeAllWindow = new PButton("Close all windows");
closeAllWindow.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent event) {
for (final PWindow window : windows) {
window.close();
}
}
});
verticalPanel.add(new PHTML("<b>Simple popup</b>"));
verticalPanel.add(table);
verticalPanel.add(open);
verticalPanel.add(new PHTML("<br><br><b>Communicating popup</b>"));
verticalPanel.add(table2);
verticalPanel.add(open2);
verticalPanel.add(postHello);
verticalPanel.add(closeAllWindow);
examplePanel.setWidget(verticalPanel);
}