Search in sources :

Example 1 with EOModelProcessor

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);
        }
    }
}
Also used : FSPath(org.apache.cayenne.modeler.pref.FSPath) EOModelProcessor(org.apache.cayenne.wocompat.EOModelProcessor) File(java.io.File) URL(java.net.URL) DataMap(org.apache.cayenne.map.DataMap)

Aggregations

File (java.io.File)1 URL (java.net.URL)1 DataMap (org.apache.cayenne.map.DataMap)1 FSPath (org.apache.cayenne.modeler.pref.FSPath)1 EOModelProcessor (org.apache.cayenne.wocompat.EOModelProcessor)1