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