CorrelativeFieldSelector { public void updatePointDataSource(Product product) { if (product != null) { final Class pointClass = com.vividsolutions.jts.geom.Point.class; final ProductNodeGroup<VectorDataNode> vectorDataGroup = product.getVectorDataGroup(); final List<VectorDataNode> vectorDataNodes = new ArrayList<VectorDataNode>(); for (VectorDataNode vectorDataNode : vectorDataGroup.toArray(new VectorDataNode[vectorDataGroup.getNodeCount()])) { final GeometryDescriptor geometryDescriptor = vectorDataNode.getFeatureType().getGeometryDescriptor(); if (geometryDescriptor != null && pointClass.isAssignableFrom(geometryDescriptor.getType().getBinding())) { vectorDataNodes.add(vectorDataNode); } } final ValueSet valueSet = new ValueSet(vectorDataNodes.toArray()); pointDataSourceProperty.getDescriptor().setValueSet(valueSet); } else { pointDataSourceProperty.getDescriptor().setValueSet(null); dataFieldProperty.getDescriptor().setValueSet(null); try { pointDataSourceProperty.setValue(null); dataFieldProperty.setValue(null); } catch (ValidationException ignore) { } } } CorrelativeFieldSelector(BindingContext bindingContext); void updatePointDataSource(Product product); void updateDataField(); void tryToSelectPointDataSource(VectorDataNode pointDataSource); void tryToSelectDataField(AttributeDescriptor dataField);  }
@Test public void testUpdatePointDataSource() throws Exception { final BindingContext bindingContext = new BindingContext(); bindingContext.getPropertySet().addProperties(Property.create("pointDataSource", VectorDataNode.class)); bindingContext.getPropertySet().addProperties(Property.create("dataField", AttributeDescriptor.class)); final CorrelativeFieldSelector correlativeFieldSelector = new CorrelativeFieldSelector(bindingContext); final Product product = new Product("name", "type", 10, 10); product.getVectorDataGroup().add(new VectorDataNode("a", createFeatureType(Geometry.class))); product.getVectorDataGroup().add(new VectorDataNode("b", createFeatureType(Point.class))); assertEquals(0, correlativeFieldSelector.pointDataSourceList.getItemCount()); assertEquals(0, correlativeFieldSelector.dataFieldList.getItemCount()); correlativeFieldSelector.updatePointDataSource(product); assertEquals(3, correlativeFieldSelector.pointDataSourceList.getItemCount()); assertEquals(0, correlativeFieldSelector.dataFieldList.getItemCount()); correlativeFieldSelector.pointDataSourceProperty.setValue(product.getVectorDataGroup().get("b")); assertEquals(3, correlativeFieldSelector.dataFieldList.getItemCount()); }