/* ----------------------------------------
 * Origin  : GFI INFORMATIQUE 
 * Project : CDPP Propagation Tool 
 * ----------------------------------------
 * History 
 * Version : 01/05/2015 : SCA : V2.1
 * ----------------------------------------
 */
package fr.tlse.irap.pt.client.controller.common;

import javafx.scene.control.TextField;

public class Style {

	public static final String PRESS_BUTTON = "press-btn";
	public static final String LIGHT_ORANGE = "button-light-orange";
	public static final String LIGHT_BLUE = "button-light-blue";
	public static final String VALIDATION_ERROR = "validation-error";
	public static final String VALIDATION_WARNING = "validation-warning";
	public static final String LION_DEFAULT_DATEPICKER = "lion-default_datePicker";

	public static void setEditMode(TextField txtField, boolean editMode) {
		if (editMode) {
			if (!txtField.getStyleClass().contains(LIGHT_BLUE)) {
				txtField.getStyleClass().remove(LIGHT_ORANGE);
				txtField.getStyleClass().add(LIGHT_BLUE);
			}
		} else {
			if (!txtField.getStyleClass().contains(LIGHT_ORANGE)) {
				txtField.getStyleClass().remove(LIGHT_BLUE);
				txtField.getStyleClass().add(LIGHT_ORANGE);
			}
		}
		txtField.setEditable(editMode);
	}

	public static void setOnError(TextField txtField, boolean isOnError) {
		if (isOnError) {
			if (!txtField.getStyleClass().contains(VALIDATION_ERROR)) {
				txtField.getStyleClass().add(VALIDATION_ERROR);
			}
		} else {
			txtField.getStyleClass().removeAll(VALIDATION_ERROR);
		}
	}

	public static void setWarning(TextField txtField, Boolean isWarning) {
		if (isWarning) {
			if (!txtField.getStyleClass().contains(VALIDATION_WARNING))
				txtField.getStyleClass().add(VALIDATION_WARNING);
		} else {
			if (txtField.getStyleClass().contains(VALIDATION_WARNING))
				txtField.getStyleClass().remove(VALIDATION_WARNING);
		}
	}

	public boolean isWarning(TextField txtField) {
		return txtField.getStyleClass().contains(VALIDATION_WARNING);
	}

}
