List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:org.mklab.taskit.client.ui.admin.ReportEditorView.java
License:Apache License
private Column<ReportProxy, String> createTitleColumn() { final Column<ReportProxy, String> titleColumn = new Column<ReportProxy, String>(new TextInputCell()) { @Override// w w w .j ava 2s . c om public String getValue(ReportProxy object) { return object.getTitle(); } }; titleColumn.setFieldUpdater(new FieldUpdater<ReportProxy, String>() { @Override public void update(@SuppressWarnings("unused") int index, ReportProxy object, String value) { final ReportProxy report = getPresenter().edit(object); report.setTitle(value); getPresenter().save(report); } }); return titleColumn; }
From source file:org.mklab.taskit.client.ui.admin.ReportEditorView.java
License:Apache License
private Column<ReportProxy, String> createDescriptionColumn() { final Column<ReportProxy, String> description = new Column<ReportProxy, String>(new TextAreaCell()) { @Override// www .j ava2s . c om public String getValue(ReportProxy object) { return object.getDescription(); } }; description.setFieldUpdater(new FieldUpdater<ReportProxy, String>() { @Override public void update(@SuppressWarnings("unused") int index, ReportProxy object, String value) { final ReportProxy report = getPresenter().edit(object); report.setDescription(value); getPresenter().save(report); } }); return description; }
From source file:org.mklab.taskit.client.ui.admin.ReportEditorView.java
License:Apache License
private Column<ReportProxy, String> createPointColumn() { final TextInputCell integerCell = new TextInputCell() { @Override//from w w w . j a v a 2 s . c o m protected void finishEditing(Element parent, String value, Object key, ValueUpdater<String> valueUpdater) { try { Integer.parseInt(value); } catch (Throwable e) { return; } super.finishEditing(parent, value, key, valueUpdater); } /** * {@inheritDoc} */ @Override public void onBrowserEvent(com.google.gwt.cell.client.Cell.Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) { if ("keyup".equals(event.getType())) { //$NON-NLS-1$ final InputElement input = getInputElement(parent); if (isNumber(input.getValue()) == false) { if (isNumber(value)) { input.setValue(value); } else { input.setValue("1"); //$NON-NLS-1$ } } } super.onBrowserEvent(context, parent, value, event, valueUpdater); } private boolean isNumber(String text) { try { Integer.parseInt(text); return true; } catch (Throwable e) { return false; } } }; final Column<ReportProxy, String> pointColumn = new Column<ReportProxy, String>(integerCell) { @Override public String getValue(ReportProxy object) { return String.valueOf(object.getPoint()); } }; pointColumn.setFieldUpdater(new FieldUpdater<ReportProxy, String>() { @Override public void update(@SuppressWarnings("unused") int index, ReportProxy object, String value) { final ReportProxy report = getPresenter().edit(object); report.setPoint(Integer.parseInt(value)); getPresenter().save(report); } }); return pointColumn; }
From source file:org.mklab.taskit.client.ui.admin.ReportEditorView.java
License:Apache License
private Column<ReportProxy, Date> createPeriodColumn() { final Column<ReportProxy, Date> periodColumn = new Column<ReportProxy, Date>(new NullableDatePickerCell()) { @Override//from w ww. jav a 2s. c om public Date getValue(ReportProxy object) { return object.getPeriod(); } }; periodColumn.setFieldUpdater(new FieldUpdater<ReportProxy, Date>() { @Override public void update(@SuppressWarnings("unused") int index, ReportProxy object, Date value) { final ReportProxy report = getPresenter().edit(object); report.setPeriod(value); getPresenter().save(report); } }); return periodColumn; }
From source file:org.mklab.taskit.client.ui.HelpCallListViewImpl.java
License:Apache License
private void initColumns() { this.table.addColumn(new Column<HelpCallListViewImpl.HelpCallListItem, String>(new TextCell()) { final DateTimeFormat format = DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM); @Override//from w w w .j a v a 2s . c o m public String getValue(HelpCallListItem object) { final Date date = object.getHelpCall().getDate(); return this.format.format(date); } }, getClientFactory().getMessages().dateLabel()); this.table.addColumn(new Column<HelpCallListItem, String>(new TextCell()) { @Override public String getValue(HelpCallListItem object) { return object.getHelpCall().getCaller().getId(); } }, getClientFactory().getMessages().callerColumnLabel()); this.table.addColumn(new Column<HelpCallListItem, String>(new TextCell()) { @Override public String getValue(HelpCallListItem object) { return object.getHelpCall().getMessage(); } }, getClientFactory().getMessages().messageLabel()); this.table.addColumn(new Column<HelpCallListItem, String>(new TextCell()) { @Override public String getValue(HelpCallListItem object) { List<String> usersInCharge = object.getUsersInCharge(); if (usersInCharge == null) return getClientFactory().getMessages().notLoadedYetMessage(); final StringBuilder userList = new StringBuilder(); for (int i = 0; i < usersInCharge.size(); i++) { if (i != 0) userList.append(","); //$NON-NLS-1$ userList.append(usersInCharge.get(i)); } return userList.toString(); } }, getClientFactory().getMessages().acceptingColumnLabel()); Column<HelpCallListItem, String> locationButtonColumn = new Column<HelpCallListItem, String>( new ButtonCell()) { @Override public String getValue(@SuppressWarnings("unused") HelpCallListItem object) { return getClientFactory().getMessages().locationLabel(); } }; locationButtonColumn.setFieldUpdater(new FieldUpdater<HelpCallListViewImpl.HelpCallListItem, String>() { @SuppressWarnings({ "synthetic-access", "unqualified-field-access" }) @Override public void update(int index, HelpCallListItem object, @SuppressWarnings("unused") String value) { final int y = table.getRowElement(index).getAbsoluteBottom(); final int x = table.getAbsoluteLeft() + table.getOffsetWidth(); final String userId = object.getHelpCall().getCaller().getId(); showUserMap(x, y, userId); } }); this.table.addColumn(locationButtonColumn); }
From source file:org.mklab.taskit.client.ui.StudentPanel.java
License:Apache License
private Column<LectureScore, AttendanceType> createAttendanceColumn() { final List<AttendanceType> attendanceTypes = new ArrayList<AttendanceType>(); for (AttendanceType type : AttendanceType.values()) { attendanceTypes.add(type);/*from ww w. j ava 2 s . co m*/ } attendanceTypes.add(null); final SelectCell<AttendanceType> selectionCell = new SelectCell<AttendanceType>(attendanceTypes, new SelectCell.Renderer<AttendanceType>() { @Override public String render(@SuppressWarnings("unused") int index, AttendanceType value) { return AttendanceListViewImpl.getLabelOfAttendanceType(StudentPanel.this.messages, value); } }); selectionCell.setEditable(this.editable); final Column<LectureScore, AttendanceType> attendanceColumn = new Column<StudentwiseRecordModel.LectureScore, AttendanceType>( selectionCell) { @Override public AttendanceType getValue(LectureScore object) { if (object.getAttendance() == null) return null; return object.getAttendance().getType(); } }; attendanceColumn.setFieldUpdater(new FieldUpdater<StudentwiseRecordModel.LectureScore, AttendanceType>() { @SuppressWarnings({ "unqualified-field-access", "synthetic-access", "unused" }) @Override public void update(int index, LectureScore object, AttendanceType value) { if (value == null) { presenter.delete(object.getAttendance()); return; } final LectureProxy lecture = object.getLecture(); presenter.attend(lecture, value); } }); return attendanceColumn; }
From source file:org.obiba.opal.web.gwt.app.client.magma.derive.view.ValueMapGrid.java
License:Open Source License
private void initializeNewValueColumn() { // New Value// ww w.j a va 2s.c o m Cell<String> cell = hasValueChoices() ? new SelectionCell(valueChoices) : new TextInputCell(); Column<ValueMapEntry, String> newValueColumn = new Column<ValueMapEntry, String>(cell) { @Override public String getValue(ValueMapEntry entry) { return entry.getNewValue(); } }; newValueColumn.setCellStyleNames("new-value"); table.addColumn(newValueColumn, translations.newValueLabel()); table.setColumnWidth(newValueColumn, "10em"); newValueColumn.setFieldUpdater(new FieldUpdater<ValueMapEntry, String>() { @Override public void update(int index, ValueMapEntry entry, String value) { entry.setNewValue(value); } }); }
From source file:org.obiba.opal.web.gwt.app.client.magma.derive.view.ValueMapGrid.java
License:Open Source License
private void initializeMissingColumn() { // Missing/*ww w.j av a2 s .co m*/ Column<ValueMapEntry, Boolean> missingColumn = new Column<ValueMapEntry, Boolean>(new CheckboxCell()) { @Override public Boolean getValue(ValueMapEntry entry) { return entry.isMissing(); } }; missingColumn.setCellStyleNames("new-missing"); table.addColumn(missingColumn, translations.missingLabel()); missingColumn.setFieldUpdater(new FieldUpdater<ValueMapEntry, Boolean>() { @Override public void update(int index, ValueMapEntry entry, Boolean value) { entry.setMissing(value); } }); }
From source file:org.obiba.opal.web.gwt.app.client.magma.importvariables.view.TableComparisonsTable.java
License:Open Source License
private void initCheckColumn() { Column<TableComparison, Boolean> checkColumn = new Column<TableComparison, Boolean>( new CheckboxCell(true, true) { @Override//from w w w . j ava2 s. c o m public void render(Context context, Boolean value, SafeHtmlBuilder sb) { // check if forbidden or has conflict TableComparison tc = (TableComparison) context.getKey(); if (tc.isSelectable()) { super.render(context, value, sb); } else { sb.append(SafeHtmlUtils.fromSafeConstant( "<input type=\"checkbox\" disabled=\"true\" tabindex=\"-1\"/>")); } } }) { @Override public Boolean getValue(TableComparison object) { // Get the value from the selection model. return getSelectionModel().isSelected(object); } }; checkColumn.setFieldUpdater(new FieldUpdater<ComparedDatasourcesReportStepView.TableComparison, Boolean>() { @Override public void update(int index, TableComparison object, Boolean value) { getSelectionModel().setSelected(object, value); } }); addColumn(checkColumn, createTableListCheckColumnHeader()); }
From source file:org.obiba.opal.web.gwt.app.client.magma.variable.view.CategoriesEditorModalView.java
License:Open Source License
private void addEditableColumns(Iterable<LocaleDto> locales) { checkActionCol = new CheckboxColumn<CategoryDto>(new CategoryDtoDisplay()); table.addColumn(checkActionCol, checkActionCol.getCheckColumnHeader()); table.setColumnWidth(checkActionCol, 1, Style.Unit.PX); Column<CategoryDto, String> nameCol = new EditableTabableColumn<CategoryDto>() { @Override//from ww w .j a v a2s .co m public String getValue(CategoryDto object) { return object.getName(); } }; nameCol.setFieldUpdater(new FieldUpdater<CategoryDto, String>() { @Override public void update(int index, CategoryDto object, String value) { object.setName(value); } }); table.addColumn(nameCol, translations.nameLabel()); // Render no locale renderLocalizedCategoryRows(""); // prepare cells for each translations for (LocaleDto locale : locales) { renderLocalizedCategoryRows(locale.getName()); } renderMissingColumn(); }