<commit_before>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2013 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */

package org.geomajas.gwt.example.client.sample.controller;

import com.google.gwt.core.client.GWT;
import org.geomajas.gwt.example.base.SamplePanel;
import org.geomajas.gwt.example.base.SamplePanelFactory;
import org.geomajas.gwt.client.controller.listener.AbstractListener;
import org.geomajas.gwt.client.controller.listener.Listener;
import org.geomajas.gwt.client.controller.listener.ListenerEvent;
import org.geomajas.gwt.client.widget.MapWidget;

import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Button;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.PortalLayout;
import com.smartgwt.client.widgets.layout.Portlet;
import com.smartgwt.client.widgets.layout.VLayout;
import org.geomajas.gwt.example.client.sample.i18n.SampleMessages;

/**
 * <p>
 * Sample that demonstrates the use of multiple listeners on the map.
 * </p>
 * 
 * @author <NAME>
 */
public class MultipleListenersSample extends SamplePanel {

	private static final SampleMessages MESSAGES = GWT.create(SampleMessages.class);

	public static final String TITLE = "MultipleListeners";

	public static final SamplePanelFactory FACTORY = new SamplePanelFactory() {

		public SamplePanel createPanel() {
			return new MultipleListenersSample();
		}
	};

	private int column;

	/**
	 * @return The viewPanel Canvas
	 */
	public Canvas getViewPanel() {
		VLayout layout = new VLayout();
		layout.setWidth100();
		layout.setHeight100();

		// Create the map, using the wmsMap configuration (mapOsm.xml):
		final MapWidget map = new MapWidget("mapOsm", "gwtExample");

		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(MESSAGES.multipleListenersBtn());
		add.setLayoutAlign(VerticalAlignment.CENTER);
		add.setAutoFit(true);
		add.addClickHandler(new ClickHandler() {

			public void onClick(ClickEvent event) {
				final Portlet portlet = new Portlet();
				portlet.setTitle(MESSAGES.multipleListenersPortletTitle());

				final Label label = new Label();
				label.setHeight(30);
				label.setContents(MESSAGES.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(MESSAGES.multipleListenersPortletText() + " = "
								+ event.getScreenPosition());
					}
				};
				map.addListener(listener);
				portlet.addCloseClickHandler(new CloseClickHandler() {

					public void onCloseClick(CloseClientEvent event) {
						map.removeListener(listener);
						if (map.getListeners() != null) {
							SC.say(MESSAGES.multipleListenersCount(map.getListeners().size()));
						}
						portlet.destroy();
					}
				});
				SC.say(MESSAGES.multipleListenersCount(map.getListeners().size()));
			}
		});<commit_msg>GWT-437 Update to smartgwt 3.1/gwt 2.5<commit_after>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2013 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */

package org.geomajas.gwt.example.client.sample.controller;

import com.google.gwt.core.client.GWT;
import org.geomajas.gwt.example.base.SamplePanel;
import org.geomajas.gwt.example.base.SamplePanelFactory;
import org.geomajas.gwt.client.controller.listener.AbstractListener;
import org.geomajas.gwt.client.controller.listener.Listener;
import org.geomajas.gwt.client.controller.listener.ListenerEvent;
import org.geomajas.gwt.client.widget.MapWidget;

import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Button;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClickEvent;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.PortalLayout;
import com.smartgwt.client.widgets.layout.Portlet;
import com.smartgwt.client.widgets.layout.VLayout;
import org.geomajas.gwt.example.client.sample.i18n.SampleMessages;

/**
 * <p>
 * Sample that demonstrates the use of multiple listeners on the map.
 * </p>
 * 
 * @author <NAME>
 */
public class MultipleListenersSample extends SamplePanel {

	private static final SampleMessages MESSAGES = GWT.create(SampleMessages.class);

	public static final String TITLE = "MultipleListeners";

	public static final SamplePanelFactory FACTORY = new SamplePanelFactory() {

		public SamplePanel createPanel() {
			return new MultipleListenersSample();
		}
	};

	private int column;

	/**
	 * @return The viewPanel Canvas
	 */
	public Canvas getViewPanel() {
		VLayout layout = new VLayout();
		layout.setWidth100();
		layout.setHeight100();

		// Create the map, using the wmsMap configuration (mapOsm.xml):
		final MapWidget map = new MapWidget("mapOsm", "gwtExample");

		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(MESSAGES.multipleListenersBtn());
		add.setLayoutAlign(VerticalAlignment.CENTER);
		add.setAutoFit(true);
		add.addClickHandler(new ClickHandler() {

			public void onClick(ClickEvent event) {
				final Portlet portlet = new Portlet();
				portlet.setTitle(MESSAGES.multipleListenersPortletTitle());

				final Label label = new Label();
				label.setHeight(30);
				label.setContents(MESSAGES.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(MESSAGES.multipleListenersPortletText() + " = "
								+ event.getScreenPosition());
					}
				};
				map.addListener(listener);
				portlet.addCloseClickHandler(new CloseClickHandler() {

					public void onCloseClick(CloseClickEvent event) {
						map.removeListener(listener);
						if (map.getListeners() != null) {
							SC.say(MESSAGES.multipleListenersCount(map.getListeners().size()));
						}
						portlet.destroy();
					}
				});
				SC.say(MESSAGES.multipleListenersCount(map.getListeners().size()));
			}
		});
{'fraction_non_alphanumeric': 0.11551827441581786, 'fraction_numerical': 0.009706411024565608, 'mean_word_length': 4.685286103542234, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6895420', 'n_tokens_mistral': 2910, 'n_tokens_neox': 2529, 'n_words': 513}