cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skolbac...@apache.org
Subject [2/7] cayenne git commit: Correctly update data sources selection dialog after modifying or deleting data source
Date Thu, 03 Nov 2016 20:13:23 GMT
Correctly update data sources selection dialog after modifying or deleting data source


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

Branch: refs/heads/master
Commit: 55f7a2319900a407aa7676710c701ad127803a4b
Parents: 78a9c9b
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Tue Nov 1 09:56:23 2016 +0300
Committer: Savva Kolbachev <s.kolbachev@gmail.com>
Committed: Thu Nov 3 22:54:28 2016 +0300

----------------------------------------------------------------------
 .../modeler/dialog/db/DataSourceWizard.java        | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/55f7a231/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DataSourceWizard.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DataSourceWizard.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DataSourceWizard.java
index 32cb698..101bb8b 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DataSourceWizard.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DataSourceWizard.java
@@ -186,14 +186,10 @@ public class DataSourceWizard extends CayenneController {
 				.getChildrenPreferences();
 
 		// 1.2 migration fix - update data source adapter names
-		Iterator it = dataSources.values().iterator();
-
 		final String _12package = "org.objectstyle.cayenne.";
-		while (it.hasNext()) {
-			DBConnectionInfo info = (DBConnectionInfo) it.next();
+		for(DBConnectionInfo info : dataSources.values()) {
 			if (info.getDbAdapter() != null && info.getDbAdapter().startsWith(_12package))
{
 				info.setDbAdapter("org.apache.cayenne." + info.getDbAdapter().substring(_12package.length()));
-
 				// info.getObjectContext().commitChanges();
 			}
 		}
@@ -206,19 +202,16 @@ public class DataSourceWizard extends CayenneController {
 		Arrays.sort(keys);
 		view.getDataSources().setModel(new DefaultComboBoxModel<>(keys));
 
-		if (getDataSourceKey() == null) {
-			String key = null;
-
+		String key = null;
+		if (getDataSourceKey() == null || !dataSources.containsKey(getDataSourceKey())) {
 			if (altDataSourceKey != null) {
 				key = altDataSourceKey;
 			} else if (keys.length > 0) {
 				key = keys[0];
 			}
-
-			setDataSourceKey(key);
-			dataSourceBinding.updateView();
 		}
 
-		view.getDataSources().setSelectedItem(getDataSourceKey());
+		setDataSourceKey(key != null ? key : getDataSourceKey());
+		dataSourceBinding.updateView();
 	}
 }


Mime
View raw message