assertThat(property).isNotNull();
assertThat(property.getValue()).isSameAs(dataSource.getObject());
}
public void test_set_dataSource() throws Exception {
CanvasInfo canvas =
parseJavaInfo(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" final Canvas canvas = new Canvas();",
" FilterBuilder fb = new FilterBuilder();",
" canvas.addChild(fb);",
" ListGrid listGrid = new ListGrid();",
" DataSource dataSource = new DataSource();",
" dataSource.addField(new DataSourceTextField('newDSTextField_1', 'New TextField'));",
" listGrid.setDataSource(dataSource);",
" canvas.addChild(listGrid);",
" listGrid.moveTo(44, 90);",
" canvas.draw();",
" }",
"}");
canvas.refresh();
FilterBuilderInfo filterBuilder = canvas.getChildren(FilterBuilderInfo.class).get(0);
ListGridInfo listGrid = canvas.getChildren(ListGridInfo.class).get(0);
DataSourceInfo dataSource;
{
Property property = listGrid.getPropertyByTitle("dataSource");
ObjectPropertyEditor editor = (ObjectPropertyEditor) property.getEditor();
dataSource = (DataSourceInfo) editor.getValueComponent(property);
}
//
assertThat(filterBuilder.getChildren()).isEmpty();
assertThat(filterBuilder.getDataSource()).isNull();
Property property = filterBuilder.getPropertyByTitle("dataSource");
assertThat(property).isNotNull();
assertThat(property.getValue()).isNotNull(); // fake data source used
// assign DataSiurce
ObjectPropertyEditor editor = (ObjectPropertyEditor) property.getEditor();
editor.setComponent((GenericProperty) property, dataSource);
canvas.refresh();
// check
assertThat(filterBuilder.getChildren()).isEmpty();
assertThat(filterBuilder.getDataSource()).isSameAs(dataSource);
assertThat(property.getValue()).isSameAs(dataSource.getObject());
assertEditor(