cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abulat...@apache.org
Subject [cayenne] branch master updated: CAY-2531 Importing same schema after Import Revert clears all entities in datamap
Date Wed, 06 Mar 2019 08:37:59 GMT
This is an automated email from the ASF dual-hosted git repository.

abulatski 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 40a2298  CAY-2531 Importing same schema after Import Revert clears all entities in
datamap
40a2298 is described below

commit 40a2298356b1552f49d9fe6dcafc6bfc46cb86cd
Author: Arseni Bulatski <ancarseni@gmail.com>
AuthorDate: Tue Feb 12 12:35:32 2019 +0300

    CAY-2531 Importing same schema after Import Revert clears all entities in datamap
---
 RELEASE-NOTES.txt                                  |  1 +
 .../modeler/dialog/db/load/DbLoadResultDialog.java | 18 ++++++--
 .../dialog/db/load/ModelerDbImportAction.java      | 51 +++++++++++-----------
 .../cayenne/modeler/editor/DbImportController.java |  9 ++--
 4 files changed, 46 insertions(+), 33 deletions(-)

diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 796ddb2..5a63a04 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -30,6 +30,7 @@ Bug Fixes:
 CAY-2332 Property API: unable to use eq() and in() methods for toMany relationships
 CAY-2509 Result of resolving lazily faulted relationships can be out-of-date
 CAY-2530 DB Import and Class Generation from Project is performed for removed datamaps
+CAY-2531 Importing same schema after Import Revert clears all entities in datamap
 CAY-2544 Possible name clash of ivar and property name in generated class
 CAY-2547 CayenneDataObject serialization issue
 
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoadResultDialog.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoadResultDialog.java
index 898b9b1..33ae7ea 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoadResultDialog.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoadResultDialog.java
@@ -19,10 +19,6 @@
 
 package org.apache.cayenne.modeler.dialog.db.load;
 
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.FormLayout;
-import org.apache.cayenne.map.DataMap;
-
 import javax.swing.BoxLayout;
 import javax.swing.JButton;
 import javax.swing.JDialog;
@@ -36,9 +32,14 @@ import javax.swing.table.DefaultTableModel;
 import java.awt.BorderLayout;
 import java.awt.Dimension;
 import java.awt.FlowLayout;
+import java.awt.event.ActionListener;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.FormLayout;
+import org.apache.cayenne.map.DataMap;
+
 /**
  * @since 4.1
  */
@@ -124,6 +125,15 @@ public class DbLoadResultDialog extends JDialog {
         return tokensTableModel;
     }
 
+    public void removeListenersFromButtons() {
+        for(ActionListener actionListener : okButton.getActionListeners()) {
+            okButton.removeActionListener(actionListener);
+        }
+        for(ActionListener actionListener : revertButton.getActionListeners()) {
+            revertButton.removeActionListener(actionListener);
+        }
+    }
+
     public synchronized void addRowToOutput(String output, DataMap dataMap) {
         prepareTable(dataMap).addRow(new Object[]{output});
     }
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/ModelerDbImportAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/ModelerDbImportAction.java
index 8be5309..476f4d0 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/ModelerDbImportAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/ModelerDbImportAction.java
@@ -19,6 +19,14 @@
 
 package org.apache.cayenne.modeler.dialog.db.load;
 
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.configuration.DataChannelDescriptorLoader;
 import org.apache.cayenne.configuration.DataMapLoader;
@@ -36,14 +44,6 @@ import org.apache.cayenne.modeler.editor.DbImportController;
 import org.apache.cayenne.project.ProjectSaver;
 import org.slf4j.Logger;
 
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-
 public class ModelerDbImportAction extends DefaultDbImportAction {
 
     private static final String DIALOG_TITLE = "Reverse Engineering Result";
@@ -85,23 +85,6 @@ public class ModelerDbImportAction extends DefaultDbImportAction {
     @Override
     protected Collection<MergerToken> log(List<MergerToken> tokens) {
         resultDialog = dbImportController.createDialog();
-        logger.info("");
-        if (tokens.isEmpty()) {
-            logger.info("Detected changes: No changes to import.");
-            resultDialog.addMsg(targetMap);
-            isNothingChanged = true;
-            return tokens;
-        }
-
-        logger.info("Detected changes: ");
-        for (MergerToken token : tokens) {
-            String logString = String.format("    %-20s %s", token.getTokenName(), token.getTokenValue());
-            logger.info(logString);
-            resultDialog.addRowToOutput(logString, targetMap);
-            isNothingChanged = false;
-        }
-
-        logger.info("");
         resultDialog.getOkButton().addActionListener(e -> {
             try {
                 if(resultDialog.getTableForMap().containsKey(targetMap)) {
@@ -124,6 +107,24 @@ public class ModelerDbImportAction extends DefaultDbImportAction {
             }
         });
 
+        logger.info("");
+        if (tokens.isEmpty()) {
+            logger.info("Detected changes: No changes to import.");
+            resultDialog.addMsg(targetMap);
+            isNothingChanged = true;
+            return tokens;
+        }
+
+        logger.info("Detected changes: ");
+        for (MergerToken token : tokens) {
+            String logString = String.format("    %-20s %s", token.getTokenName(), token.getTokenValue());
+            logger.info(logString);
+            resultDialog.addRowToOutput(logString, targetMap);
+            isNothingChanged = false;
+        }
+
+        logger.info("");
+
         return tokens;
     }
 
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DbImportController.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DbImportController.java
index 932c739..201293e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DbImportController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DbImportController.java
@@ -18,15 +18,15 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.editor;
 
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableModel;
+import java.util.concurrent.ConcurrentMap;
+
 import org.apache.cayenne.configuration.event.DataMapEvent;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.dialog.db.load.DbLoadResultDialog;
 
-import javax.swing.JTable;
-import javax.swing.table.DefaultTableModel;
-import java.util.concurrent.ConcurrentMap;
-
 /**
  * @since 4.1
  */
@@ -74,6 +74,7 @@ public class DbImportController {
         }
 
         dbLoadResultDialog.getTableForMap().clear();
+        dbLoadResultDialog.removeListenersFromButtons();
         dbLoadResultDialog.getTablePanel().removeAll();
     }
 


Mime
View raw message