Search in sources :

Example 6 with EntityDisplayEvent

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

the class CreateAttributeUndoableEdit method undo.

@Override
public void undo() throws CannotUndoException {
    RemoveAttributeAction action = actionManager.getAction(RemoveAttributeAction.class);
    if (objEntity != null) {
        action.removeObjAttributes(objEntity, new ObjAttribute[] { objAttr });
        controller.fireObjEntityDisplayEvent(new EntityDisplayEvent(this, objEntity, dataMap, domain));
    }
    if (dbEntity != null) {
        action.removeDbAttributes(dataMap, dbEntity, new DbAttribute[] { dbAttr });
        controller.fireDbEntityDisplayEvent(new EntityDisplayEvent(this, dbEntity, dataMap, domain));
    }
}
Also used : EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) RemoveAttributeAction(org.apache.cayenne.modeler.action.RemoveAttributeAction)

Example 7 with EntityDisplayEvent

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

the class CreateRelationshipUndoableEdit method undo.

@Override
public void undo() throws CannotUndoException {
    RemoveRelationshipAction action = actionManager.getAction(RemoveRelationshipAction.class);
    if (objEnt != null) {
        action.removeObjRelationships(objEnt, objectRel);
        controller.fireObjEntityDisplayEvent(new EntityDisplayEvent(this, objEnt, objEnt.getDataMap(), (DataChannelDescriptor) controller.getProject().getRootNode()));
    }
    if (dbEnt != null) {
        action.removeDbRelationships(dbEnt, dbRel);
        controller.fireDbEntityDisplayEvent(new EntityDisplayEvent(this, dbEnt, dbEnt.getDataMap(), (DataChannelDescriptor) controller.getProject().getRootNode()));
    }
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) RemoveRelationshipAction(org.apache.cayenne.modeler.action.RemoveRelationshipAction)

Example 8 with EntityDisplayEvent

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

the class ObjEntitySyncAction method syncObjEntity.

protected void syncObjEntity() {
    ProjectController mediator = getProjectController();
    ObjEntity entity = mediator.getCurrentObjEntity();
    if (entity != null && entity.getDbEntity() != null) {
        EntityMergeSupport merger = new EntitySyncController(Application.getInstance().getFrameController(), entity).createMerger();
        if (merger == null) {
            return;
        }
        merger.setNameGenerator(new DbEntitySyncAction.PreserveRelationshipNameGenerator());
        if (merger.synchronizeWithDbEntity(entity)) {
            mediator.fireObjEntityEvent(new EntityEvent(this, entity, MapEvent.CHANGE));
            mediator.fireObjEntityDisplayEvent(new EntityDisplayEvent(this, entity, entity.getDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode()));
        }
    }
}
Also used : EntityMergeSupport(org.apache.cayenne.dbsync.merge.context.EntityMergeSupport) ObjEntity(org.apache.cayenne.map.ObjEntity) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) EntityEvent(org.apache.cayenne.map.event.EntityEvent) ProjectController(org.apache.cayenne.modeler.ProjectController) EntitySyncController(org.apache.cayenne.modeler.dialog.objentity.EntitySyncController)

Example 9 with EntityDisplayEvent

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

the class AttributeDisplayEventType 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;
    }
    Attribute[] attributes = getLastEntityAttributes(entity);
    EntityDisplayEvent entityDisplayEvent = new EntityDisplayEvent(this, entity, dataMap, dataNode, dataChannel);
    AttributeDisplayEvent attributeDisplayEvent = new AttributeDisplayEvent(this, attributes, entity, dataMap, dataChannel);
    if (entity instanceof ObjEntity) {
        controller.fireObjEntityDisplayEvent(entityDisplayEvent);
        controller.fireObjAttributeDisplayEvent(attributeDisplayEvent);
    } else if (entity instanceof DbEntity) {
        controller.fireDbEntityDisplayEvent(entityDisplayEvent);
        controller.fireDbAttributeDisplayEvent(attributeDisplayEvent);
    }
}
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) AttributeDisplayEvent(org.apache.cayenne.modeler.event.AttributeDisplayEvent) ObjEntity(org.apache.cayenne.map.ObjEntity) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) DbEntity(org.apache.cayenne.map.DbEntity) Attribute(org.apache.cayenne.map.Attribute) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) DataMap(org.apache.cayenne.map.DataMap)

Example 10 with EntityDisplayEvent

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

the class ObjEntityTab method processExistingSelection.

public void processExistingSelection(EventObject e) {
    EntityDisplayEvent ede = new EntityDisplayEvent(this, mediator.getCurrentObjEntity(), mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode());
    mediator.fireObjEntityDisplayEvent(ede);
}
Also used : EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent)

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