cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [04/32] cayenne git commit: Create global cgen action.
Date Wed, 14 Nov 2018 14:27:35 GMT
Create global cgen action.


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/b85a0900
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/b85a0900
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/b85a0900

Branch: refs/heads/master
Commit: b85a090025c21e1cbe781f47c58737fefb67e892
Parents: d489f2a
Author: Arseni Bulatski <ancarseni@gmail.com>
Authored: Wed Jun 20 10:50:42 2018 +0300
Committer: Arseni Bulatski <ancarseni@gmail.com>
Committed: Wed Oct 24 13:40:57 2018 +0300

----------------------------------------------------------------------
 .../cayenne/gen/ClassGenerationAction.java      | 45 ++++++---
 .../cayenne/gen/xml/CgenConfigHandler.java      | 46 +++++++++-
 .../cayenne/modeler/CayenneModelerFrame.java    | 96 +++-----------------
 .../cayenne/modeler/CodeTemplateManager.java    | 29 ++++++
 .../cayenne/modeler/action/CgenAction.java      | 53 +++++++++++
 .../modeler/action/DefaultActionManager.java    |  5 +-
 .../editor/cgen/ClassesTabController.java       |  2 +-
 .../editor/cgen/CodeGeneratorController.java    |  1 +
 .../editor/cgen/CustomModeController.java       | 82 +++++++++++------
 .../modeler/editor/cgen/CustomModePanel.java    | 44 ++++-----
 .../editor/cgen/GeneratorController.java        | 23 +----
 .../editor/cgen/GeneratorTabController.java     |  2 +-
 12 files changed, 258 insertions(+), 170 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
index 423fb92..35e34cf 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationAction.java
@@ -89,7 +89,6 @@ public class ClassGenerationAction implements Serializable, XMLSerializable
{
 	protected Map<String, Template> templateCache;
 
 	public ClassGenerationAction() {
-//		this.destDir = new File(System.getProperty("user.dir"));
 		this.outputPattern = "*.java";
 		this.timestamp = 0L;
 		this.usePkgPath = true;
@@ -99,6 +98,10 @@ public class ClassGenerationAction implements Serializable, XMLSerializable
{
 
 		this.template = SUBCLASS_TEMPLATE;
 		this.superTemplate = SUPERCLASS_TEMPLATE;
+
+		this.embeddableTemplate = EMBEDDABLE_SUBCLASS_TEMPLATE;
+		this.embeddableSuperTemplate = EMBEDDABLE_SUPERCLASS_TEMPLATE;
+
 		this.artifactsGenerationMode = ArtifactsGenerationMode.ENTITY;
 
 		this.artifacts = new ArrayList<>();
@@ -253,6 +256,7 @@ public class ClassGenerationAction implements Serializable, XMLSerializable
{
 	}
 
 	public void prepareArtifacts(){
+//		resetArtifacts();
 		if(!entityArtifacts.isEmpty()) {
 			for(String name : entityArtifacts) {
 				ObjEntity objEntity = dataMap.getObjEntity(name);
@@ -621,18 +625,6 @@ public class ClassGenerationAction implements Serializable, XMLSerializable
{
 		}
 	}
 
-	public String getArtifactsGenerationMode(){
-		return artifactsGenerationMode.getLabel();
-	}
-
-	public boolean isForce() {
-		return force;
-	}
-
-	public void setForce(boolean force) {
-		this.force = force;
-	}
-
 	/**
 	 * @since 4.1
 	 */
@@ -719,6 +711,30 @@ public class ClassGenerationAction implements Serializable, XMLSerializable
{
 		return embeddableArtifacts;
 	}
 
+	public String getArtifactsGenerationMode(){
+		return artifactsGenerationMode.getLabel();
+	}
+
+	public boolean isForce() {
+		return force;
+	}
+
+	public void setForce(boolean force) {
+		this.force = force;
+	}
+
+	public String getEncoding() {
+		return encoding;
+	}
+
+	public String getEmbeddableTemplate() {
+		return embeddableTemplate;
+	}
+
+	public String getEmbeddableSuperTemplate() {
+		return embeddableSuperTemplate;
+	}
+
 	@Override
 	public void encodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate) {
 		encoder.start("cgen")
@@ -729,12 +745,15 @@ public class ClassGenerationAction implements Serializable, XMLSerializable
{
 				.simpleTag("generationMode", this.artifactsGenerationMode.getLabel())
 				.simpleTag("subclassTemplate", this.template)
 				.simpleTag("superclassTemplate", this.superTemplate)
+				.simpleTag("embeddableTemplate", this.embeddableTemplate)
+				.simpleTag("embeddableSuperclassTemplate", this.embeddableSuperTemplate)
 				.simpleTag("outputPattern", this.outputPattern)
 				.simpleTag("makePairs", Boolean.toString(this.makePairs))
 				.simpleTag("usePkgPath", Boolean.toString(this.usePkgPath))
 				.simpleTag("overwriteSubclasses", Boolean.toString(this.overwrite))
 				.simpleTag("createPropertyNames", Boolean.toString(this.createPropertyNames))
 				.simpleTag("superPkg", this.superPkg)
+				.simpleTag("encoding", this.encoding)
 				.end();
 	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
----------------------------------------------------------------------
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
index fa89bf5..667a4a6 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
@@ -25,6 +25,9 @@ public class CgenConfigHandler extends NamespaceAwareNestedTagHandler{
     private static final String SUPER_PKG_TAG = "superPkg";
     private static final String OBJENTITY_TAG = "objEntity";
     private static final String EMBEDDABLE_TAG = "embeddable";
+    private static final String ENCODING_TAG = "encoding";
+    private static final String EMBEDDABLE_TEMPLATE_TAG = "embeddableTemplate";
+    private static final String EMBEDDABLE_SUPERCLASS_TEMPLATE_TAG = "embeddableSuperclassTemplate";
 
     public static final String TRUE = "true";
 
@@ -96,6 +99,16 @@ public class CgenConfigHandler extends NamespaceAwareNestedTagHandler{
             case SUPER_PKG_TAG:
                 createSuperPkg(data);
                 break;
+            case ENCODING_TAG:
+                createEncoding(data);
+                break;
+            case EMBEDDABLE_TEMPLATE_TAG:
+                createEmbeddableTemplate(data);
+                break;
+            case EMBEDDABLE_SUPERCLASS_TEMPLATE_TAG:
+                createEmbeddableSuperclassTemplate(data);
+                break;
+
         }
     }
 
@@ -139,6 +152,26 @@ public class CgenConfigHandler extends NamespaceAwareNestedTagHandler{
         }
     }
 
+    public void createEmbeddableTemplate(String template) {
+        if(template.trim().length() == 0) {
+            return;
+        }
+
+        if(configuration != null) {
+            configuration.setEmbeddableTemplate(template);
+        }
+    }
+
+    public void createEmbeddableSuperclassTemplate(String template) {
+        if(template.trim().length() == 0) {
+            return;
+        }
+
+        if(configuration != null) {
+            configuration.setEmbeddableSuperTemplate(template);
+        }
+    }
+
     private void createOutputPattern(String pattern) {
         if(pattern.trim().length() == 0) {
             return;
@@ -215,11 +248,22 @@ public class CgenConfigHandler extends NamespaceAwareNestedTagHandler{
         }
     }
 
+    private void createEncoding(String data) {
+        if(data.trim().length() == 0) {
+            return;
+        }
+
+        if(configuration != null) {
+            configuration.setEncoding(data);
+        }
+    }
+
     private void createConfig() {
         configuration = new ClassGenerationAction();
         loaderContext.addDataMapListener(dataMap -> {
-            CgenConfigHandler.this.metaData.add(dataMap, configuration);
             configuration.setDataMap(dataMap);
+            configuration.prepareArtifacts();
+            CgenConfigHandler.this.metaData.add(dataMap, configuration);
         });
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
index 507919d..0b12dcd 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
@@ -19,94 +19,12 @@
 
 package org.apache.cayenne.modeler;
 
-import java.awt.AWTEvent;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Font;
-import java.awt.Toolkit;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.util.List;
-import java.util.Vector;
-
-import javax.swing.Action;
-import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JPanel;
-import javax.swing.JSplitPane;
-import javax.swing.JTextField;
-import javax.swing.JToolBar;
-
-import org.apache.cayenne.modeler.action.AboutAction;
-import org.apache.cayenne.modeler.action.ActionManager;
-import org.apache.cayenne.modeler.action.ConfigurePreferencesAction;
-import org.apache.cayenne.modeler.action.CopyAction;
-import org.apache.cayenne.modeler.action.CreateDataMapAction;
-import org.apache.cayenne.modeler.action.CreateDbEntityAction;
-import org.apache.cayenne.modeler.action.CreateEmbeddableAction;
-import org.apache.cayenne.modeler.action.CreateNodeAction;
-import org.apache.cayenne.modeler.action.CreateObjEntityAction;
-import org.apache.cayenne.modeler.action.CreateProcedureAction;
-import org.apache.cayenne.modeler.action.CreateQueryAction;
-import org.apache.cayenne.modeler.action.CutAction;
-import org.apache.cayenne.modeler.action.DbEntitySyncAction;
-import org.apache.cayenne.modeler.action.DocumentationAction;
-import org.apache.cayenne.modeler.action.ExitAction;
-import org.apache.cayenne.modeler.action.FindAction;
-import org.apache.cayenne.modeler.action.GenerateCodeAction;
-import org.apache.cayenne.modeler.action.GenerateDBAction;
-import org.apache.cayenne.modeler.action.ReverseEngineeringAction;
-import org.apache.cayenne.modeler.action.ImportDataMapAction;
-import org.apache.cayenne.modeler.action.ImportEOModelAction;
-import org.apache.cayenne.modeler.action.InferRelationshipsAction;
-import org.apache.cayenne.modeler.action.MigrateAction;
-import org.apache.cayenne.modeler.action.NavigateBackwardAction;
-import org.apache.cayenne.modeler.action.NavigateForwardAction;
-import org.apache.cayenne.modeler.action.NewProjectAction;
-import org.apache.cayenne.modeler.action.ObjEntitySyncAction;
-import org.apache.cayenne.modeler.action.OpenProjectAction;
-import org.apache.cayenne.modeler.action.PasteAction;
-import org.apache.cayenne.modeler.action.ProjectAction;
-import org.apache.cayenne.modeler.action.RedoAction;
-import org.apache.cayenne.modeler.action.RemoveAction;
-import org.apache.cayenne.modeler.action.RevertAction;
-import org.apache.cayenne.modeler.action.SaveAction;
-import org.apache.cayenne.modeler.action.SaveAsAction;
-import org.apache.cayenne.modeler.action.ShowLogConsoleAction;
-import org.apache.cayenne.modeler.action.UndoAction;
-import org.apache.cayenne.modeler.action.ValidateAction;
+import org.apache.cayenne.modeler.action.*;
 import org.apache.cayenne.modeler.action.dbimport.ReverseEngineeringToolMenuAction;
 import org.apache.cayenne.modeler.dialog.LogConsole;
 import org.apache.cayenne.modeler.dialog.welcome.WelcomeScreen;
 import org.apache.cayenne.modeler.editor.EditorView;
-import org.apache.cayenne.modeler.event.DataMapDisplayEvent;
-import org.apache.cayenne.modeler.event.DataMapDisplayListener;
-import org.apache.cayenne.modeler.event.DataNodeDisplayEvent;
-import org.apache.cayenne.modeler.event.DataNodeDisplayListener;
-import org.apache.cayenne.modeler.event.DbEntityDisplayListener;
-import org.apache.cayenne.modeler.event.EmbeddableDisplayEvent;
-import org.apache.cayenne.modeler.event.EmbeddableDisplayListener;
-import org.apache.cayenne.modeler.event.EntityDisplayEvent;
-import org.apache.cayenne.modeler.event.MultipleObjectsDisplayEvent;
-import org.apache.cayenne.modeler.event.MultipleObjectsDisplayListener;
-import org.apache.cayenne.modeler.event.ObjEntityDisplayListener;
-import org.apache.cayenne.modeler.event.ProcedureDisplayEvent;
-import org.apache.cayenne.modeler.event.ProcedureDisplayListener;
-import org.apache.cayenne.modeler.event.QueryDisplayEvent;
-import org.apache.cayenne.modeler.event.QueryDisplayListener;
-import org.apache.cayenne.modeler.event.RecentFileListListener;
+import org.apache.cayenne.modeler.event.*;
 import org.apache.cayenne.modeler.pref.ComponentGeometry;
 import org.apache.cayenne.modeler.util.ModelerUtil;
 import org.apache.cayenne.modeler.util.RecentFileMenu;
@@ -114,6 +32,15 @@ import org.apache.cayenne.swing.components.MainToolBar;
 import org.apache.cayenne.swing.components.TopBorder;
 import org.slf4j.LoggerFactory;
 
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.util.List;
+import java.util.Vector;
+
 /**
  * Main frame of CayenneModeler. Responsibilities include coordination of
  * enabling/disabling of menu and toolbar.
@@ -237,6 +164,7 @@ public class CayenneModelerFrame extends JFrame implements DataNodeDisplayListen
         toolMenu.add(getAction(InferRelationshipsAction.class).buildMenu());
         toolMenu.add(getAction(ImportEOModelAction.class).buildMenu());
         toolMenu.addSeparator();
+        toolMenu.add(getAction(CgenAction.class).buildMenu());
         toolMenu.add(getAction(GenerateCodeAction.class).buildMenu());
         toolMenu.add(getAction(GenerateDBAction.class).buildMenu());
         toolMenu.add(getAction(MigrateAction.class).buildMenu());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CodeTemplateManager.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CodeTemplateManager.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CodeTemplateManager.java
index 1d51503..b56851a 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CodeTemplateManager.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CodeTemplateManager.java
@@ -43,6 +43,10 @@ public class CodeTemplateManager {
 	static final String STANDARD_CLIENT_SUPERCLASS = "Standard Client Superclass";
 	static final String STANDARD_CLIENT_SUBCLASS = "Standard Client Subclass";
 
+	public static final String STANDART_EMBEDDABLE_SUPERCLASS = "Standart Embeddable Superclass";
+	public static final String STANDART_EMBEDDABLE_SUBCLASS = "Standart Embeddable Subclass";
+	public static final String SINGLE_EMBEDDABLE_CLASS = "Single Embeddable class";
+
 	public static final String NODE_NAME = "codeTemplateManager";
 
 	protected List<String> standardSubclassTemplates;
@@ -50,6 +54,9 @@ public class CodeTemplateManager {
 	protected Map<String, String> customTemplates;
 	protected Map<String, String> standardTemplates;
 
+	protected List<String> standartEmbeddableTemplates;
+	protected List<String> standartEmbeddableSuperclassTemplates;
+
 	private Map<String, String> reverseStandartTemplates;
 
 	private static Logger logger = LoggerFactory.getLogger(CodeTemplateManager.class);
@@ -69,6 +76,13 @@ public class CodeTemplateManager {
 		standardSubclassTemplates.add(STANDARD_CLIENT_SUBCLASS);
 		standardSubclassTemplates.add(SINGLE_SERVER_CLASS);
 
+		standartEmbeddableTemplates = new ArrayList<>();
+		standartEmbeddableTemplates.add(SINGLE_EMBEDDABLE_CLASS);
+		standartEmbeddableTemplates.add(STANDART_EMBEDDABLE_SUBCLASS);
+
+		standartEmbeddableSuperclassTemplates = new ArrayList<>();
+		standartEmbeddableSuperclassTemplates.add(STANDART_EMBEDDABLE_SUPERCLASS);
+
 		updateCustomTemplates(getTemplatePreferences(application));
 
 		standardTemplates = new HashMap<>();
@@ -78,6 +92,10 @@ public class CodeTemplateManager {
 		standardTemplates.put(STANDARD_CLIENT_SUBCLASS, ClientClassGenerationAction.SUBCLASS_TEMPLATE);
 		standardTemplates.put(SINGLE_SERVER_CLASS, ClassGenerationAction.SINGLE_CLASS_TEMPLATE);
 
+		standardTemplates.put(STANDART_EMBEDDABLE_SUPERCLASS, ClassGenerationAction.EMBEDDABLE_SUPERCLASS_TEMPLATE);
+		standardTemplates.put(STANDART_EMBEDDABLE_SUBCLASS, ClassGenerationAction.EMBEDDABLE_SUBCLASS_TEMPLATE);
+		standardTemplates.put(SINGLE_EMBEDDABLE_CLASS, ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE);
+
 		reverseStandartTemplates = new HashMap<>();
 		reverseStandartTemplates.put(ClassGenerationAction.SUBCLASS_TEMPLATE, STANDARD_SERVER_SUBCLASS);
 		reverseStandartTemplates.put(ClientClassGenerationAction.SUBCLASS_TEMPLATE, STANDARD_CLIENT_SUBCLASS);
@@ -85,6 +103,9 @@ public class CodeTemplateManager {
 		reverseStandartTemplates.put(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, STANDARD_CLIENT_SUPERCLASS);
 		reverseStandartTemplates.put(ClassGenerationAction.SUPERCLASS_TEMPLATE, STANDARD_SERVER_SUPERCLASS);
 
+		reverseStandartTemplates.put(ClassGenerationAction.EMBEDDABLE_SUPERCLASS_TEMPLATE, STANDART_EMBEDDABLE_SUPERCLASS);
+		reverseStandartTemplates.put(ClassGenerationAction.EMBEDDABLE_SUBCLASS_TEMPLATE, STANDART_EMBEDDABLE_SUBCLASS);
+		reverseStandartTemplates.put(ClassGenerationAction.EMBEDDABLE_SINGLE_CLASS_TEMPLATE, SINGLE_EMBEDDABLE_CLASS);
 	}
 
 	/**
@@ -137,4 +158,12 @@ public class CodeTemplateManager {
 	public List<String> getStandardSuperclassTemplates() {
 		return standardSuperclassTemplates;
 	}
+
+	public List<String> getStandartEmbeddableTemplates() {
+		return standartEmbeddableTemplates;
+	}
+
+	public List<String> getStandartEmbeddableSuperclassTemplates() {
+		return standartEmbeddableSuperclassTemplates;
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CgenAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CgenAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CgenAction.java
new file mode 100644
index 0000000..2cd3012
--- /dev/null
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CgenAction.java
@@ -0,0 +1,53 @@
+package org.apache.cayenne.modeler.action;
+
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.configuration.xml.DataChannelMetaData;
+import org.apache.cayenne.gen.ClassGenerationAction;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.util.CayenneAction;
+import org.apache.cayenne.project.Project;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.util.Collection;
+
+public class CgenAction extends CayenneAction{
+
+    private static Logger logObj = LoggerFactory.getLogger(CgenAction.class);
+
+    public CgenAction(Application application) {
+        super(getActionName(), application);
+    }
+
+    public static String getActionName(){
+        return "Generate All Classes";
+    }
+
+    @Override
+    public void performAction(ActionEvent e) {
+        Collection<DataMap> dataMaps;
+        DataChannelMetaData metaData = getApplication().getMetaData();
+
+        try {
+            Project project = getProjectController().getProject();
+            dataMaps = ((DataChannelDescriptor) project.getRootNode()).getDataMaps();
+            for (DataMap dataMap : dataMaps) {
+                ClassGenerationAction classGenerationAction = metaData.get(dataMap, ClassGenerationAction.class);
+                if (classGenerationAction != null) {
+                    classGenerationAction.execute();
+                }
+            }
+            JOptionPane.showMessageDialog(
+                    this.getApplication().getFrameController().getView(),
+                    "Class generation finished");
+        } catch (Exception ex) {
+            logObj.error("Error generating classes", e);
+            JOptionPane.showMessageDialog(
+                    this.getApplication().getFrameController().getView(),
+                    "Error generating classes - " + ex.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
index c476fff..d2ad35f 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
@@ -167,6 +167,8 @@ public class DefaultActionManager implements ActionManager {
 
         registerAction(new LinkDataMapAction(application));
         registerAction(new LinkDataMapsAction(application));
+
+        registerAction(new CgenAction((application)));
     }
 
     private void initActions() {
@@ -195,7 +197,8 @@ public class DefaultActionManager implements ActionManager {
                 GenerateCodeAction.class.getName(),
                 GenerateDBAction.class.getName(),
                 PasteAction.class.getName(),
-                ReverseEngineeringToolMenuAction.class.getName()));
+                ReverseEngineeringToolMenuAction.class.getName(),
+                CgenAction.class.getName()));
 
         DATA_NODE_ACTIONS = new HashSet<>(DOMAIN_ACTIONS);
         DATA_NODE_ACTIONS.addAll(Arrays.asList(

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/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 3a63297..586416e 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
@@ -122,6 +122,6 @@ public class ClassesTabController extends CayenneController {
 
     private void updateEntities(){
         getParentController().updateEntities();
-        getParentController().getProjectController().setDirty(true);
+//        getParentController().getProjectController().setDirty(true);
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/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 45d3e51..ac5e152 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
@@ -59,6 +59,7 @@ public class CodeGeneratorController extends CodeGeneratorControllerBase
{
             super.startup(e.getDataMap());
             classesSelector.startup();
             generatorSelector.startup(e.getDataMap());
+
             GeneratorController modeController = generatorSelector.getGeneratorController();
             ClassGenerationAction classGenerationAction = modeController.createGenerator();
             ((CustomModeController)modeController).initForm(classGenerationAction);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/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 3d07c60..134381b 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
@@ -20,10 +20,8 @@
 package org.apache.cayenne.modeler.editor.cgen;
 
 import org.apache.cayenne.gen.ClassGenerationAction;
-import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.modeler.CodeTemplateManager;
 import org.apache.cayenne.modeler.dialog.pref.PreferenceDialog;
-import org.apache.cayenne.modeler.pref.DataMapDefaults;
 import org.apache.cayenne.swing.BindingBuilder;
 import org.apache.cayenne.swing.ObjectBinding;
 
@@ -73,10 +71,6 @@ public class CustomModeController extends GeneratorController {
 
     private ClassGenerationAction classGenerationAction;
 
-    public CustomPreferencesUpdater getCustomPreferencesUpdater() {
-        return preferencesUpdater;
-    }
-
     public CustomModeController(CodeGeneratorControllerBase parent) {
         super(parent);
         this.view = new CustomModePanel();
@@ -92,27 +86,23 @@ public class CustomModeController extends GeneratorController {
         updateTemplates();
     }
 
-    public void startup(DataMap dataMap) {
-        createDefaults();
-    }
-
     protected void createDefaults() {
-        TreeMap<DataMap, DataMapDefaults> map = new TreeMap<>();
-        DataMap dataMap = getParentController().getDataMap();
-        DataMapDefaults preferences;
-        preferences = getApplication().getFrameController().getProjectController()
-                .getDataMapPreferences(this.getClass().getName().replace(".", "/"), dataMap);
-        preferences.setSuperclassPackage("");
-        preferences.updateSuperclassPackage(dataMap, false);
-
-        map.put(dataMap, preferences);
-
-        if (getOutputPath() == null) {
-            setOutputPath(preferences.getOutputPath());
-        }
-
-        setMapPreferences(map);
-        preferencesUpdater = new CustomPreferencesUpdater(map);
+//        TreeMap<DataMap, DataMapDefaults> map = new TreeMap<>();
+//        DataMap dataMap = getParentController().getDataMap();
+//        DataMapDefaults preferences;
+//        preferences = getApplication().getFrameController().getProjectController()
+//                .getDataMapPreferences(this.getClass().getName().replace(".", "/"), dataMap);
+//        preferences.setSuperclassPackage("");
+//        preferences.updateSuperclassPackage(dataMap, false);
+//
+//        map.put(dataMap, preferences);
+//
+//        if (getOutputPath() == null) {
+//            setOutputPath(preferences.getOutputPath());
+//        }
+//
+//        setMapPreferences(map);
+//        preferencesUpdater = new CustomPreferencesUpdater(map);
     }
 
     protected void updateTemplates() {
@@ -132,8 +122,19 @@ public class CustomModeController extends GeneratorController {
         Collections.sort(subTemplates);
         subTemplates.addAll(customTemplates);
 
+        List<String> embeddableTemplates = new ArrayList<>(templateManager.getStandartEmbeddableTemplates());
+        Collections.sort(embeddableTemplates);
+        embeddableTemplates.addAll(customTemplates);
+
+        List<String> embeddableSuperTemplates = new ArrayList<>(templateManager.getStandartEmbeddableSuperclassTemplates());
+        Collections.sort(embeddableSuperTemplates);
+        embeddableSuperTemplates.addAll(customTemplates);
+
         this.view.getSubclassTemplate().setModel(new DefaultComboBoxModel(subTemplates.toArray()));
         this.view.getSuperclassTemplate().setModel(new DefaultComboBoxModel(superTemplates.toArray()));
+
+        this.view.getEmbeddableTemplate().setModel(new DefaultComboBoxModel(embeddableTemplates.toArray()));
+        this.view.getEmbeddableSuperTemplate().setModel(new DefaultComboBoxModel(embeddableSuperTemplates.toArray()));
     }
 
     public Component getView() {
@@ -196,6 +197,16 @@ public class CustomModeController extends GeneratorController {
             getParentController().getProjectController().setDirty(true);
         });
 
+        view.getEmbeddableTemplate().addActionListener(val -> {
+            classGenerationAction.setEmbeddableTemplate(getApplication().getCodeTemplateManager().getTemplatePath(String.valueOf(view.getEmbeddableTemplate().getSelectedItem())));
+            getParentController().getProjectController().setDirty(true);
+        });
+
+        view.getEmbeddableSuperTemplate().addActionListener(val -> {
+            classGenerationAction.setEmbeddableSuperTemplate(getApplication().getCodeTemplateManager().getTemplatePath(String.valueOf(view.getEmbeddableSuperTemplate().getSelectedItem())));
+            getParentController().getProjectController().setDirty(true);
+        });
+
         view.getGenerationMode().addActionListener(val -> {
             classGenerationAction.setArtifactsGenerationMode(modesByLabel.get(view.getGenerationMode().getSelectedItem()));
             getParentController().getProjectController().setDirty(true);
@@ -228,6 +239,20 @@ public class CustomModeController extends GeneratorController {
             @Override
             public void changedUpdate(DocumentEvent e) {}
         });
+
+        view.getEncoding().getDocument().addDocumentListener(new DocumentListener() {
+            @Override
+            public void insertUpdate(DocumentEvent e) {
+                classGenerationAction.setEncoding(view.getEncoding().getText());
+                getParentController().getProjectController().setDirty(true);
+            }
+
+            @Override
+            public void removeUpdate(DocumentEvent e) {}
+
+            @Override
+            public void changedUpdate(DocumentEvent e) {}
+        });
     }
 
     public void initForm(ClassGenerationAction classGenerationAction){
@@ -243,5 +268,10 @@ public class CustomModeController extends GeneratorController {
         view.setOverwrite(classGenerationAction.isOverwrite());
         view.setCreatePropertyNames(classGenerationAction.isCreatePropertyNames());
         view.setSuperclassPackage(classGenerationAction.getSuperPkg());
+        view.setEncoding(classGenerationAction.getEncoding());
+        view.setEmbeddableTemplate(getApplication().getCodeTemplateManager().getNameByPath(classGenerationAction.getEmbeddableTemplate()));
+        view.setEmbeddableSuperTemplate(getApplication().getCodeTemplateManager().getNameByPath(classGenerationAction.getEmbeddableSuperTemplate()));
+
+//        getParentController().getProjectController().setDirty(false);
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/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 720c521..e79ef7a 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
@@ -28,19 +28,16 @@ import java.awt.*;
 
 public class CustomModePanel extends GeneratorControllerPanel {
 
-    protected JComboBox generationMode;
-    protected JComboBox subclassTemplate;
-    protected JComboBox superclassTemplate;
+    private JComboBox generationMode;
+    private JComboBox subclassTemplate;
+    private JComboBox superclassTemplate;
     protected JCheckBox pairs;
-    protected JCheckBox overwrite;
-    protected JCheckBox usePackagePath;
-    protected JTextField outputPattern;
-    protected JCheckBox createPropertyNames;
+    private JCheckBox overwrite;
+    private JCheckBox usePackagePath;
+    private JTextField outputPattern;
+    private JCheckBox createPropertyNames;
     private JTextField superclassPackage;
 
-    private JTextField additionalMaps;
-    private JButton selectAdditionalMaps;
-    private JCheckBox client;
     private JTextField encoding;
     private JComboBox embeddableTemplate;
     private JComboBox embeddableSuperTemplate;
@@ -64,9 +61,6 @@ public class CustomModePanel extends GeneratorControllerPanel {
         this.manageTemplatesLink.setFont(manageTemplatesLink.getFont().deriveFont(10f));
         this.superclassPackage = new JTextField();
 
-        this.additionalMaps = new JTextField();
-        this.selectAdditionalMaps = new JButton("Select");
-        this.client = new JCheckBox();
         this.encoding = new JTextField();
         this.embeddableTemplate = new JComboBox();
         this.embeddableSuperTemplate = new JComboBox();
@@ -79,7 +73,6 @@ public class CustomModePanel extends GeneratorControllerPanel {
         });
 
         // assemble
-
         FormLayout layout = new FormLayout(
                 "right:77dlu, 3dlu, fill:200:grow, 6dlu, fill:50dlu, 3dlu", "");
         builder = new DefaultFormBuilder(layout);
@@ -88,9 +81,6 @@ public class CustomModePanel extends GeneratorControllerPanel {
         builder.append("Output Directory:", outputFolder, selectOutputFolder);
         builder.nextLine();
 
-        builder.append("Additional DataMaps", additionalMaps, selectAdditionalMaps);
-        builder.nextLine();
-
         builder.append("Generation Mode:", generationMode);
         builder.nextLine();
 
@@ -124,9 +114,6 @@ public class CustomModePanel extends GeneratorControllerPanel {
         builder.append("Create Property Names:", createPropertyNames);
         builder.nextLine();
 
-        builder.append("Client", client);
-        builder.nextLine();
-
         builder.append(dataMapName);
         builder.nextLine();
 
@@ -150,9 +137,11 @@ public class CustomModePanel extends GeneratorControllerPanel {
         return manageTemplatesLink;
     }
 
-    public JComboBox getSubclassTemplate() {
-        return subclassTemplate;
-    }
+    public JComboBox getSubclassTemplate() { return subclassTemplate; }
+
+    public JComboBox getEmbeddableTemplate() { return embeddableTemplate; }
+
+    public JComboBox getEmbeddableSuperTemplate() { return embeddableSuperTemplate; }
 
     public JComboBox getSuperclassTemplate() {
         return superclassTemplate;
@@ -178,11 +167,12 @@ public class CustomModePanel extends GeneratorControllerPanel {
         return createPropertyNames;
     }
 
-
     public JTextField getSuperclassPackage() {
         return superclassPackage;
     }
 
+    public JTextField getEncoding() { return encoding; }
+
     public void setDataMapName(String mapName){
         dataMapName.setText(mapName);
     }
@@ -222,4 +212,10 @@ public class CustomModePanel extends GeneratorControllerPanel {
     public void setGenerationMode(String mode) {
         generationMode.setSelectedItem(mode);
     }
+
+    public void setEncoding(String encoding) { this.encoding.setText(encoding); }
+
+    public void setEmbeddableTemplate(String template) { embeddableTemplate.setSelectedItem(template);
}
+
+    public void setEmbeddableSuperTemplate(String template) { embeddableSuperTemplate.setSelectedItem(template);
}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/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 a1ccf8f..7a62efc 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
@@ -111,9 +111,10 @@ public abstract class GeneratorController extends CayenneController {
 
         ClassGenerationAction generator = getParentController().projectController.getApplication().getMetaData().get(map,
ClassGenerationAction.class);
         if(generator != null){
-            generator.prepareArtifacts();
             getParentController().addToSelectedEntities(generator.getEntities());
             getParentController().addToSelectedEmbeddables(generator.getEmbeddables());
+            generator.getEntities().clear();
+            generator.getEmbeddables().clear();
             return generator;
         }
 
@@ -489,24 +490,8 @@ public abstract class GeneratorController extends CayenneController {
     }
 
     private void initOutputFolder() {
-        String path;
-        if (getOutputPath() == null) {
-            if (System.getProperty("cayenne.cgen.destdir") != null) {
-                setOutputPath(System.getProperty("cayenne.cgen.destdir"));
-            } else {
-                // init default directory..
-                FSPath lastPath = Application.getInstance().getFrameController().getLastDirectory();
-
-                path = checkDefaultMavenResourceDir(lastPath, "test");
-
-                if (path != null || (path = checkDefaultMavenResourceDir(lastPath, "main"))
!= null) {
-                    setOutputPath(path);
-                } else {
-                    File lastDir = (lastPath != null) ? lastPath.getExistingDirectory(false)
: null;
-                    setOutputPath(lastDir != null ? lastDir.getAbsolutePath() : null);
-                }
-            }
-        }
+        String pathString = System.getProperty("user.home");
+        setOutputPath(pathString);
     }
 
     private String checkDefaultMavenResourceDir(FSPath lastPath, String dirType) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b85a0900/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 1e338eb..fc3f567 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
@@ -44,7 +44,7 @@ public class GeneratorTabController extends CayenneController {
     }
 
     public void startup(DataMap dataMap){
-        customModeController.startup(dataMap);
+//        customModeController.startup(dataMap);
     }
 
     public Component getView() {


Mime
View raw message