Search in sources :

Example 6 with AttributeDisplayEvent

use of org.apache.cayenne.modeler.event.AttributeDisplayEvent in project cayenne by apache.

the class ObjAttributeInfoDialog method changeAttributeObject.

private void changeAttributeObject() {
    if (attributeSaved instanceof EmbeddedAttribute && embeddableModel.isAttributeOverrideChange()) {
        Map<String, String> overrides = ((EmbeddedAttribute) attributeSaved).getAttributeOverrides();
        Map<String, String> currentOverrAttr = getCurrentOverrideAttribute();
        compareAndSetOverrideInEmbeddedAttribute(attributeSaved, overrides, currentOverrAttr);
    }
    if (attributeSaved instanceof EmbeddedAttribute) {
        attributeSaved.setDbAttributePath(null);
        model.setUpdatedValueAt(attributeSaved.getDbAttributePath(), row, 3);
    }
    model.getEntity().removeAttribute(attribute.getName());
    model.getEntity().addAttribute(attributeSaved);
    mediator.fireObjEntityEvent(new EntityEvent(this, model.getEntity(), MapEvent.CHANGE));
    EntityDisplayEvent event = new EntityDisplayEvent(this, mediator.getCurrentObjEntity(), mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode());
    mediator.fireObjEntityDisplayEvent(event);
    mediator.fireObjAttributeEvent(new AttributeEvent(this, attributeSaved, model.getEntity(), MapEvent.CHANGE));
    AttributeDisplayEvent eventAttr = new AttributeDisplayEvent(this, attributeSaved, mediator.getCurrentObjEntity(), mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode());
    mediator.fireObjAttributeDisplayEvent(eventAttr);
}
Also used : AttributeDisplayEvent(org.apache.cayenne.modeler.event.AttributeDisplayEvent) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) EntityEvent(org.apache.cayenne.map.event.EntityEvent) EmbeddedAttribute(org.apache.cayenne.map.EmbeddedAttribute) AttributeEvent(org.apache.cayenne.map.event.AttributeEvent)

Example 7 with AttributeDisplayEvent

use of org.apache.cayenne.modeler.event.AttributeDisplayEvent in project cayenne by apache.

the class CreateAttributeAction method fireObjAttributeEvent.

/**
 * Fires events when an obj attribute was added
 */
static void fireObjAttributeEvent(Object src, ProjectController mediator, DataMap map, ObjEntity objEntity, ObjAttribute attr) {
    mediator.fireObjAttributeEvent(new AttributeEvent(src, attr, objEntity, MapEvent.ADD));
    DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
    AttributeDisplayEvent ade = new AttributeDisplayEvent(src, attr, objEntity, map, domain);
    mediator.fireObjAttributeDisplayEvent(ade);
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) EmbeddableAttributeDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent) AttributeDisplayEvent(org.apache.cayenne.modeler.event.AttributeDisplayEvent) AttributeEvent(org.apache.cayenne.map.event.AttributeEvent) EmbeddableAttributeEvent(org.apache.cayenne.map.event.EmbeddableAttributeEvent)

Aggregations

AttributeDisplayEvent (org.apache.cayenne.modeler.event.AttributeDisplayEvent)7 ObjEntity (org.apache.cayenne.map.ObjEntity)4 AttributeEvent (org.apache.cayenne.map.event.AttributeEvent)4 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)3 DbEntity (org.apache.cayenne.map.DbEntity)3 EmbeddableAttributeDisplayEvent (org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent)3 EntityDisplayEvent (org.apache.cayenne.modeler.event.EntityDisplayEvent)3 Attribute (org.apache.cayenne.map.Attribute)2 DataMap (org.apache.cayenne.map.DataMap)2 EmbeddedAttribute (org.apache.cayenne.map.EmbeddedAttribute)2 Entity (org.apache.cayenne.map.Entity)2 ObjAttribute (org.apache.cayenne.map.ObjAttribute)2 EmbeddableAttributeEvent (org.apache.cayenne.map.event.EmbeddableAttributeEvent)2 EntityEvent (org.apache.cayenne.map.event.EntityEvent)2 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)1 DbAttribute (org.apache.cayenne.map.DbAttribute)1 DbRelationship (org.apache.cayenne.map.DbRelationship)1 DetectedDbEntity (org.apache.cayenne.map.DetectedDbEntity)1 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)1 ObjRelationship (org.apache.cayenne.map.ObjRelationship)1