cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [cayenne] branch master updated: Cleanup
Date Mon, 03 Feb 2020 14:54:25 GMT
This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new 5586c3f  Cleanup
5586c3f is described below

commit 5586c3fe358a610d9dd313ad84b97b2a2afc61dc
Author: Nikita Timofeev <stariy95@gmail.com>
AuthorDate: Mon Feb 3 17:54:14 2020 +0300

    Cleanup
---
 .../modeler/editor/cgen/ClientModeController.java      |  6 +++++-
 .../modeler/editor/cgen/CodeGeneratorController.java   | 12 +++++++-----
 .../editor/cgen/CodeGeneratorControllerBase.java       |  4 ++--
 .../modeler/editor/cgen/CustomModeController.java      | 13 ++++++-------
 .../modeler/editor/cgen/GeneratorController.java       | 18 +++++++++---------
 .../modeler/editor/cgen/StandardModeController.java    |  7 ++-----
 6 files changed, 31 insertions(+), 29 deletions(-)

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 330359e..02f28a2 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
@@ -31,8 +31,12 @@ public class ClientModeController extends StandardModeController {
         super(parent);
     }
 
-    protected GeneratorControllerPanel createView() {
+    protected void createView() {
         this.view = new StandardModePanel(getParentController());
+    }
+
+    @Override
+    public StandardModePanel getView() {
         return view;
     }
 
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 03caae6..7ee45ae 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
@@ -78,11 +78,13 @@ public class CodeGeneratorController extends CodeGeneratorControllerBase
impleme
         super.startup(dataMap);
         classesSelectedAction();
         CgenConfiguration cgenConfiguration = createConfiguration();
-        GeneratorController modeController = prevGeneratorController.get(dataMap) != null
?
-                prevGeneratorController.get(dataMap) : isDefaultConfig(cgenConfiguration)
?
-                cgenConfiguration.isClient() ? generatorSelector.getClientGeneratorController()
:
-                        generatorSelector.getStandartController() :
-                generatorSelector.getCustomModeController();
+        GeneratorController modeController = prevGeneratorController.get(dataMap) != null
+                        ? prevGeneratorController.get(dataMap)
+                        : isDefaultConfig(cgenConfiguration)
+                            ? cgenConfiguration.isClient()
+                                ? generatorSelector.getClientGeneratorController()
+                                : generatorSelector.getStandartController()
+                            : generatorSelector.getCustomModeController();
 
         prevGeneratorController.put(dataMap, modeController);
         generatorSelector.setSelectedController(modeController);
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 7d137a8..375960a 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
@@ -160,8 +160,8 @@ public abstract class CodeGeneratorControllerBase extends CayenneController
{
                 .stream()
                 .map(Embeddable::getClassName)
                 .collect(Collectors.toList()));
-       getApplication().getMetaData().add(map, cgenConfiguration);
-       projectController.setDirty(true);
+        getApplication().getMetaData().add(map, cgenConfiguration);
+        projectController.setDirty(true);
 
         return cgenConfiguration;
     }
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 46f8f33..760f2eb 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
@@ -19,13 +19,13 @@
 
 package org.apache.cayenne.modeler.editor.cgen;
 
-import javax.swing.*;
-import java.awt.*;
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import javax.swing.DefaultComboBoxModel;
+
 import org.apache.cayenne.gen.CgenConfiguration;
 import org.apache.cayenne.gen.ClassGenerationAction;
 import org.apache.cayenne.gen.ClientClassGenerationAction;
@@ -49,8 +49,11 @@ public class CustomModeController extends GeneratorController {
     }
 
     @Override
-    protected GeneratorControllerPanel createView() {
+    protected void createView() {
         this.view = new CustomModePanel(getApplication().getFrameController().getProjectController(),
getParentController());
+    }
+
+    public CustomModePanel getView() {
         return view;
     }
 
@@ -83,10 +86,6 @@ public class CustomModeController extends GeneratorController {
         this.view.getSuperclassTemplate().getComboBox().setModel(new DefaultComboBoxModel<>(superTemplates.toArray(new
String[0])));
     }
 
-    public Component getView() {
-        return view;
-    }
-
     public void missTemplateDialog(CgenConfiguration cgenConfiguration, String template,
String superTemplate) {
         new TemplateDialog(this, cgenConfiguration, template, superTemplate).startupAction();
         updateComboBoxes();
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 ec782f3..1c08e54 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
@@ -19,7 +19,6 @@
 
 package org.apache.cayenne.modeler.editor.cgen;
 
-import org.apache.cayenne.gen.ArtifactsGenerationMode;
 import org.apache.cayenne.gen.CgenConfiguration;
 import org.apache.cayenne.map.Embeddable;
 import org.apache.cayenne.map.EmbeddableAttribute;
@@ -50,7 +49,6 @@ import java.util.function.Predicate;
  */
 public abstract class GeneratorController extends CayenneController {
 
-    protected String mode = ArtifactsGenerationMode.ENTITY.getLabel();
     protected CgenConfiguration cgenConfiguration;
 
     public GeneratorController(CodeGeneratorControllerBase parent) {
@@ -61,7 +59,7 @@ public abstract class GeneratorController extends CayenneController {
     }
 
     protected void initBindings(BindingBuilder bindingBuilder) {
-        JButton outputSelect = ((GeneratorControllerPanel) getView()).getSelectOutputFolder();
+        JButton outputSelect = getView().getSelectOutputFolder();
         bindingBuilder.bindToAction(outputSelect, "selectOutputFolderAction()");
     }
 
@@ -69,11 +67,14 @@ public abstract class GeneratorController extends CayenneController {
         return (CodeGeneratorControllerBase) getParent();
     }
 
-    protected abstract GeneratorControllerPanel createView();
+    protected abstract void createView();
+
+    @Override
+    public abstract GeneratorControllerPanel getView();
 
     protected void initForm(CgenConfiguration cgenConfiguration) {
         this.cgenConfiguration = cgenConfiguration;
-        ((GeneratorControllerPanel)getView()).getOutputFolder().setText(cgenConfiguration.buildPath().toString());
+        getView().getOutputFolder().setText(cgenConfiguration.buildPath().toString());
         if(cgenConfiguration.getArtifactsGenerationMode().equalsIgnoreCase("all")) {
             ((CodeGeneratorControllerBase) parent).setCurrentClass(cgenConfiguration.getDataMap());
             ((CodeGeneratorControllerBase) parent).setSelected(true);
@@ -296,8 +297,7 @@ public abstract class GeneratorController extends CayenneController {
      */
     public void selectOutputFolderAction() {
 
-        TextAdapter outputFolder = ((GeneratorControllerPanel) getView()).getOutputFolder();
-
+        TextAdapter outputFolder = getView().getOutputFolder();
         String currentDir = outputFolder.getComponent().getText();
 
         JFileChooser chooser = new JFileChooser();
@@ -318,8 +318,8 @@ public abstract class GeneratorController extends CayenneController {
 
             // update model
             String path = selected.getAbsolutePath();
-            ((GeneratorControllerPanel) getView()).getOutputFolder().setText(path);
-            ((GeneratorControllerPanel) getView()).getOutputFolder().updateModel();
+            getView().getOutputFolder().setText(path);
+            getView().getOutputFolder().updateModel();
         }
     }
 }
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 1493d29..a948b6f 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
@@ -19,8 +19,6 @@
 
 package org.apache.cayenne.modeler.editor.cgen;
 
-import java.awt.*;
-
 import org.apache.cayenne.gen.CgenConfiguration;
 import org.apache.cayenne.gen.ClassGenerationAction;
 import org.apache.cayenne.modeler.pref.DataMapDefaults;
@@ -37,12 +35,11 @@ public class StandardModeController extends GeneratorController {
         super(parent);
     }
 
-    protected GeneratorControllerPanel createView() {
+    protected void createView() {
         this.view = new StandardModePanel(getParentController());
-        return view;
     }
 
-    public Component getView() {
+    public StandardModePanel getView() {
         return view;
     }
 


Mime
View raw message