Search in sources :

Example 1 with AttributeDisplayEvent

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);
    }
}
Also used : AttributeDisplayEvent(org.apache.cayenne.modeler.event.AttributeDisplayEvent) ObjEntity(org.apache.cayenne.map.ObjEntity) DbEntity(org.apache.cayenne.map.DbEntity)

Example 2 with AttributeDisplayEvent

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();
        }
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) Entity(org.apache.cayenne.map.Entity) DetectedDbEntity(org.apache.cayenne.dbsync.model.DetectedDbEntity) DbEntity(org.apache.cayenne.map.DbEntity) EmbeddableAttributeDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent) AttributeDisplayEvent(org.apache.cayenne.modeler.event.AttributeDisplayEvent) DbAttribute(org.apache.cayenne.map.DbAttribute) ObjAttribute(org.apache.cayenne.map.ObjAttribute) Attribute(org.apache.cayenne.map.Attribute) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) Relationship(org.apache.cayenne.map.Relationship) DbRelationship(org.apache.cayenne.map.DbRelationship) ObjRelationship(org.apache.cayenne.map.ObjRelationship) DbRelationship(org.apache.cayenne.map.DbRelationship) DbAttribute(org.apache.cayenne.map.DbAttribute) DataMap(org.apache.cayenne.map.DataMap) RelationshipDisplayEvent(org.apache.cayenne.modeler.event.RelationshipDisplayEvent)

Example 3 with AttributeDisplayEvent

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);
}
Also used : EmbeddableAttributeDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent) AttributeDisplayEvent(org.apache.cayenne.modeler.event.AttributeDisplayEvent) AttributeEvent(org.apache.cayenne.map.event.AttributeEvent) EmbeddableAttributeEvent(org.apache.cayenne.map.event.EmbeddableAttributeEvent)

Example 4 with AttributeDisplayEvent

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);
    }
}
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 5 with 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()));
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) AttributeDisplayEvent(org.apache.cayenne.modeler.event.AttributeDisplayEvent) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) ObjAttribute(org.apache.cayenne.map.ObjAttribute) EntityEvent(org.apache.cayenne.map.event.EntityEvent) EmbeddedAttribute(org.apache.cayenne.map.EmbeddedAttribute) AttributeEvent(org.apache.cayenne.map.event.AttributeEvent)

Aggregations

AttributeDisplayEvent (org.apache.cayenne.modeler.event.AttributeDisplayEvent)7 ObjEntity (org.apache.cayenne.map.ObjEntity)4 AttributeEvent (org.apache.cayenne.map.event.AttributeEvent)4 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)3 DbEntity (org.apache.cayenne.map.DbEntity)3 EmbeddableAttributeDisplayEvent (org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent)3 EntityDisplayEvent (org.apache.cayenne.modeler.event.EntityDisplayEvent)3 Attribute (org.apache.cayenne.map.Attribute)2 DataMap (org.apache.cayenne.map.DataMap)2 EmbeddedAttribute (org.apache.cayenne.map.EmbeddedAttribute)2 Entity (org.apache.cayenne.map.Entity)2 ObjAttribute (org.apache.cayenne.map.ObjAttribute)2 EmbeddableAttributeEvent (org.apache.cayenne.map.event.EmbeddableAttributeEvent)2 EntityEvent (org.apache.cayenne.map.event.EntityEvent)2 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)1 DetectedDbEntity (org.apache.cayenne.dbsync.model.DetectedDbEntity)1 DbAttribute (org.apache.cayenne.map.DbAttribute)1 DbRelationship (org.apache.cayenne.map.DbRelationship)1 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)1 ObjRelationship (org.apache.cayenne.map.ObjRelationship)1