use of org.apache.cayenne.modeler.event.AttributeDisplayEvent in project cayenne by apache.
the class AttributeErrorMsg method displayField.
public void displayField(ProjectController mediator, JFrame frame) {
AttributeDisplayEvent event = new AttributeDisplayEvent(frame, attribute, entity, map, domain);
// twice
if (entity instanceof ObjEntity) {
mediator.fireObjEntityDisplayEvent(event);
mediator.fireObjAttributeDisplayEvent(event);
} else if (entity instanceof DbEntity) {
mediator.fireDbEntityDisplayEvent(event);
mediator.fireDbAttributeDisplayEvent(event);
}
}
use of org.apache.cayenne.modeler.event.AttributeDisplayEvent 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);
editor.getDbDetailView().repaint();
} else {
editor.getObjDetailView().currentObjAttributeChanged(event);
editor.getObjDetailView().repaint();
}
} 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);
editor.getDbDetailView().repaint();
} else {
editor.getObjDetailView().currentObjRelationshipChanged(event);
editor.getObjDetailView().repaint();
}
}
}
use of org.apache.cayenne.modeler.event.AttributeDisplayEvent in project cayenne by apache.
the class CreateAttributeAction method fireDbAttributeEvent.
/**
* Fires events when a db attribute was added
*/
static void fireDbAttributeEvent(Object src, ProjectController mediator, DataMap map, DbEntity dbEntity, DbAttribute attr) {
mediator.fireDbAttributeEvent(new AttributeEvent(src, attr, dbEntity, MapEvent.ADD));
AttributeDisplayEvent ade = new AttributeDisplayEvent(src, attr, dbEntity, map, (DataChannelDescriptor) mediator.getProject().getRootNode());
mediator.fireDbAttributeDisplayEvent(ade);
}
use of org.apache.cayenne.modeler.event.AttributeDisplayEvent 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.AttributeDisplayEvent in project cayenne by apache.
the class ObjAttributeTableModel method setObjAttributeType.
private void setObjAttributeType(ObjAttributeWrapper attribute, Object value) {
String oldType = attribute.getType();
String newType = value != null ? value.toString() : null;
attribute.setType(newType);
if (oldType == null || newType == null) {
return;
}
String[] registeredTypes = ModelerUtil.getRegisteredTypeNames();
Collection<String> registeredTypesList = Arrays.asList(registeredTypes);
if (registeredTypesList.contains(oldType) == registeredTypesList.contains(newType)) {
return;
}
ObjEntity entity = attribute.getEntity();
ObjAttribute attributeNew;
if (registeredTypesList.contains(newType) || !mediator.getEmbeddableNamesInCurrentDataDomain().contains(newType)) {
attributeNew = new ObjAttribute();
attributeNew.setDbAttributePath(attribute.getDbAttributePath());
} else {
attributeNew = new EmbeddedAttribute();
attributeNew.setDbAttributePath(null);
}
attributeNew.setName(attribute.getName());
attributeNew.setEntity(entity);
attributeNew.setParent(attribute.getParent());
attributeNew.setType(attribute.getType());
attributeNew.setUsedForLocking(attribute.isUsedForLocking());
attributeNew.setLazy(attribute.isLazy());
entity.updateAttribute(attributeNew);
mediator.fireObjEntityEvent(new EntityEvent(this, entity, MapEvent.CHANGE));
mediator.fireObjEntityDisplayEvent(new EntityDisplayEvent(this, mediator.getCurrentObjEntity(), mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode()));
mediator.fireObjAttributeEvent(new AttributeEvent(this, attributeNew, entity, MapEvent.CHANGE));
mediator.fireObjAttributeDisplayEvent(new AttributeDisplayEvent(this, attributeNew, mediator.getCurrentObjEntity(), mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode()));
}
Aggregations