Search in sources :

Example 1 with DataMapEvent

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

the class DataMapView method setDataMapName.

void setDataMapName(String newName) {
    if (newName == null || newName.trim().length() == 0) {
        throw new ValidationException("Enter name for DataMap");
    }
    DataMap map = eventController.getCurrentDataMap();
    // search for matching map name across domains, as currently they have to be
    // unique globally
    DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
    DataMap matchingMap = dataChannelDescriptor.getDataMap(newName);
    if (matchingMap != null && !matchingMap.equals(map)) {
        // there is an entity with the same name
        throw new ValidationException("There is another DataMap named '" + newName + "'. Use a different name.");
    }
    String oldName = map.getName();
    if (Util.nullSafeEquals(newName, oldName)) {
        return;
    }
    // completely new name, set new name for domain
    DataMapDefaults pref = eventController.getDataMapPreferences("");
    DataMapEvent e = new DataMapEvent(this, map, map.getName());
    ProjectUtil.setDataMapName((DataChannelDescriptor) eventController.getProject().getRootNode(), map, newName);
    pref.copyPreferences(newName);
    eventController.fireDataMapEvent(e);
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ValidationException(org.apache.cayenne.validation.ValidationException) DataMapDefaults(org.apache.cayenne.modeler.pref.DataMapDefaults) DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent) DataMap(org.apache.cayenne.map.DataMap)

Example 2 with DataMapEvent

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

the class DataMapView method updateComment.

void updateComment(String comment) {
    DataMap dataMap = eventController.getCurrentDataMap();
    if (dataMap == null) {
        return;
    }
    ObjectInfo.putToMetaData(eventController.getApplication().getMetaData(), dataMap, ObjectInfo.COMMENT, comment);
    eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
}
Also used : DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent) DataMap(org.apache.cayenne.map.DataMap)

Example 3 with DataMapEvent

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

the class DataMapView method setClientSupport.

void setClientSupport(boolean flag) {
    DataMap dataMap = eventController.getCurrentDataMap();
    if (dataMap == null) {
        return;
    }
    if (dataMap.isClientSupported() != flag) {
        dataMap.setClientSupported(flag);
        toggleClientProperties(flag);
        eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
    }
}
Also used : DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent) DataMap(org.apache.cayenne.map.DataMap)

Example 4 with DataMapEvent

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

the class DataMapView method setDefaultSchema.

void setDefaultSchema(String newSchema) {
    DataMap dataMap = eventController.getCurrentDataMap();
    if (dataMap == null) {
        return;
    }
    if (newSchema != null && newSchema.trim().length() == 0) {
        newSchema = null;
    }
    String oldSchema = dataMap.getDefaultSchema();
    if (Util.nullSafeEquals(newSchema, oldSchema)) {
        return;
    }
    dataMap.setDefaultSchema(newSchema);
    eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
}
Also used : DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent) DataMap(org.apache.cayenne.map.DataMap)

Example 5 with DataMapEvent

use of org.apache.cayenne.configuration.event.DataMapEvent 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)

Aggregations

DataMapEvent (org.apache.cayenne.configuration.event.DataMapEvent)19 DataMap (org.apache.cayenne.map.DataMap)15 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)3 Test (org.junit.Test)3 DataNodeEvent (org.apache.cayenne.configuration.event.DataNodeEvent)2 ProjectController (org.apache.cayenne.modeler.ProjectController)2 DataMapDisplayEvent (org.apache.cayenne.modeler.event.DataMapDisplayEvent)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 EventObject (java.util.EventObject)1 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)1 DomainEvent (org.apache.cayenne.configuration.event.DomainEvent)1 ProcedureEvent (org.apache.cayenne.configuration.event.ProcedureEvent)1 QueryEvent (org.apache.cayenne.configuration.event.QueryEvent)1 EmbeddableEvent (org.apache.cayenne.map.event.EmbeddableEvent)1 EntityEvent (org.apache.cayenne.map.event.EntityEvent)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