Search in sources :

Example 1 with EmbeddableDisplayEvent

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

the class FindAction method jumpToEmbeddableResult.

private static void jumpToEmbeddableResult(Embeddable embeddable, EditorView editor, DataChannelDescriptor domain) {
    DataMap map = embeddable.getDataMap();
    buildAndSelectTreePath(map, embeddable, editor);
    EmbeddableDisplayEvent event = new EmbeddableDisplayEvent(editor.getProjectTreeView(), embeddable, map, domain);
    event.setMainTabFocus(true);
    editor.currentEmbeddableChanged(event);
}
Also used : EmbeddableDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableDisplayEvent) DataMap(org.apache.cayenne.map.DataMap)

Example 2 with EmbeddableDisplayEvent

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

the class CreateEmbeddableAction method fireEmbeddableEvent.

static void fireEmbeddableEvent(Object src, ProjectController mediator, DataMap dataMap, Embeddable embeddable) {
    mediator.fireEmbeddableEvent(new EmbeddableEvent(src, embeddable, MapEvent.ADD), dataMap);
    EmbeddableDisplayEvent displayEvent = new EmbeddableDisplayEvent(src, embeddable, dataMap, (DataChannelDescriptor) mediator.getProject().getRootNode());
    displayEvent.setMainTabFocus(true);
    mediator.fireEmbeddableDisplayEvent(displayEvent);
}
Also used : EmbeddableEvent(org.apache.cayenne.map.event.EmbeddableEvent) EmbeddableDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableDisplayEvent)

Example 3 with EmbeddableDisplayEvent

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

the class EmbeddableDisplayEventType method fireLastDisplayEvent.

@Override
public void fireLastDisplayEvent() {
    DataChannelDescriptor dataChannel = (DataChannelDescriptor) controller.getProject().getRootNode();
    if (!dataChannel.getName().equals(preferences.getDomain())) {
        return;
    }
    DataMap dataMap = dataChannel.getDataMap(preferences.getDataMap());
    if (dataMap == null) {
        return;
    }
    Embeddable embeddable = dataMap.getEmbeddable(preferences.getEmbeddable());
    if (embeddable == null) {
        return;
    }
    EmbeddableDisplayEvent embeddableDisplayEvent = new EmbeddableDisplayEvent(this, embeddable, dataMap, dataChannel);
    controller.fireEmbeddableDisplayEvent(embeddableDisplayEvent);
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) EmbeddableDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableDisplayEvent) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable)

Example 4 with EmbeddableDisplayEvent

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

the class ProjectController method removeFromHistory.

private void removeFromHistory(EventObject e) {
    int count = controllerStateHistory.size();
    List<ControllerState> removeList = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        ControllerState cs = controllerStateHistory.get(i);
        if (cs == null || cs.event == null) {
            continue;
        }
        EventObject csEvent = cs.event;
        if (e instanceof EntityEvent && csEvent instanceof EntityDisplayEvent) {
            if (((EntityEvent) e).getEntity() == ((EntityDisplayEvent) csEvent).getEntity()) {
                removeList.add(cs);
            }
        } else if (e instanceof EmbeddableEvent && csEvent instanceof EmbeddableDisplayEvent) {
            if (((EmbeddableEvent) e).getEmbeddable() == ((EmbeddableDisplayEvent) csEvent).getEmbeddable()) {
                removeList.add(cs);
            }
        } else if (e instanceof ProcedureEvent && csEvent instanceof ProcedureDisplayEvent) {
            if (((ProcedureEvent) e).getProcedure() == ((ProcedureDisplayEvent) csEvent).getProcedure()) {
                removeList.add(cs);
            }
        } else if (e instanceof QueryEvent && csEvent instanceof QueryDisplayEvent) {
            if (((QueryEvent) e).getQuery() == ((QueryDisplayEvent) csEvent).getQuery()) {
                removeList.add(cs);
            }
        } else if (e instanceof DataMapEvent && csEvent instanceof DataMapDisplayEvent) {
            if (((DataMapEvent) e).getDataMap() == ((DataMapDisplayEvent) csEvent).getDataMap()) {
                removeList.add(cs);
            }
        } else if (e instanceof DataNodeEvent && csEvent instanceof DataNodeDisplayEvent) {
            if (((DataNodeEvent) e).getDataNode() == ((DataNodeDisplayEvent) csEvent).getDataNode()) {
                removeList.add(cs);
            }
        } else if (e instanceof DomainEvent && csEvent instanceof DomainDisplayEvent) {
            if (((DomainEvent) e).getDomain() == ((DomainDisplayEvent) csEvent).getDomain()) {
                removeList.add(cs);
            }
        }
    }
    for (ControllerState o : removeList) {
        controllerStateHistory.remove(o);
    }
}
Also used : ProcedureDisplayEvent(org.apache.cayenne.modeler.event.ProcedureDisplayEvent) EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) EmbeddableEvent(org.apache.cayenne.map.event.EmbeddableEvent) DomainEvent(org.apache.cayenne.configuration.event.DomainEvent) ProcedureEvent(org.apache.cayenne.configuration.event.ProcedureEvent) EmbeddableDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableDisplayEvent) ArrayList(java.util.ArrayList) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent) DataMapDisplayEvent(org.apache.cayenne.modeler.event.DataMapDisplayEvent) EventObject(java.util.EventObject) DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent) QueryDisplayEvent(org.apache.cayenne.modeler.event.QueryDisplayEvent) DomainDisplayEvent(org.apache.cayenne.modeler.event.DomainDisplayEvent) DataNodeEvent(org.apache.cayenne.configuration.event.DataNodeEvent) DataNodeDisplayEvent(org.apache.cayenne.modeler.event.DataNodeDisplayEvent) EntityEvent(org.apache.cayenne.map.event.EntityEvent)

Example 5 with EmbeddableDisplayEvent

use of org.apache.cayenne.modeler.event.EmbeddableDisplayEvent 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

EmbeddableDisplayEvent (org.apache.cayenne.modeler.event.EmbeddableDisplayEvent)8 DataMap (org.apache.cayenne.map.DataMap)4 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)3 Embeddable (org.apache.cayenne.map.Embeddable)3 DataMapDisplayEvent (org.apache.cayenne.modeler.event.DataMapDisplayEvent)3 DataNodeDisplayEvent (org.apache.cayenne.modeler.event.DataNodeDisplayEvent)3 DomainDisplayEvent (org.apache.cayenne.modeler.event.DomainDisplayEvent)3 EntityDisplayEvent (org.apache.cayenne.modeler.event.EntityDisplayEvent)3 ProcedureDisplayEvent (org.apache.cayenne.modeler.event.ProcedureDisplayEvent)3 QueryDisplayEvent (org.apache.cayenne.modeler.event.QueryDisplayEvent)3 EventObject (java.util.EventObject)2 DbEntity (org.apache.cayenne.map.DbEntity)2 ObjEntity (org.apache.cayenne.map.ObjEntity)2 EmbeddableEvent (org.apache.cayenne.map.event.EmbeddableEvent)2 EmbeddableAttributeDisplayEvent (org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent)2 ArrayList (java.util.ArrayList)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)1 DataMapEvent (org.apache.cayenne.configuration.event.DataMapEvent)1 DataNodeEvent (org.apache.cayenne.configuration.event.DataNodeEvent)1