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.guvnor.enums.client.editor.EnumEditorViewImpl.java
License:Apache License
@PostConstruct public void init() { final CellTable<EnumRow> cellTable = new CellTable<EnumRow>(Integer.MAX_VALUE); cellTable.setWidth("100%"); final VerticalPanel panel = new VerticalPanel(); //Column definitions final DeleteButtonCellWidget deleteButton = new DeleteButtonCellWidget(); final Column<EnumRow, String> deleteButtonColumn = new Column<EnumRow, String>(deleteButton) { @Override/* ww w . ja v a2 s . com*/ public String getValue(final EnumRow enumRow) { return ""; } }; final Column<EnumRow, String> factNameColumn = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(final EnumRow enumRow) { return enumRow.getFactName(); } }; final Column<EnumRow, String> fieldNameColumn = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(final EnumRow enumRow) { return enumRow.getFieldName(); } }; final Column<EnumRow, String> contextColumn = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(final EnumRow enumRow) { return enumRow.getContext(); } }; //Write updates back to the model deleteButtonColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow object, final String value) { isDirty = true; dataProvider.getList().remove(index); } }); factNameColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow object, final String value) { isDirty = true; object.setFactName(value); } }); fieldNameColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow object, final String value) { isDirty = true; object.setFieldName(value); } }); contextColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow object, final String value) { isDirty = true; object.setContext(value); } }); cellTable.addColumn(deleteButtonColumn); cellTable.addColumn(factNameColumn, Constants.INSTANCE.FactColumnHeader()); cellTable.addColumn(fieldNameColumn, Constants.INSTANCE.FieldColumnHeader()); cellTable.addColumn(contextColumn, Constants.INSTANCE.ContextColumnHeader()); // Connect the table to the data provider. dataProvider.addDataDisplay(cellTable); final Button addButton = new Button(Constants.INSTANCE.AddEnum(), new ClickHandler() { public void onClick(ClickEvent clickEvent) { isDirty = true; final EnumRow enumRow = new EnumRow(); dataProvider.getList().add(enumRow); } }); panel.add(addButton); panel.add(cellTable); initWidget(panel); }
From source file:org.kie.guvnor.guided.scorecard.client.editor.GuidedScoreCardEditor.java
License:Apache License
private Widget addAttributeCellTable(final DirtyableFlexTable cGrid, final Characteristic characteristic) { final CellTable<Attribute> attributeCellTable = new CellTable<Attribute>(); final List<String> operators = new ArrayList<String>(); String dataType;/*from w w w. j a v a2 s . c om*/ if (characteristic == null) { dataType = "String"; } else { dataType = characteristic.getDataType(); } if ("String".equalsIgnoreCase(dataType)) { operators.addAll(Arrays.asList(stringOperators)); } else if ("boolean".equalsIgnoreCase(dataType)) { operators.addAll(Arrays.asList(booleanOperators)); } else { operators.addAll(Arrays.asList(numericOperators)); } //Operators column final DynamicSelectionCell categoryCell = new DynamicSelectionCell(operators); final Column<Attribute, String> operatorColumn = new Column<Attribute, String>(categoryCell) { public String getValue(final Attribute object) { return object.getOperator(); } }; operatorColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setOperator(value); attributeCellTable.redraw(); } }); //Value column final Column<Attribute, String> valueColumn = new Column<Attribute, String>(new CustomEditTextCell()) { public String getValue(final Attribute attribute) { return attribute.getValue(); } }; valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setValue(value); attributeCellTable.redraw(); } }); //Partial Score column final EditTextCell partialScoreCell = new EditTextCell(); final Column<Attribute, String> partialScoreColumn = new Column<Attribute, String>(partialScoreCell) { public String getValue(final Attribute attribute) { return "" + attribute.getPartialScore(); } }; partialScoreColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { try { double d = Double.parseDouble(value); object.setPartialScore(d); } catch (Exception e1) { partialScoreCell.clearViewData(object); } attributeCellTable.redraw(); } }); //Reason Code column final Column<Attribute, String> reasonCodeColumn = new Column<Attribute, String>(new EditTextCell()) { public String getValue(final Attribute attribute) { return attribute.getReasonCode(); } }; reasonCodeColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setReasonCode(value); attributeCellTable.redraw(); } }); final ActionCell.Delegate<Attribute> delegate = new ActionCell.Delegate<Attribute>() { public void execute(final Attribute attribute) { if (Window.confirm(Constants.INSTANCE.promptDeleteAttribute())) { final List<Attribute> list = characteristicsAttrMap.get(cGrid).getList(); list.remove(attribute); ((ListBox) cGrid.getWidget(2, 0)).setEnabled(list.size() == 0); ((ListBox) cGrid.getWidget(2, 1)).setEnabled(list.size() == 0); ((Button) cGrid.getWidget(0, 3)).setEnabled(list.size() != 2); attributeCellTable.redraw(); } } }; final Cell<Attribute> actionCell = new ActionCell<Attribute>(Constants.INSTANCE.remove(), delegate); final Column<Attribute, String> actionColumn = new IdentityColumn(actionCell); // Add the columns. attributeCellTable.addColumn(operatorColumn, Constants.INSTANCE.operator()); attributeCellTable.addColumn(valueColumn, Constants.INSTANCE.value()); attributeCellTable.addColumn(partialScoreColumn, Constants.INSTANCE.partialScore()); attributeCellTable.addColumn(reasonCodeColumn, Constants.INSTANCE.reasonCode()); attributeCellTable.addColumn(actionColumn, Constants.INSTANCE.actions()); attributeCellTable.setWidth("100%", true); attributeCellTable.setColumnWidth(operatorColumn, 5.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(valueColumn, 10.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(partialScoreColumn, 10.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(reasonCodeColumn, 10.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(actionColumn, 5.0, Style.Unit.PCT); ListDataProvider<Attribute> dataProvider = new ListDataProvider<Attribute>(); dataProvider.addDataDisplay(attributeCellTable); characteristicsAttrMap.put(cGrid, dataProvider); return (attributeCellTable); }
From source file:org.kie.guvnor.projecteditor.client.forms.DependencyGridViewImpl.java
License:Apache License
private void addArtifactIdColumn() { Column<Dependency, String> column = new Column<Dependency, String>(new EditTextCell()) { @Override// ww w. j ava 2s.c om public String getValue(Dependency dependency) { if (dependency.getArtifactId() != null) { return dependency.getArtifactId(); } else { return ""; } } }; column.setFieldUpdater(new FieldUpdater<Dependency, String>() { @Override public void update(int index, Dependency dependency, String value) { if (checkIsInValid(value)) { Window.alert(ProjectEditorConstants.INSTANCE.XMLMarkIsNotAllowed()); return; } dependency.setArtifactId(value); } }); dataGrid.addColumn(column, ProjectEditorConstants.INSTANCE.ArtifactID()); dataGrid.setColumnWidth(column, 60, Style.Unit.PCT); }
From source file:org.kie.guvnor.projecteditor.client.forms.DependencyGridViewImpl.java
License:Apache License
private void addGroupIdColumn() { Column<Dependency, String> column = new Column<Dependency, String>(new EditTextCell()) { @Override/*w ww . ja va 2 s . co m*/ public String getValue(Dependency dependency) { if (dependency.getGroupId() != null) { return dependency.getGroupId(); } else { return ""; } } }; column.setFieldUpdater(new FieldUpdater<Dependency, String>() { @Override public void update(int index, Dependency dependency, String value) { if (checkIsInValid(value)) { Window.alert(ProjectEditorConstants.INSTANCE.XMLMarkIsNotAllowed()); return; } dependency.setGroupId(value); } }); dataGrid.addColumn(column, ProjectEditorConstants.INSTANCE.GroupID()); dataGrid.setColumnWidth(column, 60, Style.Unit.PCT); }
From source file:org.kie.guvnor.projecteditor.client.forms.DependencyGridViewImpl.java
License:Apache License
private void addVersionColumn() { Column<Dependency, String> column = new Column<Dependency, String>(new EditTextCell()) { @Override/* ww w . ja va 2s . co m*/ public String getValue(Dependency dependency) { if (dependency.getVersion() != null) { return dependency.getVersion(); } else { return ""; } } }; column.setFieldUpdater(new FieldUpdater<Dependency, String>() { @Override public void update(int index, Dependency dependency, String value) { if (checkIsInValid(value)) { Window.alert(ProjectEditorConstants.INSTANCE.XMLMarkIsNotAllowed()); return; } dependency.setVersion(value); } }); dataGrid.addColumn(column, ProjectEditorConstants.INSTANCE.VersionID()); dataGrid.setColumnWidth(column, 60, Style.Unit.PCT); }
From source file:org.kie.guvnor.projecteditor.client.forms.DependencyGridViewImpl.java
License:Apache License
private void addRemoveRowColumn() { Column<Dependency, ImageResource> column = new Column<Dependency, ImageResource>(new TrashCanImageCell()) { @Override/* w ww.ja va 2s. c om*/ public ImageResource getValue(Dependency dependency) { return ProjectEditorResources.INSTANCE.Trash(); } }; column.setFieldUpdater(new FieldUpdater<Dependency, ImageResource>() { @Override public void update(int index, Dependency dependency, ImageResource value) { presenter.onRemoveDependency(dependency); } }); dataGrid.addColumn(column); dataGrid.setColumnWidth(column, 40, Style.Unit.PCT); }
From source file:org.kie.guvnor.projecteditor.client.messages.ProblemsScreenViewImpl.java
License:Apache License
private void addFileNameColumn() { Column<BuildMessage, String> column = new Column<BuildMessage, String>(new ClickableTextCell()) { @Override//from w ww . jav a 2s.c o m public String getValue(BuildMessage message) { if (message.getPath() != null) { return message.getPath().getFileName(); } else { return "-"; } } }; column.setFieldUpdater(new FieldUpdater<BuildMessage, String>() { @Override public void update(int index, BuildMessage buildMessage, String value) { if (buildMessage.getPath() != null) { placeManager.goTo(buildMessage.getPath()); } } }); dataGrid.addColumn(column, ProjectEditorConstants.INSTANCE.FileName()); dataGrid.setColumnWidth(column, 60, Style.Unit.PCT); }
From source file:org.kie.uberfire.plugin.client.editor.DynamicMenuEditor.java
License:Apache License
private void initTable(final AbstractCellTable<DynamicMenuItem> exampleTable) { exampleTable.setEmptyTableWidget(new Label("No menu items.")); final TextColumn<DynamicMenuItem> activityCol = new TextColumn<DynamicMenuItem>() { @Override//from w ww .j a v a 2 s. co m public String getValue(DynamicMenuItem object) { return String.valueOf(object.getActivityId()); } }; exampleTable.addColumn(activityCol, "Activity"); final TextColumn<DynamicMenuItem> labelCol = new TextColumn<DynamicMenuItem>() { @Override public String getValue(DynamicMenuItem object) { return object.getMenuLabel(); } }; exampleTable.addColumn(labelCol, "Label"); final ButtonCell buttonCell = new ButtonCell(IconType.REMOVE, ButtonType.DANGER, ButtonSize.MINI); final TooltipCellDecorator<String> decorator = new TooltipCellDecorator<String>(buttonCell); decorator.setText("delete row, if click"); Column<DynamicMenuItem, String> buttonCol = new Column<DynamicMenuItem, String>(decorator) { @Override public String getValue(DynamicMenuItem object) { return "delete"; } }; buttonCol.setFieldUpdater(new FieldUpdater<DynamicMenuItem, String>() { @Override public void update(final int index, final DynamicMenuItem object, final String value) { dataProvider.getList().remove(object); dataProvider.flush(); dataProvider.refresh(); } }); exampleTable.addColumn(buttonCol); final SingleSelectionModel<DynamicMenuItem> selectionModel = new SingleSelectionModel<DynamicMenuItem>(); selectionModel.addSelectionChangeHandler(new Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { DynamicMenuItem person = selectionModel.getSelectedObject(); DynamicMenuEditor.this.driver.edit(person); } }); exampleTable .setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.BOUND_TO_SELECTION); exampleTable.setSelectionModel(selectionModel); dataProvider.addDataDisplay(exampleTable); }
From source file:org.kie.workbench.common.forms.crud.client.component.CrudComponentViewImpl.java
License:Apache License
@Override public void showDeleteButtons() { final Column<MODEL, String> column = new Column<MODEL, String>( new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL)) { @Override/*from www . j a v a 2s. c o m*/ public String getValue(final MODEL model) { return translationService .getTranslation(CrudComponentConstants.CrudComponentViewImplDeleteInstance); } }; column.setFieldUpdater(new FieldUpdater<MODEL, String>() { @Override public void update(final int index, final Object model, final String s) { if (Window.confirm(translationService .getTranslation(CrudComponentConstants.CrudComponentViewImplDeleteBody))) { presenter.deleteInstance(index); } } }); table.addColumn(column, ""); }
From source file:org.kie.workbench.common.forms.crud.client.component.CrudComponentViewImpl.java
License:Apache License
@Override public void showEditButtons() { final Column<MODEL, String> column = new Column<MODEL, String>( new ButtonCell(IconType.EDIT, ButtonType.PRIMARY, ButtonSize.SMALL)) { @Override/* ww w . j a v a2 s . co m*/ public String getValue(final Object model) { return translationService .getTranslation(CrudComponentConstants.CrudComponentViewImplEditInstanceButton); } }; column.setFieldUpdater(new FieldUpdater<MODEL, String>() { @Override public void update(final int index, final Object model, final String s) { presenter.editInstance(index); } }); table.addColumn(column, ""); }