You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2018/04/11 11:16:56 UTC

[1/3] cayenne git commit: CAY-2422

Repository: cayenne
Updated Branches:
  refs/heads/master 125a9a813 -> 5f510107b


CAY-2422

Added message popup window with possibility to setup driver on Driver not found exception.


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

Branch: refs/heads/master
Commit: a316ff4553e4a7f4d78161d3eaf4ce6c0de4c800
Parents: 67aad8a
Author: kkomyak <co...@gmail.com>
Authored: Wed Apr 4 12:06:12 2018 +0300
Committer: kkomyak <co...@gmail.com>
Committed: Mon Apr 9 09:51:24 2018 +0300

----------------------------------------------------------------------
 .../modeler/dialog/db/DataSourceWizard.java     | 71 ++++++++++++++------
 .../modeler/dialog/pref/PreferenceDialog.java   | 38 ++++++-----
 2 files changed, 72 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/a316ff45/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 0ecb849..0b1ccf7 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
@@ -35,6 +35,7 @@ import org.apache.cayenne.swing.ObjectBinding;
 
 import javax.sql.DataSource;
 import javax.swing.DefaultComboBoxModel;
+import javax.swing.JOptionPane;
 import javax.swing.WindowConstants;
 import java.awt.Component;
 import java.sql.Connection;
@@ -74,7 +75,7 @@ public class DataSourceWizard extends CayenneController {
 	private DbAdapter adapter;
 	private DataSource dataSource;
 
-	public DataSourceWizard(CayenneController parent, String title) {
+	public DataSourceWizard(final CayenneController parent, final String title) {
 		super(parent);
 
 		this.view = createView(title);
@@ -85,7 +86,7 @@ public class DataSourceWizard extends CayenneController {
 		initDataSourceListener();
 	}
 
-	private String[] getLabelsForDialog(String viewTitle) {
+	private String[] getLabelsForDialog(final String viewTitle) {
 		switch (viewTitle) {
 			case GetDbConnectionAction.DIALOG_TITLE: {
 				return new String[]{"Save", "Cancel"};
@@ -98,13 +99,13 @@ public class DataSourceWizard extends CayenneController {
 	/**
 	 * Creates swing dialog for this wizard
 	 */
-	private DataSourceWizardView createView(String viewTitle) {
-		String[] labels = getLabelsForDialog(viewTitle);
+	private DataSourceWizardView createView(final String viewTitle) {
+		final String[] labels = getLabelsForDialog(viewTitle);
 		return new DataSourceWizardView(this, labels);
 	}
 
 	protected void initBindings() {
-		BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
+		final BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
 
 		dataSourceBinding = builder.bindToComboSelection(view.getDataSources(), "dataSourceKey");
 
@@ -129,9 +130,9 @@ public class DataSourceWizard extends CayenneController {
 	}
 
 	private void initFavouriteDataSource() {
-		Preferences pref = getApplication().getPreferencesNode(GeneralPreferences.class, "");
-		String favouriteDataSource = pref.get(GeneralPreferences.FAVOURITE_DATA_SOURCE, null);
-		if(favouriteDataSource != null && dataSources.containsKey(favouriteDataSource)) {
+		final Preferences pref = getApplication().getPreferencesNode(GeneralPreferences.class, "");
+		final String favouriteDataSource = pref.get(GeneralPreferences.FAVOURITE_DATA_SOURCE, null);
+		if (favouriteDataSource != null && dataSources.containsKey(favouriteDataSource)) {
 			setDataSourceKey(favouriteDataSource);
 			dataSourceBinding.updateView();
 		}
@@ -143,8 +144,8 @@ public class DataSourceWizard extends CayenneController {
 	}
 
 	private DBConnectionInfo getConnectionInfoFromPreferences() {
-		DBConnectionInfo connectionInfo = new DBConnectionInfo();
-		DataMapDefaults dataMapDefaults = projectController.
+		final DBConnectionInfo connectionInfo = new DBConnectionInfo();
+		final DataMapDefaults dataMapDefaults = projectController.
 				getDataMapPreferences(projectController.getCurrentDataMap());
 		connectionInfo.setDbAdapter(dataMapDefaults.getCurrentPreference().get(DB_ADAPTER_PROPERTY, null));
 		connectionInfo.setUrl(dataMapDefaults.getCurrentPreference().get(URL_PROPERTY, null));
@@ -158,11 +159,11 @@ public class DataSourceWizard extends CayenneController {
 		return dataSourceKey;
 	}
 
-	public void setDataSourceKey(String dataSourceKey) {
+	public void setDataSourceKey(final String dataSourceKey) {
 		this.dataSourceKey = dataSourceKey;
 
 		// update a clone object that will be used to obtain connection...
-		DBConnectionInfo currentInfo = dataSources.get(dataSourceKey);
+		final DBConnectionInfo currentInfo = dataSources.get(dataSourceKey);
 		if (currentInfo != null) {
 			currentInfo.copyTo(connectionInfo);
 		} else {
@@ -180,7 +181,7 @@ public class DataSourceWizard extends CayenneController {
 		refreshDataSources();
 		initFavouriteDataSource();
 
-		DataMapDefaults dataMapDefaults = projectController.
+		final DataMapDefaults dataMapDefaults = projectController.
 				getDataMapPreferences(projectController.getCurrentDataMap());
 		if (dataMapDefaults.getCurrentPreference().get(DB_ADAPTER_PROPERTY, null) != null) {
 			getConnectionInfoFromPreferences().copyTo(connectionInfo);
@@ -205,13 +206,19 @@ public class DataSourceWizard extends CayenneController {
 	 * conneciton. Does not store the open connection.
 	 */
 	public void okAction() {
-		DBConnectionInfo info = getConnectionInfo();
-		ClassLoadingService classLoader = getApplication().getClassLoadingService();
+		final DBConnectionInfo info = getConnectionInfo();
+		final ClassLoadingService classLoader = getApplication().getClassLoadingService();
 
 		// doing connection testing...
 		try {
-			this.adapter = info.makeAdapter(classLoader);
-			this.dataSource = info.makeDataSource(classLoader);
+			try {
+				this.adapter = info.makeAdapter(classLoader);
+				this.dataSource = info.makeDataSource(classLoader);
+			} catch (SQLException ignore) {
+				showNoConnectorDialog("Driver is not configured!", "You didn't attach the proper driver.");
+				return;
+			}
+
 			try (Connection connection = dataSource.getConnection()) {
 			} catch (SQLException ignore) {
 			}
@@ -229,7 +236,7 @@ public class DataSourceWizard extends CayenneController {
 	/**
 	 * On close handler. Introduced to remove data source listener.
 	 */
-	protected void onClose(boolean canceled) {
+	protected void onClose(final boolean canceled) {
 		// set success flag, and unblock the caller...
 		this.canceled = canceled;
 		view.dispose();
@@ -244,18 +251,27 @@ public class DataSourceWizard extends CayenneController {
 	 * Opens preferences panel to allow configuration of DataSource presets.
 	 */
 	public void dataSourceConfigAction() {
-		PreferenceDialog prefs = new PreferenceDialog(this);
+		final PreferenceDialog prefs = new PreferenceDialog(this);
 		prefs.showDataSourceEditorAction(dataSourceKey);
 		refreshDataSources();
 	}
 
+	/**
+	 * Opens preferences panel to allow configuration of classpath.
+	 */
+	public void classPathConfigAction() {
+		final PreferenceDialog prefs = new PreferenceDialog(this);
+		prefs.showClassPathEditorAction();
+		refreshDataSources();
+	}
+
 	public Component getView() {
 		return view;
 	}
 
 	@SuppressWarnings("unchecked")
 	private void refreshDataSources() {
-		this.dataSources = (Map<String, DBConnectionInfo>)getApplication().getCayenneProjectPreferences().getDetailObject(DBConnectionInfo.class)
+		this.dataSources = (Map<String, DBConnectionInfo>) getApplication().getCayenneProjectPreferences().getDetailObject(DBConnectionInfo.class)
 				.getChildrenPreferences();
 
 		// 1.2 migration fix - update data source adapter names
@@ -266,7 +282,7 @@ public class DataSourceWizard extends CayenneController {
 			}
 		}
 
-		String[] keys = dataSources.keySet().toArray(new String[0]);
+		final String[] keys = dataSources.keySet().toArray(new String[0]);
 		Arrays.sort(keys);
 		view.getDataSources().setModel(new DefaultComboBoxModel<>(keys));
 
@@ -281,6 +297,17 @@ public class DataSourceWizard extends CayenneController {
 		dataSourceBinding.updateView();
 	}
 
+	protected void showNoConnectorDialog(final String title, final String message) {
+
+		final String [] options = {"Setup driver", "OK"};
+
+		final int selection = JOptionPane.showOptionDialog(getView(), message, title, JOptionPane.ERROR_MESSAGE,
+				JOptionPane.ERROR_MESSAGE, null, options, options[1]);
+		if (selection == 0) {
+			classPathConfigAction();
+		}
+	}
+
 	public DataSource getDataSource() {
 		return dataSource;
 	}
@@ -292,7 +319,7 @@ public class DataSourceWizard extends CayenneController {
 		return adapter;
 	}
 
-	public void setProjectController(ProjectController projectController) {
+	public void setProjectController(final ProjectController projectController) {
 		this.projectController = projectController;
 	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/a316ff45/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/pref/PreferenceDialog.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/pref/PreferenceDialog.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/pref/PreferenceDialog.java
index 6ade6f9..2e2ab38 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/pref/PreferenceDialog.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/pref/PreferenceDialog.java
@@ -23,16 +23,12 @@ import java.awt.Component;
 import java.awt.Dialog;
 import java.awt.Frame;
 import java.awt.Window;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.swing.JDialog;
 import javax.swing.JList;
 import javax.swing.SwingUtilities;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
 
 import org.apache.cayenne.modeler.util.CayenneController;
 import org.apache.cayenne.pref.PreferenceEditor;
@@ -56,10 +52,10 @@ public class PreferenceDialog extends CayenneController {
     protected Map<String, CayenneController> detailControllers;
     protected PreferenceEditor editor;
 
-    public PreferenceDialog(CayenneController parent) {
+    public PreferenceDialog(final CayenneController parent) {
         super(parent);
 
-        Window parentView = parent.getView() instanceof Window
+        final Window parentView = parent.getView() instanceof Window
                 ? (Window) parent.getView()
                 : SwingUtilities.getWindowAncestor(parent.getView());
         this.view = (parentView instanceof Dialog)
@@ -83,7 +79,7 @@ public class PreferenceDialog extends CayenneController {
     }
 
     public void updateSelection() {
-        String selection = view.getList().getSelectedValue();
+        final String selection = view.getList().getSelectedValue();
         if (selection != null) {
             view.getDetailLayout().show(view.getDetailPanel(), selection);
         }
@@ -103,25 +99,37 @@ public class PreferenceDialog extends CayenneController {
      * Configures preferences dialog to display an editor for a local DataSource with
      * specified name.
      */
-    public void showDataSourceEditorAction(Object dataSourceKey) {
+    public void showDataSourceEditorAction(final Object dataSourceKey) {
         configure();
 
         // this will install needed controller
         view.getDetailLayout().show(view.getDetailPanel(), DATA_SOURCES_KEY);
 
-        DataSourcePreferences controller = (DataSourcePreferences) detailControllers
+        final DataSourcePreferences controller = (DataSourcePreferences) detailControllers
                 .get(DATA_SOURCES_KEY);
         controller.editDataSourceAction(dataSourceKey);
         view.setVisible(true);
     }
 
-    public void startupAction(String key) {
-        if (key == null) {
-            key = GENERAL_KEY;
-        }
+    /**
+     * Configures preferences dialog to display an editor for a local DataSource with
+     * specified name.
+     */
+    public void showClassPathEditorAction() {
+        configure();
+
+        // this will install needed controller
+        view.getDetailLayout().show(view.getDetailPanel(), CLASS_PATH_KEY);
+
+        ClasspathPreferences controller = (ClasspathPreferences) detailControllers
+                .get(CLASS_PATH_KEY);
+        controller.getView().setEnabled(true);
+        view.setVisible(true);
+    }
 
+    public void startupAction(final String key) {
         configure();
-        view.getList().setSelectedValue(key, true);
+        view.getList().setSelectedValue(key == null ? GENERAL_KEY : key, true);
         view.setVisible(true);
     }
 
@@ -142,7 +150,7 @@ public class PreferenceDialog extends CayenneController {
         view.setModal(true);
     }
 
-    protected void registerPanel(String name, CayenneController panelController) {
+    protected void registerPanel(final String name, final CayenneController panelController) {
         detailControllers.put(name, panelController);
         view.getDetailPanel().add(panelController.getView(), name);
     }


[3/3] cayenne git commit: CAY-2422 release notes

Posted by nt...@apache.org.
CAY-2422 release notes


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

Branch: refs/heads/master
Commit: 5f510107bfd134ed15fbd9aa771fcda9c2c8d6df
Parents: f713940
Author: Nikita Timofeev <st...@gmail.com>
Authored: Wed Apr 11 14:16:01 2018 +0300
Committer: Nikita Timofeev <st...@gmail.com>
Committed: Wed Apr 11 14:16:01 2018 +0300

----------------------------------------------------------------------
 RELEASE-NOTES.txt | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/5f510107/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 514df07..ade19f2 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -32,6 +32,7 @@ CAY-2410 Add prefetch type support for SQLTemplate query and SelectQuery
 CAY-2414 Modeler: new icon design
 CAY-2415 Transaction isolation and propagation support
 CAY-2416 Change TreeMap for HashMap to store data in Cayenne model classes
+CAY-2422 Modeler: Open driver setup window on driver load error
 
 Bug Fixes:
 


[2/3] cayenne git commit: Merge PR #283

Posted by nt...@apache.org.
Merge PR #283


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

Branch: refs/heads/master
Commit: f713940e51d25dd849ebef204ebde7fd8aa0177b
Parents: 125a9a8 a316ff4
Author: Nikita Timofeev <st...@gmail.com>
Authored: Wed Apr 11 14:14:24 2018 +0300
Committer: Nikita Timofeev <st...@gmail.com>
Committed: Wed Apr 11 14:14:24 2018 +0300

----------------------------------------------------------------------
 .../modeler/dialog/db/DataSourceWizard.java     | 71 ++++++++++++++------
 .../modeler/dialog/pref/PreferenceDialog.java   | 38 ++++++-----
 2 files changed, 72 insertions(+), 37 deletions(-)
----------------------------------------------------------------------