Revision: 6171
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6171&view=rev
Author: gerdwagner
Date: 2011-03-04 19:04:41 +0000 (Fri, 04 Mar 2011)
Log Message:
-----------
I ran into a problem when comparing tables of the same Session. After starting SQuirreL I opened a Session then chose select on one table and compare on another which led to the exception below.
I must admit that I looked at the exception even before I noticed the message 'To compare, you must have exactly two tables selected in the object tree' in the message panel.
I believe I found a fix that removes the NPE and allows the user to compare within one Session the same way as with different Sessions using select and compare. And also keep the old way to compare inside on Session without using Select.
Modified Paths:
--------------
trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/actions/CompareAction.java
Modified: trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/actions/CompareAction.java
===================================================================
--- trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/actions/CompareAction.java 2011-02-22 18:30:20 UTC (rev 6170)
+++ trunk/sql12/plugins/dbdiff/src/main/java/net/sourceforge/squirrel_sql/plugins/dbdiff/actions/CompareAction.java 2011-03-04 19:04:41 UTC (rev 6171)
@@ -71,11 +71,15 @@
}
final IDatabaseObjectInfo[] dbObjs = api.getSelectedDatabaseObjects();
+
+ boolean clearSource = false;
+
// sourceSession can be null in the case where two tables are selected in the same schema for direct
// compare.
- if (sourceSession != null && !sourceSession.getIdentifier().equals(destSession.getIdentifier()))
+ if ( sourceExists() )
{
sessionInfoProv.setDestSelectedDatabaseObjects(dbObjs);
+ clearSource = true;
}
else
{
@@ -88,6 +92,7 @@
sessionInfoProv.setSourceSelectedDatabaseObjects(new IDatabaseObjectInfo[] { dbObjs[0] });
sessionInfoProv.setDestSession(destSession);
sessionInfoProv.setDestSelectedDatabaseObjects(new IDatabaseObjectInfo[] { dbObjs[1] });
+ clearSource = true;
}
else
{
@@ -115,9 +120,21 @@
command.setPluginPreferencesManager(pluginPreferencesManager);
command.execute();
+ if(clearSource)
+ {
+ sessionInfoProv.setSourceSelectedDatabaseObjects(new IDatabaseObjectInfo[0]);
+ }
+
}
- /**
+ private boolean sourceExists()
+ {
+ return sessionInfoProv.getSourceSession() != null &&
+ null != sessionInfoProv.getSourceSelectedDatabaseObjects()
+ && 0 < sessionInfoProv.getSourceSelectedDatabaseObjects().length;
+ }
+
+ /**
* Set the current session.
*
* @param session
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|