List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:eu.europeana.uim.gui.cp.client.europeanawidgets.ImportResourcesWidget.java
License:EUPL
/** * Add the columns to the table.//from www . j a va2s .c o m */ private void initTableColumns(final SelectionModel<SugarCRMRecordDTO> selectionModel, ListHandler<SugarCRMRecordDTO> sortHandler) { // Checkbox column. This table will uses a checkbox column for // selection. // Alternatively, you can call cellTable.setSelectionEnabled(true) to // enable // mouse selection. Column<SugarCRMRecordDTO, Boolean> checkColumn = new Column<SugarCRMRecordDTO, Boolean>( new CheckboxCell(true, false)) { @Override public Boolean getValue(SugarCRMRecordDTO object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; cellTable.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); cellTable.setColumnWidth(checkColumn, 40, Unit.PX); // IsImported column Column<SugarCRMRecordDTO, String> isImportedColumn = new Column<SugarCRMRecordDTO, String>( new ImageCell()) { @Override public String getValue(SugarCRMRecordDTO object) { return object.getImportedIMG(); } }; isImportedColumn.setSortable(true); sortHandler.setComparator(isImportedColumn, new Comparator<SugarCRMRecordDTO>() { public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) { return o1.getImportedIMG().compareTo(o2.getImportedIMG()); } }); cellTable.addColumn(isImportedColumn, EuropeanaClientConstants.UIMSTATELABEL); isImportedColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() { public void update(int index, SugarCRMRecordDTO object, String value) { dataProvider.refresh(); } }); cellTable.setColumnWidth(isImportedColumn, 7, Unit.PCT); // Collection Name Column Column<SugarCRMRecordDTO, Anchor> collectionColumn = new Column<SugarCRMRecordDTO, Anchor>( new AnchorCell()) { @Override public Anchor getValue(SugarCRMRecordDTO object) { Anchor hyper = new Anchor(); hyper.setName(object.getName()); hyper.setText(object.getName()); hyper.setHref(sugarLocation + object.getId()); hyper.setTarget("TOP"); return hyper; } }; collectionColumn.setSortable(true); sortHandler.setComparator(collectionColumn, new Comparator<SugarCRMRecordDTO>() { public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) { return o1.getName().compareTo(o2.getName()); } }); cellTable.addColumn(collectionColumn, EuropeanaClientConstants.DSNAMESEARCHLABEL); collectionColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, Anchor>() { public void update(int index, SugarCRMRecordDTO object, Anchor value) { dataProvider.refresh(); } }); cellTable.setColumnWidth(collectionColumn, 40, Unit.PCT); // Organization Name Column Column<SugarCRMRecordDTO, String> organizationColumn = new Column<SugarCRMRecordDTO, String>( new TextCell()) { @Override public String getValue(SugarCRMRecordDTO object) { return object.getOrganization_name(); } }; collectionColumn.setSortable(true); sortHandler.setComparator(organizationColumn, new Comparator<SugarCRMRecordDTO>() { public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) { return o1.getOrganization_name().compareTo(o2.getOrganization_name()); } }); cellTable.addColumn(organizationColumn, EuropeanaClientConstants.ORGANIZATIONSEARCHLABEL); organizationColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() { public void update(int index, SugarCRMRecordDTO object, String value) { dataProvider.refresh(); } }); cellTable.setColumnWidth(organizationColumn, 20, Unit.PCT); // Country Column Column<SugarCRMRecordDTO, String> countryColumn = new Column<SugarCRMRecordDTO, String>(new TextCell()) { @Override public String getValue(SugarCRMRecordDTO object) { return object.getCountry_c(); } }; countryColumn.setSortable(true); sortHandler.setComparator(countryColumn, new Comparator<SugarCRMRecordDTO>() { public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) { return o1.getCountry_c().compareTo(o2.getCountry_c()); } }); cellTable.addColumn(countryColumn, EuropeanaClientConstants.COUNTRYSEARCHLABEL); countryColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() { public void update(int index, SugarCRMRecordDTO object, String value) { dataProvider.refresh(); } }); cellTable.setColumnWidth(countryColumn, 5, Unit.PCT); // Status Column Column<SugarCRMRecordDTO, String> statusColumn = new Column<SugarCRMRecordDTO, String>(new TextCell()) { @Override public String getValue(SugarCRMRecordDTO object) { return object.getStatus(); } }; statusColumn.setSortable(true); sortHandler.setComparator(statusColumn, new Comparator<SugarCRMRecordDTO>() { public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) { return o1.getStatus().compareTo(o2.getStatus()); } }); cellTable.addColumn(statusColumn, EuropeanaClientConstants.STATUSSEARCHLABEL); statusColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() { public void update(int index, SugarCRMRecordDTO object, String value) { dataProvider.refresh(); } }); cellTable.setColumnWidth(statusColumn, 20, Unit.PCT); // Amount Column Column<SugarCRMRecordDTO, String> amountColumn = new Column<SugarCRMRecordDTO, String>(new TextCell()) { @Override public String getValue(SugarCRMRecordDTO object) { return object.getIngested_total_c(); } }; amountColumn.setSortable(true); sortHandler.setComparator(amountColumn, new Comparator<SugarCRMRecordDTO>() { public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) { return o1.getIngested_total_c().compareTo(o2.getIngested_total_c()); } }); cellTable.addColumn(amountColumn, EuropeanaClientConstants.AMOUNTSEARCHLABEL); amountColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() { public void update(int index, SugarCRMRecordDTO object, String value) { dataProvider.refresh(); } }); cellTable.setColumnWidth(amountColumn, 20, Unit.PCT); // Ingestion Date Column Column<SugarCRMRecordDTO, String> ingestionDateColumn = new Column<SugarCRMRecordDTO, String>( new TextCell()) { @Override public String getValue(SugarCRMRecordDTO object) { return object.getExpected_ingestion_date(); } }; ingestionDateColumn.setSortable(true); sortHandler.setComparator(ingestionDateColumn, new Comparator<SugarCRMRecordDTO>() { public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) { return o1.getExpected_ingestion_date().compareTo(o2.getExpected_ingestion_date()); } }); cellTable.addColumn(ingestionDateColumn, EuropeanaClientConstants.INGESTDATESEARCHLABEL); ingestionDateColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() { public void update(int index, SugarCRMRecordDTO object, String value) { dataProvider.refresh(); } }); cellTable.setColumnWidth(ingestionDateColumn, 20, Unit.PCT); // User Column Column<SugarCRMRecordDTO, String> userColumn = new Column<SugarCRMRecordDTO, String>(new TextCell()) { @Override public String getValue(SugarCRMRecordDTO object) { return object.getAssigned_user_name(); } }; userColumn.setSortable(true); sortHandler.setComparator(userColumn, new Comparator<SugarCRMRecordDTO>() { public int compare(SugarCRMRecordDTO o1, SugarCRMRecordDTO o2) { return o1.getAssigned_user_name().compareTo(o2.getAssigned_user_name()); } }); cellTable.addColumn(userColumn, EuropeanaClientConstants.USERSEARCHLABEL); userColumn.setFieldUpdater(new FieldUpdater<SugarCRMRecordDTO, String>() { public void update(int index, SugarCRMRecordDTO object, String value) { dataProvider.refresh(); } }); cellTable.setColumnWidth(userColumn, 20, Unit.PCT); }
From source file:eu.riscoss.client.riskanalysis.RASSelectionPanel.java
License:Apache License
public RASSelectionPanel() { exportJS();/*from w w w. ja va 2 s . c om*/ table = new CellTable<JRASInfo>(15, (Resources) GWT.create(TableResources.class)); table.addColumn(new Column<JRASInfo, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(JRASInfo object) { return new LinkHtml(object.getName(), "javascript:setSelectedRAS(\"" + object.getId() + "\")"); }; }, "Available Risk Analysis Sessions"); Column<JRASInfo, String> c = new Column<JRASInfo, String>(new ButtonCell()) { @Override public String getValue(JRASInfo object) { return "Delete"; } }; c.setFieldUpdater(new FieldUpdater<JRASInfo, String>() { @Override public void update(int index, JRASInfo object, String value) { deleteRAS(object); } }); table.addColumn(c, ""); dataProvider = new ListDataProvider<JRASInfo>(); dataProvider.addDataDisplay(table); Button button = new Button("Create New"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { onNewSessionRequested(); } }); SimplePager pager = new SimplePager(); pager.setDisplay(table); VerticalPanel tablePanel = new VerticalPanel(); tablePanel.add(table); tablePanel.add(pager); panel.add(button, DockPanel.NORTH); panel.add(tablePanel, DockPanel.CENTER); }
From source file:eu.riscoss.client.riskconfs.RiskConfsModule.java
License:Apache License
private <C> Column<RCInfo, C> addColumn(Cell<C> cell, final GetValue<C> getter, FieldUpdater<RCInfo, C> fieldUpdater) { Column<RCInfo, C> column = new Column<RCInfo, C>(cell) { @Override//from w w w . ja va2 s. c om public C getValue(RCInfo object) { return getter.getValue(object); } }; column.setFieldUpdater(fieldUpdater); return column; }
From source file:eu.zeigermann.gwt.demo.client.item.DefaultItemView.java
License:Apache License
private void addCheckedColumn() { Column<ItemDto, Boolean> checkedColumn = new Column<ItemDto, Boolean>(new CheckboxCell()) { @Override//from w ww . j a v a2 s . c o m public Boolean getValue(ItemDto object) { return object.isChecked(); } }; checkedColumn.setFieldUpdater(new FieldUpdater<ItemDto, Boolean>() { @Override public void update(int index, ItemDto object, Boolean value) { presenter.check(object, value); } }); cellTable.addColumn(checkedColumn, SafeHtmlUtils.fromSafeConstant("Checked")); }
From source file:gwt.material.design.demo.client.application.components.datagrid.DatagridView.java
License:Apache License
private DataGrid<OrderDTO> createDatagrid() { this.sortDataHandler = new ColumnSortEvent.ListHandler<>(new ArrayList<OrderDTO>()); // CHECKBOX/*from w ww . ja va 2 s. c o m*/ Column<OrderDTO, Boolean> checkColumn = new Column<OrderDTO, Boolean>(new MaterialCheckBoxCell()) { @Override public Boolean getValue(OrderDTO object) { return selectionModel.isSelected(object); } }; FieldUpdater<OrderDTO, Boolean> checkColumnFU = new FieldUpdater<OrderDTO, Boolean>() { @Override public void update(int index, OrderDTO object, Boolean value) { selectionModel.setSelected(object, value); } }; checkColumn.setFieldUpdater(checkColumnFU); // IMAGE Column<OrderDTO, MaterialImage> imageProfile = new Column<OrderDTO, MaterialImage>( new MaterialImageCell()) { @Override public MaterialImage getValue(OrderDTO object) { MaterialImage img = new MaterialImage(); img.setUrl(object.getUserPicture()); img.setWidth("40px"); img.setHeight("40px"); //SET IMAGE TO CIRCLE img.setType(ImageType.CIRCLE); return img; } }; // USER TextColumn<OrderDTO> colUser = new TextColumn<OrderDTO>() { @Override public String getValue(OrderDTO object) { return object.getUser(); } }; colUser.setSortable(true); sortDataHandler.setComparator(colUser, new Comparator<OrderDTO>() { @Override public int compare(OrderDTO o1, OrderDTO o2) { return o1.getUser().compareTo(o2.getUser()); } }); // ITEM NAME TextColumn<OrderDTO> colName = new TextColumn<OrderDTO>() { @Override public String getValue(OrderDTO object) { return object.getName(); } }; colName.setSortable(true); sortDataHandler.setComparator(colName, new Comparator<OrderDTO>() { @Override public int compare(OrderDTO o1, OrderDTO o2) { return o1.getName().compareTo(o2.getName()); } }); // PRICE TextColumn<OrderDTO> colPrice = new TextColumn<OrderDTO>() { @Override public String getValue(OrderDTO object) { return object.getPrice(); } }; colPrice.setSortable(true); sortDataHandler.setComparator(colPrice, new Comparator<OrderDTO>() { @Override public int compare(OrderDTO o1, OrderDTO o2) { return o1.getPrice().compareTo(o2.getPrice()); } }); // ACTION BUTTON Column<OrderDTO, MaterialButton> showLogBtnColumn = new Column<OrderDTO, MaterialButton>( new MaterialButtonCell()) { @Override public MaterialButton getValue(OrderDTO object) { MaterialButton mb = new MaterialButton(ButtonType.RAISED); mb.setText("Show log"); mb.setBackgroundColor("blue"); mb.setWaves(WavesType.LIGHT); mb.setIconType(IconType.POLYMER); mb.setIconPosition(IconPosition.LEFT); return mb; } }; showLogBtnColumn.setFieldUpdater(new FieldUpdater<OrderDTO, MaterialButton>() { @Override public void update(int index, OrderDTO object, MaterialButton value) { MaterialToast.fireToast(object.getName()); } }); final DataGrid<OrderDTO> dataGrid = new DataGrid<OrderDTO>(100, KEY_PROVIDER); dataGrid.setSize("100%", "40vh"); dataGrid.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); dataGrid.setColumnWidth(checkColumn, "50px"); dataGrid.addColumn(imageProfile, "Picture"); dataGrid.addColumn(colUser, "User"); dataGrid.addColumn(colName, "Item Name"); dataGrid.addColumn(colPrice, "Price"); dataGrid.addColumn(showLogBtnColumn, "Action"); dataGrid.setStyleName("striped responsive-table"); SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); SimplePager pager = new SimplePager(SimplePager.TextLocation.CENTER, pagerResources, false, 0, true); pager.setDisplay(dataGrid); pagerPanel.add(pager); orderDTOProvider = new ListDataProvider<OrderDTO>(); orderDTOProvider.addDataDisplay(dataGrid); dataGrid.addColumnSortHandler(sortDataHandler); return dataGrid; }
From source file:io.pelle.mango.client.gwt.modules.dictionary.controls.BaseControlFactory.java
License:Open Source License
@Override public <VOType extends IBaseVO> Column<ITableRow<VOType>, ?> createColumn(ControlType baseControl, boolean editable, final ListDataProvider<ITableRow<VOType>> listDataProvider, IMangoCellTable<VOType> mangoCellTable) { Column<IBaseTable.ITableRow<VOType>, String> column; if (editable) { final EditTextCellWithValidation editTextCell = new EditTextCellWithValidation(baseControl); column = new TableRowColumn<VOType>(baseControl.getModel(), editTextCell); FieldUpdater<IBaseTable.ITableRow<VOType>, String> fieldUpdater = new FieldUpdater<IBaseTable.ITableRow<VOType>, String>() { @Override/* w ww. j ava 2 s. c o m*/ public void update(int index, IBaseTable.ITableRow<VOType> tableRow, String value) { // Object key = BaseCellTable.KEYPROVIDER.getKey(tableRow); // // ViewData<String> viewData = (ViewData<String>) // editTextCell.getViewData(key); // if (validationMessages != null && // ValidationUtils.hasError(validationMessages)) // { // viewData.setValidationMessages(validationMessages); // // dataGrid.redraw(); // } // else // { // viewData.getValidationMessages().clear(); // // // vo.set(baseControl.getModel().getAttributePath(), // // // TypeHelper.convert(vo.getAttributeDescriptor(baseControl.getModel().getAttributePath()).getAttributeType(), // // value)); // } listDataProvider.refresh(); } }; column.setFieldUpdater(fieldUpdater); } else { column = new TableRowColumn<VOType>(baseControl.getModel(), new HighlightingTextCell(mangoCellTable)); } return column; }
From source file:io.pelle.mango.client.gwt.modules.dictionary.controls.BooleanControlFactory.java
License:Open Source License
@Override public <VOType extends IBaseVO> Column<ITableRow<VOType>, ?> createColumn(final BooleanControl booleanControl, boolean editable, ListDataProvider<ITableRow<VOType>> listDataProvider, IMangoCellTable<VOType> mangoCellTable) { if (editable) { final CheckboxCell checkboxCell = new CheckboxCell(); Column<IBaseTable.ITableRow<VOType>, Boolean> column = new Column<IBaseTable.ITableRow<VOType>, Boolean>( checkboxCell) {/*from w ww . j a v a 2 s . c o m*/ @Override public Boolean getValue(IBaseTable.ITableRow<VOType> tableRow) { return (Boolean) tableRow.getElement(booleanControl.getModel()).getValue(); } }; FieldUpdater<IBaseTable.ITableRow<VOType>, Boolean> fieldUpdater = new FieldUpdater<IBaseTable.ITableRow<VOType>, Boolean>() { @SuppressWarnings("unchecked") @Override public void update(int index, IBaseTable.ITableRow<VOType> tableRow, Boolean value) { tableRow.getElement(booleanControl.getModel()).setValue(value); } }; column.setFieldUpdater(fieldUpdater); return column; } else { return super.createColumn(booleanControl, editable, listDataProvider, mangoCellTable); } }
From source file:io.pelle.mango.client.gwt.modules.dictionary.controls.EnumerationControlFactory.java
License:Open Source License
@Override public <VOType extends IBaseVO> Column<ITableRow<VOType>, ?> createColumn( final EnumerationControl<ENUM_TYPE> enumerationControl, boolean editable, ListDataProvider<ITableRow<VOType>> listDataProvider, IMangoCellTable<VOType> mangoCellTable) { if (editable) { final SelectionCell selectionCell = new SelectionCell( new ArrayList(enumerationControl.getEnumerationMap().values())); Column<IBaseTable.ITableRow<VOType>, String> column = new Column<IBaseTable.ITableRow<VOType>, String>( selectionCell) {/* w w w . java2 s .c o m*/ @Override public String getValue(IBaseTable.ITableRow<VOType> tableRow) { return tableRow.getElement(enumerationControl.getModel()).format(); } }; FieldUpdater<IBaseTable.ITableRow<VOType>, String> fieldUpdater = new FieldUpdater<IBaseTable.ITableRow<VOType>, String>() { @SuppressWarnings("unchecked") @Override public void update(int index, IBaseTable.ITableRow<VOType> tableRow, String value) { tableRow.getElement(enumerationControl.getModel()) .setValue(GwtEnumerationControl.getEnumForText(enumerationControl, value)); } }; column.setFieldUpdater(fieldUpdater); return column; } else { return super.createColumn(enumerationControl, editable, listDataProvider, mangoCellTable); } }
From source file:io.pelle.mango.client.gwt.modules.dictionary.controls.ReferenceControlFactory.java
License:Open Source License
@Override public <VOType extends IBaseVO> Column<ITableRow<VOType>, ?> createColumn( final ReferenceControl<?> referenceControl, boolean editable, ListDataProvider<ITableRow<VOType>> listDataProvider, IMangoCellTable<VOType> mangoCellTable) { Column<IBaseTable.ITableRow<VOType>, VOType> column; if (editable) { final BaseCellControl<VOType> editTextCell; switch (referenceControl.getModel().getControlType()) { default:/*from ww w . j a v a2 s . c om*/ editTextCell = new SuggestCellControl<VOType>(referenceControl.getModel(), new MangoSuggestOracle(referenceControl)); break; } column = new Column<IBaseTable.ITableRow<VOType>, VOType>(editTextCell) { @SuppressWarnings("unchecked") @Override public VOType getValue(IBaseTable.ITableRow<VOType> tableRow) { return (VOType) tableRow.getElement(referenceControl.getModel()).getValue(); } }; FieldUpdater<IBaseTable.ITableRow<VOType>, VOType> fieldUpdater = new FieldUpdater<IBaseTable.ITableRow<VOType>, VOType>() { @SuppressWarnings("unchecked") @Override public void update(int index, IBaseTable.ITableRow<VOType> tableRow, VOType value) { tableRow.getElement(referenceControl.getModel()).setValue(value); } }; column.setFieldUpdater(fieldUpdater); } else { column = new Column<IBaseTable.ITableRow<VOType>, VOType>( new ReferenceCell<VOType>(referenceControl.getModel())) { @SuppressWarnings("unchecked") @Override public VOType getValue(IBaseTable.ITableRow<VOType> tableRow) { return (VOType) tableRow.getElement(referenceControl.getModel()).getValue(); } }; } return column; }
From source file:io.pelle.mango.client.gwt.modules.dictionary.controls.time.DateControlFactory.java
License:Open Source License
@Override public <VOType extends IBaseVO> Column<ITableRow<VOType>, ?> createColumn(final DateControl dateControl, boolean editable, ListDataProvider<ITableRow<VOType>> listDataProvider, IMangoCellTable<VOType> mangoCellTable) { if (editable) { final DatePickerCell datePickerCell = new DatePickerCell(); Column<IBaseTable.ITableRow<VOType>, Date> column = new Column<IBaseTable.ITableRow<VOType>, Date>( datePickerCell) {/* w w w. j av a2 s . c o m*/ @Override public Date getValue(IBaseTable.ITableRow<VOType> tableRow) { Object date = tableRow.getElement(dateControl.getModel()).getValue(); if (date == null) { return new Date(); } else { return (Date) tableRow.getElement(dateControl.getModel()).getValue(); } } }; FieldUpdater<IBaseTable.ITableRow<VOType>, Date> fieldUpdater = new FieldUpdater<IBaseTable.ITableRow<VOType>, Date>() { @SuppressWarnings("unchecked") @Override public void update(int index, IBaseTable.ITableRow<VOType> tableRow, Date value) { tableRow.getElement(dateControl.getModel()).setValue(value); } }; column.setFieldUpdater(fieldUpdater); return column; } else { return super.createColumn(dateControl, editable, listDataProvider, mangoCellTable); } }