Example usage for com.google.gwt.view.client CellPreviewEvent isCellEditing

List of usage examples for com.google.gwt.view.client CellPreviewEvent isCellEditing

Introduction

In this page you can find the example usage for com.google.gwt.view.client CellPreviewEvent isCellEditing.

Prototype

boolean isCellEditing

To view the source code for com.google.gwt.view.client CellPreviewEvent isCellEditing.

Click Source Link

Usage

From source file:com.bearsoft.gwt.ui.widgets.grid.GridSection.java

public GridSection(ProvidesKey<T> keyProvider) {
    super(15, ThemedGridResources.instance, keyProvider, null, true, false);
    setKeyboardPagingPolicy(HasKeyboardPagingPolicy.KeyboardPagingPolicy.CURRENT_PAGE);
    setLoadingIndicator(null);/*from  w w w .  j  ava 2  s . c  o  m*/
    setEmptyTableWidget(null);
    getElement().getStyle().setProperty("borderCollapse", "collapse");
    setKeyboardSelectionHandler(new CellTableKeyboardSelectionHandler<T>(this) {

        @Override
        public void onCellPreview(CellPreviewEvent<T> event) {
            NativeEvent nativeEvent = event.getNativeEvent();
            String eventType = event.getNativeEvent().getType();
            if (BrowserEvents.KEYDOWN.equals(eventType) && !event.isCellEditing()) {
                /*
                 * Handle keyboard navigation, unless the cell is being
                 * edited. If the cell is being edited, we do not want to
                 * change rows.
                 * 
                 * Prevent default on navigation events to prevent default
                 * scrollbar behavior.
                 */
                int oldRow = GridSection.this.getKeyboardSelectedRow();
                int oldColumn = GridSection.this.getKeyboardSelectedColumn();
                boolean isRtl = LocaleInfo.getCurrentLocale().isRTL();
                int keyCodeLineEnd = isRtl ? KeyCodes.KEY_LEFT : KeyCodes.KEY_RIGHT;
                int keyCodeLineStart = isRtl ? KeyCodes.KEY_RIGHT : KeyCodes.KEY_LEFT;
                int keyCode = nativeEvent.getKeyCode();
                super.onCellPreview(event);
                if (keyCode == keyCodeLineEnd) {
                    GridSection.this.setKeyboardSelectedRow(oldRow);
                    if (GridSection.this.getKeyboardSelectedColumn() < oldColumn)
                        GridSection.this.setKeyboardSelectedColumn(oldColumn);
                } else if (keyCode == keyCodeLineStart) {
                    GridSection.this.setKeyboardSelectedRow(oldRow);
                    if (GridSection.this.getKeyboardSelectedColumn() > oldColumn)
                        GridSection.this.setKeyboardSelectedColumn(oldColumn);
                }
            } else
                super.onCellPreview(event);
        }
    });
}

From source file:org.gss_project.gss.web.client.GSSSelectionEventManager.java

License:Open Source License

public void onCellPreview(CellPreviewEvent<T> event) {
    // Early exit if selection is already handled or we are editing.
    if (event.isCellEditing() || event.isSelectionHandled()) {
        return;/*from w  w  w.j av  a  2s  .  c o  m*/
    }

    // Early exit if we do not have a SelectionModel.
    HasData<T> display = event.getDisplay();
    SelectionModel<? super T> selectionModel = display.getSelectionModel();
    if (selectionModel == null) {
        return;
    }

    // Check for user defined actions.
    SelectAction action = (translator == null) ? SelectAction.DEFAULT
            : translator.translateSelectionEvent(event);

    // Handle the event based on the SelectionModel type.
    if (selectionModel instanceof MultiSelectionModel) {
        // Add shift key support for MultiSelectionModel.
        handleMultiSelectionEvent(event, action, (MultiSelectionModel<? super T>) selectionModel);
    } else {
        // Use the standard handler.
        handleSelectionEvent(event, action, selectionModel);
    }
}