private ShapePart createShapePart(ShapeFactoryCaseDef shapeFactoryCase, Element modelElement) { ShapeDef shapeDef = shapeFactoryCase.getShape().content(); ShapePart shapePart = createShapePart(shapeDef, modelElement); if (shapeFactoryCase.getSelectionPresentation() != null) { shapePart.setSelectionPresentation(shapeFactoryCase.getSelectionPresentation()); } return shapePart; }
private ShapeFactoryCaseDef getShapeFactoryCase(Element listEntryModelElement) { for (ShapeFactoryCaseDef shapeFactoryCase : this.shapeFactoryDef.getCases()) { JavaType javaType = shapeFactoryCase.getType().resolve(); Class<?> cl = javaType.artifact(); if (cl.isAssignableFrom(listEntryModelElement.getClass())) { return shapeFactoryCase; } } return null; }
@Override protected void init() { super.init(); this.modelElement = getModelElement(); this.shapeFactoryDef = (ShapeFactoryDef) super.definition; this.children = new ArrayList<ShapePart>(); this.javaTypes = new ArrayList<JavaType>(); for (ShapeFactoryCaseDef shapeCase : this.shapeFactoryDef.getCases()) { this.javaTypes.add(shapeCase.getType().resolve()); } this.propertyName = this.shapeFactoryDef.getProperty().content(); this.modelProperty = (ListProperty) resolve(this.modelElement, this.propertyName); ElementList<?> list = this.modelElement.property(this.modelProperty); for (Element listEntryModelElement : list) { ShapeFactoryCaseDef shapeFactoryCase = getShapeFactoryCase(listEntryModelElement); ShapePart childShapePart = createShapePart(shapeFactoryCase, listEntryModelElement); if (childShapePart != null) { this.children.add(childShapePart); } } // Separator if (this.shapeFactoryDef.getSeparator().content() != null) { this.separator = createShapePart(this.shapeFactoryDef.getSeparator().content(), this.modelElement); } // Add listeners this.shapePropertyListener = new FilteredListener<PropertyEvent>() { @Override protected void handleTypedEvent(final PropertyEvent event) { handleModelPropertyChange(event); } }; this.modelElement.attach(this.shapePropertyListener, this.propertyName); }