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