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));
}
}
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()));
}
}
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()));
}
}
}
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);
}
}
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);
}
Aggregations