Search in sources :

Example 1 with QueryDisplayEvent

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

the class CreateQueryAction method fireQueryEvent.

/**
 * Fires events when a query was added
 */
public static void fireQueryEvent(Object src, ProjectController mediator, DataChannelDescriptor domain, DataMap dataMap, QueryDescriptor query) {
    mediator.fireQueryEvent(new QueryEvent(src, query, MapEvent.ADD, dataMap));
    mediator.fireQueryDisplayEvent(new QueryDisplayEvent(src, query, dataMap, domain));
}
Also used : QueryDisplayEvent(org.apache.cayenne.modeler.event.QueryDisplayEvent) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Example 2 with QueryDisplayEvent

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

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

the class QueryDisplayEventType 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;
    }
    QueryDescriptor query = dataMap.getQueryDescriptor(preferences.getQuery());
    if (query == null) {
        return;
    }
    QueryDisplayEvent queryDisplayEvent = new QueryDisplayEvent(this, query, dataMap, dataChannel);
    controller.fireQueryDisplayEvent(queryDisplayEvent);
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) QueryDisplayEvent(org.apache.cayenne.modeler.event.QueryDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DataMap(org.apache.cayenne.map.DataMap)

Example 4 with QueryDisplayEvent

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

the class QueryErrorMsg method displayField.

public void displayField(ProjectController mediator, JFrame frame) {
    Object object = super.validationFailure.getSource();
    DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
    QueryDescriptor query = (QueryDescriptor) object;
    DataMap map = query.getDataMap();
    QueryDisplayEvent event = new QueryDisplayEvent(frame, query, map, domain);
    mediator.fireQueryDisplayEvent(event);
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) QueryDisplayEvent(org.apache.cayenne.modeler.event.QueryDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DataMap(org.apache.cayenne.map.DataMap)

Example 5 with QueryDisplayEvent

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

the class QueryType method fireQueryEvent.

/**
 * Fires events when a query was added
 */
public static void fireQueryEvent(Object src, ProjectController mediator, DataMap dataMap, QueryDescriptor query) {
    mediator.fireQueryEvent(new QueryEvent(src, query, MapEvent.ADD, dataMap));
    mediator.fireQueryDisplayEvent(new QueryDisplayEvent(src, query, dataMap, (DataChannelDescriptor) mediator.getProject().getRootNode()));
}
Also used : QueryDisplayEvent(org.apache.cayenne.modeler.event.QueryDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Aggregations

QueryDisplayEvent (org.apache.cayenne.modeler.event.QueryDisplayEvent)11 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)4 DataMap (org.apache.cayenne.map.DataMap)4 ChangeEvent (javax.swing.event.ChangeEvent)3 ChangeListener (javax.swing.event.ChangeListener)3 QueryEvent (org.apache.cayenne.configuration.event.QueryEvent)3 QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)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 EmbeddableDisplayEvent (org.apache.cayenne.modeler.event.EmbeddableDisplayEvent)3 EntityDisplayEvent (org.apache.cayenne.modeler.event.EntityDisplayEvent)3 ProcedureDisplayEvent (org.apache.cayenne.modeler.event.ProcedureDisplayEvent)3 QueryDisplayListener (org.apache.cayenne.modeler.event.QueryDisplayListener)3 EventObject (java.util.EventObject)2 DbEntity (org.apache.cayenne.map.DbEntity)2 ObjEntity (org.apache.cayenne.map.ObjEntity)2 ArrayList (java.util.ArrayList)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)1