use of org.apache.cayenne.wocompat.EOModelProcessor in project cayenne by apache.
the class ImportEOModelAction method importEOModel.
/**
* Allows user to select an EOModel, then imports it as a DataMap.
*/
protected void importEOModel() {
JFileChooser fileChooser = getEOModelChooser();
int status = fileChooser.showOpenDialog(Application.getFrame());
if (status == JFileChooser.APPROVE_OPTION) {
// save preferences
FSPath lastDir = getApplication().getFrameController().getLastEOModelDirectory();
lastDir.updateFromChooser(fileChooser);
File file = fileChooser.getSelectedFile();
if (file.isFile()) {
file = file.getParentFile();
}
DataMap currentMap = getProjectController().getCurrentDataMap();
try {
URL url = file.toURI().toURL();
EOModelProcessor processor = new EOModelProcessor();
// load DataNode if we are not merging with an existing map
if (currentMap == null) {
loadDataNode(processor.loadModeIndex(url));
}
// load DataMap
DataMap map = processor.loadEOModel(url);
addDataMap(map, currentMap);
} catch (Exception ex) {
logObj.info("EOModel Loading Exception", ex);
ErrorDebugDialog.guiException(ex);
}
}
}
Aggregations