Search in sources :

Example 1 with EditorOpenListener

use of org.vaadin.patrik.FastNavigation.EditorOpenListener in project GridFastNavigation by TatuLund.

the class DemoUI method initNavigation.

private void initNavigation(final Grid grid) {
    FastNavigation nav = new FastNavigation(grid, false, true);
    nav.setChangeColumnAfterLastRow(true);
    nav.addRowEditListener(new RowEditListener() {

        @Override
        public void onEvent(RowEditEvent event) {
            int rowIndex = event.getRowIndex();
            if (rowIndex >= 0) {
                Indexed ds = grid.getContainerDataSource();
                Object itemId = event.getItemId();
                printChangedRow(rowIndex, ds, itemId);
            }
        }
    });
    // Open with F2
    nav.addEditorOpenShortcut(KeyCode.F2);
    writeOutput("Editor can also be opened with F2");
    // Close with F3
    nav.addEditorCloseShortcut(KeyCode.F3);
    writeOutput("Editor can also be closed with F3");
    // Row focus change
    nav.addRowFocusListener(new RowFocusListener() {

        @Override
        public void onEvent(RowFocusEvent event) {
            int row = event.getRow();
            writeOutput("Focus moved to row " + event.getRow());
            grid.select(event.getItemId());
        }
    });
    writeOutput("Added row focus change listener");
    // Cell focus change
    nav.addCellFocusListener(new CellFocusListener() {

        @Override
        public void onEvent(CellFocusEvent event) {
            int row = event.getRow();
            int col = event.getColumn();
            writeOutput("Focus moved to cell [" + row + ", " + col + " ]");
        }
    });
    writeOutput("Added cell focus change listener");
    // Listening to opening of editor
    nav.addEditorOpenListener(new EditorOpenListener() {

        @Override
        public void onEvent(EditorOpenEvent event) {
            int row = event.getRow();
            writeOutput("Editor opened on row " + row + " at column " + event.getColumn());
        }
    });
    writeOutput("Added editor open listener");
    // Listening to closing of editor
    nav.addEditorCloseListener(new EditorCloseListener() {

        @Override
        public void onEvent(EditorCloseEvent event) {
            writeOutput("Editor closed on row " + event.getRow() + ", column " + event.getColumn() + ", " + (event.wasCancelled() ? "user cancelled change" : "user saved change"));
        }
    });
    writeOutput("Added editor close listener");
    nav.addClickOutListener(new ClickOutListener() {

        @Override
        public void onEvent(ClickOutEvent event) {
            writeOutput("User click outside Grid: " + event.getSource().toString());
        }
    });
}
Also used : FastNavigation(org.vaadin.patrik.FastNavigation) RowFocusEvent(org.vaadin.patrik.events.RowFocusEvent) ClickOutEvent(org.vaadin.patrik.events.ClickOutEvent) EditorOpenListener(org.vaadin.patrik.FastNavigation.EditorOpenListener) ClickOutListener(org.vaadin.patrik.FastNavigation.ClickOutListener) RowEditEvent(org.vaadin.patrik.events.RowEditEvent) EditorCloseListener(org.vaadin.patrik.FastNavigation.EditorCloseListener) EditorCloseEvent(org.vaadin.patrik.events.EditorCloseEvent) RowEditListener(org.vaadin.patrik.FastNavigation.RowEditListener) EditorOpenEvent(org.vaadin.patrik.events.EditorOpenEvent) RowFocusListener(org.vaadin.patrik.FastNavigation.RowFocusListener) Indexed(com.vaadin.data.Container.Indexed) CellFocusEvent(org.vaadin.patrik.events.CellFocusEvent) CellFocusListener(org.vaadin.patrik.FastNavigation.CellFocusListener)

Aggregations

Indexed (com.vaadin.data.Container.Indexed)1 FastNavigation (org.vaadin.patrik.FastNavigation)1 CellFocusListener (org.vaadin.patrik.FastNavigation.CellFocusListener)1 ClickOutListener (org.vaadin.patrik.FastNavigation.ClickOutListener)1 EditorCloseListener (org.vaadin.patrik.FastNavigation.EditorCloseListener)1 EditorOpenListener (org.vaadin.patrik.FastNavigation.EditorOpenListener)1 RowEditListener (org.vaadin.patrik.FastNavigation.RowEditListener)1 RowFocusListener (org.vaadin.patrik.FastNavigation.RowFocusListener)1 CellFocusEvent (org.vaadin.patrik.events.CellFocusEvent)1 ClickOutEvent (org.vaadin.patrik.events.ClickOutEvent)1 EditorCloseEvent (org.vaadin.patrik.events.EditorCloseEvent)1 EditorOpenEvent (org.vaadin.patrik.events.EditorOpenEvent)1 RowEditEvent (org.vaadin.patrik.events.RowEditEvent)1 RowFocusEvent (org.vaadin.patrik.events.RowFocusEvent)1