// Copyright 2012 Georg-August-Universität Göttingen, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package de.ugoe.cs.autoquest.plugin.html.eventcore; import java.util.Map; import java.util.logging.Level; import de.ugoe.cs.autoquest.eventcore.IEventType; import de.ugoe.cs.autoquest.eventcore.gui.IInteraction; import de.ugoe.cs.autoquest.eventcore.gui.KeyPressed; import de.ugoe.cs.autoquest.eventcore.gui.KeyboardFocusChange; import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonInteraction; import de.ugoe.cs.autoquest.eventcore.gui.MouseClick; import de.ugoe.cs.autoquest.eventcore.gui.MouseDoubleClick; import de.ugoe.cs.autoquest.eventcore.gui.Scroll; import de.ugoe.cs.autoquest.eventcore.gui.TextInput; import de.ugoe.cs.autoquest.eventcore.gui.ValueSelection; import de.ugoe.cs.autoquest.eventcore.guimodel.ICheckBox; import de.ugoe.cs.autoquest.eventcore.guimodel.IComboBox; import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; import de.ugoe.cs.autoquest.eventcore.guimodel.IRadioButton; import de.ugoe.cs.autoquest.eventcore.guimodel.ITextArea; import de.ugoe.cs.autoquest.eventcore.guimodel.ITextField; import de.ugoe.cs.autoquest.keyboardmaps.VirtualKey; import de.ugoe.cs.util.console.Console; /** *
* convenience class to instantiate the correct event type based on an event name, event parameters, * and the target GUI element. *
* * @author Patrick Harms * @author Fabian Glaser */ public class HTMLEventTypeFactory { /** ** single instance *
*/ private static HTMLEventTypeFactory instance = new HTMLEventTypeFactory(); /** ** private constructor to implement correct singleton *
*/ private HTMLEventTypeFactory() {} /** ** singleton retrieval *
*/ public static HTMLEventTypeFactory getInstance() { return instance; } /** ** returns the event type for the given event name, the parameters as well as the target GUI * element *
* * @param eventName the name of the event, e.g., onscroll * @param eventParameters the parameters of the event, e.g., scroll coordinates * @param guiElement the target GUI element of the event (required for some event type * differentiation * * @return the event type matching the proviced parameters * * @throws IllegalArgumentException if the provided parameters in their combination do not * correctly specify an event type */ public IEventType getEventType(String eventName, Map* convenience method to retrieve coordinates from the event parameters. *
*/ private int[] getCoordinateParameter(String xParamName, String yParamName, String eventName, Map