Search in sources :

Example 16 with EntityDisplayEvent

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

the class BaseViewEntityAction method navigateToEntity.

public void navigateToEntity(Entity entity) {
    TreePath path = buildTreePath(entity);
    editor().getProjectTreeView().getSelectionModel().setSelectionPath(path);
    EntityDisplayEvent event = new EntityDisplayEvent(editor().getProjectTreeView(), entity, entity.getDataMap(), (DataChannelDescriptor) getProjectController().getProject().getRootNode());
    if (entity instanceof DbEntity) {
        getProjectController().fireDbEntityDisplayEvent(event);
    } else if (entity instanceof ObjEntity) {
        getProjectController().fireObjEntityDisplayEvent(event);
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) TreePath(javax.swing.tree.TreePath) DbEntity(org.apache.cayenne.map.DbEntity)

Example 17 with EntityDisplayEvent

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

the class CreateDbEntityAction method fireDbEntityEvent.

/**
 * Fires events when a db entity was added
 */
static void fireDbEntityEvent(Object src, ProjectController mediator, DbEntity entity) {
    mediator.fireDbEntityEvent(new EntityEvent(src, entity, MapEvent.ADD));
    EntityDisplayEvent displayEvent = new EntityDisplayEvent(src, entity, mediator.getCurrentDataMap(), mediator.getCurrentDataNode(), (DataChannelDescriptor) mediator.getProject().getRootNode());
    displayEvent.setMainTabFocus(true);
    mediator.fireDbEntityDisplayEvent(displayEvent);
}
Also used : EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) EntityEvent(org.apache.cayenne.map.event.EntityEvent)

Example 18 with EntityDisplayEvent

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

the class CreateObjEntityAction method fireObjEntityEvent.

static void fireObjEntityEvent(Object src, ProjectController mediator, DataMap dataMap, ObjEntity entity) {
    mediator.fireObjEntityEvent(new EntityEvent(src, entity, MapEvent.ADD));
    EntityDisplayEvent displayEvent = new EntityDisplayEvent(src, entity, dataMap, mediator.getCurrentDataNode(), (DataChannelDescriptor) mediator.getProject().getRootNode());
    displayEvent.setMainTabFocus(true);
    mediator.fireObjEntityDisplayEvent(displayEvent);
}
Also used : EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) EntityEvent(org.apache.cayenne.map.event.EntityEvent)

Example 19 with EntityDisplayEvent

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

the class EntityDisplayEventType 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;
    }
    EntityDisplayEvent entityDisplayEvent = new EntityDisplayEvent(this, entity, dataMap, dataNode, dataChannel);
    if (entity instanceof ObjEntity) {
        controller.fireObjEntityDisplayEvent(entityDisplayEvent);
    } else if (entity instanceof DbEntity) {
        controller.fireDbEntityDisplayEvent(entityDisplayEvent);
    }
}
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) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) DataMap(org.apache.cayenne.map.DataMap)

Example 20 with EntityDisplayEvent

use of org.apache.cayenne.modeler.event.EntityDisplayEvent 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

EntityDisplayEvent (org.apache.cayenne.modeler.event.EntityDisplayEvent)20 ObjEntity (org.apache.cayenne.map.ObjEntity)10 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)8 DbEntity (org.apache.cayenne.map.DbEntity)7 EntityEvent (org.apache.cayenne.map.event.EntityEvent)7 DataMap (org.apache.cayenne.map.DataMap)6 Entity (org.apache.cayenne.map.Entity)5 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)4 AttributeDisplayEvent (org.apache.cayenne.modeler.event.AttributeDisplayEvent)3 EmbeddedAttribute (org.apache.cayenne.map.EmbeddedAttribute)2 ObjAttribute (org.apache.cayenne.map.ObjAttribute)2 AttributeEvent (org.apache.cayenne.map.event.AttributeEvent)2 DomainDisplayEvent (org.apache.cayenne.modeler.event.DomainDisplayEvent)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 LinkedList (java.util.LinkedList)1