Search in sources :

Example 16 with DataMapEvent

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

the class DataMapView method setDefaultLockType.

void setDefaultLockType(int lockType) {
    DataMap dataMap = eventController.getCurrentDataMap();
    if (dataMap == null) {
        return;
    }
    int oldType = dataMap.getDefaultLockType();
    if (oldType == lockType) {
        return;
    }
    dataMap.setDefaultLockType(lockType);
    eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
}
Also used : DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent) DataMap(org.apache.cayenne.map.DataMap)

Example 17 with DataMapEvent

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

the class RemoveAction method removeDataMap.

public void removeDataMap(DataMap map) {
    ProjectController mediator = getProjectController();
    DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
    DataMapEvent e = new DataMapEvent(Application.getFrame(), map, MapEvent.REMOVE);
    e.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
    domain.getDataMaps().remove(map);
    if (map.getConfigurationSource() != null) {
        URL mapURL = map.getConfigurationSource().getURL();
        Collection<URL> unusedResources = getCurrentProject().getUnusedResources();
        unusedResources.add(mapURL);
    }
    for (DataNodeDescriptor node : domain.getNodeDescriptors()) {
        if (node.getDataMapNames().contains(map.getName())) {
            removeDataMapFromDataNode(node, map);
        }
    }
    mediator.fireDataMapEvent(e);
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) ProjectController(org.apache.cayenne.modeler.ProjectController) DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent) URL(java.net.URL)

Example 18 with DataMapEvent

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

the class DbImportProjectSaver method save.

@Override
public void save(Project project) {
    DataMap dataMap = (DataMap) project.getRootNode();
    if (projectController.getCurrentDataMap() != null) {
        projectController.fireDataMapEvent(new DataMapEvent(Application.getFrame(), dataMap, MapEvent.REMOVE));
        projectController.fireDataMapEvent(new DataMapEvent(Application.getFrame(), dataMap, MapEvent.ADD));
    } else {
        DataChannelDescriptor currentDomain = (DataChannelDescriptor) projectController.getProject().getRootNode();
        Resource baseResource = currentDomain.getConfigurationSource();
        // a new DataMap, so need to set configuration source for it
        if (baseResource != null) {
            Resource dataMapResource = baseResource.getRelativeResource(nameMapper.configurationLocation(dataMap));
            dataMap.setConfigurationSource(dataMapResource);
        }
        projectController.addDataMap(Application.getFrame(), dataMap);
    }
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) Resource(org.apache.cayenne.resource.Resource) DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent) DataMap(org.apache.cayenne.map.DataMap)

Example 19 with DataMapEvent

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

the class MergerOptions method notifyProjectModified.

private void notifyProjectModified(boolean modelChanged) {
    if (!modelChanged) {
        return;
    }
    // mark the model as unsaved
    Project project = getApplication().getProject();
    project.setModified(true);
    ProjectController projectController = getProjectController();
    projectController.setDirty(true);
    projectController.fireDataMapEvent(new DataMapEvent(Application.getFrame(), dataMap, MapEvent.REMOVE));
    projectController.fireDataMapEvent(new DataMapEvent(Application.getFrame(), dataMap, MapEvent.ADD));
}
Also used : Project(org.apache.cayenne.project.Project) ProjectController(org.apache.cayenne.modeler.ProjectController) DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent)

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