Search in sources :

Example 1 with ProcedureEvent

use of org.apache.cayenne.configuration.event.ProcedureEvent in project cayenne by apache.

the class CreateProcedureAction method fireProcedureEvent.

/**
 * Fires events when a procedure was added
 */
static void fireProcedureEvent(Object src, ProjectController mediator, DataMap dataMap, Procedure procedure) {
    mediator.fireProcedureEvent(new ProcedureEvent(src, procedure, MapEvent.ADD));
    mediator.fireProcedureDisplayEvent(new ProcedureDisplayEvent(src, procedure, mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode()));
}
Also used : ProcedureDisplayEvent(org.apache.cayenne.modeler.event.ProcedureDisplayEvent) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ProcedureEvent(org.apache.cayenne.configuration.event.ProcedureEvent)

Example 2 with ProcedureEvent

use of org.apache.cayenne.configuration.event.ProcedureEvent in project cayenne by apache.

the class CatalogUpdateController method updateCatalog.

protected void updateCatalog() {
    boolean doAll = isAllEntities();
    String defaultCatalog = dataMap.getDefaultCatalog();
    // set catalog for DbEntities
    for (DbEntity entity : dataMap.getDbEntities()) {
        if (doAll || Util.isEmptyString(entity.getCatalog())) {
            if (!Util.nullSafeEquals(defaultCatalog, entity.getCatalog())) {
                entity.setCatalog(defaultCatalog);
                // any way to batch events, a big change will flood the app
                // with entity events..?
                mediator.fireDbEntityEvent(new EntityEvent(this, entity));
            }
        }
    }
    // set catalog for procedures...
    for (Procedure procedure : dataMap.getProcedures()) {
        if (doAll || Util.isEmptyString(procedure.getCatalog())) {
            if (!Util.nullSafeEquals(defaultCatalog, procedure.getCatalog())) {
                procedure.setCatalog(defaultCatalog);
                // any way to batch events, a big change will flood the app
                // with procedure events..?
                mediator.fireProcedureEvent(new ProcedureEvent(this, procedure));
            }
        }
    }
    view.dispose();
}
Also used : DbEntity(org.apache.cayenne.map.DbEntity) EntityEvent(org.apache.cayenne.map.event.EntityEvent) ProcedureEvent(org.apache.cayenne.configuration.event.ProcedureEvent) Procedure(org.apache.cayenne.map.Procedure)

Example 3 with ProcedureEvent

use of org.apache.cayenne.configuration.event.ProcedureEvent 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 4 with ProcedureEvent

use of org.apache.cayenne.configuration.event.ProcedureEvent in project cayenne by apache.

the class ProcedureTab method setComment.

void setComment(String comment) {
    Procedure procedure = eventController.getCurrentProcedure();
    if (procedure == null) {
        return;
    }
    ObjectInfo.putToMetaData(eventController.getApplication().getMetaData(), procedure, ObjectInfo.COMMENT, comment);
    eventController.fireProcedureEvent(new ProcedureEvent(this, procedure));
}
Also used : ProcedureEvent(org.apache.cayenne.configuration.event.ProcedureEvent) Procedure(org.apache.cayenne.map.Procedure)

Example 5 with ProcedureEvent

use of org.apache.cayenne.configuration.event.ProcedureEvent in project cayenne by apache.

the class ProcedureTab method setCatalog.

void setCatalog(String text) {
    if (text != null && text.trim().length() == 0) {
        text = null;
    }
    Procedure procedure = eventController.getCurrentProcedure();
    if (procedure != null && !Util.nullSafeEquals(procedure.getCatalog(), text)) {
        procedure.setCatalog(text);
        eventController.fireProcedureEvent(new ProcedureEvent(this, procedure));
    }
}
Also used : ProcedureEvent(org.apache.cayenne.configuration.event.ProcedureEvent) Procedure(org.apache.cayenne.map.Procedure)

Aggregations

ProcedureEvent (org.apache.cayenne.configuration.event.ProcedureEvent)10 Procedure (org.apache.cayenne.map.Procedure)6 EntityEvent (org.apache.cayenne.map.event.EntityEvent)3 DbEntity (org.apache.cayenne.map.DbEntity)2 ProcedureDisplayEvent (org.apache.cayenne.modeler.event.ProcedureDisplayEvent)2 ArrayList (java.util.ArrayList)1 EventObject (java.util.EventObject)1 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)1 DataMapEvent (org.apache.cayenne.configuration.event.DataMapEvent)1 DataNodeEvent (org.apache.cayenne.configuration.event.DataNodeEvent)1 DomainEvent (org.apache.cayenne.configuration.event.DomainEvent)1 QueryEvent (org.apache.cayenne.configuration.event.QueryEvent)1 ProcedureParameter (org.apache.cayenne.map.ProcedureParameter)1 EmbeddableEvent (org.apache.cayenne.map.event.EmbeddableEvent)1 ProjectController (org.apache.cayenne.modeler.ProjectController)1 DataMapDisplayEvent (org.apache.cayenne.modeler.event.DataMapDisplayEvent)1 DataNodeDisplayEvent (org.apache.cayenne.modeler.event.DataNodeDisplayEvent)1 DomainDisplayEvent (org.apache.cayenne.modeler.event.DomainDisplayEvent)1 EmbeddableDisplayEvent (org.apache.cayenne.modeler.event.EmbeddableDisplayEvent)1 EntityDisplayEvent (org.apache.cayenne.modeler.event.EntityDisplayEvent)1