Search in sources :

Example 1 with RelationshipDisplayEvent

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

the class CreateRelationshipAction method fireObjRelationshipEvent.

/**
 * Fires events when a obj rel was added
 */
static void fireObjRelationshipEvent(Object src, ProjectController mediator, ObjEntity objEntity, ObjRelationship rel) {
    mediator.fireObjRelationshipEvent(new RelationshipEvent(src, rel, objEntity, MapEvent.ADD));
    RelationshipDisplayEvent rde = new RelationshipDisplayEvent(src, rel, objEntity, mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode());
    mediator.fireObjRelationshipDisplayEvent(rde);
}
Also used : RelationshipEvent(org.apache.cayenne.map.event.RelationshipEvent) RelationshipDisplayEvent(org.apache.cayenne.modeler.event.RelationshipDisplayEvent)

Example 2 with RelationshipDisplayEvent

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

the class FindAction method jumpToAttributeResult.

private static void jumpToAttributeResult(SearchResultEntry searchResultEntry, EditorView editor, DataChannelDescriptor domain) {
    DataMap map;
    Entity entity;
    if (searchResultEntry.getObject() instanceof Attribute) {
        map = ((Attribute) searchResultEntry.getObject()).getEntity().getDataMap();
        entity = ((Attribute) searchResultEntry.getObject()).getEntity();
    } else {
        map = ((Relationship) searchResultEntry.getObject()).getSourceEntity().getDataMap();
        entity = ((Relationship) searchResultEntry.getObject()).getSourceEntity();
    }
    buildAndSelectTreePath(map, entity, editor);
    if (searchResultEntry.getObject() instanceof Attribute) {
        AttributeDisplayEvent event = new AttributeDisplayEvent(editor.getProjectTreeView(), (Attribute) searchResultEntry.getObject(), entity, map, domain);
        event.setMainTabFocus(true);
        if (searchResultEntry.getObject() instanceof DbAttribute) {
            editor.getDbDetailView().currentDbAttributeChanged(event);
        } else {
            editor.getObjDetailView().currentObjAttributeChanged(event);
        }
    } else if (searchResultEntry.getObject() instanceof Relationship) {
        RelationshipDisplayEvent event = new RelationshipDisplayEvent(editor.getProjectTreeView(), (Relationship) searchResultEntry.getObject(), entity, map, domain);
        event.setMainTabFocus(true);
        if (searchResultEntry.getObject() instanceof DbRelationship) {
            editor.getDbDetailView().currentDbRelationshipChanged(event);
        } else {
            editor.getObjDetailView().currentObjRelationshipChanged(event);
        }
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DetectedDbEntity(org.apache.cayenne.map.DetectedDbEntity) Entity(org.apache.cayenne.map.Entity) DbEntity(org.apache.cayenne.map.DbEntity) EmbeddableAttributeDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent) AttributeDisplayEvent(org.apache.cayenne.modeler.event.AttributeDisplayEvent) DbAttribute(org.apache.cayenne.map.DbAttribute) ObjAttribute(org.apache.cayenne.map.ObjAttribute) Attribute(org.apache.cayenne.map.Attribute) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) Relationship(org.apache.cayenne.map.Relationship) DbRelationship(org.apache.cayenne.map.DbRelationship) ObjRelationship(org.apache.cayenne.map.ObjRelationship) DbRelationship(org.apache.cayenne.map.DbRelationship) DbAttribute(org.apache.cayenne.map.DbAttribute) DataMap(org.apache.cayenne.map.DataMap) RelationshipDisplayEvent(org.apache.cayenne.modeler.event.RelationshipDisplayEvent)

Example 3 with RelationshipDisplayEvent

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

the class RelationshipErrorMsg method displayField.

public void displayField(ProjectController mediator, JFrame frame) {
    RelationshipDisplayEvent event = new RelationshipDisplayEvent(frame, rel, entity, map, domain);
    // twice
    if (entity instanceof ObjEntity) {
        mediator.fireObjEntityDisplayEvent(event);
        mediator.fireObjRelationshipDisplayEvent(event);
    } else if (entity instanceof DbEntity) {
        mediator.fireDbEntityDisplayEvent(event);
        mediator.fireDbRelationshipDisplayEvent(event);
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DbEntity(org.apache.cayenne.map.DbEntity) RelationshipDisplayEvent(org.apache.cayenne.modeler.event.RelationshipDisplayEvent)

Example 4 with RelationshipDisplayEvent

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

the class CreateRelationshipAction method fireDbRelationshipEvent.

/**
 * Fires events when a db rel was added
 */
static void fireDbRelationshipEvent(Object src, ProjectController mediator, DbEntity dbEntity, DbRelationship rel) {
    mediator.fireDbRelationshipEvent(new RelationshipEvent(src, rel, dbEntity, MapEvent.ADD));
    RelationshipDisplayEvent rde = new RelationshipDisplayEvent(src, rel, dbEntity, mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode());
    mediator.fireDbRelationshipDisplayEvent(rde);
}
Also used : RelationshipEvent(org.apache.cayenne.map.event.RelationshipEvent) RelationshipDisplayEvent(org.apache.cayenne.modeler.event.RelationshipDisplayEvent)

Example 5 with RelationshipDisplayEvent

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

the class RelationshipDisplayEventType method fireLastDisplayEvent.

@Override
public void fireLastDisplayEvent() {
    DataChannelDescriptor dataChannel = (DataChannelDescriptor) controller.getProject().getRootNode();
    if (!dataChannel.getName().equals(preferences.getDomain())) {
        return;
    }
    DataNodeDescriptor dataNode = dataChannel.getNodeDescriptor(preferences.getNode());
    DataMap dataMap = dataChannel.getDataMap(preferences.getDataMap());
    if (dataMap == null) {
        return;
    }
    Entity entity = getLastEntity(dataMap);
    if (entity == null) {
        return;
    }
    Relationship[] relationships = getLastEntityRelationships(entity);
    EntityDisplayEvent entityDisplayEvent = new EntityDisplayEvent(this, entity, dataMap, dataNode, dataChannel);
    RelationshipDisplayEvent displayEvent = new RelationshipDisplayEvent(this, relationships, entity, dataMap, dataChannel);
    if (entity instanceof ObjEntity) {
        controller.fireObjEntityDisplayEvent(entityDisplayEvent);
        controller.fireObjRelationshipDisplayEvent(displayEvent);
    } else if (entity instanceof DbEntity) {
        controller.fireDbEntityDisplayEvent(entityDisplayEvent);
        controller.fireDbRelationshipDisplayEvent(displayEvent);
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DbEntity(org.apache.cayenne.map.DbEntity) Entity(org.apache.cayenne.map.Entity) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ObjEntity(org.apache.cayenne.map.ObjEntity) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) DbEntity(org.apache.cayenne.map.DbEntity) Relationship(org.apache.cayenne.map.Relationship) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) DataMap(org.apache.cayenne.map.DataMap) RelationshipDisplayEvent(org.apache.cayenne.modeler.event.RelationshipDisplayEvent)

Aggregations

RelationshipDisplayEvent (org.apache.cayenne.modeler.event.RelationshipDisplayEvent)5 DbEntity (org.apache.cayenne.map.DbEntity)3 ObjEntity (org.apache.cayenne.map.ObjEntity)3 DataMap (org.apache.cayenne.map.DataMap)2 Entity (org.apache.cayenne.map.Entity)2 Relationship (org.apache.cayenne.map.Relationship)2 RelationshipEvent (org.apache.cayenne.map.event.RelationshipEvent)2 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)1 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)1 Attribute (org.apache.cayenne.map.Attribute)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 ObjAttribute (org.apache.cayenne.map.ObjAttribute)1 ObjRelationship (org.apache.cayenne.map.ObjRelationship)1 AttributeDisplayEvent (org.apache.cayenne.modeler.event.AttributeDisplayEvent)1 EmbeddableAttributeDisplayEvent (org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent)1 EntityDisplayEvent (org.apache.cayenne.modeler.event.EntityDisplayEvent)1