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

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

Introduction

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

Prototype

public NativeEvent getNativeEvent() 

Source Link

Document

Get the NativeEvent to preview.

Usage

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);// w  ww  . j  av  a2  s . co 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   ww  w  . j a 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.retech.reader.web.client.labs.Labs.java

License:Apache License

@Inject
Labs(final CellList.Resources resource, final PlaceController placeController, final Provider<BasePlace> base) {
    this.setWaveContent(binder.createAndBindUi(this));

    setColor.setChangeElm(simplePanel.getElement());

    minimize.setIconElement(/* ww w  . ja v  a 2 s  .c o  m*/
            AbstractImagePrototype.create(WaveTitleResources.image().waveTitleMinimize()).createElement());

    // add Data
    List<LabsIconDecorator> list = listDataProvider.getList();
    LabsIconDecorator touch = new LabsIconDecorator(bunder.laboratory(), "", WaveTest.class);
    list.add(touch);

    LabsIconDecorator flip = new LabsIconDecorator(bunder.laboratory(), "3D", BookFlip.class);
    list.add(flip);

    LabsIconDecorator contact = new LabsIconDecorator(bunder.laboratory(), "??",
            ContactPanel.class);
    list.add(contact);

    LabsIconDecorator treeTest = new LabsIconDecorator(bunder.laboratory(), "TreeTest", TreeTest.class);
    list.add(treeTest);

    LabsIconDecorator search = new LabsIconDecorator(bunder.laboratory(), "?", SearchPanel.class);
    list.add(search);

    LabsIconDecorator blipTest = new LabsIconDecorator(bunder.laboratory(), "BlipTest", BlipTest.class);
    list.add(blipTest);

    LabsIconDecorator blipTree = new LabsIconDecorator(bunder.laboratory(), "NestedBlipTest",
            NestedBlipTest.class);
    list.add(blipTree);

    LabsIconDecorator settingsView = new LabsIconDecorator(bunder.laboratory(), "", SettingsView.class);
    list.add(settingsView);

    LabsIconDecorator contactPanel = new LabsIconDecorator(bunder.laboratory(), "", ContactPanel.class);
    list.add(contactPanel);

    server.add(
            new Anchor("Android", "https://build.phonegap.com/apps/95095/download/android", "_blank"));
    server.add(
            new Anchor("iOS", "https://build.phonegap.com/apps/95095/download/ios", "_blank"));
    server.add(new Anchor("Google Play?",
            "https://play.google.com/store/apps/details?id=com.goodow.web.mobile", "_blank"));
    server.add(new Anchor("SCM - Subversion", SERVER_URL + "/svn/retech", "_blank"));
    server.add(new Anchor("Files", SERVER_URL + "/files", "_blank"));
    server.add(new Anchor("Document", SERVER_URL + "/svn/retech/document", "_blank"));
    server.add(new Anchor("CI - Hudson", SERVER_URL + ":8080", "_blank"));
    server.add(new Anchor("Repository - Nexus", SERVER_URL + ":8081/nexus", "_blank"));

    // add cell
    List<HasCell<LabsIconDecorator, ?>> hasCells = new ArrayList<HasCell<LabsIconDecorator, ?>>();
    hasCells.add(new HasCell<LabsIconDecorator, LabsIconDecorator>() {

        LabsIconDecoratorCell cell = new LabsIconDecoratorCell(
                new LabsIconDecoratorCell.Delegate<LabsIconDecorator>() {

                    @Override
                    public void execute(final LabsIconDecorator object) {
                        placeController.goTo(base.get().setPath(object.getClassName().getName()));
                    }
                });

        @Override
        public Cell<LabsIconDecorator> getCell() {
            return cell;
        }

        @Override
        public FieldUpdater<LabsIconDecorator, LabsIconDecorator> getFieldUpdater() {
            return null;
        }

        @Override
        public LabsIconDecorator getValue(final LabsIconDecorator object) {
            return object;
        }
    });

    hasCells.add(new HasCell<LabsIconDecorator, LabsIconDecorator>() {

        private TrangleButtonCell<LabsIconDecorator> tbc = new TrangleButtonCell<LabsIconDecorator>();

        @Override
        public Cell<LabsIconDecorator> getCell() {
            return tbc;
        }

        @Override
        public FieldUpdater<LabsIconDecorator, LabsIconDecorator> getFieldUpdater() {
            return null;
        }

        @Override
        public LabsIconDecorator getValue(final LabsIconDecorator object) {
            return object;
        }
    });

    compositeCell = new CompositeCell<LabsIconDecorator>(hasCells) {

        @Override
        public void render(final com.google.gwt.cell.client.Cell.Context context, final LabsIconDecorator value,
                final SafeHtmlBuilder sb) {
            super.render(context, value, sb);
        }

        @Override
        protected Element getContainerElement(final Element parent) {
            return parent;
        }

        @Override
        protected <X> void render(final com.google.gwt.cell.client.Cell.Context context,
                final LabsIconDecorator value, final SafeHtmlBuilder sb,
                final HasCell<LabsIconDecorator, X> hasCell) {
            Cell<X> cell = hasCell.getCell();
            cell.render(context, hasCell.getValue(value), sb);
        }
    };

    // add cellList
    cellList = new CellList<LabsIconDecorator>(compositeCell, resource);

    // add cellPreviewHanler
    cellList.addCellPreviewHandler(new CellPreviewEvent.Handler<LabsIconDecorator>() {

        @Override
        public void onCellPreview(final CellPreviewEvent<LabsIconDecorator> event) {
            NativeEvent nativeEvent = event.getNativeEvent();
            boolean isClick = nativeEvent.getType().equals(BrowserEvents.CLICK);
            if (isClick) {
                Element clickelm = cellList.getRowElement(event.getIndex());
                Element eventTarget = Element.as(nativeEvent.getEventTarget());
                if (clickelm.getFirstChildElement() == eventTarget) {
                    if (Labs.this.lastElm == null) {
                        Labs.this.lastElm = clickelm;
                    }
                    if (Labs.this.lastElm != clickelm) {
                        Labs.this.lastElm.removeClassName(LabsResources.css().cellListSelectionItem());
                        clickelm.addClassName(LabsResources.css().cellListSelectionItem());
                        Labs.this.lastElm = clickelm;
                    } else if (Labs.this.lastElm == clickelm) {
                        clickelm.addClassName(LabsResources.css().cellListSelectionItem());
                    }
                }
            }
        }
    });
    simplePanel.add(cellList);
}

From source file:eu.zeigermann.gwt.demo.client.item.DefaultItemView.java

License:Apache License

private void initTable(AsyncDataProvider<ItemDto> dataProvider) {
    final ProvidesKey<ItemDto> keyProvider = new ProvidesKey<ItemDto>() {
        public Object getKey(ItemDto list) {
            return list == null ? null : list.getId();
        }/*from www. j a  v  a 2s  .c om*/
    };
    cellTable = new CellTable<ItemDto>(keyProvider);
    dataProvider.addDataDisplay(cellTable);
    cellTable.setPageSize(5);

    cellTable.sinkEvents(Event.ONDBLCLICK);
    final MultiSelectionModel<ItemDto> selectionModel = new MultiSelectionModel<ItemDto>(keyProvider);
    cellTable.setSelectionModel(selectionModel, new CellPreviewEvent.Handler<ItemDto>() {

        @Override
        public void onCellPreview(CellPreviewEvent<ItemDto> event) {
            int eventType = Event.getTypeInt(event.getNativeEvent().getType());
            if (eventType == Event.ONDBLCLICK) {
                ItemDto list = event.getValue();
                presenter.edit(list);
            }
        }
    });

    // styles

    // bootstrap
    cellTable.addStyleName("table");
    cellTable.addStyleName("table-bordered");
    // makes selection invisible on every even row
    // cellTable.addStyleName("table-striped");

    AsyncHandler columnSortHandler = new AsyncHandler(cellTable);

    // columns
    addShopColumn(columnSortHandler);
    addNameColumn();
    addCheckedColumn();
    addEditColumn();
    addDeleteColumn();
}

From source file:eu.zeigermann.gwt.demo.client.list.DefaultShoppingListView.java

License:Apache License

private void initTable(ListDataProvider<ShoppingList> dataProvider) {
    final ProvidesKey<ShoppingList> keyProvider = new ProvidesKey<ShoppingList>() {
        public Object getKey(ShoppingList list) {
            return list == null ? null : list.getId();
        }// w ww .  jav a  2 s  .c  o  m
    };
    cellTable = new CellTable<ShoppingList>(keyProvider);
    dataProvider.addDataDisplay(cellTable);
    cellTable.setPageSize(5);

    cellTable.sinkEvents(Event.ONDBLCLICK);
    final MultiSelectionModel<ShoppingList> selectionModel = new MultiSelectionModel<ShoppingList>(keyProvider);
    cellTable.setSelectionModel(selectionModel, new CellPreviewEvent.Handler<ShoppingList>() {

        @Override
        public void onCellPreview(CellPreviewEvent<ShoppingList> event) {
            int eventType = Event.getTypeInt(event.getNativeEvent().getType());
            if (eventType == Event.ONDBLCLICK) {
                ShoppingList list = event.getValue();
                presenter.editItems(list);
            }
        }
    });

    // styles

    // bootstrap
    cellTable.addStyleName("table");
    cellTable.addStyleName("table-bordered");
    // makes selection invisible on every even row
    // cellTable.addStyleName("table-striped");

    // columns
    addNameColumn(dataProvider);
    addEditColumn();
    addDeleteColumn();
}

From source file:eu.zeigermann.gwt.demo.client.shop.DefaultShopView.java

License:Apache License

private void initTable(ListDataProvider<Shop> dataProvider) {
    final ProvidesKey<Shop> keyProvider = new ProvidesKey<Shop>() {
        public Object getKey(Shop list) {
            return list == null ? null : list.getId();
        }//w ww .j av  a2 s. c o  m
    };
    cellTable = new CellTable<Shop>(keyProvider);
    dataProvider.addDataDisplay(cellTable);
    cellTable.setPageSize(5);

    final MultiSelectionModel<Shop> selectionModel = new MultiSelectionModel<Shop>(keyProvider);
    cellTable.setSelectionModel(selectionModel, new CellPreviewEvent.Handler<Shop>() {

        @Override
        public void onCellPreview(CellPreviewEvent<Shop> event) {
            int eventType = Event.getTypeInt(event.getNativeEvent().getType());
            if (eventType == Event.ONCLICK) {
                Shop list = event.getValue();
                presenter.edit(list);
            }
        }
    });

    // styles

    // bootstrap
    cellTable.addStyleName("table");
    cellTable.addStyleName("table-bordered");
    // makes selection invisible on every even row
    // cellTable.addStyleName("table-striped");

    // columns
    addNameColumn(dataProvider);
    addEditColumn();
    addDeleteColumn();
}

From source file:org.aksw.TripleCheckMate.client.widgets.EvaluationTable.java

License:Apache License

private void createTable() {
    // Link to data provider
    dataProvider.addDataDisplay(tblEvalTriples);

    // Table properties
    tblEvalTriples.setPageSize(arrPagerSizes[0]);

    // Set Pagers (add both bottom and top)
    pgrTop.setDisplay(tblEvalTriples);//w w w.  j av a  2  s  .  c o  m
    pgrBottom.setDisplay(tblEvalTriples);

    // Table columns
    final SafeHtmlCell cellP = new SafeHtmlCell();
    Column<EvaluateItem, SafeHtml> colPred = new Column<EvaluateItem, SafeHtml>(cellP) {

        public SafeHtml getValue(EvaluateItem item) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.appendHtmlConstant(item.P.toHTMLString());
            return sb.toSafeHtml();
        }
    };

    tblEvalTriples.addColumn(colPred, "Predicate");

    final SafeHtmlCell cellO = new SafeHtmlCell();
    Column<EvaluateItem, SafeHtml> colObj = new Column<EvaluateItem, SafeHtml>(cellO) {

        public SafeHtml getValue(EvaluateItem item) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.appendHtmlConstant(item.O.toHTMLString());
            return sb.toSafeHtml();
        }
    };
    tblEvalTriples.addColumn(colObj, "Object");

    Column<EvaluateItem, Boolean> colIsValid = new Column<EvaluateItem, Boolean>(
            new CheckboxCell(true, false)) {

        public Boolean getValue(EvaluateItem item) {
            return item.isWrong;
        }
    };

    tblEvalTriples.addColumn(colIsValid, "Is Wrong");

    // Add a field updater to be notified when the user enters a new name.
    colIsValid.setFieldUpdater(new FieldUpdater<EvaluateItem, Boolean>() {

        public void update(int index, EvaluateItem object, Boolean value) {
            dataProvider.getList().get(index).isWrong = value;
            if (value == false) {
                dataProvider.getList().get(index).errorTittle = "";
                tblEvalTriples.redraw();
            } else {
                dlgEdit.setEvaluateItem(dataProvider.getList().get(index), true);
                dlgEdit.center();
                dlgEdit.show();
            }

        }
    });

    tblEvalTriples.addCellPreviewHandler(new CellPreviewEvent.Handler<EvaluateItem>() {

        long lastClick = -1000;

        public void onCellPreview(CellPreviewEvent<EvaluateItem> event) {

            long clictAt = System.currentTimeMillis();

            if (event.getNativeEvent().getType().contains("click")) {
                if (clictAt - lastClick < 600) { // dblclick on 2 clicks detected within 300 ms
                    int index = event.getIndex();
                    dlgEdit.setEvaluateItem(dataProvider.getList().get(index), false);
                    dlgEdit.center();
                    dlgEdit.show();
                }
                lastClick = System.currentTimeMillis();

            }
        }
    });

    final SafeHtmlCell cellError = new SafeHtmlCell();
    Column<EvaluateItem, SafeHtml> colError = new Column<EvaluateItem, SafeHtml>(cellError) {

        public SafeHtml getValue(EvaluateItem item) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.appendHtmlConstant(item.errorTittle);
            return sb.toSafeHtml();
        }
    };
    tblEvalTriples.addColumn(colError, "Error");

    // Setup sorting

    colPred.setSortable(true);
    sortHandler.setComparator(colPred, new Comparator<EvaluateItem>() {
        public int compare(EvaluateItem o1, EvaluateItem o2) {
            return o1.P.toString().compareTo(o2.P.toString());
        }
    });

    colObj.setSortable(true);
    sortHandler.setComparator(colObj, new Comparator<EvaluateItem>() {
        public int compare(EvaluateItem o1, EvaluateItem o2) {
            return o1.P.toString().compareTo(o2.P.toString());
        }
    });

    colIsValid.setSortable(true);
    sortHandler.setComparator(colIsValid, new Comparator<EvaluateItem>() {
        public int compare(EvaluateItem o1, EvaluateItem o2) {
            if (o1.isWrong == o2.isWrong)
                return 0;
            else
                return (o1.isWrong ? 1 : -1);
        }
    });

    colError.setSortable(true);
    sortHandler.setComparator(colError, new Comparator<EvaluateItem>() {
        public int compare(EvaluateItem o1, EvaluateItem o2) {
            return o1.errorTittle.compareTo(o2.errorTittle);
        }
    });

    tblEvalTriples.addColumnSortHandler(sortHandler);
    tblEvalTriples.getColumnSortList().push(colObj);
    tblEvalTriples.getColumnSortList().push(colPred);

    for (int i = 0; i < arrPagerSizes.length; i++) {
        lstPager.addItem("" + arrPagerSizes[i]);
    }
    lstPager.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            tblEvalTriples.setPageSize(arrPagerSizes[lstPager.getSelectedIndex()]);
        }
    });
}

From source file:org.apache.hupa.client.activity.MessageListActivity.java

License:Apache License

private boolean hasClickedButFirstCol(CellPreviewEvent<Message> event) {
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x0_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db2_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x1_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x20x00x1_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x20x0_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x2_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x3_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x20x00x0");
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x30x00x00x00x00x0_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x30x0_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x30x00x00x0_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x30x00x0_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x30x00x00x00x0_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x30x00x00x10x0_____org_apache_hupa_client_activity_MessageListActivity_java0x031dd50d6107e0db20x30x00x00x1");
    return "click".equals(event.getNativeEvent().getType()) && 0 != event.getColumn();
}

From source file:org.codesearch.searcher.client.ui.searchview.SearchViewImpl.java

License:Open Source License

private void initResultTable() {
    resultTable = new CellTable<SearchResultDto>(PAGE_SIZE);
    resultTable.addColumn(new TextColumn<SearchResultDto>() {

        /**/*from   w  w w .  ja v a  2  s . c o m*/
         * {@inheritDoc}
         */
        @Override
        public String getValue(SearchResultDto dto) {
            return relevanceFormatter.format(dto.getRelevance());
        }
    }, RELEVANCE_TITLE);

    resultTable.addColumn(new TextColumn<SearchResultDto>() {

        /**
         * {@inheritDoc}
         */
        @Override
        public String getValue(SearchResultDto object) {
            return object.getFilePath();
        }
    }, PATH_TITLE);
    resultTable.addColumn(new TextColumn<SearchResultDto>() {

        /**
         * {@inheritDoc}
         */
        @Override
        public String getValue(SearchResultDto dto) {
            return dto.getRepository();
        }
    }, REPOSITORY_TITLE);

    resultTable.addColumn(new TextColumn<SearchResultDto>() {

        /**
         * {@inheritDoc}
         */
        @Override
        public String getValue(SearchResultDto dto) {
            return dto.getLastRevision();
        }
    }, REVISION_TITLE);

    final SelectionModel<SearchResultDto> selectionModel = new NoSelectionModel<SearchResultDto>();
    resultTable.setSelectionModel(selectionModel);

    resultTable.addCellPreviewHandler(new CellPreviewEvent.Handler<SearchResultDto>() {

        @Override
        public void onCellPreview(CellPreviewEvent<SearchResultDto> event) {
            SearchResultDto dto = event.getValue();
            boolean open = false;
            boolean newTab = false;
            if ("click".equals(event.getNativeEvent().getType())) {
                if ((NativeEvent.BUTTON_LEFT & event.getNativeEvent().getButton()) == NativeEvent.BUTTON_LEFT) {
                    open = true;
                }
                if ((NativeEvent.BUTTON_MIDDLE
                        & event.getNativeEvent().getButton()) == NativeEvent.BUTTON_MIDDLE) {
                    open = true;
                    newTab = true;
                }
            } else if ("keyup".equals(event.getNativeEvent().getType())) {
                if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode()) {
                    open = true;
                }
            }
            if (open) {
                // either CTRL+CLICK or CTRL+ENTER open a new tab
                if (event.getNativeEvent().getCtrlKey()) {
                    newTab = true;
                }
                Place target = new FilePlace(dto.getRepository(), dto.getFilePath(), searchBox.getValue(), 1);
                if (newTab) {

                    String url = Window.Location.getPath() + "#";
                    url += ClientFactory.getDefaultFactory().getHistoryMapper().getToken(target);
                    Window.open(url, "_blank", "");
                } else {
                    presenter.goTo(target);
                }
            }
        }
    });

    // Create a pager to control the table.
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    resultTablePager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    resultTablePager.setDisplay(resultTable);
    searchResultDataProvider = new ListDataProvider<SearchResultDto>();
    searchResultDataProvider.addDataDisplay(resultTable);
}

From source file:org.eclipse.che.ide.ext.datasource.client.sqllauncher.ResultCellTable.java

License:Open Source License

@Inject
public ResultCellTable(final @Assisted int pageSize,
        final @NotNull CellTableResourcesQueryResults cellTableResources,
        final @NotNull SqlRequestLauncherConstants constants) {
    super(pageSize, cellTableResources);

    final InlineLabel emptyWidget = new InlineLabel(constants.emptyResult());
    setEmptyTableWidget(emptyWidget);/*from w w w. ja  v  a2 s  .c o m*/
    emptyWidget.setStyleName(cellTableResources.cellTableStyle().emptyTableWidget());

    addCellPreviewHandler(new CellPreviewEvent.Handler<List<String>>() {
        @Override
        public void onCellPreview(CellPreviewEvent<List<String>> event) {
            if ("click".equals(event.getNativeEvent().getType())) {
                TableCellElement cellElement = getRowElement(event.getIndex()).getCells()
                        .getItem(event.getColumn());
                cellElement.setTitle(cellElement.getInnerText());
            }
        }
    });
}