cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [20/32] cayenne git commit: Cgen task refactoring
Date Wed, 14 Nov 2018 14:27:51 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/StandardModePanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/StandardModePanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/StandardModePanel.java
deleted file mode 100644
index 81bd599..0000000
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/StandardModePanel.java
+++ /dev/null
@@ -1,42 +0,0 @@
-///*****************************************************************
-// *   Licensed to the Apache Software Foundation (ASF) under one
-// *  or more contributor license agreements.  See the NOTICE file
-// *  distributed with this work for additional information
-// *  regarding copyright ownership.  The ASF licenses this file
-// *  to you under the Apache License, Version 2.0 (the
-// *  "License"); you may not use this file except in compliance
-// *  with the License.  You may obtain a copy of the License at
-// *
-// *    http://www.apache.org/licenses/LICENSE-2.0
-// *
-// *  Unless required by applicable law or agreed to in writing,
-// *  software distributed under the License is distributed on an
-// *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// *  KIND, either express or implied.  See the License for the
-// *  specific language governing permissions and limitations
-// *  under the License.
-// ****************************************************************/
-//
-//package org.apache.cayenne.modeler.dialog.codegen;
-//
-//import com.jgoodies.forms.builder.DefaultFormBuilder;
-//import com.jgoodies.forms.layout.FormLayout;
-//
-//import java.awt.BorderLayout;
-//
-//public class StandardModePanel extends GeneratorControllerPanel {
-//
-//    private DefaultFormBuilder builder;
-//
-//    public StandardModePanel() {
-//        FormLayout layout = new FormLayout(
-//                "right:77dlu, 1dlu, fill:100:grow, 1dlu, left:80dlu, 1dlu", "");
-//
-//        builder = new DefaultFormBuilder(layout);
-//        builder.append("Output Directory:", outputFolder, selectOutputFolder);
-//        builder.nextLine();
-//
-//        setLayout(new BorderLayout());
-//        add(builder.getPanel(), BorderLayout.CENTER);
-//    }
-//}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/StandardPanelComponent.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/StandardPanelComponent.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/StandardPanelComponent.java
deleted file mode 100644
index c900728..0000000
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/StandardPanelComponent.java
+++ /dev/null
@@ -1,81 +0,0 @@
-///*****************************************************************
-// *   Licensed to the Apache Software Foundation (ASF) under one
-// *  or more contributor license agreements.  See the NOTICE file
-// *  distributed with this work for additional information
-// *  regarding copyright ownership.  The ASF licenses this file
-// *  to you under the Apache License, Version 2.0 (the
-// *  "License"); you may not use this file except in compliance
-// *  with the License.  You may obtain a copy of the License at
-// *
-// *    http://www.apache.org/licenses/LICENSE-2.0
-// *
-// *  Unless required by applicable law or agreed to in writing,
-// *  software distributed under the License is distributed on an
-// *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// *  KIND, either express or implied.  See the License for the
-// *  specific language governing permissions and limitations
-// *  under the License.
-// ****************************************************************/
-//
-//package org.apache.cayenne.modeler.dialog.codegen;
-//
-//import com.jgoodies.forms.builder.DefaultFormBuilder;
-//import com.jgoodies.forms.layout.FormLayout;
-//import org.apache.cayenne.map.DataMap;
-//import org.apache.cayenne.modeler.pref.DataMapDefaults;
-//
-//import javax.swing.JComponent;
-//import javax.swing.JLabel;
-//import javax.swing.JTextField;
-//import java.awt.BorderLayout;
-//
-//public class StandardPanelComponent extends JComponent {
-//
-//    private DataMap dataMap;
-//    private DataMapDefaults preferences;
-//    private JLabel dataMapName;
-//    private JTextField superclassPackage;
-//    private DefaultFormBuilder builder;
-//
-//    public StandardPanelComponent() {
-//        super();
-//        dataMapName = new JLabel();
-//        dataMapName.setFont(dataMapName.getFont().deriveFont(1));
-//        superclassPackage = new JTextField();
-//
-//        FormLayout layout = new FormLayout(
-//                "right:77dlu, 3dlu, fill:200:grow, 3dlu", "");
-//        builder = new DefaultFormBuilder(layout);
-//        builder.append(dataMapName);
-//        builder.nextLine();
-//        builder.append("Superclass Package:", superclassPackage);
-//
-//        setLayout(new BorderLayout());
-//        add(builder.getPanel(), BorderLayout.CENTER);
-//    }
-//
-//    public DataMap getDataMap() {
-//        return dataMap;
-//    }
-//
-//    public void setDataMap(DataMap dataMap) {
-//        this.dataMap = dataMap;
-//    }
-//
-//    public DataMapDefaults getPreferences() {
-//        return preferences;
-//    }
-//
-//    public void setPreferences(DataMapDefaults preferences) {
-//        this.preferences = preferences;
-//    }
-//
-//    public JLabel getDataMapName() {
-//        return dataMapName;
-//    }
-//
-//    public JTextField getSuperclassPackage() {
-//        return superclassPackage;
-//    }
-//
-//}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainTabbedView.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainTabbedView.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainTabbedView.java
index 96a195e..de4059e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainTabbedView.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainTabbedView.java
@@ -39,8 +39,8 @@ public class DataDomainTabbedView extends JTabbedPane
     ProjectController mediator;
     
     DataDomainGraphTab graphTab;
-    JScrollPane cgenView;
-    CgenTabController cgenTabController;
+    private JScrollPane cgenView;
+    private CgenTabController cgenTabController;
 
     /**
      * constructor

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapTabbedView.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapTabbedView.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapTabbedView.java
index 9c8fcab..ddd6893 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapTabbedView.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapTabbedView.java
@@ -31,12 +31,12 @@ import javax.swing.*;
  *
  */
 public class DataMapTabbedView extends JTabbedPane{
-    ProjectController mediator;
-    private int lastSelectionIndex;
-    private DbImportView dbImportView1;
 
+    ProjectController mediator;
+    private DbImportView dbImportView;
+    private JScrollPane dbImportScrollPane;
     private CodeGeneratorController codeGeneratorController;
-    JScrollPane cgenView;
+    private JScrollPane cgenView;
 
     /**
      * constructor
@@ -59,37 +59,23 @@ public class DataMapTabbedView extends JTabbedPane{
         // note that those panels that have no internal scrollable tables
         // must be wrapped in a scroll pane
         JScrollPane dataMapScrollPane = new JScrollPane(new DataMapView(mediator));
-        dbImportView1 = new DbImportView(mediator);
-        JScrollPane dbImportScrollPane = new JScrollPane(dbImportView1);
+        dbImportView = new DbImportView(mediator);
+        dbImportScrollPane = new JScrollPane(dbImportView);
+        codeGeneratorController = new CodeGeneratorController(Application.getInstance().getFrameController(), mediator);
+        cgenView = new JScrollPane(codeGeneratorController.getView());
         addTab("DataMap", dataMapScrollPane);
         addTab("DB Import", dbImportScrollPane);
-        addChangeListener(e -> {
-            lastSelectionIndex = getSelectedIndex();
-            updateTabs();
-        });
-    }
-
-    private void updateTabs() {
-        switch (lastSelectionIndex) {
-            case 1:
-                dbImportView1.initFromModel();
-            break;
-        }
-        JScrollPane dataMapView = new JScrollPane(new DataMapView(mediator));
-        JScrollPane dbImportView = new JScrollPane(new DbImportView(mediator));
-        this.codeGeneratorController = new CodeGeneratorController(Application.getInstance().getFrameController(), mediator);
-        cgenView = new JScrollPane(codeGeneratorController.getView());
-        addTab("DataMap", dataMapView);
-        addTab("DbImport", dbImportView);
         addTab("Class Generation", cgenView);
 
         addChangeListener(tab -> {
             if(isCgenTabActive()) {
                 codeGeneratorController.startup(mediator.getCurrentDataMap());
+            } else if(isDbImportTabActive()) {
+                dbImportView.initFromModel();
             }
         });
         mediator.addDataMapDisplayListener(e -> {
-            if(isCgenTabActive()) {
+            if(isCgenTabActive() || isDbImportTabActive()) {
                 fireStateChanged();
             } else if(e.getSource() instanceof CgenTab){
                 setSelectedComponent(cgenView);
@@ -100,5 +86,9 @@ public class DataMapTabbedView extends JTabbedPane{
     private boolean isCgenTabActive() {
         return getSelectedComponent() == cgenView;
     }
+
+    private boolean isDbImportTabActive() {
+        return getSelectedComponent() == dbImportScrollPane;
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/ClassesTabController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/ClassesTabController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/ClassesTabController.java
index cfa6a57..7b98f4c 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/ClassesTabController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/ClassesTabController.java
@@ -100,7 +100,11 @@ public class ClassesTabController extends CayenneController {
         int selectedCount = getParentController().getSelectedEntitiesSize()
                 + getParentController().getSelectedEmbeddablesSize()
                 + (getParentController().isDataMapSelected() ? 1 : 0);
-
+        if(selectedCount == 0) {
+            getParentController().enableGenerateButton(false);
+        } else {
+            getParentController().enableGenerateButton(true);
+        }
         if (selectedCount < getParentController().getClasses().size()) {
             view.getCheckAll().setSelected(false);
         }
@@ -118,6 +122,11 @@ public class ClassesTabController extends CayenneController {
         if (getParentController().updateSelection(view.getCheckAll().isSelected() ? o -> true : o -> false)) {
             tableBinding.updateView();
             getParentController().updateEntities();
+            if(view.getCheckAll().isSelected()) {
+                getParentController().enableGenerateButton(true);
+            } else {
+                getParentController().enableGenerateButton(false);
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/ClientModeController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/ClientModeController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/ClientModeController.java
index 87881f4..7485d25 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/ClientModeController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/ClientModeController.java
@@ -28,16 +28,11 @@ public class ClientModeController extends StandardModeController {
     }
 
     protected GeneratorControllerPanel createView() {
-        this.view = new StandardModePanel();
+        this.view = new StandardModePanel(getParentController());
         return view;
     }
 
     @Override
-    public CgenConfiguration createConfiguration() {
-        return super.createConfiguration();
-    }
-
-    @Override
     public void updateConfiguration(CgenConfiguration cgenConfiguration) {
         cgenConfiguration.setClient(true);
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorController.java
index f4ab6bc..1274ecb 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorController.java
@@ -65,14 +65,13 @@ public class CodeGeneratorController extends CodeGeneratorControllerBase {
     public void startup(DataMap dataMap) {
         super.startup(dataMap);
         classesSelectedAction();
-        GeneratorController modeController = prevGeneratorController.get(dataMap) != null ? prevGeneratorController.get(dataMap) : generatorSelector.getStandartController();
-        CgenConfiguration cgenConfiguration = modeController.createConfiguration();
-        if(cgenConfiguration.isClient()) {
-            modeController = generatorSelector.getClientGeneratorController();
-        }
-        classesSelector.startup();
+        CgenConfiguration cgenConfiguration = createConfiguration();
+        GeneratorController modeController = prevGeneratorController.get(dataMap) != null ? prevGeneratorController.get(dataMap) : cgenConfiguration.isClient() ?
+                generatorSelector.getClientGeneratorController() : generatorSelector.getStandartController();
         prevGeneratorController.put(dataMap, modeController);
         generatorSelector.setSelectedController(modeController);
+        classesSelector.startup();
+        initFromModel = false;
     }
 
     private void initListeners(){
@@ -147,11 +146,13 @@ public class CodeGeneratorController extends CodeGeneratorControllerBase {
         }
 
         ((GeneratorTabPanel)generatorSelector.getView()).getClassesCount().setText(label);
-        projectController.setDirty(true);
+        if(!isInitFromModel()) {
+            getProjectController().setDirty(true);
+        }
     }
 
     public void generateAction() {
-        CgenConfiguration cgenConfiguration = generatorSelector.getConfiguration();
+        CgenConfiguration cgenConfiguration = createConfiguration();
         ClassGenerationAction generator = cgenConfiguration.isClient() ?
                 new ClientClassGenerationAction(cgenConfiguration) :
                 new ClassGenerationAction(cgenConfiguration);
@@ -173,4 +174,8 @@ public class CodeGeneratorController extends CodeGeneratorControllerBase {
     public ConcurrentMap<DataMap, GeneratorController> getPrevGeneratorController() {
         return prevGeneratorController;
     }
+
+    public void enableGenerateButton(boolean enable) {
+        ((GeneratorTabPanel)generatorSelector.getView()).getGenerateButton().setEnabled(enable);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorControllerBase.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorControllerBase.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorControllerBase.java
index 35ba15e..211384d 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorControllerBase.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CodeGeneratorControllerBase.java
@@ -22,18 +22,27 @@ package org.apache.cayenne.modeler.editor.cgen;
 import org.apache.cayenne.gen.CgenConfiguration;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.dialog.pref.GeneralPreferences;
 import org.apache.cayenne.modeler.util.CayenneController;
 import org.apache.cayenne.modeler.util.CellRenderers;
+import org.apache.cayenne.modeler.util.ModelerUtil;
 import org.apache.cayenne.validation.ValidationFailure;
 import org.apache.cayenne.validation.ValidationResult;
 
 import javax.swing.*;
 import java.awt.*;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.*;
 import java.util.List;
 import java.util.function.Predicate;
+import java.util.prefs.Preferences;
+import java.util.stream.Collectors;
 
 /**
  * A base superclass of a top controller for the code generator. Defines all common model
@@ -56,6 +65,8 @@ public abstract class CodeGeneratorControllerBase extends CayenneController {
     protected transient Object currentClass;
     protected ProjectController projectController;
 
+    protected boolean initFromModel;
+
     public CodeGeneratorControllerBase(CayenneController parent, ProjectController projectController) {
         super(parent);
         this.projectController = projectController;
@@ -66,6 +77,7 @@ public abstract class CodeGeneratorControllerBase extends CayenneController {
     }
 
     public void startup(DataMap dataMap){
+        initFromModel = true;
         this.dataMap = dataMap;
         prepareClasses(dataMap);
     }
@@ -87,6 +99,65 @@ public abstract class CodeGeneratorControllerBase extends CayenneController {
                 value == null ? new HashSet<>() : value);
     }
 
+    /**
+     * Creates a class generator for provided selections.
+     */
+    public CgenConfiguration createConfiguration() {
+        DataMap map = projectController.getCurrentDataMap();
+        CgenConfiguration cgenConfiguration = projectController.getApplication().getMetaData().get(map, CgenConfiguration.class);
+        if(cgenConfiguration != null){
+            addToSelectedEntities(cgenConfiguration.getDataMap(), cgenConfiguration.getEntities());
+            addToSelectedEmbeddables(cgenConfiguration.getDataMap(), cgenConfiguration.getEmbeddables());
+            return cgenConfiguration;
+        }
+
+        try {
+            cgenConfiguration = new CgenConfiguration();
+            cgenConfiguration.setDataMap(map);
+
+            Path basePath = Paths.get(ModelerUtil.initOutputFolder());
+
+            // no destination folder
+            if (basePath == null) {
+                JOptionPane.showMessageDialog(this.getView(), "Select directory for source files.");
+                return null;
+            }
+
+            // no such folder
+            if (!Files.exists(basePath)) {
+                Files.createDirectories(basePath);
+            }
+
+            // not a directory
+            if (!Files.isDirectory(basePath)) {
+                JOptionPane.showMessageDialog(this.getView(), basePath + " is not a valid directory.");
+                return null;
+            }
+
+            cgenConfiguration.setRootPath(basePath);
+            Preferences preferences = application.getPreferencesNode(GeneralPreferences.class, "");
+            if (preferences != null) {
+                cgenConfiguration.setEncoding(preferences.get(GeneralPreferences.ENCODING_PREFERENCE, null));
+            }
+            addToSelectedEntities(map, map.getObjEntities()
+                    .stream()
+                    .map(Entity::getName)
+                    .collect(Collectors.toList()));
+            addToSelectedEmbeddables(map, map.getEmbeddables()
+                    .stream()
+                    .map(Embeddable::getClassName)
+                    .collect(Collectors.toList()));
+           getApplication().getMetaData().add(map, cgenConfiguration);
+           projectController.setDirty(true);
+        } catch (IOException exception) {
+            JOptionPane.showMessageDialog(this.getView(), "Can't create directory. " +
+                    ". Select a different one.");
+            return null;
+        }
+
+        return cgenConfiguration;
+    }
+
     public List<Object> getClasses() {
         return classes;
     }
@@ -363,4 +434,15 @@ public abstract class CodeGeneratorControllerBase extends CayenneController {
     public void setCurrentClass(Object currentClass) {
         this.currentClass = currentClass;
     }
+
+    public boolean isInitFromModel() {
+        return initFromModel;
+    }
+
+    public void setInitFromModel(boolean initFromModel) {
+        this.initFromModel = initFromModel;
+    }
+
+
+    public abstract void enableGenerateButton(boolean enabled);
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModeController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModeController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModeController.java
index 5626a38..247d747 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModeController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModeController.java
@@ -46,7 +46,7 @@ public class CustomModeController extends GeneratorController {
 
     @Override
     protected GeneratorControllerPanel createView() {
-        this.view = new CustomModePanel(getApplication().getFrameController().getProjectController());
+        this.view = new CustomModePanel(getApplication().getFrameController().getProjectController(), getParentController());
         return view;
     }
 
@@ -91,11 +91,6 @@ public class CustomModeController extends GeneratorController {
         view.setDisableSuperComboBoxes(view.getPairs().isSelected());
     }
 
-    @Override
-    public CgenConfiguration createConfiguration() {
-        return super.createConfiguration();
-    }
-
     private void initListeners(){
         view.getPairs().addActionListener(val -> {
             cgenConfiguration.setMakePairs(view.getPairs().isSelected());
@@ -109,27 +104,37 @@ public class CustomModeController extends GeneratorController {
                 cgenConfiguration.setQueryTemplate(ClassGenerationAction.DATAMAP_SUBCLASS_TEMPLATE);
             }
             initForm(cgenConfiguration);
-            getParentController().getProjectController().setDirty(true);
+            if(!getParentController().isInitFromModel()) {
+                getParentController().getProjectController().setDirty(true);
+            }
         });
 
         view.getOverwrite().addActionListener(val -> {
             cgenConfiguration.setOverwrite(view.getOverwrite().isSelected());
-            getParentController().getProjectController().setDirty(true);
+            if(!getParentController().isInitFromModel()) {
+                getParentController().getProjectController().setDirty(true);
+            }
         });
 
         view.getCreatePropertyNames().addActionListener(val -> {
             cgenConfiguration.setCreatePropertyNames(view.getCreatePropertyNames().isSelected());
-            getParentController().getProjectController().setDirty(true);
+            if(!getParentController().isInitFromModel()) {
+                getParentController().getProjectController().setDirty(true);
+            }
         });
 
         view.getUsePackagePath().addActionListener(val -> {
             cgenConfiguration.setUsePkgPath(view.getUsePackagePath().isSelected());
-            getParentController().getProjectController().setDirty(true);
+            if(!getParentController().isInitFromModel()) {
+                getParentController().getProjectController().setDirty(true);
+            }
         });
 
         view.getPkProperties().addActionListener(val -> {
             cgenConfiguration.setCreatePKProperties(view.getPkProperties().isSelected());
-            getParentController().getProjectController().setDirty(true);
+            if(!getParentController().isInitFromModel()) {
+                getParentController().getProjectController().setDirty(true);
+            }
         });
     }
 
@@ -146,6 +151,7 @@ public class CustomModeController extends GeneratorController {
             ((CodeGeneratorControllerBase) parent).setSelected(true);
         }
         updateComboBoxes();
+        getParentController().setInitFromModel(false);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModePanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModePanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModePanel.java
index a8c0183..468eec7 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModePanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/CustomModePanel.java
@@ -45,14 +45,16 @@ public class CustomModePanel extends GeneratorControllerPanel {
 
     private ActionLink manageTemplatesLink;
 
-    CustomModePanel(ProjectController projectController) {
-        super(projectController);
+    CustomModePanel(ProjectController projectController, CodeGeneratorControllerBase codeGeneratorControllerBase) {
+        super(projectController, codeGeneratorControllerBase);
         JComboBox<String> superclassField = new JComboBox<>();
         this.superclassTemplate = new ComboBoxAdapter<String>(superclassField) {
             @Override
             protected void updateModel(String item) throws ValidationException {
                 getCgenByDataMap().setSuperTemplate(Application.getInstance().getCodeTemplateManager().getTemplatePath(String.valueOf(item)));
-                projectController.setDirty(true);
+                if(!codeGeneratorControllerBase.isInitFromModel()) {
+                    projectController.setDirty(true);
+                }
             }
         };
 
@@ -61,7 +63,9 @@ public class CustomModePanel extends GeneratorControllerPanel {
             @Override
             protected void updateModel(String item) throws ValidationException {
                 getCgenByDataMap().setTemplate(Application.getInstance().getCodeTemplateManager().getTemplatePath(String.valueOf(item)));
-                projectController.setDirty(true);
+                if(!codeGeneratorControllerBase.isInitFromModel()) {
+                    projectController.setDirty(true);
+                }
             }
         };
 
@@ -72,7 +76,10 @@ public class CustomModePanel extends GeneratorControllerPanel {
         JTextField outputPatternField = new JTextField();
         this.outputPattern = new TextAdapter(outputPatternField) {
             protected void updateModel(String text) {
-
+                getCgenByDataMap().setOutputPattern(text);
+                if(!codeGeneratorControllerBase.isInitFromModel()) {
+                    projectController.setDirty(true);
+                }
             }
         };
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorController.java
index 31aec74..22187f5 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorController.java
@@ -23,11 +23,9 @@ import org.apache.cayenne.gen.ArtifactsGenerationMode;
 import org.apache.cayenne.gen.CgenConfiguration;
 import org.apache.cayenne.map.*;
 import org.apache.cayenne.modeler.Application;
-import org.apache.cayenne.modeler.dialog.pref.GeneralPreferences;
 import org.apache.cayenne.modeler.pref.FSPath;
 import org.apache.cayenne.modeler.util.CayenneController;
 import org.apache.cayenne.modeler.util.CodeValidationUtil;
-import org.apache.cayenne.modeler.util.ModelerUtil;
 import org.apache.cayenne.modeler.util.TextAdapter;
 import org.apache.cayenne.swing.BindingBuilder;
 import org.apache.cayenne.util.Util;
@@ -38,13 +36,7 @@ import org.apache.cayenne.validation.ValidationResult;
 
 import javax.swing.*;
 import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.function.Predicate;
-import java.util.prefs.Preferences;
-import java.util.stream.Collectors;
 
 /**
  * A mode-specific part of the code generation dialog.
@@ -75,70 +67,11 @@ public abstract class GeneratorController extends CayenneController {
 
     protected void initForm(CgenConfiguration cgenConfiguration) {
         this.cgenConfiguration = cgenConfiguration;
-        ((GeneratorControllerPanel)getView()).getOutputFolder().setText(cgenConfiguration.getDir());
+        ((GeneratorControllerPanel)getView()).getOutputFolder().setText(cgenConfiguration.buildPath().toString());
     }
 
     public abstract void updateConfiguration(CgenConfiguration cgenConfiguration);
 
-    /**
-     * Creates a class generator for provided selections.
-     */
-    public CgenConfiguration createConfiguration() {
-        DataMap map = getParentController().getProjectController().getCurrentDataMap();
-        CgenConfiguration cgenConfiguration = getParentController().projectController.getApplication().getMetaData().get(map, CgenConfiguration.class);
-        if(cgenConfiguration != null){
-            getParentController().addToSelectedEntities(cgenConfiguration.getDataMap(), cgenConfiguration.getEntities());
-            getParentController().addToSelectedEmbeddables(cgenConfiguration.getDataMap(), cgenConfiguration.getEmbeddables());
-            cgenConfiguration.setRootPath(Paths.get(ModelerUtil.initOutputFolder()));
-            return cgenConfiguration;
-        }
-
-        try {
-            cgenConfiguration = new CgenConfiguration();
-            cgenConfiguration.setDataMap(map);
-
-            Path basePath = Paths.get(ModelerUtil.initOutputFolder());
-
-            // no destination folder
-            if (basePath == null) {
-                JOptionPane.showMessageDialog(this.getView(), "Select directory for source files.");
-                return null;
-            }
-
-            // no such folder
-            if (!Files.exists(basePath)) {
-                Files.createDirectories(basePath);
-            }
-
-            // not a directory
-            if (!Files.isDirectory(basePath)) {
-                JOptionPane.showMessageDialog(this.getView(), basePath + " is not a valid directory.");
-                return null;
-            }
-
-            cgenConfiguration.setRootPath(basePath);
-            Preferences preferences = application.getPreferencesNode(GeneralPreferences.class, "");
-            if (preferences != null) {
-                cgenConfiguration.setEncoding(preferences.get(GeneralPreferences.ENCODING_PREFERENCE, null));
-            }
-            getParentController().addToSelectedEntities(map, map.getObjEntities()
-                    .stream()
-                    .map(Entity::getName)
-                    .collect(Collectors.toList()));
-            getParentController().addToSelectedEmbeddables(map, map.getEmbeddables()
-                    .stream()
-                    .map(Embeddable::getClassName)
-                    .collect(Collectors.toList()));
-            getParentController().projectController.getApplication().getMetaData().add(map, cgenConfiguration);
-        } catch (IOException exception) {
-            JOptionPane.showMessageDialog(this.getView(), "Can't create directory. " +
-                    ". Select a different one.");
-            return null;
-        }
-
-        return cgenConfiguration;
-    }
-
     public void validateEmbeddable(ValidationResult validationBuffer, Embeddable embeddable) {
         ValidationFailure embeddableFailure = validateEmbeddable(embeddable);
         if (embeddableFailure != null) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorControllerPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorControllerPanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorControllerPanel.java
index 21bd223..5771b89 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorControllerPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorControllerPanel.java
@@ -26,8 +26,6 @@ import org.apache.cayenne.modeler.util.TextAdapter;
 import org.apache.cayenne.validation.ValidationException;
 
 import javax.swing.*;
-import java.util.ArrayList;
-import java.util.Collection;
 
 /**
  * A generic panel that is a superclass of generator panels, defining common fields.
@@ -35,19 +33,19 @@ import java.util.Collection;
  */
 public class GeneratorControllerPanel extends JPanel {
 
-    protected Collection<StandardPanelComponent> dataMapLines;
     protected TextAdapter outputFolder;
     protected JButton selectOutputFolder;
     protected ProjectController projectController;
 
-    public GeneratorControllerPanel(ProjectController projectController) {
-        this.dataMapLines = new ArrayList<>();
+    public GeneratorControllerPanel(ProjectController projectController, CodeGeneratorControllerBase codeGeneratorControllerBase) {
         this.projectController = projectController;
         this.outputFolder = new TextAdapter(new JTextField()) {
             @Override
             protected void updateModel(String text) throws ValidationException {
                 getCgenByDataMap().setRelPath(text);
-                projectController.setDirty(true);
+                if(!codeGeneratorControllerBase.isInitFromModel()) {
+                    projectController.setDirty(true);
+                }
             }
         };
         this.selectOutputFolder = new JButton("Select");

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorTabController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorTabController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorTabController.java
index 16aebae..6af5436 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorTabController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorTabController.java
@@ -77,7 +77,7 @@ public class GeneratorTabController extends CayenneController {
         view.getGenerationMode().addActionListener(action -> {
             String name = (String)view.getGenerationMode().getSelectedItem();
             GeneratorController modeController = getGeneratorController();
-            CgenConfiguration cgenConfiguration = modeController.createConfiguration();
+            CgenConfiguration cgenConfiguration = getParentController().createConfiguration();
             modeController.updateConfiguration(cgenConfiguration);
             controllers.get(name).initForm(cgenConfiguration);
             ((CodeGeneratorController)getParentController()).getPrevGeneratorController().put(cgenConfiguration.getDataMap(), modeController);
@@ -104,9 +104,4 @@ public class GeneratorTabController extends CayenneController {
     GeneratorController getClientGeneratorController() {
         return controllers.get(CLIENT_OBJECTS_MODE);
     }
-
-    public CgenConfiguration getConfiguration() {
-        GeneratorController modeController = getGeneratorController();
-        return (modeController != null) ? modeController.createConfiguration() : null;
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorTabPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorTabPanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorTabPanel.java
index 9cfd542..08f1dee 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorTabPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/GeneratorTabPanel.java
@@ -45,6 +45,7 @@ public class GeneratorTabPanel extends JPanel {
         this.generateButton = new JButton("Generate");
         generateButton.setIcon(ModelerUtil.buildIcon("icon-gen_java.png"));
         generateButton.setPreferredSize(new Dimension(180, 30));
+        generateButton.setEnabled(false);
         this.classesCount = new JLabel("No classes selected");
         classesCount.setFont(classesCount.getFont().deriveFont(10f));
         JPanel messages = new JPanel(new BorderLayout());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardModeController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardModeController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardModeController.java
index 69cb19f..5b34efc 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardModeController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardModeController.java
@@ -34,7 +34,7 @@ public class StandardModeController extends GeneratorController {
     }
 
     protected GeneratorControllerPanel createView() {
-        this.view = new StandardModePanel();
+        this.view = new StandardModePanel(getParentController());
         return view;
     }
 
@@ -43,13 +43,9 @@ public class StandardModeController extends GeneratorController {
     }
 
     @Override
-    public CgenConfiguration createConfiguration() {
-        return super.createConfiguration();
-    }
-
-    @Override
     protected void initForm(CgenConfiguration cgenConfiguration) {
         super.initForm(cgenConfiguration);
+        getParentController().setInitFromModel(false);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardModePanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardModePanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardModePanel.java
index 0ddf1e2..2b755e7 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardModePanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardModePanel.java
@@ -27,8 +27,8 @@ import java.awt.*;
 
 public class StandardModePanel extends GeneratorControllerPanel {
 
-    public StandardModePanel() {
-        super(Application.getInstance().getFrameController().getProjectController());
+    public StandardModePanel(CodeGeneratorControllerBase codeGeneratorControllerBase) {
+        super(Application.getInstance().getFrameController().getProjectController(), codeGeneratorControllerBase);
         FormLayout layout = new FormLayout(
                 "right:88dlu, 1dlu, fill:300:grow, 1dlu, left:100dlu, 100dlu", "");
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardPanelComponent.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardPanelComponent.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardPanelComponent.java
deleted file mode 100644
index 8170548..0000000
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/StandardPanelComponent.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.modeler.editor.cgen;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.FormLayout;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.modeler.pref.DataMapDefaults;
-
-import javax.swing.*;
-import java.awt.*;
-
-public class StandardPanelComponent extends JComponent {
-
-    private DataMap dataMap;
-    private DataMapDefaults preferences;
-
-    public StandardPanelComponent() {
-        super();
-
-        FormLayout layout = new FormLayout(
-                "right:77dlu, 3dlu, fill:100:grow, 3dlu", "");
-        DefaultFormBuilder builder = new DefaultFormBuilder(layout);
-        builder.nextLine();
-
-        setLayout(new BorderLayout());
-        add(builder.getPanel(), BorderLayout.CENTER);
-    }
-
-    public DataMap getDataMap() {
-        return dataMap;
-    }
-
-    public void setDataMap(DataMap dataMap) {
-        this.dataMap = dataMap;
-    }
-
-    public DataMapDefaults getPreferences() {
-        return preferences;
-    }
-
-    public void setPreferences(DataMapDefaults preferences) {
-        this.preferences = preferences;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenPanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenPanel.java
index cf9b27a8..637cc12 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenPanel.java
@@ -1,3 +1,22 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
 package org.apache.cayenne.modeler.editor.cgen.domain;
 
 import com.jgoodies.forms.builder.DefaultFormBuilder;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenTab.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenTab.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenTab.java
index 87a7cc4..0c5288e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenTab.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenTab.java
@@ -1,3 +1,22 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
 package org.apache.cayenne.modeler.editor.cgen.domain;
 
 import com.jgoodies.forms.builder.DefaultFormBuilder;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenTabController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenTabController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenTabController.java
index daeb677..0f82abf 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenTabController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/cgen/domain/CgenTabController.java
@@ -1,3 +1,22 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
 package org.apache.cayenne.modeler.editor.cgen.domain;
 
 import org.apache.cayenne.configuration.DataChannelDescriptor;
@@ -19,7 +38,6 @@ import org.slf4j.LoggerFactory;
 import javax.swing.*;
 import java.awt.event.ItemEvent;
 import java.io.IOException;
-import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -115,14 +133,6 @@ public class CgenTabController {
                 if(cgenConfiguration == null) {
                     cgenConfiguration = createConfiguration(dataMap);
                 }
-                if(cgenConfiguration.getRootPath() == null) {
-                    URL url = projectController.getProject().getConfigurationResource().getURL();
-                    Path resourcePath = Paths.get(url.getPath());
-                    if(Files.isRegularFile(resourcePath)) {
-                        resourcePath = resourcePath.getParent();
-                    }
-                    cgenConfiguration.setRootPath(resourcePath);
-                }
                 ClassGenerationAction classGenerationAction = cgenConfiguration.isClient() ? new ClientClassGenerationAction(cgenConfiguration) :
                         new ClassGenerationAction(cgenConfiguration);
                 classGenerationAction.prepareArtifacts();

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b30e5eb5/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java
index 90c6d19..ab1e01e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java
@@ -215,6 +215,9 @@ public final class ModelerUtil {
         child.setLocation(x, y);
     }
 
+    /**
+     * @since 4.1
+     */
     public static String initOutputFolder() {
         String path;
         if (System.getProperty("cayenne.cgen.destdir") != null) {


Mime
View raw message