use of org.vaadin.patrik.client.FocusTracker.FocusListener in project GridFastNavigation by TatuLund.
the class GridFastNavigationConnector method extend.
@Override
@SuppressWarnings("unchecked")
protected void extend(ServerConnector target) {
grid = (Grid<Object>) ((ComponentConnector) target).getWidget();
rpc = getRpcProxy(FastNavigationServerRPC.class);
editorManager = new EditorStateManager(grid, getState());
focusTracker = new FocusTracker(grid);
registerRpc(FastNavigationClientRPC.class, new FastNavigationClientRPC() {
@Override
public void setDisabledColumns(List<Integer> indices) {
editorManager.setDisabledColumns(indices);
}
@Override
public void unlockEditor(int lockId) {
editorManager.externalUnlock(lockId);
}
});
editorManager.addListener(new EditorListener() {
@Override
public void editorOpened(Grid<Object> grid, Editor<Object> editor, int row, int col, int lockId) {
editorManager.clearDisabledColumns();
if (getState().hasEditorOpenListener) {
rpc.editorOpened(row, col, lockId);
}
}
@Override
public void editorClosed(Grid<Object> grid, Editor<Object> editor, int row, int col, boolean cancel) {
editorManager.clearDisabledColumns();
if (getState().hasEditorCloseListener) {
rpc.editorClosed(row, col, cancel);
}
}
@Override
public void dataChanged(Grid<Object> grid, Editor<Object> editor, Widget widget, String newContent, int row, int col) {
if (getState().hasCellEditListener) {
rpc.cellUpdated(row, col, newContent);
}
if (getState().hasRowEditListener) {
rpc.rowUpdated(row);
}
}
@Override
public void clickOut(Grid<Object> grid) {
if (getState().hasClickOutListener) {
rpc.clickOut();
}
}
});
focusTracker.addListener(new FocusListener() {
@Override
public void focusMoved(int currentRow, int currentCol, int lastRow, int lastCol) {
editorManager.notifyIfDataChanged(lastRow, lastCol);
editorManager.saveOldContent(currentCol);
if (getState().hasFocusListener) {
rpc.focusUpdated(currentRow, currentCol);
}
}
});
updateCloseShortcuts();
updateOpenShortcuts();
updateFocusTracking();
}
Aggregations