List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:com.google.gwt.sample.expenses.client.ExpenseReportDetails.java
License:Apache License
private CellTable<ExpenseProxy> initTable() { CellTable.Resources resources = GWT.create(TableResources.class); table = new CellTable<ExpenseProxy>(100, resources, new EntityProxyKeyProvider<ExpenseProxy>()); Styles.Common common = Styles.common(); table.addColumnStyleName(0, common.spacerColumn()); table.addColumnStyleName(1, common.expenseDetailsDateColumn()); table.addColumnStyleName(3, common.expenseDetailsCategoryColumn()); table.addColumnStyleName(4, common.expenseDetailsAmountColumn()); table.addColumnStyleName(5, common.expenseDetailsApprovalColumn()); table.addColumnStyleName(6, common.spacerColumn()); // Spacer column. table.addColumn(new SpacerColumn<ExpenseProxy>()); // Created column. GetValue<ExpenseProxy, Date> createdGetter = new GetValue<ExpenseProxy, Date>() { public Date getValue(ExpenseProxy object) { return object.getCreated(); }/*from ww w . j a v a 2s . c om*/ }; defaultComparator = createColumnComparator(createdGetter, false); Comparator<ExpenseProxy> createdDesc = createColumnComparator(createdGetter, true); addColumn(table, "Created", new DateCell(DateTimeFormat.getFormat("MMM dd yyyy")), createdGetter, defaultComparator, createdDesc); lastComparator = defaultComparator; // Description column. addColumn(table, "Description", new TextCell(), new GetValue<ExpenseProxy, String>() { public String getValue(ExpenseProxy object) { return object.getDescription(); } }); // Category column. addColumn(table, "Category", new TextCell(), new GetValue<ExpenseProxy, String>() { public String getValue(ExpenseProxy object) { return object.getCategory(); } }); // Amount column. final GetValue<ExpenseProxy, Double> amountGetter = new GetValue<ExpenseProxy, Double>() { public Double getValue(ExpenseProxy object) { return object.getAmount(); } }; Comparator<ExpenseProxy> amountAsc = createColumnComparator(amountGetter, false); Comparator<ExpenseProxy> amountDesc = createColumnComparator(amountGetter, true); addColumn(table, "Amount", new NumberCell(NumberFormat.getCurrencyFormat()), new GetValue<ExpenseProxy, Number>() { public Number getValue(ExpenseProxy object) { return amountGetter.getValue(object); } }, amountAsc, amountDesc); // Dialog box to obtain a reason for a denial denialPopup.addCloseHandler(new CloseHandler<PopupPanel>() { public void onClose(CloseEvent<PopupPanel> event) { String reasonDenied = denialPopup.getReasonDenied(); ExpenseProxy record = denialPopup.getExpenseRecord(); if (reasonDenied == null || reasonDenied.length() == 0) { // Clear the view data. final Object key = items.getKey(record); approvalCell.clearViewData(key); // We need to redraw the table to reset the select box. syncCommit(record, null); } else { updateExpenseRecord(record, "Denied", reasonDenied); } // Return focus to the table. table.setFocus(true); } }); // Approval column. approvalCell = new ApprovalCell(); Column<ExpenseProxy, String> approvalColumn = addColumn(table, "Approval Status", approvalCell, new GetValue<ExpenseProxy, String>() { public String getValue(ExpenseProxy object) { return object.getApproval(); } }); approvalColumn.setFieldUpdater(new FieldUpdater<ExpenseProxy, String>() { public void update(int index, final ExpenseProxy object, String value) { if ("Denied".equals(value)) { denialPopup.setExpenseRecord(object); denialPopup.setReasonDenied(object.getReasonDenied()); denialPopup.popup(); } else { updateExpenseRecord(object, value, ""); } } }); // Spacer column. table.addColumn(new SpacerColumn<ExpenseProxy>()); return table; }
From source file:com.google.gwt.sample.showcase.client.content.cell.CwCellSampler.java
License:Apache License
/** * Add a column with a header.//from w ww .j a v a 2 s .c o m * * @param <C> the cell type * @param cell the cell used to render the column * @param headerText the header string * @param getter the value getter for the cell */ @ShowcaseSource private <C> Column<ContactInfo, C> addColumn(Cell<C> cell, String headerText, final GetValue<C> getter, FieldUpdater<ContactInfo, C> fieldUpdater) { Column<ContactInfo, C> column = new Column<ContactInfo, C>(cell) { @Override public C getValue(ContactInfo object) { return getter.getValue(object); } }; column.setFieldUpdater(fieldUpdater); if (cell instanceof AbstractEditableCell<?, ?>) { editableCells.add((AbstractEditableCell<?, ?>) cell); } contactList.addColumn(column, headerText); return column; }
From source file:com.google.gwt.sample.showcase.client.content.cell.CwCellTable.java
License:Apache License
/** * Add the columns to the table.// ww w . j ava2 s. c o m */ @ShowcaseSource private void initTableColumns(final SelectionModel<ContactInfo> selectionModel, ListHandler<ContactInfo> sortHandler) { // Checkbox column. This table will uses a checkbox column for selection. // Alternatively, you can call cellTable.setSelectionEnabled(true) to enable // mouse selection. Column<ContactInfo, Boolean> checkColumn = new Column<ContactInfo, Boolean>(new CheckboxCell(true, false)) { @Override public Boolean getValue(ContactInfo object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; cellTable.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); cellTable.setColumnWidth(checkColumn, 40, Unit.PX); // First name. Column<ContactInfo, String> firstNameColumn = new Column<ContactInfo, String>(new EditTextCell()) { @Override public String getValue(ContactInfo object) { return object.getFirstName(); } }; firstNameColumn.setSortable(true); sortHandler.setComparator(firstNameColumn, new Comparator<ContactInfo>() { public int compare(ContactInfo o1, ContactInfo o2) { return o1.getFirstName().compareTo(o2.getFirstName()); } }); cellTable.addColumn(firstNameColumn, constants.cwCellTableColumnFirstName()); firstNameColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { // Called when the user changes the value. object.setFirstName(value); ContactDatabase.get().refreshDisplays(); } }); cellTable.setColumnWidth(firstNameColumn, 20, Unit.PCT); // Last name. Column<ContactInfo, String> lastNameColumn = new Column<ContactInfo, String>(new EditTextCell()) { @Override public String getValue(ContactInfo object) { return object.getLastName(); } }; lastNameColumn.setSortable(true); sortHandler.setComparator(lastNameColumn, new Comparator<ContactInfo>() { public int compare(ContactInfo o1, ContactInfo o2) { return o1.getLastName().compareTo(o2.getLastName()); } }); cellTable.addColumn(lastNameColumn, constants.cwCellTableColumnLastName()); lastNameColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { // Called when the user changes the value. object.setLastName(value); ContactDatabase.get().refreshDisplays(); } }); cellTable.setColumnWidth(lastNameColumn, 20, Unit.PCT); // Category. final Category[] categories = ContactDatabase.get().queryCategories(); List<String> categoryNames = new ArrayList<String>(); for (Category category : categories) { categoryNames.add(category.getDisplayName()); } SelectionCell categoryCell = new SelectionCell(categoryNames); Column<ContactInfo, String> categoryColumn = new Column<ContactInfo, String>(categoryCell) { @Override public String getValue(ContactInfo object) { return object.getCategory().getDisplayName(); } }; cellTable.addColumn(categoryColumn, constants.cwCellTableColumnCategory()); categoryColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { for (Category category : categories) { if (category.getDisplayName().equals(value)) { object.setCategory(category); } } ContactDatabase.get().refreshDisplays(); } }); cellTable.setColumnWidth(categoryColumn, 130, Unit.PX); // Address. Column<ContactInfo, String> addressColumn = new Column<ContactInfo, String>(new TextCell()) { @Override public String getValue(ContactInfo object) { return object.getAddress(); } }; addressColumn.setSortable(true); addressColumn.setDefaultSortAscending(false); sortHandler.setComparator(addressColumn, new Comparator<ContactInfo>() { public int compare(ContactInfo o1, ContactInfo o2) { return o1.getAddress().compareTo(o2.getAddress()); } }); cellTable.addColumn(addressColumn, constants.cwCellTableColumnAddress()); cellTable.setColumnWidth(addressColumn, 60, Unit.PCT); }
From source file:com.google.gwt.sample.showcase.client.content.cell.CwCellValidation.java
License:Apache License
/** * Initialize this example.//from ww w .ja v a 2 s . co m */ @ShowcaseSource @Override public Widget onInitialize() { // Create a table. final CellTable<ContactInfo> table = new CellTable<ContactInfo>(10, ContactInfo.KEY_PROVIDER); // Add the Name column. table.addColumn(new Column<ContactInfo, String>(new TextCell()) { @Override public String getValue(ContactInfo object) { return object.getFullName(); } }, constants.cwCellValidationColumnName()); // Add an editable address column. final ValidatableInputCell addressCell = new ValidatableInputCell(constants.cwCellValidationError()); Column<ContactInfo, String> addressColumn = new Column<ContactInfo, String>(addressCell) { @Override public String getValue(ContactInfo object) { return object.getAddress(); } }; table.addColumn(addressColumn, constants.cwCellValidationColumnAddress()); addressColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, final ContactInfo object, final String value) { // Perform validation after 2 seconds to simulate network delay. new Timer() { @Override public void run() { if (isAddressValid(value)) { // The cell will clear the view data when it sees the updated // value. object.setAddress(value); // Push the change to the views. ContactDatabase.get().refreshDisplays(); } else { // Update the view data to mark the pending value as invalid. ValidationData viewData = addressCell .getViewData(ContactInfo.KEY_PROVIDER.getKey(object)); viewData.setInvalid(true); // We only modified the cell, so do a local redraw. table.redraw(); } } }.schedule(1000); } }); // Add the table to the database. ContactDatabase.get().addDataDisplay(table); return table; }
From source file:com.google.gwt.sample.showcase.client.content.cell.CwDataGrid.java
License:Apache License
/** * Add the columns to the table.//from w ww . j a va 2 s. co m */ @ShowcaseSource private void initTableColumns(final SelectionModel<ContactInfo> selectionModel, ListHandler<ContactInfo> sortHandler) { // Checkbox column. This table will uses a checkbox column for selection. // Alternatively, you can call dataGrid.setSelectionEnabled(true) to enable // mouse selection. Column<ContactInfo, Boolean> checkColumn = new Column<ContactInfo, Boolean>(new CheckboxCell(true, false)) { @Override public Boolean getValue(ContactInfo object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; dataGrid.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); dataGrid.setColumnWidth(checkColumn, 40, Unit.PX); // First name. Column<ContactInfo, String> firstNameColumn = new Column<ContactInfo, String>(new EditTextCell()) { @Override public String getValue(ContactInfo object) { return object.getFirstName(); } }; firstNameColumn.setSortable(true); sortHandler.setComparator(firstNameColumn, new Comparator<ContactInfo>() { public int compare(ContactInfo o1, ContactInfo o2) { return o1.getFirstName().compareTo(o2.getFirstName()); } }); dataGrid.addColumn(firstNameColumn, constants.cwDataGridColumnFirstName()); firstNameColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { // Called when the user changes the value. object.setFirstName(value); ContactDatabase.get().refreshDisplays(); } }); dataGrid.setColumnWidth(firstNameColumn, 20, Unit.PCT); // Last name. Column<ContactInfo, String> lastNameColumn = new Column<ContactInfo, String>(new EditTextCell()) { @Override public String getValue(ContactInfo object) { return object.getLastName(); } }; lastNameColumn.setSortable(true); sortHandler.setComparator(lastNameColumn, new Comparator<ContactInfo>() { public int compare(ContactInfo o1, ContactInfo o2) { return o1.getLastName().compareTo(o2.getLastName()); } }); dataGrid.addColumn(lastNameColumn, constants.cwDataGridColumnLastName()); lastNameColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { // Called when the user changes the value. object.setLastName(value); ContactDatabase.get().refreshDisplays(); } }); dataGrid.setColumnWidth(lastNameColumn, 20, Unit.PCT); // Age. Column<ContactInfo, Number> ageColumn = new Column<ContactInfo, Number>(new NumberCell()) { @Override public Number getValue(ContactInfo object) { return object.getAge(); } }; lastNameColumn.setSortable(true); sortHandler.setComparator(ageColumn, new Comparator<ContactInfo>() { public int compare(ContactInfo o1, ContactInfo o2) { return o1.getBirthday().compareTo(o2.getBirthday()); } }); Header<String> ageFooter = new Header<String>(new TextCell()) { @Override public String getValue() { List<ContactInfo> items = dataGrid.getVisibleItems(); if (items.size() == 0) { return ""; } else { int totalAge = 0; for (ContactInfo item : items) { totalAge += item.getAge(); } return "Avg: " + totalAge / items.size(); } } }; dataGrid.addColumn(ageColumn, new SafeHtmlHeader(SafeHtmlUtils.fromSafeConstant(constants.cwDataGridColumnAge())), ageFooter); dataGrid.setColumnWidth(ageColumn, 7, Unit.EM); // Category. final Category[] categories = ContactDatabase.get().queryCategories(); List<String> categoryNames = new ArrayList<String>(); for (Category category : categories) { categoryNames.add(category.getDisplayName()); } SelectionCell categoryCell = new SelectionCell(categoryNames); Column<ContactInfo, String> categoryColumn = new Column<ContactInfo, String>(categoryCell) { @Override public String getValue(ContactInfo object) { return object.getCategory().getDisplayName(); } }; dataGrid.addColumn(categoryColumn, constants.cwDataGridColumnCategory()); categoryColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { for (Category category : categories) { if (category.getDisplayName().equals(value)) { object.setCategory(category); } } ContactDatabase.get().refreshDisplays(); } }); dataGrid.setColumnWidth(categoryColumn, 130, Unit.PX); // Address. Column<ContactInfo, String> addressColumn = new Column<ContactInfo, String>(new TextCell()) { @Override public String getValue(ContactInfo object) { return object.getAddress(); } }; addressColumn.setSortable(true); sortHandler.setComparator(addressColumn, new Comparator<ContactInfo>() { public int compare(ContactInfo o1, ContactInfo o2) { return o1.getAddress().compareTo(o2.getAddress()); } }); dataGrid.addColumn(addressColumn, constants.cwDataGridColumnAddress()); dataGrid.setColumnWidth(addressColumn, 60, Unit.PCT); }
From source file:com.gwt2go.dev.client.ui.CellTableSortingViewImpl.java
License:Apache License
private void initTableColumns(final SelectionModel<ContactInfo> selectionModel, CellTableSorting<ContactInfo> cellTable) { // This table will uses a checkbox column for selection. // Alternatively, you can call cellTable.setSelectionEnabled(true) to // enable mouse selection. Column<ContactInfo, Boolean> checkColumn = new Column<ContactInfo, Boolean>(new CheckboxCell(true, true)) { @Override//ww w.j a v a 2s . co m public Boolean getValue(ContactInfo object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; checkColumn.setFieldUpdater(new FieldUpdater<ContactInfo, Boolean>() { public void update(int index, ContactInfo object, Boolean value) { // Called when the user clicks on a checkbox. selectionModel.setSelected(object, value); } }); cellTable.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br>")); cellTable.addColumn("First name", new TextCell(), new GetValue<ContactInfo, String>() { public String getValue(ContactInfo object) { return object.getFirstName(); } }, new SortHeader("First name")); // Last name. Column<ContactInfo, String> lastNameColumn = new Column<ContactInfo, String>(new EditTextCell()) { @Override public String getValue(ContactInfo object) { return object.getLastName(); } }; cellTable.addColumn(lastNameColumn, "Last name"); lastNameColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { // Called when the user changes the value. object.setLastName(value); ContactDatabase.get().refreshDisplays(); } }); // Category. final Category[] categories = ContactDatabase.get().queryCategories(); List<String> categoryNames = new ArrayList<String>(); for (Category category : categories) { categoryNames.add(category.getDisplayName()); } SelectionCell categoryCell = new SelectionCell(categoryNames); Column<ContactInfo, String> categoryColumn = new Column<ContactInfo, String>(categoryCell) { @Override public String getValue(ContactInfo object) { return object.getCategory().getDisplayName(); } }; cellTable.addColumn(categoryColumn, "Category"); categoryColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { for (Category category : categories) { if (category.getDisplayName().equals(value)) { object.setCategory(category); } } ContactDatabase.get().refreshDisplays(); } }); // Address. cellTable.addColumn("Address", new TextCell(), new GetValue<ContactInfo, String>() { public String getValue(ContactInfo object) { return object.getAddress(); } }, new SortHeader("Address")); cellTable.addColumn("Birthday", new DateCell(), new GetValue<ContactInfo, Date>() { public Date getValue(ContactInfo object) { return object.getBirthday(); } }, new SortHeader("Birthday")); }
From source file:com.gwt2go.dev.client.ui.CellTableViewImpl.java
License:Apache License
/** * Add the columns to the table.//from ww w .ja va 2 s . c o m */ private void initTableColumns(final SelectionModel<ContactInfo> selectionModel) { // This table will uses a checkbox column for selection. // Alternatively, you can call cellTable.setSelectionEnabled(true) to // enable mouse selection. Column<ContactInfo, Boolean> checkColumn = new Column<ContactInfo, Boolean>(new CheckboxCell(true, true)) { @Override public Boolean getValue(ContactInfo object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; checkColumn.setFieldUpdater(new FieldUpdater<ContactInfo, Boolean>() { public void update(int index, ContactInfo object, Boolean value) { // Called when the user clicks on a checkbox. selectionModel.setSelected(object, value); } }); cellTable.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br>")); // First name. // Column<ContactInfo, String> firstNameColumn = new Column<ContactInfo, // String>( // new EditTextCell()) { // @Override // public String getValue(ContactInfo object) { // return object.getFirstName(); // } // }; // TextHeader firstNameHeader = new TextHeader("First name"); // firstNameHeader.setUpdater(new ValueUpdater<String>() { // @Override // public void update(String value) { // Window.alert("Update the header"); // } // }); // // cellTable.addColumn(firstNameColumn, firstNameHeader); // // firstNameColumn // .setFieldUpdater(new FieldUpdater<ContactInfo, String>() { // public void update(int index, ContactInfo object, // String value) { // // Called when the user changes the value. // object.setFirstName(value); // ContactDatabase.get().refreshDisplays(); // } // }); addColumn("First name", new TextCell(), new GetValue<ContactInfo, String>() { public String getValue(ContactInfo object) { return object.getFirstName(); } }); // Last name. Column<ContactInfo, String> lastNameColumn = new Column<ContactInfo, String>(new EditTextCell()) { @Override public String getValue(ContactInfo object) { return object.getLastName(); } }; cellTable.addColumn(lastNameColumn, "Last name"); lastNameColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { // Called when the user changes the value. object.setLastName(value); ContactDatabase.get().refreshDisplays(); } }); // Category. final Category[] categories = ContactDatabase.get().queryCategories(); List<String> categoryNames = new ArrayList<String>(); for (Category category : categories) { categoryNames.add(category.getDisplayName()); } SelectionCell categoryCell = new SelectionCell(categoryNames); Column<ContactInfo, String> categoryColumn = new Column<ContactInfo, String>(categoryCell) { @Override public String getValue(ContactInfo object) { return object.getCategory().getDisplayName(); } }; cellTable.addColumn(categoryColumn, "Category"); categoryColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { for (Category category : categories) { if (category.getDisplayName().equals(value)) { object.setCategory(category); } } ContactDatabase.get().refreshDisplays(); } }); // Address. addColumn("Address", new TextCell(), new GetValue<ContactInfo, String>() { public String getValue(ContactInfo object) { return object.getAddress(); } }); // cellTable.addColumn(new Column<ContactInfo, String>(new TextCell()) { // @Override // public String getValue(ContactInfo object) { // return object.getAddress(); // } // }, "Address"); }
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 . j a v a 2s . co 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.mquick.client.application.home.HomePageView.java
License:Apache License
private void initCellTable() { TextColumn<ClientEntity> id_Column = new TextColumn<ClientEntity>() { @Override/* w w w . j av a2s. com*/ public String getValue(ClientEntity object) { if (object == null) return " "; return object.getMaigcCode() + ""; } }; expressportals.addColumn(id_Column, "ID"); TextColumn<ClientEntity> name_Column = new TextColumn<ClientEntity>() { @Override public String getValue(ClientEntity object) { if (object == null) return " "; return object.getName(); } }; expressportals.addColumn(name_Column, "NAME"); ButtonCell buttonCell = new ButtonCell(); Column<ClientEntity, String> action_Column = new Column<ClientEntity, String>(buttonCell) { @Override public String getValue(ClientEntity object) { // The value to display in the button. return "unimpl"; //object.getName(); } }; action_Column.setFieldUpdater(new FieldUpdater<ClientEntity, String>() { @Override public void update(int index, ClientEntity object, String value) { getUiHandlers().pushTerminal(index, object, value); } }); expressportals.addColumn(action_Column, "ACTION"); }
From source file:com.mvp4g.example.client.views.desktop.list.MailListView.java
License:Apache License
/** * Add a column with a header./*from www . j a va 2s. c o m*/ * * @param <C> the cell type * @param cell the cell used to render the column * @param headerText the header string * @param getter the value getter for the cell */ private <C> Column<MailItem, C> addColumn(com.google.gwt.cell.client.Cell<C> cell, String headerText, final GetValue<C> getter, FieldUpdater<MailItem, C> fieldUpdater) { Column<MailItem, C> column = new Column<MailItem, C>(cell) { @Override public C getValue(MailItem object) { return getter.getValue(object); } }; column.setFieldUpdater(fieldUpdater); list.addColumn(column, headerText); return column; }