VLayout layout = new VLayout();
layout.setWidth100();
layout.setHeight100();
// Create the map, using the wmsMap configuration (mapOsm.xml):
final MapWidget map = new MapWidget("mapOsm", "gwt-samples");
VLayout mapLayout = new VLayout();
mapLayout.setShowEdges(true);
mapLayout.setHeight("50%");
mapLayout.addMember(map);
layout.addMember(mapLayout);
final PortalLayout portalLayout = new PortalLayout(3);
portalLayout.setWidth100();
portalLayout.setHeight("50%");
portalLayout.setShowColumnMenus(false);
HLayout buttonLayout = new HLayout(10);
buttonLayout.setAlign(Alignment.CENTER);
buttonLayout.setHeight(30);
buttonLayout.setWidth100();
Button add = new Button(I18nProvider.getSampleMessages().multipleListenersBtn());
add.setLayoutAlign(VerticalAlignment.CENTER);
add.setAutoFit(true);
add.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final Portlet portlet = new Portlet();
portlet.setTitle(I18nProvider.getSampleMessages().multipleListenersPortletTitle());
final Label label = new Label();
label.setHeight(30);
label.setContents(I18nProvider.getSampleMessages().multipleListenersPortletText() + " = ?");
portlet.setHeight(70);
portlet.addItem(label);
portalLayout.addPortlet(portlet, (column++) % 3, 0);
final Listener listener = new AbstractListener() {
public void onMouseMove(ListenerEvent event) {
label.setContents(I18nProvider.getSampleMessages().multipleListenersPortletText() + " = "
+ event.getScreenPosition());
}
};
map.addListener(listener);
portlet.addCloseClickHandler(new CloseClickHandler() {
public void onCloseClick(CloseClientEvent event) {
map.removeListener(listener);
if (map.getListeners() != null) {
SC.say(I18nProvider.getSampleMessages().multipleListenersCount(map.getListeners().size()));
}
portlet.destroy();
}
});
SC.say(I18nProvider.getSampleMessages().multipleListenersCount(map.getListeners().size()));
}
});
buttonLayout.addMember(add);
layout.addMember(buttonLayout);
layout.addMember(portalLayout);