<commit_before>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2014 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the Apache
 * License, Version 2.0. 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.hammergwt.client.impl;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.ui.IsWidget;
import org.geomajas.hammergwt.client.event.EventType;
import org.geomajas.hammergwt.client.handler.HammerDragEndHandler;
import org.geomajas.hammergwt.client.handler.HammerDragHandler;
import org.geomajas.hammergwt.client.handler.HammerDragStartHandler;
import org.geomajas.hammergwt.client.handler.HammerHandler;
import org.geomajas.hammergwt.client.handler.HammerPinchHandler;
import org.geomajas.hammergwt.client.handler.HammerPinchInHandler;
import org.geomajas.hammergwt.client.handler.HammerPinchOutHandler;
import org.geomajas.hammergwt.client.handler.HammerTapHandler;
import org.geomajas.hammergwt.client.impl.option.GestureOption;

/**
 * Hammer GWT implementation.
 *
 * @author <NAME>
 *
 * @version 1.0
 */
public final class HammerGWT {

	protected HammerGWT() {
	}

	/**
	 * Sets hammer time options
	 * @param gestureOptions
	 */
	private static void setOptions(GestureOption[] gestureOptions, JavaScriptObject hammerGwt) {
		String gestureOptionsStr = "";

		for (GestureOption option : gestureOptions) {
			gestureOptionsStr = gestureOptionsStr + option + ", ";
		}

		gestureOptionsStr = gestureOptionsStr.substring(0, gestureOptionsStr.lastIndexOf(',')); //trim last comma

		setOptions(hammerGwt);
	}

	/**
	 * Detach event of a widget.
	 *
	 * @param widget
	 * @param eventType
	 */
	public static void off(IsWidget widget, EventType eventType) {
		off(widget.asWidget().getElement(), eventType.getText());
	}

	/**
	 * Add multiple hammer event.
	 *
	 *
	 * @param handler EventType handles all kinds of hammer event
	 * @param eventTypes type that hammer should handle
	 *
	 * @return Hammertime object
	 */
	public static HammerTime on(IsWidget widget, HammerHandler handler, EventType... eventTypes) {
		return on(widget, null, handler, eventTypes);
	}

	/**
	 * Add multiple hammer event.
	 *
	 * @param handler EventType handles all kinds of hammer event
	 * @param eventTypes type that hammer should handle
	 */
	public static HammerTime on(IsWidget widget, String eventNamespace,
			HammerHandler handler, EventType... eventTypes) {
		//JsArrayString arr = JavaScriptObject.createArray().cast();
		String eventTypesStr = "";

		for (EventType hammerEventType : eventTypes) {
			String namespace = "";

			if (null != eventNamespace && !eventNamespace.isEmpty()) {
				namespace = "." + eventNamespace;
			}

			eventTypesStr = eventTypesStr + hammerEventType.getText() + namespace + " ";
		}

		eventTypesStr = eventTypesStr.substring(0, eventTypesStr.lastIndexOf(" ")); //trim last space

		HammerTime obj = getInstance(widget.asWidget().getElement());

		on(obj, eventTypesStr, handler);

		return obj;
	}
<commit_msg>possibility to add hammer on dom element<commit_after>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2014 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the Apache
 * License, Version 2.0. 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.hammergwt.client.impl;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.IsWidget;
import org.geomajas.hammergwt.client.event.EventType;
import org.geomajas.hammergwt.client.handler.HammerDragEndHandler;
import org.geomajas.hammergwt.client.handler.HammerDragHandler;
import org.geomajas.hammergwt.client.handler.HammerDragStartHandler;
import org.geomajas.hammergwt.client.handler.HammerHandler;
import org.geomajas.hammergwt.client.handler.HammerPinchHandler;
import org.geomajas.hammergwt.client.handler.HammerPinchInHandler;
import org.geomajas.hammergwt.client.handler.HammerPinchOutHandler;
import org.geomajas.hammergwt.client.handler.HammerTapHandler;
import org.geomajas.hammergwt.client.impl.option.GestureOption;

/**
 * Hammer GWT implementation.
 *
 * @author <NAME>
 *
 * @version 1.0
 */
public final class HammerGWT {

	protected HammerGWT() {
	}

	/**
	 * Sets hammer time options
	 * @param gestureOptions
	 */
	private static void setOptions(GestureOption[] gestureOptions, JavaScriptObject hammerGwt) {
		String gestureOptionsStr = "";

		for (GestureOption option : gestureOptions) {
			gestureOptionsStr = gestureOptionsStr + option + ", ";
		}

		gestureOptionsStr = gestureOptionsStr.substring(0, gestureOptionsStr.lastIndexOf(',')); //trim last comma

		setOptions(hammerGwt);
	}

	/**
	 * Detach event of a widget.
	 *
	 * @param widget
	 * @param eventType
	 */
	public static void off(IsWidget widget, EventType eventType) {
		off(widget.asWidget().getElement(), eventType.getText());
	}

	/**
	 * Add multiple hammer event.
	 *
	 *
	 * @param handler EventType handles all kinds of hammer event
	 * @param eventTypes type that hammer should handle
	 *
	 * @return Hammertime object
	 */
	public static HammerTime on(IsWidget widget, HammerHandler handler, EventType... eventTypes) {
		return on(widget, null, handler, eventTypes);
	}

	/**
	 * Add multiple hammer event.
	 *
	 * @param handler EventType handles all kinds of hammer event
	 * @param eventTypes type that hammer should handle
	 */
	public static HammerTime on(IsWidget widget, String eventNamespace,
								HammerHandler handler, EventType... eventTypes) {
		return on(widget.asWidget().getElement(), eventNamespace, handler, eventTypes);
	}

	/**
	 * Add multiple hammer event.
	 *
	 * @param handler EventType handles all kinds of hammer event
	 * @param eventTypes type that hammer should handle
	 */
	public static HammerTime on(Element element, String eventNamespace,
			HammerHandler handler, EventType... eventTypes) {
		//JsArrayString arr = JavaScriptObject.createArray().cast();
		String eventTypesStr = "";

		for (EventType hammerEventType : eventTypes) {
			String namespace = "";

			if (null != eventNamespace && !eventNamespace.isEmpty()) {
				namespace = "." + eventNamespace;
			}

			eventTypesStr = eventTypesStr + hammerEventType.getText() + namespace + " ";
		}

		eventTypesStr = eventTypesStr.substring(0, eventTypesStr.lastIndexOf(" ")); //trim last space

		HammerTime obj = getInstance(element);

		on(obj, eventTypesStr, handler);

		return obj;
	}

{'fraction_non_alphanumeric': 0.1074861637052141, 'fraction_numerical': 0.00407806583163414, 'mean_word_length': 4.36484375, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6081152', 'n_tokens_mistral': 2252, 'n_tokens_neox': 1987, 'n_words': 528}