Example usage for com.google.gwt.dom.client BrowserEvents DBLCLICK

List of usage examples for com.google.gwt.dom.client BrowserEvents DBLCLICK

Introduction

In this page you can find the example usage for com.google.gwt.dom.client BrowserEvents DBLCLICK.

Prototype

String DBLCLICK

To view the source code for com.google.gwt.dom.client BrowserEvents DBLCLICK.

Click Source Link

Usage

From source file:com.jitlogic.zico.client.views.traces.TraceSearchPanel.java

License:Open Source License

private void createTraceGrid() {
    grid = new DataGrid<TraceInfo>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER);
    selection = new SingleSelectionModel<TraceInfo>(KEY_PROVIDER);
    grid.setSelectionModel(selection);// w w w  . j ava  2 s  . co  m

    data = new ListDataProvider<TraceInfo>();
    data.addDataDisplay(grid);

    sortHandler = new ColumnSortEvent.ListHandler<TraceInfo>(data.getList());
    grid.addColumnSortHandler(sortHandler);

    Column<TraceInfo, TraceInfo> colExpander = new IdentityColumn<TraceInfo>(DETAIL_EXPANDER_CELL);
    grid.addColumn(colExpander, "#");
    grid.setColumnWidth(colExpander, 32, Style.Unit.PX);

    Column<TraceInfo, TraceInfo> colTraceClock = new IdentityColumn<TraceInfo>(TRACE_CLOCK_CELL);
    grid.addColumn(colTraceClock, new ResizableHeader<TraceInfo>("Clock", grid, colTraceClock));
    grid.setColumnWidth(colTraceClock, 140, Style.Unit.PX);

    colTraceClock.setSortable(true);
    sortHandler.setComparator(colTraceClock, new Comparator<TraceInfo>() {
        @Override
        public int compare(TraceInfo o1, TraceInfo o2) {
            return (int) (o1.getClock() - o2.getClock());
        }
    });

    Column<TraceInfo, TraceInfo> colTraceType = new IdentityColumn<TraceInfo>(TRACE_TYPE_CELL);
    grid.addColumn(colTraceType, new ResizableHeader<TraceInfo>("Type", grid, colTraceType));
    grid.setColumnWidth(colTraceType, 60, Style.Unit.PX);

    Column<TraceInfo, TraceInfo> colTraceDuration = new IdentityColumn<TraceInfo>(TRACE_DURATION_CELL);
    grid.addColumn(colTraceDuration, new ResizableHeader<TraceInfo>("Time", grid, colTraceDuration));
    grid.setColumnWidth(colTraceDuration, 64, Style.Unit.PX);
    colTraceDuration.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

    colTraceDuration.setSortable(true);
    sortHandler.setComparator(colTraceDuration, new Comparator<TraceInfo>() {
        @Override
        public int compare(TraceInfo o1, TraceInfo o2) {
            return (int) ((o1.getExecutionTime() - o2.getExecutionTime()) / 1000000L);
        }
    });

    Column<TraceInfo, TraceInfo> colTraceCalls = new IdentityColumn<TraceInfo>(TRACE_CALLS_CELL);
    grid.addColumn(colTraceCalls, new ResizableHeader<TraceInfo>("Calls", grid, colTraceCalls));
    grid.setColumnWidth(colTraceCalls, 50, Style.Unit.PX);

    colTraceCalls.setSortable(true);
    sortHandler.setComparator(colTraceCalls, new Comparator<TraceInfo>() {
        @Override
        public int compare(TraceInfo o1, TraceInfo o2) {
            return (int) (o1.getCalls() - o2.getCalls());
        }
    });

    Column<TraceInfo, TraceInfo> colTraceErrors = new IdentityColumn<TraceInfo>(TRACE_ERRORS_CELL);
    grid.addColumn(colTraceErrors, new ResizableHeader<TraceInfo>("Errs", grid, colTraceErrors));
    grid.setColumnWidth(colTraceErrors, 50, Style.Unit.PX);

    colTraceErrors.setSortable(true);
    sortHandler.setComparator(colTraceErrors, new Comparator<TraceInfo>() {
        @Override
        public int compare(TraceInfo o1, TraceInfo o2) {
            return (int) (o1.getErrors() - o2.getErrors());
        }
    });

    Column<TraceInfo, TraceInfo> colTraceRecords = new IdentityColumn<TraceInfo>(TRACE_RECORDS_CELL);
    grid.addColumn(colTraceRecords, new ResizableHeader<TraceInfo>("Recs", grid, colTraceRecords));
    grid.setColumnWidth(colTraceRecords, 50, Style.Unit.PX);

    colTraceRecords.setSortable(true);
    sortHandler.setComparator(colTraceRecords, new Comparator<TraceInfo>() {
        @Override
        public int compare(TraceInfo o1, TraceInfo o2) {
            return (int) (o1.getRecords() - o2.getRecords());
        }
    });

    Column<TraceInfo, TraceInfo> colTraceDesc = new IdentityColumn<TraceInfo>(TRACE_NAME_CELL);
    grid.addColumn(colTraceDesc, "Description");
    grid.setColumnWidth(colTraceDesc, 100, Style.Unit.PCT);

    rowBuilder = new TraceSearchTableBuilder(grid, expandedDetails);
    grid.setTableBuilder(rowBuilder);

    grid.setSkipRowHoverStyleUpdate(true);
    grid.setSkipRowHoverFloatElementCheck(true);
    grid.setSkipRowHoverCheck(true);
    grid.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED);

    grid.addCellPreviewHandler(new CellPreviewEvent.Handler<TraceInfo>() {
        @Override
        public void onCellPreview(CellPreviewEvent<TraceInfo> event) {
            NativeEvent nev = event.getNativeEvent();
            String eventType = nev.getType();
            if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER)
                    || BrowserEvents.DBLCLICK.equals(nev.getType())) {
                selection.setSelected(event.getValue(), true);
                openDetailView();
            }
            if (BrowserEvents.CONTEXTMENU.equals(eventType)) {
                selection.setSelected(event.getValue(), true);
                if (selection.getSelectedObject() != null) {
                    contextMenu.setPopupPosition(event.getNativeEvent().getClientX(),
                            event.getNativeEvent().getClientY());
                    contextMenu.show();
                }
            }
        }
    });

    grid.addDomHandler(new DoubleClickHandler() {
        @Override
        public void onDoubleClick(DoubleClickEvent event) {
            event.preventDefault();
        }
    }, DoubleClickEvent.getType());
    grid.addDomHandler(new ContextMenuHandler() {
        @Override
        public void onContextMenu(ContextMenuEvent event) {
            event.preventDefault();
        }
    }, ContextMenuEvent.getType());
}

From source file:com.jitlogic.zico.client.views.traces.TraceStatsPanel.java

License:Open Source License

private void createTraceGrid() {
    grid = new DataGrid<TraceInfoStatsResult>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER);
    selection = new SingleSelectionModel<TraceInfoStatsResult>(KEY_PROVIDER);
    grid.setSelectionModel(selection);/*from  w  w  w  . j  ava  2  s  .  c  o  m*/

    data = new ListDataProvider<TraceInfoStatsResult>();
    data.addDataDisplay(grid);

    sortHandler = new ColumnSortEvent.ListHandler<TraceInfoStatsResult>(data.getList());
    grid.addColumnSortHandler(sortHandler);

    Column<TraceInfoStatsResult, TraceInfoStatsResult> colTraceCalls = new IdentityColumn<TraceInfoStatsResult>(
            TRACE_CALLS_CELL);
    grid.addColumn(colTraceCalls, new ResizableHeader<TraceInfoStatsResult>("Calls", grid, colTraceCalls));
    grid.setColumnWidth(colTraceCalls, 50, Style.Unit.PX);

    colTraceCalls.setSortable(true);
    sortHandler.setComparator(colTraceCalls, new Comparator<TraceInfoStatsResult>() {
        @Override
        public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) {
            return o1.getCalls() - o2.getCalls();
        }
    });

    Column<TraceInfoStatsResult, TraceInfoStatsResult> colTraceErrors = new IdentityColumn<TraceInfoStatsResult>(
            TRACE_ERRORS_CELL);
    grid.addColumn(colTraceErrors, new ResizableHeader<TraceInfoStatsResult>("Errors", grid, colTraceErrors));
    grid.setColumnWidth(colTraceErrors, 50, Style.Unit.PX);

    colTraceErrors.setSortable(true);
    sortHandler.setComparator(colTraceErrors, new Comparator<TraceInfoStatsResult>() {
        @Override
        public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) {
            return o1.getErrors() - o2.getErrors();
        }
    });

    Column<TraceInfoStatsResult, TraceInfoStatsResult> colSumTime = new IdentityColumn<TraceInfoStatsResult>(
            TIME_SUM_CELL);
    grid.addColumn(colSumTime, new ResizableHeader<TraceInfoStatsResult>("Sum Time", grid, colSumTime));
    grid.setColumnWidth(colSumTime, 96, Style.Unit.PX);

    colSumTime.setSortable(true);
    sortHandler.setComparator(colSumTime, new Comparator<TraceInfoStatsResult>() {
        @Override
        public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) {
            return (int) ((o1.getSumTime() - o2.getSumTime()) / 1000000L);
        }
    });

    // avgTime

    Column<TraceInfoStatsResult, TraceInfoStatsResult> colMinTime = new IdentityColumn<TraceInfoStatsResult>(
            TIME_MIN_CELL);
    grid.addColumn(colMinTime, new ResizableHeader<TraceInfoStatsResult>("Min Time", grid, colMinTime));
    grid.setColumnWidth(colMinTime, 96, Style.Unit.PX);

    colMinTime.setSortable(true);
    sortHandler.setComparator(colMinTime, new Comparator<TraceInfoStatsResult>() {
        @Override
        public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) {
            return (int) ((o1.getMinTime() - o2.getMinTime()) / 1000000L);
        }
    });

    Column<TraceInfoStatsResult, TraceInfoStatsResult> colMaxTime = new IdentityColumn<TraceInfoStatsResult>(
            TIME_MAX_CELL);
    grid.addColumn(colMaxTime, new ResizableHeader<TraceInfoStatsResult>("Max Time", grid, colMaxTime));
    grid.setColumnWidth(colMaxTime, 96, Style.Unit.PX);

    colMaxTime.setSortable(true);
    sortHandler.setComparator(colMaxTime, new Comparator<TraceInfoStatsResult>() {
        @Override
        public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) {
            return (int) ((o1.getMaxTime() - o2.getMaxTime()) / 1000000L);
        }
    });

    Column<TraceInfoStatsResult, TraceInfoStatsResult> colAttr = new IdentityColumn<TraceInfoStatsResult>(
            ATTR_CELL);
    colAttr.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    grid.addColumn(colAttr, new ResizableHeader<TraceInfoStatsResult>("Attr", grid, colAttr));
    grid.setColumnWidth(colAttr, 100, Style.Unit.PCT);

    colAttr.setSortable(true);
    sortHandler.setComparator(colAttr, new Comparator<TraceInfoStatsResult>() {
        @Override
        public int compare(TraceInfoStatsResult o1, TraceInfoStatsResult o2) {
            return o1.getAttr().compareTo(o2.getAttr());
        }
    });

    grid.addCellPreviewHandler(new CellPreviewEvent.Handler<TraceInfoStatsResult>() {
        @Override
        public void onCellPreview(CellPreviewEvent<TraceInfoStatsResult> event) {
            NativeEvent nev = event.getNativeEvent();
            String eventType = nev.getType();
            if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER)
                    || BrowserEvents.DBLCLICK.equals(nev.getType())) {
                selection.setSelected(event.getValue(), true);
                openSearchView();
            }
            if (BrowserEvents.CONTEXTMENU.equals(eventType)) {
                selection.setSelected(event.getValue(), true);
                if (selection.getSelectedObject() != null) {
                    contextMenu.setPopupPosition(event.getNativeEvent().getClientX(),
                            event.getNativeEvent().getClientY());
                    contextMenu.show();
                }
            }
        }
    });

    grid.addDomHandler(new DoubleClickHandler() {
        @Override
        public void onDoubleClick(DoubleClickEvent event) {
            event.preventDefault();
        }
    }, DoubleClickEvent.getType());
    grid.addDomHandler(new ContextMenuHandler() {
        @Override
        public void onContextMenu(ContextMenuEvent event) {
            event.preventDefault();
        }
    }, ContextMenuEvent.getType());
}

From source file:com.jitlogic.zico.widgets.demo.client.views.UserManagementPanel.java

License:Open Source License

private void createUserGrid() {
    userGrid = new DataGrid<UserInfo>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER);
    selectionModel = new SingleSelectionModel<UserInfo>(KEY_PROVIDER);
    userGrid.setSelectionModel(selectionModel);

    Column<UserInfo, String> colUserId = new Column<UserInfo, String>(new TextCell()) {
        @Override//from   w ww  . ja v  a 2  s .  c  o  m
        public String getValue(UserInfo object) {
            return "" + object.getId();
        }
    };
    userGrid.addColumn(colUserId, new ResizableHeader<UserInfo>("#", userGrid, colUserId));
    userGrid.setColumnWidth(colUserId, 35, Style.Unit.PX);

    final EditTextCell cellUsername = new EditTextCell();
    Column<UserInfo, String> colUsername = new Column<UserInfo, String>(cellUsername) {
        @Override
        public String getValue(UserInfo user) {
            return user.getUsername();
        }
    };
    colUsername.setFieldUpdater(new FieldUpdater<UserInfo, String>() {
        public void update(int index, UserInfo user, String value) {
            markChange(user);
            user.setUsername(value);
            cellUsername.clearViewData(user.getId());
        }
    });
    userGrid.addColumn(colUsername, new ResizableHeader<UserInfo>("Username", userGrid, colUsername));
    userGrid.setColumnWidth(colUsername, 128, Style.Unit.PX);

    Map<String, Integer> roles = ZicoWidgets.map("VIEWER", 1, "ADMIN", 2);

    final SelectCell<String, Integer> cellRoles = new SelectCell<String, Integer>(roles);
    Column<UserInfo, Integer> colUserRole = new Column<UserInfo, Integer>(cellRoles) {
        @Override
        public Integer getValue(UserInfo user) {
            return user.getRole();
        }
    };
    colUserRole.setFieldUpdater(new FieldUpdater<UserInfo, Integer>() {
        public void update(int index, UserInfo user, Integer value) {
            markChange(user);
            user.setRole(value);
            cellRoles.clearViewData(user.getId());
        }
    });
    userGrid.addColumn(colUserRole, new ResizableHeader<UserInfo>("Role", userGrid, colUserRole));
    userGrid.setColumnWidth(colUserRole, 128, Style.Unit.PX);

    final EditTextCell cellFullname = new EditTextCell();
    Column<UserInfo, String> colFullname = new Column<UserInfo, String>(cellFullname) {
        @Override
        public String getValue(UserInfo user) {
            return user.getFullname();
        }
    };
    colFullname.setFieldUpdater(new FieldUpdater<UserInfo, String>() {
        public void update(int index, UserInfo user, String value) {
            markChange(user);
            user.setFullname(value);
            cellFullname.clearViewData(user.getId());
        }
    });
    userGrid.addColumn(colFullname, new ResizableHeader<UserInfo>("Full Name", userGrid, colFullname));
    userGrid.setColumnWidth(colFullname, 256, Style.Unit.PX);

    final EditTextCell cellComment = new EditTextCell();
    Column<UserInfo, String> colComment = new Column<UserInfo, String>(cellComment) {
        @Override
        public String getValue(UserInfo user) {
            return user.getComment();
        }
    };
    colComment.setFieldUpdater(new FieldUpdater<UserInfo, String>() {
        public void update(int index, UserInfo user, String value) {
            markChange(user);
            user.setComment(value);
            cellComment.clearViewData(user.getId());
        }
    });
    userGrid.addColumn(colComment, "Comment");
    userGrid.setColumnWidth(colComment, 100, Style.Unit.PC);

    userStore = new ListDataProvider<UserInfo>(KEY_PROVIDER);
    userStore.addDataDisplay(userGrid);

    userGrid.addCellPreviewHandler(new CellPreviewEvent.Handler<UserInfo>() {
        public void onCellPreview(CellPreviewEvent<UserInfo> event) {
            NativeEvent nev = event.getNativeEvent();
            String eventType = nev.getType();
            if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER)
                    || BrowserEvents.DBLCLICK.equals(nev.getType())) {
                selectionModel.setSelected(event.getValue(), true);
                editUser(null);
            }
            if (BrowserEvents.CONTEXTMENU.equals(eventType)) {
                selectionModel.setSelected(event.getValue(), true);
                if (event.getValue() != null) {
                    contextMenu.setPopupPosition(event.getNativeEvent().getClientX(),
                            event.getNativeEvent().getClientY());
                    contextMenu.show();
                }
            }

        }
    });

    userGrid.addDomHandler(new DoubleClickHandler() {
        public void onDoubleClick(DoubleClickEvent event) {
            event.preventDefault();
        }
    }, DoubleClickEvent.getType());
    userGrid.addDomHandler(new ContextMenuHandler() {
        public void onContextMenu(ContextMenuEvent event) {
            event.preventDefault();
        }
    }, ContextMenuEvent.getType());

}

From source file:com.vaadin.client.widget.grid.events.GridDoubleClickEvent.java

License:Apache License

@Override
protected String getBrowserEventType() {
    return BrowserEvents.DBLCLICK;
}

From source file:com.vaadin.client.widgets.Grid.java

License:Apache License

/**
 * Creates a new instance.//from  w  w w  . j a  v a2 s  . c  o m
 */
public Grid() {
    initWidget(escalator);
    getElement().setTabIndex(0);
    cellFocusHandler = new CellFocusHandler();

    setStylePrimaryName(STYLE_NAME);

    escalator.getHeader().setEscalatorUpdater(createHeaderUpdater());
    escalator.getBody().setEscalatorUpdater(createBodyUpdater());
    escalator.getFooter().setEscalatorUpdater(createFooterUpdater());

    header.setGrid(this);
    HeaderRow defaultRow = header.appendRow();
    header.setDefaultRow(defaultRow);

    footer.setGrid(this);

    editor.setGrid(this);

    setSelectionMode(SelectionMode.SINGLE);

    escalator.getBody().setSpacerUpdater(gridSpacerUpdater);

    escalator.addScrollHandler(new ScrollHandler() {
        @Override
        public void onScroll(ScrollEvent event) {
            fireEvent(new ScrollEvent());
        }
    });

    escalator.addRowVisibilityChangeHandler(new RowVisibilityChangeHandler() {
        @Override
        public void onRowVisibilityChange(RowVisibilityChangeEvent event) {
            if (dataSource != null && dataSource.size() != 0) {
                dataIsBeingFetched = true;
                dataSource.ensureAvailability(event.getFirstVisibleRow(), event.getVisibleRowCount());
            }
        }
    });

    // Default action on SelectionEvents. Refresh the body so changed
    // become visible.
    addSelectionHandler(new SelectionHandler<T>() {

        @Override
        public void onSelect(SelectionEvent<T> event) {
            refreshBody();
        }
    });

    // Sink header events and key events
    sinkEvents(getHeader().getConsumedEvents());
    sinkEvents(Arrays.asList(BrowserEvents.KEYDOWN, BrowserEvents.KEYUP, BrowserEvents.KEYPRESS,
            BrowserEvents.DBLCLICK, BrowserEvents.MOUSEDOWN, BrowserEvents.CLICK));

    // Make ENTER and SHIFT+ENTER in the header perform sorting
    addHeaderKeyUpHandler(new HeaderKeyUpHandler() {
        @Override
        public void onKeyUp(GridKeyUpEvent event) {
            if (event.getNativeKeyCode() != KeyCodes.KEY_ENTER) {
                return;
            }
            if (getHeader().getRow(event.getFocusedCell().getRowIndex()).isDefault()) {
                // Only sort for enter on the default header
                sorter.sort(event.getFocusedCell().getColumn(), event.isShiftKeyDown());
            }
        }
    });

    addDataAvailableHandler(new DataAvailableHandler() {
        @Override
        public void onDataAvailable(DataAvailableEvent event) {
            dataIsBeingFetched = false;
        }
    });
}

From source file:com.vaadin.client.widgets.Grid.java

License:Apache License

private boolean handleRendererEvent(Event event, RowContainer container) {

    if (container == escalator.getBody()) {
        Column<?, T> gridColumn = eventCell.getColumn();
        boolean enterKey = event.getType().equals(BrowserEvents.KEYDOWN)
                && event.getKeyCode() == KeyCodes.KEY_ENTER;
        boolean doubleClick = event.getType().equals(BrowserEvents.DBLCLICK);

        if (gridColumn.getRenderer() instanceof ComplexRenderer) {
            ComplexRenderer<?> cplxRenderer = (ComplexRenderer<?>) gridColumn.getRenderer();
            if (cplxRenderer.getConsumedEvents().contains(event.getType())) {
                if (cplxRenderer.onBrowserEvent(eventCell, event)) {
                    return true;
                }//w  w w .ja  va  2  s.  com
            }

            // Calls onActivate if KeyDown and Enter or double click
            if ((enterKey || doubleClick) && cplxRenderer.onActivate(eventCell)) {
                return true;
            }
        }
    }
    return false;
}

From source file:com.vaadin.v7.client.widgets.Grid.java

License:Apache License

/**
 * Creates a new instance./*from  ww w  .  j a  v a2  s .  c  o  m*/
 */
public Grid() {
    initWidget(escalator);
    getElement().setTabIndex(0);
    cellFocusHandler = new CellFocusHandler();

    setStylePrimaryName(STYLE_NAME);

    escalator.getHeader().setEscalatorUpdater(createHeaderUpdater());
    escalator.getBody().setEscalatorUpdater(createBodyUpdater());
    escalator.getFooter().setEscalatorUpdater(createFooterUpdater());

    header.setGrid(this);
    HeaderRow defaultRow = header.appendRow();
    header.setDefaultRow(defaultRow);

    footer.setGrid(this);

    editor.setGrid(this);

    setSelectionMode(SelectionMode.SINGLE);

    escalator.getBody().setSpacerUpdater(gridSpacerUpdater);

    escalator.addScrollHandler(new ScrollHandler() {
        @Override
        public void onScroll(ScrollEvent event) {
            fireEvent(new ScrollEvent());
        }
    });

    escalator.addRowVisibilityChangeHandler(new RowVisibilityChangeHandler() {
        @Override
        public void onRowVisibilityChange(RowVisibilityChangeEvent event) {
            if (dataSource != null && dataSource.size() != 0) {
                dataSource.ensureAvailability(event.getFirstVisibleRow(), event.getVisibleRowCount());
            }
        }
    });

    // Default action on SelectionEvents. Refresh the body so changed
    // become visible.
    addSelectionHandler(new SelectionHandler<T>() {

        @Override
        public void onSelect(SelectionEvent<T> event) {
            refreshBody();
        }
    });

    // Sink header events and key events
    sinkEvents(getHeader().getConsumedEvents());
    sinkEvents(Arrays.asList(BrowserEvents.KEYDOWN, BrowserEvents.KEYUP, BrowserEvents.KEYPRESS,
            BrowserEvents.DBLCLICK, BrowserEvents.MOUSEDOWN, BrowserEvents.CLICK));

    // Make ENTER and SHIFT+ENTER in the header perform sorting
    addHeaderKeyUpHandler(new HeaderKeyUpHandler() {
        @Override
        public void onKeyUp(GridKeyUpEvent event) {
            if (event.getNativeKeyCode() != KeyCodes.KEY_ENTER) {
                return;
            }
            if (getHeader().getRow(event.getFocusedCell().getRowIndex()).isDefault()) {
                // Only sort for enter on the default header
                sorter.sort(event.getFocusedCell().getColumn(), event.isShiftKeyDown());
            }
        }
    });

    browserEventHandlers.addAll(Arrays.asList(
            // Opening, closing and navigating in the editor
            new EditorEventHandler(),
            // Keyboard and click handlers, Escalator events
            new SuperEventHandler(),
            // Column reordering via header drag&drop
            new HeaderCellDragStartHandler(),
            // Column sorting via header click
            new HeaderDefaultRowEventHandler(),
            // Invoking event-aware renderers
            new RendererEventHandler(),
            // Moving cell focus by keyboard or mouse
            new CellFocusEventHandler()));

}

From source file:org.jbpm.console.ng.dm.client.experimental.pagination.DocumentListViewImpl.java

License:Apache License

private void initTableColumns(final SelectionModel<CMSContentSummary> selectionModel) {

    processdefListGrid.addCellPreviewHandler(new CellPreviewEvent.Handler<CMSContentSummary>() {

        @Override/*  w  w  w . ja va  2 s .c o  m*/
        public void onCellPreview(final CellPreviewEvent<CMSContentSummary> event) {
            CMSContentSummary summary = event.getValue();

            if (BrowserEvents.DBLCLICK.equalsIgnoreCase(event.getNativeEvent().getType())) {
                selectDocEvent.fire(new DocumentsListSearchEvent(summary));
                pathLink.setText(summary.getPath());
            }
        }
    });

    // Name String.
    Column<CMSContentSummary, String> processNameColumn = new Column<CMSContentSummary, String>(
            new TextCell()) {
        @Override
        public String getValue(CMSContentSummary object) {
            return object.getName();
        }
    };
    processNameColumn.setSortable(true);
    sortHandler.setComparator(processNameColumn, new Comparator<CMSContentSummary>() {
        @Override
        public int compare(CMSContentSummary o1, CMSContentSummary o2) {
            return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
        }
    });

    processdefListGrid.addColumn(processNameColumn,
            new ResizableHeader<CMSContentSummary>("Name", processdefListGrid, processNameColumn));

    // Version Type
    Column<CMSContentSummary, String> idColumn = new Column<CMSContentSummary, String>(new TextCell()) {
        @Override
        public String getValue(CMSContentSummary object) {
            return object.getId();
        }
    };

    processdefListGrid.addColumn(idColumn, new ResizableHeader("ID", processdefListGrid, idColumn));

    // actions (icons)
    List<HasCell<CMSContentSummary, ?>> cells = new LinkedList<HasCell<CMSContentSummary, ?>>();

    cells.add(new GoHasCell("Go", new Delegate<CMSContentSummary>() {
        @Override
        public void execute(CMSContentSummary process) {
            selectDocEvent.fire(new DocumentsListSearchEvent(process));
            pathLink.setText(process.getPath());
        }
    }));

    cells.add(new RemoveHasCell("Remove", new Delegate<CMSContentSummary>() {
        @Override
        public void execute(CMSContentSummary process) {
            removeDocEvent.fire(new DocumentRemoveSearchEvent(process));
        }
    }));

    CompositeCell<CMSContentSummary> cell = new CompositeCell<CMSContentSummary>(cells);
    Column<CMSContentSummary, CMSContentSummary> actionsColumn = new Column<CMSContentSummary, CMSContentSummary>(
            cell) {
        @Override
        public CMSContentSummary getValue(CMSContentSummary object) {
            return object;
        }
    };
    processdefListGrid.addColumn(actionsColumn,
            new ResizableHeader("Actions", processdefListGrid, actionsColumn));
    processdefListGrid.setColumnWidth(actionsColumn, "70px");
}