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));
}
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);
}
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);
}
}
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));
}
Aggregations