Search in sources :

Example 11 with EntityDisplayEvent

use of org.apache.cayenne.modeler.event.EntityDisplayEvent in project cayenne by apache.

the class ObjAttributeInfoDialog method changeAttributeObject.

private void changeAttributeObject() {
    if (attributeSaved instanceof EmbeddedAttribute && embeddableModel.isAttributeOverrideChange()) {
        Map<String, String> overrides = ((EmbeddedAttribute) attributeSaved).getAttributeOverrides();
        Map<String, String> currentOverrAttr = getCurrentOverrideAttribute();
        compareAndSetOverrideInEmbeddedAttribute(attributeSaved, overrides, currentOverrAttr);
    }
    if (attributeSaved instanceof EmbeddedAttribute) {
        attributeSaved.setDbAttributePath(null);
        model.setUpdatedValueAt(attributeSaved.getDbAttributePath(), row, 3);
    }
    model.getEntity().removeAttribute(attribute.getName());
    model.getEntity().addAttribute(attributeSaved);
    mediator.fireObjEntityEvent(new EntityEvent(this, model.getEntity(), MapEvent.CHANGE));
    EntityDisplayEvent event = new EntityDisplayEvent(this, mediator.getCurrentObjEntity(), mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode());
    mediator.fireObjEntityDisplayEvent(event);
    mediator.fireObjAttributeEvent(new AttributeEvent(this, attributeSaved, model.getEntity(), MapEvent.CHANGE));
    AttributeDisplayEvent eventAttr = new AttributeDisplayEvent(this, attributeSaved, mediator.getCurrentObjEntity(), mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode());
    mediator.fireObjAttributeDisplayEvent(eventAttr);
}
Also used : AttributeDisplayEvent(org.apache.cayenne.modeler.event.AttributeDisplayEvent) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) EntityEvent(org.apache.cayenne.map.event.EntityEvent) EmbeddedAttribute(org.apache.cayenne.map.EmbeddedAttribute) AttributeEvent(org.apache.cayenne.map.event.AttributeEvent)

Example 12 with EntityDisplayEvent

use of org.apache.cayenne.modeler.event.EntityDisplayEvent in project cayenne by apache.

the class DbEntityTab method processExistingSelection.

public void processExistingSelection(EventObject e) {
    EntityDisplayEvent ede = new EntityDisplayEvent(this, mediator.getCurrentDbEntity(), mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode());
    mediator.fireDbEntityDisplayEvent(ede);
}
Also used : EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent)

Example 13 with EntityDisplayEvent

use of org.apache.cayenne.modeler.event.EntityDisplayEvent in project cayenne by apache.

the class ChangePKGeneratorUndoableEdit method fireEvents.

private void fireEvents() {
    controller.fireDbEntityEvent(new EntityEvent(this, dbEntity));
    controller.fireDbEntityDisplayEvent(new EntityDisplayEvent(this, dbEntity));
}
Also used : EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) EntityEvent(org.apache.cayenne.map.event.EntityEvent)

Example 14 with EntityDisplayEvent

use of org.apache.cayenne.modeler.event.EntityDisplayEvent in project cayenne by apache.

the class FindAction method jumpToEntityResult.

private static void jumpToEntityResult(Entity entity, EditorView editor, DataChannelDescriptor domain) {
    DataMap map = entity.getDataMap();
    buildAndSelectTreePath(map, entity, editor);
    EntityDisplayEvent event = new EntityDisplayEvent(editor.getProjectTreeView(), entity, map, domain);
    event.setMainTabFocus(true);
    if (entity instanceof ObjEntity) {
        editor.getObjDetailView().currentObjEntityChanged(event);
    } else if (entity instanceof DbEntity) {
        editor.getDbDetailView().currentDbEntityChanged(event);
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) DetectedDbEntity(org.apache.cayenne.map.DetectedDbEntity) DbEntity(org.apache.cayenne.map.DbEntity) DataMap(org.apache.cayenne.map.DataMap)

Example 15 with EntityDisplayEvent

use of org.apache.cayenne.modeler.event.EntityDisplayEvent in project cayenne by apache.

the class ProjectTreeView method processSelection.

/**
 * Processes node selection regardless of whether a new node was selected, or an
 * already selected node was clicked again. Normally called from event listener
 * methods.
 */
public void processSelection(TreePath path) {
    if (path == null) {
        return;
    }
    DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) path.getLastPathComponent();
    Object[] data = getUserObjects(currentNode);
    if (data.length == 0) {
        // this should clear the right-side panel
        DomainDisplayEvent domEvent = new DomainDisplayEvent(this, null);
        domEvent.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
        mediator.fireDomainDisplayEvent(domEvent);
        return;
    }
    Object obj = data[data.length - 1];
    if (obj instanceof DataChannelDescriptor) {
        mediator.fireDomainDisplayEvent(new DomainDisplayEvent(this, (DataChannelDescriptor) obj));
    } else if (obj instanceof DataMap) {
        if (data.length == 2) {
            mediator.fireDataMapDisplayEvent(new DataMapDisplayEvent(this, (DataMap) obj, (DataChannelDescriptor) mediator.getProject().getRootNode(), (DataNodeDescriptor) data[data.length - 2]));
        } else if (data.length == 1) {
            mediator.fireDataMapDisplayEvent(new DataMapDisplayEvent(this, (DataMap) obj, (DataChannelDescriptor) mediator.getProject().getRootNode()));
        }
    } else if (obj instanceof DataNodeDescriptor) {
        if (data.length == 1) {
            mediator.fireDataNodeDisplayEvent(new DataNodeDisplayEvent(this, (DataChannelDescriptor) mediator.getProject().getRootNode(), (DataNodeDescriptor) obj));
        }
    } else if (obj instanceof Entity) {
        EntityDisplayEvent e = new EntityDisplayEvent(this, (Entity) obj);
        e.setUnselectAttributes(true);
        if (data.length == 3) {
            e.setDataMap((DataMap) data[data.length - 2]);
            e.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
            e.setDataNode((DataNodeDescriptor) data[data.length - 3]);
        } else if (data.length == 2) {
            e.setDataMap((DataMap) data[data.length - 2]);
            e.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
        }
        if (obj instanceof ObjEntity) {
            mediator.fireObjEntityDisplayEvent(e);
        } else if (obj instanceof DbEntity) {
            mediator.fireDbEntityDisplayEvent(e);
        }
    } else if (obj instanceof Embeddable) {
        EmbeddableDisplayEvent e = new EmbeddableDisplayEvent(this, (Embeddable) obj, (DataMap) data[data.length - 2], (DataChannelDescriptor) mediator.getProject().getRootNode());
        mediator.fireEmbeddableDisplayEvent(e);
    } else if (obj instanceof Procedure) {
        ProcedureDisplayEvent e = new ProcedureDisplayEvent(this, (Procedure) obj, (DataMap) data[data.length - 2], (DataChannelDescriptor) mediator.getProject().getRootNode());
        mediator.fireProcedureDisplayEvent(e);
    } else if (obj instanceof QueryDescriptor) {
        QueryDisplayEvent e = new QueryDisplayEvent(this, (QueryDescriptor) obj, (DataMap) data[data.length - 2], (DataChannelDescriptor) mediator.getProject().getRootNode());
        mediator.fireQueryDisplayEvent(e);
    }
    this.scrollPathToVisible(path);
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) Entity(org.apache.cayenne.map.Entity) DbEntity(org.apache.cayenne.map.DbEntity) ProcedureDisplayEvent(org.apache.cayenne.modeler.event.ProcedureDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) EmbeddableDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableDisplayEvent) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) DataMapDisplayEvent(org.apache.cayenne.modeler.event.DataMapDisplayEvent) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable) QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) QueryDisplayEvent(org.apache.cayenne.modeler.event.QueryDisplayEvent) ObjEntity(org.apache.cayenne.map.ObjEntity) DomainDisplayEvent(org.apache.cayenne.modeler.event.DomainDisplayEvent) DbEntity(org.apache.cayenne.map.DbEntity) DataNodeDisplayEvent(org.apache.cayenne.modeler.event.DataNodeDisplayEvent) Procedure(org.apache.cayenne.map.Procedure)

Aggregations

EntityDisplayEvent (org.apache.cayenne.modeler.event.EntityDisplayEvent)20 ObjEntity (org.apache.cayenne.map.ObjEntity)10 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)8 DbEntity (org.apache.cayenne.map.DbEntity)7 EntityEvent (org.apache.cayenne.map.event.EntityEvent)7 DataMap (org.apache.cayenne.map.DataMap)6 Entity (org.apache.cayenne.map.Entity)5 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)4 AttributeDisplayEvent (org.apache.cayenne.modeler.event.AttributeDisplayEvent)3 EmbeddedAttribute (org.apache.cayenne.map.EmbeddedAttribute)2 ObjAttribute (org.apache.cayenne.map.ObjAttribute)2 AttributeEvent (org.apache.cayenne.map.event.AttributeEvent)2 DomainDisplayEvent (org.apache.cayenne.modeler.event.DomainDisplayEvent)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 LinkedList (java.util.LinkedList)1