<commit_before>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2012 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.widget.searchandfilter.client.widget.geometricsearch;

import java.util.ArrayList;
import java.util.List;

import org.geomajas.annotation.Api;
import org.geomajas.gwt.client.map.MapView.ZoomOption;
import org.geomajas.gwt.client.map.event.FeatureDeselectedEvent;
import org.geomajas.gwt.client.map.event.FeatureSelectedEvent;
import org.geomajas.gwt.client.map.event.FeatureSelectionHandler;
import org.geomajas.gwt.client.map.feature.Feature;
import org.geomajas.gwt.client.map.layer.VectorLayer;
import org.geomajas.gwt.client.map.store.VectorLayerStore;
import org.geomajas.gwt.client.spatial.Bbox;
import org.geomajas.gwt.client.spatial.geometry.Geometry;
import org.geomajas.gwt.client.util.WidgetLayout;
import org.geomajas.gwt.client.widget.MapWidget;
import org.geomajas.widget.featureinfo.client.widget.Notify;
import org.geomajas.widget.searchandfilter.client.SearchAndFilterMessages;
import org.geomajas.widget.searchandfilter.client.util.DataCallback;
import org.geomajas.widget.searchandfilter.client.util.SearchCommService;

import com.google.gwt.core.client.GWT;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.IButton;
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.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.SpinnerItem;
import com.smartgwt.client.widgets.layout.HStack;
import com.smartgwt.client.widgets.layout.VLayout;

/**
 * Geometric search method based on a predefined geometry.
 *
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @since 1.0.0
 */
@Api
public class SelectionSearch extends AbstractGeometricSearchMethod implements FeatureSelectionHandler {

	private SearchAndFilterMessages messages = GWT.create(SearchAndFilterMessages.class);

	private VLayout rootLayout;
	private VLayout mainLayout;
	private DynamicForm frmBuffer;
	private SpinnerItem spiBuffer;
	private Geometry geometry;
	private List<IButton> selectButtons = new ArrayList<IButton>();
	private Label noSelection;

	public String getTitle() {
		return messages.geometricSearchWidgetSelectionSearchTitle();
	}

	public void reset() {
		geometry = null;
		frmBuffer.reset();
	}

	/** {@inheritDoc} */
	public void initialize(MapWidget mapWidget, GeometryUpdateHandler handler) {
		super.initialize(mapWidget, handler);
		mapWidget.getMapModel().addFeatureSelectionHandler(this);
	}
		
	public Canvas getSearchCanvas() {
		if (rootLayout == null) {
			rootLayout = new VLayout(15);
			rootLayout.setWidth100();
			rootLayout.setHeight100();
			rootLayout.setPadding(5);

			Canvas selectionSearch = new Canvas();
			selectionSearch.setWidth100();
			selectionSearch.setHeight100();

			mainLayout = new VLayout(20);
			mainLayout.setWidth100();
			mainLayout.setHeight100();
	
			Label titleBar = new Label(messages.geometricSearchWidgetSelectionSearchTitle());
			titleBar.setBackgroundColor("#E0E9FF");
			titleBar.setWidth100();<commit_msg>GSF-54 Selection is ignored when opening selectiensearchpanel<commit_after>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2012 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.widget.searchandfilter.client.widget.geometricsearch;

import java.util.ArrayList;
import java.util.List;

import org.geomajas.annotation.Api;
import org.geomajas.gwt.client.map.MapView.ZoomOption;
import org.geomajas.gwt.client.map.event.FeatureDeselectedEvent;
import org.geomajas.gwt.client.map.event.FeatureSelectedEvent;
import org.geomajas.gwt.client.map.event.FeatureSelectionHandler;
import org.geomajas.gwt.client.map.feature.Feature;
import org.geomajas.gwt.client.map.layer.VectorLayer;
import org.geomajas.gwt.client.map.store.VectorLayerStore;
import org.geomajas.gwt.client.spatial.Bbox;
import org.geomajas.gwt.client.spatial.geometry.Geometry;
import org.geomajas.gwt.client.util.WidgetLayout;
import org.geomajas.gwt.client.widget.MapWidget;
import org.geomajas.widget.featureinfo.client.widget.Notify;
import org.geomajas.widget.searchandfilter.client.SearchAndFilterMessages;
import org.geomajas.widget.searchandfilter.client.util.DataCallback;
import org.geomajas.widget.searchandfilter.client.util.SearchCommService;

import com.google.gwt.core.client.GWT;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.IButton;
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.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.SpinnerItem;
import com.smartgwt.client.widgets.layout.HStack;
import com.smartgwt.client.widgets.layout.VLayout;

/**
 * Geometric search method based on a predefined geometry.
 *
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @since 1.0.0
 */
@Api
public class SelectionSearch extends AbstractGeometricSearchMethod implements FeatureSelectionHandler {

	private SearchAndFilterMessages messages = GWT.create(SearchAndFilterMessages.class);

	private VLayout rootLayout;
	private VLayout mainLayout;
	private DynamicForm frmBuffer;
	private SpinnerItem spiBuffer;
	private Geometry geometry;
	private List<IButton> selectButtons = new ArrayList<IButton>();
	private Label noSelection;

	public String getTitle() {
		return messages.geometricSearchWidgetSelectionSearchTitle();
	}

	public void reset() {
		geometry = null;
		frmBuffer.reset();
	}

	/** {@inheritDoc} */
	public void initialize(MapWidget mapWidget, GeometryUpdateHandler handler) {
		super.initialize(mapWidget, handler);
		mapWidget.getMapModel().addFeatureSelectionHandler(this);
		updateState();
	}
		
	public Canvas getSearchCanvas() {
		if (rootLayout == null) {
			rootLayout = new VLayout(15);
			rootLayout.setWidth100();
			rootLayout.setHeight100();
			rootLayout.setPadding(5);

			Canvas selectionSearch = new Canvas();
			selectionSearch.setWidth100();
			selectionSearch.setHeight100();

			mainLayout = new VLayout(20);
			mainLayout.setWidth100();
			mainLayout.setHeight100();
	
			Label titleBar = new Label(messages.geometricSearchWidgetSelectionSearchTitle());
			titleBar.setBackgroundColor("#E0E9FF");
			titleBar.setWidth100();
{'fraction_non_alphanumeric': 0.1055874527377118, 'fraction_numerical': 0.011202912757316903, 'mean_word_length': 5.510483135824977, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, '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': '6895631', 'n_tokens_mistral': 2373, 'n_tokens_neox': 2162, 'n_words': 436}