Search in sources :

Example 1 with FastNavigationClientRPC

use of org.vaadin.patrik.shared.FastNavigationClientRPC 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();
}
Also used : ComponentConnector(com.vaadin.client.ComponentConnector) Widget(com.google.gwt.user.client.ui.Widget) FastNavigationServerRPC(org.vaadin.patrik.shared.FastNavigationServerRPC) FastNavigationClientRPC(org.vaadin.patrik.shared.FastNavigationClientRPC) EditorListener(org.vaadin.patrik.client.EditorStateManager.EditorListener) FocusListener(org.vaadin.patrik.client.FocusTracker.FocusListener)

Aggregations

Widget (com.google.gwt.user.client.ui.Widget)1 ComponentConnector (com.vaadin.client.ComponentConnector)1 EditorListener (org.vaadin.patrik.client.EditorStateManager.EditorListener)1 FocusListener (org.vaadin.patrik.client.FocusTracker.FocusListener)1 FastNavigationClientRPC (org.vaadin.patrik.shared.FastNavigationClientRPC)1 FastNavigationServerRPC (org.vaadin.patrik.shared.FastNavigationServerRPC)1