Search in sources :

Example 1 with DataObjectFieldCreatedEvent

use of org.kie.workbench.common.screens.datamodeller.events.DataObjectFieldCreatedEvent in project kie-wb-common by kiegroup.

the class AddPropertyCommand method execute.

@Override
public void execute() {
    // extra check
    boolean multiple = isMultiple && !getContext().getHelper().isPrimitiveType(propertyType);
    property = new ObjectPropertyImpl(propertyName, propertyType, multiple);
    if (propertyLabel != null && !"".equals(propertyLabel)) {
        Annotation annotation = new AnnotationImpl(getContext().getAnnotationDefinitions().get(MainDomainAnnotations.LABEL_ANNOTATION));
        annotation.setValue(MainDomainAnnotations.VALUE_PARAM, propertyLabel);
        property.addAnnotation(annotation);
    }
    dataObject.addProperty(property);
    if (!property.isBaseType()) {
        getContext().getHelper().dataObjectReferenced(property.getClassName(), dataObject.getClassName());
    }
    notifyChange(new DataObjectFieldCreatedEvent(getContext().getContextId(), getSource(), getDataObject(), property));
}
Also used : ObjectPropertyImpl(org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl) DataObjectFieldCreatedEvent(org.kie.workbench.common.screens.datamodeller.events.DataObjectFieldCreatedEvent) AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation)

Aggregations

DataObjectFieldCreatedEvent (org.kie.workbench.common.screens.datamodeller.events.DataObjectFieldCreatedEvent)1 Annotation (org.kie.workbench.common.services.datamodeller.core.Annotation)1 AnnotationImpl (org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl)1 ObjectPropertyImpl (org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl)1