// Path: GridFastNavigation-addon/src/main/java/org/vaadin/patrik/client/SpinLock.java
// public interface Callback {
//     void complete();
// }
// 
// Path: GridFastNavigation-addon/src/main/java/org/vaadin/patrik/client/SpinLock.java
// public interface LockFunction {
//     boolean execute();
// }
// 
// Path: GridFastNavigation-addon/src/main/java/org/vaadin/patrik/shared/FastNavigationState.java
// @SuppressWarnings("serial")
// public class FastNavigationState extends SharedState {
//     
//     public boolean openEditorOnType = true;
//     
//     public boolean selectTextOnEditorOpen = true;
// 
//     public boolean allowTabRowChange = true;
//     
//     public boolean allowArrowRowChange = true;
//     
//     public boolean changeColumnAfterLastRow = false;
//     
//     public boolean hasFocusListener = false;
//     
//     public boolean hasRowFocusListener = false;
//     
//     public boolean hasCellFocusListener = false;
//     
//     public boolean hasRowEditListener = false;
//     
//     public boolean hasCellEditListener = false;
//     
//     public boolean hasEditorOpenListener = false;
//     
//     public boolean hasEditorMoveListener = false;
//     
//     public boolean hasEditorCloseListener = false;
//     
//     public boolean hasClickOutListener = false;
//     
//     public boolean changeColumnOnEnter = false;
//     
//     public boolean openEditorWithSingleClick = true;
//     
//     public boolean dispatchEditEventOnBlur  = false;
//     
//     public boolean saveWithCtrlS = false;
//     
//     public boolean rowValidation = false;
//     
//     public boolean homeEndEnabled = true;
//     
//     public boolean enableSelectedStyle = false;
//     
//     public Set<Integer> openShortcuts = new HashSet<Integer>();
//     
//     public Set<Integer> closeShortcuts = new HashSet<Integer>();
// 
//     public Set<Integer> saveShortcuts = new HashSet<Integer>();
// 
// }


import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.vaadin.patrik.client.SpinLock.Callback;
import org.vaadin.patrik.client.SpinLock.LockFunction;
import org.vaadin.patrik.shared.FastNavigationState;
import com.google.gwt.animation.client.AnimationScheduler;
import com.google.gwt.animation.client.AnimationScheduler.AnimationCallback;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.EventTarget;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.FocusUtil;
import com.vaadin.client.ui.VOverlay;
import com.vaadin.client.widget.grid.DefaultEditorEventHandler;
import com.vaadin.client.widget.grid.EventCellReference;
import com.vaadin.client.widgets.Grid;
import com.vaadin.client.widgets.Grid.Column;
import com.vaadin.client.widgets.Grid.Editor;
import com.vaadin.client.widgets.Grid.EditorDomEvent;
import com.vaadin.event.ShortcutAction.KeyCode;
        if (validationError == -1 ) return -1;
        return validationError-hidden;
    }
            
    private List<Column<?,Object>> getErrorColumns() {
    	boolean first = true;
    	List<Column<?,Object>> columns = new ArrayList<>();
        for (int i = 0, l = grid.getColumns().size(); i < l; ++i) {
        	Column<?,Object> column = grid.getColumn(i);
        	if (grid.getEditor().isEditorColumnError(column)) {
        		if (!first) {
        			columns.add(column);        			
        		} else {
        			first = false;
        		}
        	}
        }        
        return columns;
    }

    private void setErrorColumns(List<Column<?,Object>> columns) {
    	for (Column<?,Object> col : columns) {
    		grid.getEditor().setEditorColumnError(col, true);
    	}
    }
    
    //
    // Spinlocks
    //
    private void waitForEditorOpen() {
// Path: GridFastNavigation-addon/src/main/java/org/vaadin/patrik/client/SpinLock.java
// public interface Callback {
//     void complete();
// }
// 
// Path: GridFastNavigation-addon/src/main/java/org/vaadin/patrik/client/SpinLock.java
// public interface LockFunction {
//     boolean execute();
// }
// 
// Path: GridFastNavigation-addon/src/main/java/org/vaadin/patrik/shared/FastNavigationState.java
// @SuppressWarnings("serial")
// public class FastNavigationState extends SharedState {
//     
//     public boolean openEditorOnType = true;
//     
//     public boolean selectTextOnEditorOpen = true;
// 
//     public boolean allowTabRowChange = true;
//     
//     public boolean allowArrowRowChange = true;
//     
//     public boolean changeColumnAfterLastRow = false;
//     
//     public boolean hasFocusListener = false;
//     
//     public boolean hasRowFocusListener = false;
//     
//     public boolean hasCellFocusListener = false;
//     
//     public boolean hasRowEditListener = false;
//     
//     public boolean hasCellEditListener = false;
//     
//     public boolean hasEditorOpenListener = false;
//     
//     public boolean hasEditorMoveListener = false;
//     
//     public boolean hasEditorCloseListener = false;
//     
//     public boolean hasClickOutListener = false;
//     
//     public boolean changeColumnOnEnter = false;
//     
//     public boolean openEditorWithSingleClick = true;
//     
//     public boolean dispatchEditEventOnBlur  = false;
//     
//     public boolean saveWithCtrlS = false;
//     
//     public boolean rowValidation = false;
//     
//     public boolean homeEndEnabled = true;
//     
//     public boolean enableSelectedStyle = false;
//     
//     public Set<Integer> openShortcuts = new HashSet<Integer>();
//     
//     public Set<Integer> closeShortcuts = new HashSet<Integer>();
// 
//     public Set<Integer> saveShortcuts = new HashSet<Integer>();
// 
// }


// Path: GridFastNavigation-addon/src/main/java/org/vaadin/patrik/client/EditorStateManager.java
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.vaadin.patrik.client.SpinLock.Callback;
import org.vaadin.patrik.client.SpinLock.LockFunction;
import org.vaadin.patrik.shared.FastNavigationState;
import com.google.gwt.animation.client.AnimationScheduler;
import com.google.gwt.animation.client.AnimationScheduler.AnimationCallback;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.EventTarget;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.FocusUtil;
import com.vaadin.client.ui.VOverlay;
import com.vaadin.client.widget.grid.DefaultEditorEventHandler;
import com.vaadin.client.widget.grid.EventCellReference;
import com.vaadin.client.widgets.Grid;
import com.vaadin.client.widgets.Grid.Column;
import com.vaadin.client.widgets.Grid.Editor;
import com.vaadin.client.widgets.Grid.EditorDomEvent;
import com.vaadin.event.ShortcutAction.KeyCode;

        if (validationError == -1 ) return -1;
        return validationError-hidden;
    }
            
    private List<Column<?,Object>> getErrorColumns() {
    	boolean first = true;
    	List<Column<?,Object>> columns = new ArrayList<>();
        for (int i = 0, l = grid.getColumns().size(); i < l; ++i) {
        	Column<?,Object> column = grid.getColumn(i);
        	if (grid.getEditor().isEditorColumnError(column)) {
        		if (!first) {
        			columns.add(column);        			
        		} else {
        			first = false;
        		}
        	}
        }        
        return columns;
    }

    private void setErrorColumns(List<Column<?,Object>> columns) {
    	for (Column<?,Object> col : columns) {
    		grid.getEditor().setEditorColumnError(col, true);
    	}
    }
    
    //
    // Spinlocks
    //
    private void waitForEditorOpen() {
        SpinLock.lock(new LockFunction() {