List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:org.kie.workbench.common.widgets.configresource.client.widget.unbound.ImportsWidgetViewImpl.java
License:Apache License
private void setup() { //Setup table table.setStriped(true);//from ww w. ja va 2s.c o m table.setCondensed(true); table.setBordered(true); table.setEmptyTableWidget(new Label(ImportConstants.INSTANCE.noImportsDefined())); //Columns final TextColumn<Import> importTypeColumn = new TextColumn<Import>() { @Override public String getValue(final Import importType) { return importType.getType(); } }; final ButtonCell deleteImportButton = new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL); final Column<Import, String> deleteImportColumn = new Column<Import, String>(deleteImportButton) { @Override public String getValue(final Import importType) { return ImportConstants.INSTANCE.remove(); } }; deleteImportColumn.setFieldUpdater((index, importType, value) -> { if (isReadOnly) { return; } final YesNoCancelPopup confirm = YesNoCancelPopup.newYesNoCancelPopup(ImportConstants.INSTANCE.remove(), ImportConstants.INSTANCE.promptForRemovalOfImport0(importType.getType()), () -> getRemoveImportCommand().execute(importType), () -> { /*Nothing*/}, null); confirm.show(); }); table.addColumn(importTypeColumn, new TextHeader(ImportConstants.INSTANCE.importType())); table.addColumn(deleteImportColumn, ImportConstants.INSTANCE.remove()); //Link data getDataProvider().addDataDisplay(table); getDataProvider().setList(importTypes); }
From source file:org.livespark.formmodeler.editor.client.editor.dataHolder.DataObjectsAdminView.java
License:Apache License
public void init(final FormEditorPresenter presenter) { this.presenter = presenter; final TextColumn<DataHolder> nameColumn = new TextColumn<DataHolder>() { @Override//from w w w .j a va 2 s. c o m public void render(Cell.Context context, DataHolder object, SafeHtmlBuilder sb) { SafeHtml startDiv = new SafeHtml() { @Override public String asString() { return "<div style=\"cursor: pointer;\">"; } }; SafeHtml endDiv = new SafeHtml() { @Override public String asString() { return "</div>"; } }; sb.append(startDiv); super.render(context, object, sb); sb.append(endDiv); } @Override public String getValue(final DataHolder dataHolder) { return dataHolder.getName(); } }; dataObjectTable.addColumn(nameColumn, Constants.INSTANCE.dataObjectID()); dataObjectTable.setColumnWidth(nameColumn, 30, Style.Unit.PCT); final TextColumn<DataHolder> typeColumn = new TextColumn<DataHolder>() { @Override public void render(Cell.Context context, DataHolder object, SafeHtmlBuilder sb) { SafeHtml startDiv = new SafeHtml() { @Override public String asString() { return "<div style=\"cursor: pointer;\">"; } }; SafeHtml endDiv = new SafeHtml() { @Override public String asString() { return "</div>"; } }; sb.append(startDiv); super.render(context, object, sb); sb.append(endDiv); } @Override public String getValue(final DataHolder dataHolder) { return dataHolder.getType(); } }; dataObjectTable.addColumn(typeColumn, Constants.INSTANCE.dataObjectType()); final ButtonCell deleteCell = new ButtonCell(ButtonType.DANGER, IconType.TRASH); final Column<DataHolder, String> deleteDataObject = new Column<DataHolder, String>(deleteCell) { @Override public String getValue(final DataHolder global) { return Constants.INSTANCE.remove(); } }; deleteDataObject.setFieldUpdater(new FieldUpdater<DataHolder, String>() { public void update(final int index, final DataHolder dataHolder, final String value) { boolean doIt = false; if (presenter.hasBindedFields(dataHolder)) { doIt = Window.confirm(Constants.INSTANCE.dataObjectIsBindedMessage()); } else { doIt = Window.confirm(Constants.INSTANCE.areYouSureRemoveDataObject()); } if (doIt) presenter.removeDataHolder(dataHolder.getName()); } }); dataObjectTable.addColumn(deleteDataObject); }
From source file:org.livespark.formmodeler.editor.client.editor.dataHolder.DataObjectsAdminViewImpl.java
License:Apache License
public void init(final FormEditorPresenter presenter) { this.presenter = presenter; modal.setTitle(translationService.getTranslation(FormEditorConstants.FormEditorViewImplDataObjects)); modal.setBody(this); modal.add(new ModalFooterOKButton(new Command() { @Override/* ww w.j a v a 2 s . c o m*/ public void execute() { modal.hide(); } })); //Init data objects table dataObjectTable.setEmptyTableWidget(new Label(translationService .getTranslation(FormEditorConstants.DataObjectsAdminViewImplEmptyDataObjectsTable))); dataHolderListDataProvider.addDataDisplay(dataObjectTable); final TextColumn<DataHolder> nameColumn = new TextColumn<DataHolder>() { @Override public void render(Cell.Context context, DataHolder object, SafeHtmlBuilder sb) { SafeHtml startDiv = new SafeHtml() { @Override public String asString() { return "<div style=\"cursor: pointer;\">"; } }; SafeHtml endDiv = new SafeHtml() { @Override public String asString() { return "</div>"; } }; sb.append(startDiv); super.render(context, object, sb); sb.append(endDiv); } @Override public String getValue(final DataHolder dataHolder) { return dataHolder.getName(); } }; dataObjectTable.addColumn(nameColumn, translationService.getTranslation(FormEditorConstants.DataObjectsAdminViewImplDataObjectID)); dataObjectTable.setColumnWidth(nameColumn, 30, Style.Unit.PCT); final TextColumn<DataHolder> typeColumn = new TextColumn<DataHolder>() { @Override public void render(Cell.Context context, DataHolder object, SafeHtmlBuilder sb) { SafeHtml startDiv = new SafeHtml() { @Override public String asString() { return "<div style=\"cursor: pointer;\">"; } }; SafeHtml endDiv = new SafeHtml() { @Override public String asString() { return "</div>"; } }; sb.append(startDiv); super.render(context, object, sb); sb.append(endDiv); } @Override public String getValue(final DataHolder dataHolder) { return dataHolder.getType(); } }; dataObjectTable.addColumn(typeColumn, translationService.getTranslation(FormEditorConstants.DataObjectsAdminViewImplDataObjectType)); final ButtonCell deleteCell = new ButtonCell(ButtonType.DANGER, IconType.TRASH); final Column<DataHolder, String> deleteDataObject = new Column<DataHolder, String>(deleteCell) { @Override public String getValue(final DataHolder global) { return translationService.getTranslation(FormEditorConstants.DataObjectsAdminViewImplRemove); } }; deleteDataObject.setFieldUpdater(new FieldUpdater<DataHolder, String>() { public void update(final int index, final DataHolder dataHolder, final String value) { boolean doIt = false; if (presenter.hasBindedFields(dataHolder)) { doIt = Window.confirm(translationService .getTranslation(FormEditorConstants.DataObjectsAdminViewImplDataObjectIsBindedMessage)); } else { doIt = Window.confirm(translationService.getTranslation( FormEditorConstants.DataObjectsAdminViewImplAreYouSureRemoveDataObject)); } if (doIt) presenter.removeDataHolder(dataHolder.getName()); } }); dataObjectTable.addColumn(deleteDataObject); }
From source file:org.livespark.formmodeler.editor.client.editor.rendering.renderers.selectors.SelectorOptionFormViewImpl.java
License:Apache License
public SelectorOptionFormViewImpl() { initWidget(uiBinder.createAndBindUi(SelectorOptionFormViewImpl.this)); //Init data objects table optionsTable.setEmptyTableWidget(new Label(FieldProperties.INSTANCE.noOptionsDefined())); optionsListDataProvider.addDataDisplay(optionsTable); CheckboxCellImpl defaultValue = new CheckboxCellImpl(false); final Column<SelectorOption, Boolean> defaultValueColumn = new Column<SelectorOption, Boolean>( defaultValue) {/*from w ww. j a v a2 s . c o m*/ @Override public Boolean getValue(SelectorOption object) { return object.getDefaultValue(); } }; defaultValueColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); defaultValueColumn.setFieldUpdater(new FieldUpdater<SelectorOption, Boolean>() { @Override public void update(int index, SelectorOption option, Boolean value) { presenter.setDefaultValue(option); } }); optionsTable.addColumn(defaultValueColumn, FieldProperties.INSTANCE.defaultOption()); optionsTable.setColumnWidth(defaultValueColumn, 30, Style.Unit.PCT); final TextColumn<SelectorOption> valueColumn = new TextColumn<SelectorOption>() { @Override public void render(Cell.Context context, SelectorOption object, SafeHtmlBuilder sb) { SafeHtml startDiv = new SafeHtml() { @Override public String asString() { return "<div style=\"cursor: pointer;\">"; } }; SafeHtml endDiv = new SafeHtml() { @Override public String asString() { return "</div>"; } }; sb.append(startDiv); super.render(context, object, sb); sb.append(endDiv); } @Override public String getValue(final SelectorOption option) { return option.getValue(); } }; optionsTable.addColumn(valueColumn, FieldProperties.INSTANCE.option()); final TextColumn<SelectorOption> textColumn = new TextColumn<SelectorOption>() { @Override public void render(Cell.Context context, SelectorOption object, SafeHtmlBuilder sb) { SafeHtml startDiv = new SafeHtml() { @Override public String asString() { return "<div style=\"cursor: pointer;\">"; } }; SafeHtml endDiv = new SafeHtml() { @Override public String asString() { return "</div>"; } }; sb.append(startDiv); super.render(context, object, sb); sb.append(endDiv); } @Override public String getValue(final SelectorOption option) { return option.getText(); } }; optionsTable.addColumn(textColumn, FieldProperties.INSTANCE.optionText()); final ButtonCell deleteCell = new ButtonCell(ButtonType.DANGER, IconType.TRASH); final Column<SelectorOption, String> deleteOptionColumn = new Column<SelectorOption, String>(deleteCell) { @Override public String getValue(final SelectorOption option) { return Constants.INSTANCE.remove(); } }; deleteOptionColumn.setFieldUpdater(new FieldUpdater<SelectorOption, String>() { public void update(final int index, final SelectorOption option, final String value) { presenter.removeOption(option); } }); deleteOptionColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); optionsTable.addColumn(deleteOptionColumn); }
From source file:org.livespark.widgets.crud.client.component.CrudComponentViewImpl.java
License:Apache License
@Override public void init(CrudComponent.CrudMetaDefinition crudDefinition) { content.clear();/*from ww w. j a v a 2 s . c om*/ table = new UberfirePagedTable<>(crudDefinition.getPageSize()); table.getRightToolbar().clear(); if (crudDefinition.isAllowCreate()) { Button createButton = new Button(translationService .getTranslation(CrudComponentConstants.CrudComponentViewImplNewInstanceButton)); createButton.setType(ButtonType.PRIMARY); createButton.setIcon(IconType.PLUS); table.getLeftToolbar().add(createButton); createButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { showCreateForm(); } }); } List<ColumnMeta> columns = new ArrayList<ColumnMeta>(crudDefinition.getGridColumns()); if (crudDefinition.isAllowEdit()) { Column<Object, String> column = new Column<Object, String>( new ButtonCell(IconType.EDIT, ButtonType.PRIMARY, ButtonSize.SMALL)) { @Override public String getValue(Object model) { return translationService .getTranslation(CrudComponentConstants.CrudComponentViewImplEditInstanceButton); } }; column.setFieldUpdater(new FieldUpdater<Object, String>() { @Override public void update(int index, Object model, String s) { showEditionForm(index); } }); columns.add(new ColumnMeta(column, "")); } if (crudDefinition.isAllowDelete()) { Column<Object, String> column = new Column<Object, String>( new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL)) { @Override public String getValue(Object model) { return translationService .getTranslation(CrudComponentConstants.CrudComponentViewImplDeleteInstance); } }; column.setFieldUpdater(new FieldUpdater<Object, String>() { @Override public void update(final int index, Object model, String s) { if (Window.confirm(translationService .getTranslation(CrudComponentConstants.CrudComponentViewImplDeleteBody))) { deleteInstance(index); } } }); columns.add(new ColumnMeta(column, "")); } table.addColumns(columns); table.setDataProvider(crudDefinition.getDataProvider()); presenter.refresh(); content.add(table); }
From source file:org.mklab.taskit.client.ui.admin.AbstractEntityEditorView.java
License:Apache License
/** * ????/*from w ww .ja va 2 s.c o m*/ * * @return */ protected Column<E, String> createDeleteColumn() { final Column<E, String> deleteButtonColumn = new Column<E, String>(new ButtonCell()) { @SuppressWarnings({ "unused", "synthetic-access" }) @Override public String getValue(E object) { return getClientFactory().getMessages().deleteLabel(); } }; deleteButtonColumn.setFieldUpdater(new FieldUpdater<E, String>() { @Override @SuppressWarnings("unused") public void update(int index, E object, String value) { final E lecture = getPresenter().edit(object); getPresenter().delete(lecture); } }); return deleteButtonColumn; }
From source file:org.mklab.taskit.client.ui.admin.LectureEditorView.java
License:Apache License
private Column<LectureProxy, Date> createDateColumn() { final Column<LectureProxy, Date> dateColumn = new Column<LectureProxy, Date>(new DatePickerCell()) { @Override/*from w w w . j ava 2 s .co m*/ public Date getValue(LectureProxy object) { return object.getDate(); } }; dateColumn.setFieldUpdater(new FieldUpdater<LectureProxy, Date>() { @Override public void update(@SuppressWarnings("unused") int index, LectureProxy object, Date value) { final LectureProxy lecture = getPresenter().edit(object); lecture.setDate(value); getPresenter().save(lecture); } }); return dateColumn; }
From source file:org.mklab.taskit.client.ui.admin.LectureEditorView.java
License:Apache License
private Column<LectureProxy, String> createTitleColumn() { final Column<LectureProxy, String> titleColumn = new Column<LectureProxy, String>(new TextInputCell()) { @Override/* ww w. j a va 2 s . co m*/ public String getValue(LectureProxy object) { return object.getTitle(); } }; titleColumn.setFieldUpdater(new FieldUpdater<LectureProxy, String>() { @Override public void update(@SuppressWarnings("unused") int index, LectureProxy object, String value) { final LectureProxy lecture = getPresenter().edit(object); lecture.setTitle(value); getPresenter().save(lecture); } }); return titleColumn; }
From source file:org.mklab.taskit.client.ui.admin.LectureEditorView.java
License:Apache License
private Column<LectureProxy, String> createDescriptionColumn() { final Column<LectureProxy, String> descriptionColumn = new Column<LectureProxy, String>( new TextAreaCell()) { @Override/*from ww w .ja va2 s . c om*/ public String getValue(LectureProxy object) { return object.getDescription(); } }; descriptionColumn.setFieldUpdater(new FieldUpdater<LectureProxy, String>() { @Override public void update(@SuppressWarnings("unused") int index, LectureProxy object, String value) { final LectureProxy lecture = getPresenter().edit(object); lecture.setDescription(value); getPresenter().save(lecture); } }); return descriptionColumn; }
From source file:org.mklab.taskit.client.ui.admin.ReportEditorView.java
License:Apache License
private Column<ReportProxy, LectureProxy> createLectureColumn(List<LectureProxy> lectures) { final List<LectureProxy> options = new ArrayList<LectureProxy>(lectures); options.add(null);/*from w w w.j a v a 2s. c om*/ final SelectCell.Renderer<LectureProxy> lectureRenderer = new SelectCell.Renderer<LectureProxy>() { @SuppressWarnings({ "deprecation", "synthetic-access" }) @Override public String render(int index, LectureProxy value) { if (value == null) return ""; //$NON-NLS-1$ final String lectureIndexLabel = getClientFactory().getMessages() .lectureIndexLabel(String.valueOf(index + 1)); return lectureIndexLabel + " " + value.getDate().toLocaleString(); //$NON-NLS-1$ } }; final SelectCell.Comparator<LectureProxy> lectureComparator = new SelectCell.Comparator<LectureProxy>() { @Override public boolean equals(LectureProxy e1, LectureProxy e2) { if (e1 == null) { if (e2 == null) return true; return false; } if (e2 == null) return false; return e1.getId().equals(e2.getId()); } }; final Column<ReportProxy, LectureProxy> lectureColumn = new Column<ReportProxy, LectureProxy>( new SelectCell<LectureProxy>(options, lectureRenderer, lectureComparator)) { @Override public LectureProxy getValue(ReportProxy object) { return object.getLecture(); } }; lectureColumn.setFieldUpdater(new FieldUpdater<ReportProxy, LectureProxy>() { @Override public void update(@SuppressWarnings("unused") int index, ReportProxy object, LectureProxy value) { final ReportProxy report = getPresenter().edit(object); report.setLecture(value); getPresenter().save(report); } }); return lectureColumn; }