use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow in project kie-wb-common by kiegroup.
the class ReassignmentWidgetViewImplTest method testOnAddNewValueAndClose.
@Test
public void testOnAddNewValueAndClose() {
dataProvider.setList(new ArrayList<>());
final ReassignmentTypeListValue[] value = new ReassignmentTypeListValue[1];
ReassignmentsEditorWidget.GetReassignmentsCallback callback = v -> value[0] = v;
setFieldValue(presenter, "view", view);
reassignmentWidgetViewImpl.init(presenter, generateRows());
presenter.setCallback(callback);
setFieldValue(reassignmentWidgetViewImpl, "editor", reassignmentEditorWidget);
setFieldValue(reassignmentEditorWidget, "view", reassignmentEditorWidgetImpl);
ReassignmentRow newRow = new ReassignmentRow();
newRow.setId(111);
reassignmentWidgetViewImpl.addOrEdit(newRow);
reassignmentWidgetViewImpl.onSubscription(new ReassignmentEvent(null));
reassignmentWidgetViewImpl.ok();
reassignmentWidgetViewImpl.hide();
Assert.assertEquals(0, presenter.getValue().size());
Assert.assertEquals(4, value[0].getValues().size());
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow in project kie-wb-common by kiegroup.
the class ReassignmentWidgetViewImplTest method testRowCountOneAndTwo.
@Test
public void testRowCountOneAndTwo() {
List<ReassignmentRow> rows = new ArrayList<>();
rows.add(new ReassignmentRow());
reassignmentWidgetViewImpl.init(presenter, rows);
ListDataProvider<ReassignmentRow> dataProvider = getFieldValue(ReassignmentWidgetViewImpl.class, reassignmentWidgetViewImpl, "dataProvider");
Assert.assertEquals(1, dataProvider.getList().size());
rows = new ArrayList<>();
rows.add(new ReassignmentRow());
reassignmentWidgetViewImpl.init(presenter, rows);
Assert.assertEquals(1, dataProvider.getList().size());
rows.add(new ReassignmentRow());
reassignmentWidgetViewImpl.init(presenter, rows);
Assert.assertEquals(2, dataProvider.getList().size());
reassignmentWidgetViewImpl.init(presenter, Collections.EMPTY_LIST);
Assert.assertEquals(0, dataProvider.getList().size());
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow in project kie-wb-common by kiegroup.
the class ReassignmentsEditorWidget method showReassignmentsDialog.
void showReassignmentsDialog() {
reassignmentWidget.setValue(reassignmentTypeListValue.getValues().stream().map(r -> new ReassignmentRow(r)).collect(Collectors.toList()), true);
reassignmentWidget.setCallback(data -> setValue(data, true));
reassignmentWidget.show();
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow in project kie-wb-common by kiegroup.
the class ReassignmentWidgetViewImpl method initEdit.
private void initEdit() {
AbstractCell<ReassignmentRow> buttonCell = new AbstractCell<ReassignmentRow>(ClickEvent.getType().getName()) {
@Override
public void render(Context context, ReassignmentRow value, SafeHtmlBuilder sb) {
Button button = new Button();
button.setSize(ButtonSize.SMALL);
button.add(new Icon(IconType.EDIT));
sb.append(SafeHtmlUtils.fromTrustedString(button.toString()));
}
@Override
public void onBrowserEvent(Context context, Element parent, ReassignmentRow value, NativeEvent event, ValueUpdater<ReassignmentRow> valueUpdater) {
if (!readOnly) {
addOrEdit(value);
}
}
};
Column<ReassignmentRow, ReassignmentRow> editColumn = new Column<ReassignmentRow, ReassignmentRow>(buttonCell) {
@Override
public ReassignmentRow getValue(ReassignmentRow object) {
return object;
}
};
editColumn.setSortable(false);
table.addColumn(editColumn, StunnerFormsClientFieldsConstants.CONSTANTS.Edit());
table.setColumnWidth(editColumn, 50, Style.Unit.PX);
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow in project kie-wb-common by kiegroup.
the class ReassignmentWidgetViewImpl method initUsers.
private void initUsers() {
PopoverTextCell toUsers = new PopoverTextCell();
Column<ReassignmentRow, String> toUsersColumn = new Column<ReassignmentRow, String>(toUsers) {
@Override
public String getValue(ReassignmentRow object) {
if (object.getUsers() != null) {
return object.getUsers().stream().collect(Collectors.joining(","));
} else {
return "";
}
}
};
toUsersColumn.setSortable(false);
table.addColumn(toUsersColumn, presenter.getToUsersLabel());
table.setColumnWidth(toUsersColumn, 250, Style.Unit.PX);
}
Aggregations