// Path: src/main/java/org/robotframework/formslibrary/operator/LabelOperator.java
// public class LabelOperator extends AbstractComponentOperator {
// 
// 	/**
// 	 * Initialize a LabelOperator for the given label.
// 	 */
// 	public LabelOperator(Component component) {
// 		super(component);
// 	}
// 
// 	/**
// 	 * Initialize a LabelOperator with a label with the specified name in the
// 	 * current context.
// 	 * 
// 	 * @param identifier
// 	 *            label.
// 	 */
// 	public LabelOperator(String identifier) {
// 		super(new ByNameChooser(identifier, ComponentType.LABEL, ComponentType.JRADIO_BUTTON, ComponentType.JLABEL));
// 	}
// 
// 	/**
// 	 * @return field content.
// 	 */
// 	public String getValue() {
// 		return ObjectUtil.getString(getSource(), "getText()");
// 	}
// 
// 	/**
// 	 * Verify that the field contains the given value.
// 	 */
// 	public void verifyValue(String value) {
// 		if (!TextUtil.matches(getValue(), value)) {
// 			throw new FormsLibraryException("Label value '" + getValue() + "' does not match " + value);
// 		}
// 		Logger.info("Value '" + getValue() + "' matches '" + value + "'.");
// 	}
// 
// }
// 
// Path: src/main/java/org/robotframework/formslibrary/operator/TextFieldOperatorFactory.java
// public class TextFieldOperatorFactory {
// 
// 	/**
// 	 * Create an operator for the given component.
// 	 * 
// 	 * @return TextFieldOperator or SelectFieldOperator depending on the type of
// 	 *         component that was provided.
// 	 */
// 	public static TextFieldOperator getOperator(Component component) {
// 
// 		if (component != null) {
// 			if (ComponentType.SELECT_FIELD.matches(component)) {
// 				return new SelectFieldOperator(component);
// 			} else {
// 				return new TextFieldOperator(component);
// 			}
// 		}
// 
// 		return null;
// 	}
// 
// 	/**
// 	 * Create a field operator for a component with the given name.
// 	 * 
// 	 * @return TextFieldOperator or SelectFieldOperator depending on the type of
// 	 *         component that was found.
// 	 */
// 	public static TextFieldOperator getOperator(String identifier) {
// 
// 		Component component = new ContextOperator().findTextField(new ByNameChooser(identifier, ComponentType.ALL_TEXTFIELD_TYPES));
// 		if (component != null) {
// 			return getOperator(component);
// 		}
// 
// 		return new TextFieldOperator(new ByPrecedingLabelChooser(identifier));
// 	}
// 
// 	/**
// 	 * Create a field operator for a component with the given name.
// 	 * 
// 	 * @return TextFieldOperator or SelectFieldOperator depending on the type of
// 	 *         component that was found.
// 	 */
// 	public static TextFieldOperator getOperator(LabelOperator labelOperator) {
// 		Point labelLocation = ComponentUtil.getLocationInWindow(labelOperator.getSource());
// 		List<Component> textFields = new ContextOperator().findNonTableTextFields();
// 
// 		Component textFieldToTheLeft;
// 		try {
// 			Stream<Component> textFieldsToTheLeft = textFields.stream()
// 					.filter(p -> ComponentUtil.getLocationInWindow(p).getY() == labelLocation.getY()
// 							&& ComponentUtil.getLocationInWindow(p).getX() > labelLocation.getX());
// 			textFieldToTheLeft = textFieldsToTheLeft.min((x, y) -> Integer.compare(x.getX(), y.getX())).orElse(null);
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 			throw new FormsLibraryException("Error in finding text field", e);
// 		}
// 
// 		if (textFieldToTheLeft != null) {
// 			return getOperator(textFieldToTheLeft);
// 		}
// 
// 		return null;
// 	}
// 
// }


import org.robotframework.formslibrary.operator.LabelOperator;
import org.robotframework.formslibrary.operator.TextFieldOperatorFactory;
import org.robotframework.javalib.annotation.ArgumentNames;
import org.robotframework.javalib.annotation.RobotKeyword;
import org.robotframework.javalib.annotation.RobotKeywords;

package org.robotframework.formslibrary.keyword;


@RobotKeywords
public class TextFieldKeywords {

	@RobotKeyword("Locate a field by name and set it to the given value. ':' in the field labels are ignored.\n\n" + "Example:\n"
			+ "| Set Field | _username_ | _jeff_ | \n")
	@ArgumentNames({ "identifier", "value" })
	public void setField(String identifier, String value) {
		TextFieldOperatorFactory.getOperator(identifier).setValue(value);
	}

	@RobotKeyword("Locate a field by a label on the same height to the left of the text field. ':' in the field labels are ignored.\n"
			+ "Should only be used for fields which do not have a link with the label\n\n" + "Example:\n"
			+ "| Set Field Next To Label | _username_ | _jeff_ | \n")
	@ArgumentNames({ "identifier", "value" })
	public void setFieldNextToLabel(String identifier, String value) {

// Path: src/main/java/org/robotframework/formslibrary/operator/LabelOperator.java
// public class LabelOperator extends AbstractComponentOperator {
// 
// 	/**
// 	 * Initialize a LabelOperator for the given label.
// 	 */
// 	public LabelOperator(Component component) {
// 		super(component);
// 	}
// 
// 	/**
// 	 * Initialize a LabelOperator with a label with the specified name in the
// 	 * current context.
// 	 * 
// 	 * @param identifier
// 	 *            label.
// 	 */
// 	public LabelOperator(String identifier) {
// 		super(new ByNameChooser(identifier, ComponentType.LABEL, ComponentType.JRADIO_BUTTON, ComponentType.JLABEL));
// 	}
// 
// 	/**
// 	 * @return field content.
// 	 */
// 	public String getValue() {
// 		return ObjectUtil.getString(getSource(), "getText()");
// 	}
// 
// 	/**
// 	 * Verify that the field contains the given value.
// 	 */
// 	public void verifyValue(String value) {
// 		if (!TextUtil.matches(getValue(), value)) {
// 			throw new FormsLibraryException("Label value '" + getValue() + "' does not match " + value);
// 		}
// 		Logger.info("Value '" + getValue() + "' matches '" + value + "'.");
// 	}
// 
// }
// 
// Path: src/main/java/org/robotframework/formslibrary/operator/TextFieldOperatorFactory.java
// public class TextFieldOperatorFactory {
// 
// 	/**
// 	 * Create an operator for the given component.
// 	 * 
// 	 * @return TextFieldOperator or SelectFieldOperator depending on the type of
// 	 *         component that was provided.
// 	 */
// 	public static TextFieldOperator getOperator(Component component) {
// 
// 		if (component != null) {
// 			if (ComponentType.SELECT_FIELD.matches(component)) {
// 				return new SelectFieldOperator(component);
// 			} else {
// 				return new TextFieldOperator(component);
// 			}
// 		}
// 
// 		return null;
// 	}
// 
// 	/**
// 	 * Create a field operator for a component with the given name.
// 	 * 
// 	 * @return TextFieldOperator or SelectFieldOperator depending on the type of
// 	 *         component that was found.
// 	 */
// 	public static TextFieldOperator getOperator(String identifier) {
// 
// 		Component component = new ContextOperator().findTextField(new ByNameChooser(identifier, ComponentType.ALL_TEXTFIELD_TYPES));
// 		if (component != null) {
// 			return getOperator(component);
// 		}
// 
// 		return new TextFieldOperator(new ByPrecedingLabelChooser(identifier));
// 	}
// 
// 	/**
// 	 * Create a field operator for a component with the given name.
// 	 * 
// 	 * @return TextFieldOperator or SelectFieldOperator depending on the type of
// 	 *         component that was found.
// 	 */
// 	public static TextFieldOperator getOperator(LabelOperator labelOperator) {
// 		Point labelLocation = ComponentUtil.getLocationInWindow(labelOperator.getSource());
// 		List<Component> textFields = new ContextOperator().findNonTableTextFields();
// 
// 		Component textFieldToTheLeft;
// 		try {
// 			Stream<Component> textFieldsToTheLeft = textFields.stream()
// 					.filter(p -> ComponentUtil.getLocationInWindow(p).getY() == labelLocation.getY()
// 							&& ComponentUtil.getLocationInWindow(p).getX() > labelLocation.getX());
// 			textFieldToTheLeft = textFieldsToTheLeft.min((x, y) -> Integer.compare(x.getX(), y.getX())).orElse(null);
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 			throw new FormsLibraryException("Error in finding text field", e);
// 		}
// 
// 		if (textFieldToTheLeft != null) {
// 			return getOperator(textFieldToTheLeft);
// 		}
// 
// 		return null;
// 	}
// 
// }


// Path: src/main/java/org/robotframework/formslibrary/keyword/TextFieldKeywords.java
import org.robotframework.formslibrary.operator.LabelOperator;
import org.robotframework.formslibrary.operator.TextFieldOperatorFactory;
import org.robotframework.javalib.annotation.ArgumentNames;
import org.robotframework.javalib.annotation.RobotKeyword;
import org.robotframework.javalib.annotation.RobotKeywords;

package org.robotframework.formslibrary.keyword;


@RobotKeywords
public class TextFieldKeywords {

	@RobotKeyword("Locate a field by name and set it to the given value. ':' in the field labels are ignored.\n\n" + "Example:\n"
			+ "| Set Field | _username_ | _jeff_ | \n")
	@ArgumentNames({ "identifier", "value" })
	public void setField(String identifier, String value) {
		TextFieldOperatorFactory.getOperator(identifier).setValue(value);
	}

	@RobotKeyword("Locate a field by a label on the same height to the left of the text field. ':' in the field labels are ignored.\n"
			+ "Should only be used for fields which do not have a link with the label\n\n" + "Example:\n"
			+ "| Set Field Next To Label | _username_ | _jeff_ | \n")
	@ArgumentNames({ "identifier", "value" })
	public void setFieldNextToLabel(String identifier, String value) {

		LabelOperator label = new LabelOperator(identifier);
