Search in sources :

Example 1 with CodeGeneratorController

use of org.apache.cayenne.modeler.dialog.codegen.CodeGeneratorController in project cayenne by apache.

the class GenerateCodeAction method performAction.

public void performAction(ActionEvent e) {
    Collection<DataMap> dataMaps;
    DataMap dataMap = getProjectController().getCurrentDataMap();
    if (dataMap != null) {
        dataMaps = new ArrayList<>();
        dataMaps.add(dataMap);
        new CodeGeneratorController(getApplication().getFrameController(), dataMaps).startup();
    } else if (getProjectController().getCurrentDataNode() != null) {
        Collection<String> nodeMaps = getProjectController().getCurrentDataNode().getDataMapNames();
        Project project = getProjectController().getProject();
        dataMaps = ((DataChannelDescriptor) project.getRootNode()).getDataMaps();
        Collection<DataMap> resultMaps = new ArrayList<>();
        for (DataMap map : dataMaps) {
            if (nodeMaps.contains(map.getName())) {
                resultMaps.add(map);
            }
        }
        new CodeGeneratorController(getApplication().getFrameController(), resultMaps).startup();
    } else {
        Project project = getProjectController().getProject();
        dataMaps = ((DataChannelDescriptor) project.getRootNode()).getDataMaps();
        new CodeGeneratorController(getApplication().getFrameController(), dataMaps).startup();
    }
}
Also used : Project(org.apache.cayenne.project.Project) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) CodeGeneratorController(org.apache.cayenne.modeler.dialog.codegen.CodeGeneratorController) Collection(java.util.Collection) DataMap(org.apache.cayenne.map.DataMap)

Aggregations

Collection (java.util.Collection)1 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)1 DataMap (org.apache.cayenne.map.DataMap)1 CodeGeneratorController (org.apache.cayenne.modeler.dialog.codegen.CodeGeneratorController)1 Project (org.apache.cayenne.project.Project)1