From b07d113079fa583b7ade9737b75d9fd5b17aad4b Mon Sep 17 00:00:00 2001
From: GWA
Date: Thu, 22 Jan 2026 10:06:28 +0100
Subject: [PATCH 01/18] Bug fix: Deleting or editing SQL table results or
Object tree "Content"-tables rose NullPointerException when a table had one
or more columns of type LONGVARCHAR and LONGVARCHAR types were chosen to be
left out of generated WHERE clauses. See menu File --> Global Preferences
--> tab "Data type controls" --> section "CHAR, VARCHAR, LONGVARCHAR"
---
sql12/core/doc/changes.txt | 4 +
.../DataSetUpdateableTableModelImpl.java | 40 +++++----
.../cellcomponent/DataTypeString.java | 89 ++++++++++---------
3 files changed, 75 insertions(+), 58 deletions(-)
diff --git a/sql12/core/doc/changes.txt b/sql12/core/doc/changes.txt
index f72c2d535..1a28a2e9e 100755
--- a/sql12/core/doc/changes.txt
+++ b/sql12/core/doc/changes.txt
@@ -74,6 +74,10 @@ DB2 Plugin: The table details in the Object tree has a new tab
Bug fixes:
+Deleting or editing SQL table results or Object tree "Content"-tables rose NullPointerException when
+ a table had one or more columns of type LONGVARCHAR and LONGVARCHAR types were chosen to be left out of generated WHERE clauses.
+ See menu File --> Global Preferences --> tab "Data type controls" --> section "CHAR, VARCHAR, LONGVARCHAR"
+
Alias find dialog (ctrl+alt+shift+g or ctrl+alt+shift+f):
Modifying an Alias folder raised NullPointerException.
diff --git a/sql12/core/src/net/sourceforge/squirrel_sql/client/session/DataSetUpdateableTableModelImpl.java b/sql12/core/src/net/sourceforge/squirrel_sql/client/session/DataSetUpdateableTableModelImpl.java
index fc2701f77..d39e35a1c 100644
--- a/sql12/core/src/net/sourceforge/squirrel_sql/client/session/DataSetUpdateableTableModelImpl.java
+++ b/sql12/core/src/net/sourceforge/squirrel_sql/client/session/DataSetUpdateableTableModelImpl.java
@@ -1,5 +1,14 @@
package net.sourceforge.squirrel_sql.client.session;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Vector;
+import javax.swing.JOptionPane;
+
import net.sourceforge.squirrel_sql.client.session.mainpanel.sqltypecheck.ReadOnlySessionCheck;
import net.sourceforge.squirrel_sql.client.session.properties.EditWhereCols;
import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
@@ -22,15 +31,6 @@
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-import javax.swing.JOptionPane;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Vector;
-
public class DataSetUpdateableTableModelImpl implements IDataSetUpdateableTableModel
{
@@ -646,29 +646,37 @@ private List getWhereClause(
// the user has restricted the set of columns to use.
// If this name is NOT in the list, then skip it; otherwise we fall through
// and use the column in the WHERE clause
- if (colNames.get(colDefs[i].getColumnName()) == null)
+ if( colNames.get(colDefs[i].getColumnName()) == null )
+ {
continue; // go on to the next item
+ }
}
// for the column that is being changed, use the value
// passed in by the caller (which may be either the
// current value or the new replacement value)
Object value = values[i];
- if (i == col)
+ if( i == col )
+ {
value = colValue;
+ }
- // convert user representation of null into an actual null
- if (value != null && value.toString().equals(StringUtilities.NULL_AS_STRING))
+ if( value != null && value.toString().equals(StringUtilities.NULL_AS_STRING) )
+ {
+ // convert user representation of null into an actual null
value = null;
+ }
// do different things depending on data type
ISQLDatabaseMetaData md = _session.getMetaData();
IWhereClausePart clausePart = CellComponentFactory.getWhereClauseValue(colDefs[i], value, md);
- if (clausePart.shouldBeUsed())
- // Now we know that the part should not we ignoredshould
+ if( null != clausePart && clausePart.shouldBeUsed() )
+ {
+ // Now we know that the part should not be ignored
clauseParts.add(clausePart);
+ }
}
return clauseParts;
@@ -676,7 +684,7 @@ private List getWhereClause(
}
catch (Exception e)
{
- throw new RuntimeException(e);
+ throw Utilities.wrapRuntime(e);
}
}
diff --git a/sql12/core/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeString.java b/sql12/core/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeString.java
index 3332a93b4..abec087ee 100644
--- a/sql12/core/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeString.java
+++ b/sql12/core/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeString.java
@@ -18,32 +18,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
-import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.EmptyWhereClausePart;
-import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.IWhereClausePart;
-import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.IsNullWhereClausePart;
-import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.ParameterWhereClausePart;
-import net.sourceforge.squirrel_sql.fw.datasetviewer.celldatapopup.CellDataDialogHandler;
-import net.sourceforge.squirrel_sql.fw.gui.IntegerField;
-import net.sourceforge.squirrel_sql.fw.gui.MultipleLineLabel;
-import net.sourceforge.squirrel_sql.fw.gui.OkJPanel;
-import net.sourceforge.squirrel_sql.fw.sql.ISQLDatabaseMetaData;
-import net.sourceforge.squirrel_sql.fw.util.StringManager;
-import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
-import net.sourceforge.squirrel_sql.fw.util.StringUtilities;
-import net.sourceforge.squirrel_sql.fw.util.Utilities;
-
-import javax.swing.BorderFactory;
-import javax.swing.JCheckBox;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.text.JTextComponent;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
@@ -60,6 +34,32 @@
import java.sql.ResultSet;
import java.sql.Types;
import java.util.Iterator;
+import javax.swing.BorderFactory;
+import javax.swing.JCheckBox;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.text.JTextComponent;
+
+import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
+import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.EmptyWhereClausePart;
+import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.IWhereClausePart;
+import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.IsNullWhereClausePart;
+import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.ParameterWhereClausePart;
+import net.sourceforge.squirrel_sql.fw.datasetviewer.celldatapopup.CellDataDialogHandler;
+import net.sourceforge.squirrel_sql.fw.gui.IntegerField;
+import net.sourceforge.squirrel_sql.fw.gui.MultipleLineLabel;
+import net.sourceforge.squirrel_sql.fw.gui.OkJPanel;
+import net.sourceforge.squirrel_sql.fw.sql.ISQLDatabaseMetaData;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+import net.sourceforge.squirrel_sql.fw.util.StringUtilities;
+import net.sourceforge.squirrel_sql.fw.util.Utilities;
/**
@@ -123,7 +123,7 @@ public class DataTypeString extends BaseDataTypeComponent
* otherwise do not include it.
* Oracle does not allow that type to be used in a WHERE clause
*/
- private static boolean _useLongInWhere = true;
+ private static boolean _useLongVarcharInWhere = true;
/**
@@ -163,10 +163,10 @@ private static void loadProperties() {
if (makeNewlinesVisibleString != null && makeNewlinesVisibleString.equals("false"))
_makeNewlinesVisibleInCell = false;
- _useLongInWhere = true; // set to the default
+ _useLongVarcharInWhere = true; // set to the default
String useLongInWhereString = DataTypeProps.getProperty(DataTypeString.class.getName(), "useLongInWhere");
if (useLongInWhereString != null && useLongInWhereString.equals("false"))
- _useLongInWhere = false;
+ _useLongVarcharInWhere = false;
LimitReadLengthFeatureUnstable._limitRead = false; // set to default
String limitReadString = DataTypeProps.getProperty(DataTypeString.class.getName(), "limitRead");
@@ -542,27 +542,32 @@ public Object readResultSet(ResultSet rs, int index, boolean limitDataRead)
* or whatever is appropriate for this column in the database.
*/
@Override
- public IWhereClausePart getWhereClauseValue(Object value, ISQLDatabaseMetaData md) {
+ public IWhereClausePart getWhereClauseValue(Object value, ISQLDatabaseMetaData md)
+ {
// first do special check to see if we should use LONGVARCHAR
// in the WHERE clause.
// (Oracle does not allow this.)
- if (_colDef.getSqlType() == Types.LONGVARCHAR &&
- _useLongInWhere == false)
- return null; // this column cannot be used in a WHERE clause
+ if( _colDef.getSqlType() == Types.LONGVARCHAR && _useLongVarcharInWhere == false )
+ {
+ return null; // this column cannot be used in a WHERE clause
+ }
- if (value == null || value.toString() == null )
+ if( value == null || value.toString() == null )
+ {
return new IsNullWhereClausePart(_colDef);
- else {
+ }
+ else
+ {
// We cannot use this data in the WHERE clause if it has been truncated.
// Since being truncated is the same as needing to re-read,
// only use this in the WHERE clause if we do not need to re-read
- if ( ! needToReRead(value))
+ if( !needToReRead(value) )
{
return new ParameterWhereClausePart(_colDef, value, this);
}
- else
- {
- return new EmptyWhereClausePart(); // value is truncated, so do not use in WHERE clause
+ else
+ {
+ return new EmptyWhereClausePart(); // value is truncated, so do not use in WHERE clause
}
}
}
@@ -842,7 +847,7 @@ public DataTypeStringPanel() {
_makeNewlinesVisibleInCellChk.setSelected(_makeNewlinesVisibleInCell);
// checkbox for using LONG in WHERE clause
- _useLongInWhereChk.setSelected(_useLongInWhere);
+ _useLongInWhereChk.setSelected(_useLongVarcharInWhere);
// checkbox for limit/no-limit on data read during initial table load
_limitReadChk.setSelected(LimitReadLengthFeatureUnstable._limitRead);
@@ -979,8 +984,8 @@ public void ok() {
_makeNewlinesVisibleInCell = _makeNewlinesVisibleInCellChk.isSelected();
DataTypeProps.putDataTypeProperty(DataTypeString.class.getName(), "makeNewlinesVisibleInCell", Boolean.valueOf(_makeNewlinesVisibleInCell).toString());
- _useLongInWhere = _useLongInWhereChk.isSelected();
- DataTypeProps.putDataTypeProperty(DataTypeString.class.getName(), "useLongInWhere", Boolean.valueOf(_useLongInWhere).toString());
+ _useLongVarcharInWhere = _useLongInWhereChk.isSelected();
+ DataTypeProps.putDataTypeProperty(DataTypeString.class.getName(), "useLongInWhere", Boolean.valueOf(_useLongVarcharInWhere).toString());
LimitReadLengthFeatureUnstable._limitRead = _limitReadChk.isSelected();
DataTypeProps.putDataTypeProperty(DataTypeString.class.getName(), "limitRead", Boolean.valueOf(LimitReadLengthFeatureUnstable._limitRead).toString());
From 64ea61dd370c8c57979ad0b6aaa6992b70f6ddb7 Mon Sep 17 00:00:00 2001
From: GWA
Date: Fri, 23 Jan 2026 08:38:20 +0100
Subject: [PATCH 02/18] Adjusted copyright to new year
---
.../src/net/sourceforge/squirrel_sql/client/Version.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sql12/core/src/net/sourceforge/squirrel_sql/client/Version.java b/sql12/core/src/net/sourceforge/squirrel_sql/client/Version.java
index 2203e371b..3f5575693 100644
--- a/sql12/core/src/net/sourceforge/squirrel_sql/client/Version.java
+++ b/sql12/core/src/net/sourceforge/squirrel_sql/client/Version.java
@@ -18,11 +18,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
-
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
+
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
/**
* Application version information.
*
@@ -35,7 +35,7 @@ public class Version
* No I18n/StringManager here. This class is used to early. The right Locale may not have been set yet.
*/
private static final String APP_NAME = "SQuirreL SQL Client";
- private static final String COPYRIGHT = "Copyright (c) 2001-2025\nColin Bell, Gerd Wagner, Rob Manning and others";
+ private static final String COPYRIGHT = "Copyright (c) 2001-2026\nColin Bell, Gerd Wagner, Rob Manning and others";
private static final String WEB_SITE = "http://www.squirrelsql.org";
private static final String WEB_SITE2 = "https://squirrelsql.org";
From 7c9a29b83c4002cf839efd812b87bdab27ce2d28 Mon Sep 17 00:00:00 2001
From: gerdwagner
Date: Sat, 24 Jan 2026 22:38:19 +0100
Subject: [PATCH 03/18] Feature:
https://github.com/squirrel-sql-client/squirrel-sql-code/issues/81 Session
Scripts Plugin: Session startup scripts now support running bookmarks by
@runbookmark the same way the SQL editor does.
Feature: Session Scripts Plugin: Aliases combo box of the Session startup scripts frame now
sorts Aliases alphabetically and puts the ones on top which have Session startup scripts defined.
See menu Plugins --> Session Scripts ...
---
sql12/core/doc/changes.txt | 10 +-
.../gui/db/AliasesAndDriversManager.java | 27 +++---
.../client/plugin/DefaultSessionPlugin.java | 9 +-
.../client/plugin/ISessionPlugin.java | 9 +-
.../client/plugin/PluginManager.java | 91 +++++++++----------
.../sessionscript/SQLALiasesCombo.java | 42 +++++----
.../plugins/sessionscript/ScriptsSheet.java | 31 +++----
.../sessionscript/SessionScriptPlugin.java | 27 +++---
.../ViewSessionScriptsPanel.java | 31 +++----
sql12/plugins/sqlbookmark/doc/readme.html | 13 ++-
.../sqlbookmark/SQLBookmarkPlugin.java | 2 +-
11 files changed, 158 insertions(+), 134 deletions(-)
diff --git a/sql12/core/doc/changes.txt b/sql12/core/doc/changes.txt
index 1a28a2e9e..8c26c78c9 100755
--- a/sql12/core/doc/changes.txt
+++ b/sql12/core/doc/changes.txt
@@ -6,6 +6,14 @@ Not yet released, available in our GIT repository, snapshots and future releases
Enhancements:
+https://github.com/squirrel-sql-client/squirrel-sql-code/issues/81
+ Session Scripts Plugin: Session startup scripts now support running bookmarks
+ by @runbookmark the same way the SQL editor does.
+
+Session Scripts Plugin: Aliases combo box of the Session startup scripts frame now
+ sorts Aliases alphabetically and puts the ones on top which have Session startup scripts defined.
+ See menu Plugins --> Session Scripts ...
+
https://github.com/squirrel-sql-client/squirrel-sql-code/issues/80
SQL results displayed in their own window can be rerun automatically, too.
The UI behavior of SQL results displayed in their own window was improved.
@@ -15,7 +23,7 @@ https://github.com/squirrel-sql-client/squirrel-sql-code/issues/80
To give access to this function the SQL result's rerun button was made switchable.
https://github.com/squirrel-sql-client/squirrel-sql-code/issues/81
- Bookmarks Plugin: A bookmark's statement can be run from within the SQL editor use @runbookmark
+ Bookmarks Plugin: A bookmark's statement can be run from within the SQL editor use @runbookmark
https://github.com/squirrel-sql-client/squirrel-sql-code/issues/75
The options "Allow to run all SQLs in editor" and "Allow to run a SQL in all open Sessions"
diff --git a/sql12/core/src/net/sourceforge/squirrel_sql/client/gui/db/AliasesAndDriversManager.java b/sql12/core/src/net/sourceforge/squirrel_sql/client/gui/db/AliasesAndDriversManager.java
index 22bba25d2..2a2543a36 100644
--- a/sql12/core/src/net/sourceforge/squirrel_sql/client/gui/db/AliasesAndDriversManager.java
+++ b/sql12/core/src/net/sourceforge/squirrel_sql/client/gui/db/AliasesAndDriversManager.java
@@ -18,6 +18,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import net.sourceforge.squirrel_sql.client.Main;
import net.sourceforge.squirrel_sql.client.gui.db.listholder.AliasListHolder;
import net.sourceforge.squirrel_sql.client.gui.db.listholder.DriverListHolder;
@@ -28,20 +36,15 @@
import net.sourceforge.squirrel_sql.fw.sql.ISQLDriver;
import net.sourceforge.squirrel_sql.fw.sql.SQLDriver;
import net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager;
-import net.sourceforge.squirrel_sql.fw.util.*;
+import net.sourceforge.squirrel_sql.fw.util.IMessageHandler;
+import net.sourceforge.squirrel_sql.fw.util.IObjectCacheChangeListener;
+import net.sourceforge.squirrel_sql.fw.util.NullMessageHandler;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
import net.sourceforge.squirrel_sql.fw.xml.XMLException;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
public class AliasesAndDriversManager
{
private final static StringManager s_stringMgr = StringManagerFactory.getStringManager(AliasesAndDriversManager.class);
@@ -248,12 +251,12 @@ public SQLAlias getAlias(IIdentifier id)
return _aliasListHolder.get(id);
}
- public Iterator extends SQLAlias> aliases()
+ public Iterator aliases()
{
return _aliasListHolder.getAll().iterator();
}
- public List extends SQLAlias> getAliasList()
+ public List getAliasList()
{
return _aliasListHolder.getAll();
}
diff --git a/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/DefaultSessionPlugin.java b/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/DefaultSessionPlugin.java
index 6b5047668..7bcc03073 100644
--- a/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/DefaultSessionPlugin.java
+++ b/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/DefaultSessionPlugin.java
@@ -20,14 +20,13 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-import javax.swing.JMenu;
+import javax.swing.JMenu;
import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.event.SessionAdapter;
import net.sourceforge.squirrel_sql.client.session.event.SessionEvent;
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
import net.sourceforge.squirrel_sql.client.session.properties.ISessionPropertiesPanel;
-import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
@@ -59,6 +58,12 @@ public boolean allowsSessionStartedInBackground()
return false;
}
+ @Override
+ public int getSessionStartedCallRank()
+ {
+ return 0;
+ }
+
/**
* Called when a session shutdown.
*
diff --git a/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/ISessionPlugin.java b/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/ISessionPlugin.java
index 86d19d7fa..b40572f72 100644
--- a/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/ISessionPlugin.java
+++ b/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/ISessionPlugin.java
@@ -19,11 +19,11 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
import net.sourceforge.squirrel_sql.client.session.properties.ISessionPropertiesPanel;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
/**
* Base interface for all plugins associated with a session.
*/
@@ -61,6 +61,13 @@ public interface ISessionPlugin extends IPlugin
*/
PluginSessionCallback sessionStarted(ISession session);
+ /**
+ * Allows to influence the order in which {@link #sessionStarted(ISession)} is called with respect to other SessionPlugins.
+ * Safely influencing the order is possible only when {@link #allowsSessionStartedInBackground()} returns false.
+ */
+ int getSessionStartedCallRank();
+
+
/**
* Called when a session shutdown.
*/
diff --git a/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/PluginManager.java b/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/PluginManager.java
index c26d6a4aa..9228587ff 100755
--- a/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/PluginManager.java
+++ b/sql12/core/src/net/sourceforge/squirrel_sql/client/plugin/PluginManager.java
@@ -21,6 +21,20 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import net.sourceforge.squirrel_sql.client.ApplicationArguments;
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.gui.db.SQLAlias;
@@ -45,21 +59,6 @@
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
/**
* Manages plugins for the application.
*
@@ -178,42 +177,47 @@ public synchronized void sessionStarted(final ISession session)
final List plugins = new ArrayList();
_activeSessions.put(session.getIdentifier(), plugins);
- ArrayList startInFG = new ArrayList();
- final ArrayList startInBG = new ArrayList();
+ ArrayList startInFG = new ArrayList<>();
+ final ArrayList startInBG = new ArrayList<>();
for (Iterator it = _sessionPlugins.iterator(); it.hasNext();)
{
SessionPluginInfo spi = it.next();
- if (spi.getSessionPlugin().allowsSessionStartedInBackground())
+ if(spi.getSessionPlugin().allowsSessionStartedInBackground())
{
startInBG.add(spi);
- } else
+ }
+ else
{
startInFG.add(spi);
}
-
}
session.setPluginsfinishedLoading(true);
- for (Iterator it = startInFG.iterator(); it.hasNext();)
- {
- SessionPluginInfo spi = it.next();
- sendSessionStarted(session, spi, plugins);
- }
+
+ startInFG.sort((spi1, spi2) -> compareBySessionStartedCallRank(spi1, spi2));
+ for(SessionPluginInfo spi : startInFG)
+ {
+ sendSessionStarted(session, spi, plugins);
+ }
session.getApplication().getThreadPool().addTask(new Runnable()
{
public void run()
{
- for (Iterator it = startInBG.iterator(); it.hasNext();)
- {
- SessionPluginInfo spi = it.next();
- sendSessionStarted(session, spi, plugins);
- }
+ for(SessionPluginInfo spi : startInBG)
+ {
+ sendSessionStarted(session, spi, plugins);
+ }
session.setPluginsfinishedLoading(true);
}
});
}
+ private int compareBySessionStartedCallRank(SessionPluginInfo spi1, SessionPluginInfo spi2)
+ {
+ return Integer.compare(spi1.getSessionPlugin().getSessionStartedCallRank(), spi2.getSessionPlugin().getSessionStartedCallRank());
+ }
+
private void sendSessionStarted(ISession session, SessionPluginInfo spi, List plugins)
{
try
@@ -222,30 +226,17 @@ private void sendSessionStarted(ISession session, SessionPluginInfo spi, List list =
- _pluginSessionCallbacksBySessionID.get(session.getIdentifier());
- if (null == list)
- {
- list = new ArrayList();
- _pluginSessionCallbacksBySessionID.put(session.getIdentifier(), list);
- }
- list.add(pluginSessionCallback);
-
+ List list = _pluginSessionCallbacksBySessionID.computeIfAbsent(session.getIdentifier(), k -> new ArrayList<>());
+ list.add(pluginSessionCallback);
plugins.add(spi);
}
- } catch (final Throwable th)
+ }
+ catch(final Throwable th)
{
- final String msg =
- s_stringMgr.getString("PluginManager.error.sessionstarted", spi.getPlugin().getDescriptiveName());
- s_log.error(msg, th);
- GUIUtils.processOnSwingEventThread(new Runnable()
- {
- public void run()
- {
- _app.showErrorDialog(msg, th);
- }
- });
+ final String msg =s_stringMgr.getString("PluginManager.error.sessionstarted", spi.getPlugin().getDescriptiveName());
+ s_log.error(msg, th);
+ GUIUtils.processOnSwingEventThread(() -> _app.showErrorDialog(msg, th));
}
}
diff --git a/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/SQLALiasesCombo.java b/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/SQLALiasesCombo.java
index 06b70a300..eba8d9561 100644
--- a/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/SQLALiasesCombo.java
+++ b/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/SQLALiasesCombo.java
@@ -18,11 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-import net.sourceforge.squirrel_sql.client.IApplication;
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.JComboBox;
+import net.sourceforge.squirrel_sql.client.Main;
import net.sourceforge.squirrel_sql.client.gui.db.SQLAlias;
+import org.apache.commons.lang3.StringUtils;
-import javax.swing.*;
-import java.util.Iterator;
/**
* This JComboBox will display all aliases.
*
@@ -46,22 +48,30 @@ public SQLAlias getSelectedSQLAlias()
/**
* Load control with all the aliases in the system.
- *
- * @param conn app Application API.
- *
- * @throws IllegalArgumentException
- * Thrown if a null IApplication passed.
- *
- * @throws BaseSQLException
- * Thrown if an SQL exception occurs.
*/
- public void load(IApplication app)
+ public void load(AliasScriptCache scriptsCache)
{
removeAllItems();
- for (Iterator extends SQLAlias> it = app.getAliasesAndDriversManager().aliases(); it.hasNext();)
+
+ List aliasListClone= new ArrayList<>(Main.getApplication().getAliasesAndDriversManager().getAliasList());
+
+ aliasListClone.sort((a1, a2) -> compareAliases(scriptsCache, a1, a2));
+
+ aliasListClone.forEach(a -> addItem(a));
+ }
+
+ private int compareAliases(AliasScriptCache scriptsCache, SQLAlias a1, SQLAlias a2)
+ {
+ if(false == StringUtils.isBlank(scriptsCache.get(a1).getSQL()) && StringUtils.isBlank(scriptsCache.get(a2).getSQL()))
{
- SQLAlias alias = it.next();
- addItem(alias);
+ return -1;
}
- }
+ else if(StringUtils.isBlank(scriptsCache.get(a1).getSQL()) && false == StringUtils.isBlank(scriptsCache.get(a2).getSQL()))
+ {
+ return 1;
+ }
+
+ return StringUtils.compareIgnoreCase(a1.getName(), a2.getName());
+
+ }
}
diff --git a/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/ScriptsSheet.java b/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/ScriptsSheet.java
index 1b82ad442..002e6bf91 100644
--- a/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/ScriptsSheet.java
+++ b/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/ScriptsSheet.java
@@ -18,44 +18,34 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.Dimension;
+import javax.swing.WindowConstants;
import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.Main;
import net.sourceforge.squirrel_sql.client.gui.desktopcontainer.DialogWidget;
import net.sourceforge.squirrel_sql.fw.util.StringManager;
import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
-import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
-import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-
-import javax.swing.*;
-import java.awt.*;
class ScriptsSheet extends DialogWidget
{
- private static final StringManager s_stringMgr =
- StringManagerFactory.getStringManager(ScriptsSheet.class);
+ private static final StringManager s_stringMgr = StringManagerFactory.getStringManager(ScriptsSheet.class);
-
- /** Logger for this class. */
- private static ILogger s_log =
- LoggerController.createLogger(ScriptsSheet.class);
-
/** Singleton instance of this class. */
private static ScriptsSheet s_instance;
- /** Plugin. */
private SessionScriptPlugin _plugin;
- /** Application API. */
- private IApplication _app;
/** Main panel. */
private ViewSessionScriptsPanel _mainPnl;
- private ScriptsSheet(SessionScriptPlugin plugin, IApplication app)
+ private ScriptsSheet(SessionScriptPlugin plugin)
{
// i18n[sessionscript.startupScripts=Startup Scripts]
- super(s_stringMgr.getString("sessionscript.startupScripts"), true, true, true, true);
+ super(s_stringMgr.getString("sessionscript.startupScripts"), true, true, true, true, Main.getApplication().getMainFrame());
_plugin = plugin;
- _app = app;
createUserInterface();
}
@@ -74,9 +64,10 @@ public static synchronized void showSheet(SessionScriptPlugin plugin,
{
if (s_instance == null)
{
- s_instance = new ScriptsSheet(plugin, app);
+ s_instance = new ScriptsSheet(plugin);
app.getMainFrame().addWidget(s_instance);
}
+ DialogWidget.centerWithinDesktop(s_instance);
s_instance.setVisible(true);
}
@@ -94,7 +85,7 @@ private void createUserInterface()
makeToolWindow(true);
- _mainPnl = new ViewSessionScriptsPanel(_plugin, _app);
+ _mainPnl = new ViewSessionScriptsPanel(_plugin);
Container content = getContentPane();
content.setLayout(new BorderLayout());
diff --git a/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/SessionScriptPlugin.java b/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/SessionScriptPlugin.java
index dac5fa698..6ec7267ea 100755
--- a/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/SessionScriptPlugin.java
+++ b/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/SessionScriptPlugin.java
@@ -18,8 +18,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-import java.io.IOException;
+import java.io.IOException;
+import javax.swing.SwingUtilities;
import net.sourceforge.squirrel_sql.client.IApplication;
import net.sourceforge.squirrel_sql.client.action.ActionCollection;
import net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin;
@@ -32,8 +33,7 @@
import net.sourceforge.squirrel_sql.fw.util.FileWrapper;
import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-
-import javax.swing.*;
+import org.apache.commons.lang3.StringUtils;
/**
* The plugin class.
@@ -169,7 +169,8 @@ public synchronized void initialize() throws PluginException
try
{
_cache = new AliasScriptCache(this);
- } catch (IOException ex)
+ }
+ catch(IOException ex)
{
throw new PluginException(ex);
}
@@ -189,17 +190,22 @@ public void unload()
super.unload();
}
- public PluginSessionCallback sessionStarted(final ISession session)
+ @Override
+ public int getSessionStartedCallRank()
{
- boolean rc = false;
+ // Call this Plugin's sessionStarted method last.
+ return Integer.MAX_VALUE;
+ }
+ @Override
+ public PluginSessionCallback sessionStarted(final ISession session)
+ {
AliasScript script = _cache.get(session.getAlias());
if (script != null)
{
final String sql = script.getSQL();
- if (sql != null && sql.length() > 0)
+ if (false == StringUtils.isBlank(sql))
{
- rc = true;
final ISQLPanelAPI api = session.getSessionInternalFrame().getMainSQLPanelAPI();
SwingUtilities.invokeLater(new Runnable()
@@ -212,11 +218,6 @@ public void run()
});
}
}
-
- if (false == rc)
- {
- return null;
- }
return new PluginSessionCallbackAdaptor();
}
diff --git a/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/ViewSessionScriptsPanel.java b/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/ViewSessionScriptsPanel.java
index 7d7cacb52..2a3ff4950 100644
--- a/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/ViewSessionScriptsPanel.java
+++ b/sql12/plugins/sessionscript/src/net/sourceforge/squirrel_sql/plugins/sessionscript/ViewSessionScriptsPanel.java
@@ -18,18 +18,22 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-import net.sourceforge.squirrel_sql.client.IApplication;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
import net.sourceforge.squirrel_sql.client.gui.db.SQLAlias;
import net.sourceforge.squirrel_sql.fw.util.StringManager;
import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
-import javax.swing.*;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
public class ViewSessionScriptsPanel extends JPanel
{
private static final StringManager s_stringMgr =
@@ -37,25 +41,18 @@ public class ViewSessionScriptsPanel extends JPanel
private SessionScriptPlugin _plugin;
- private IApplication _app;
private SQLALiasesCombo _aliasesCmb = new SQLALiasesCombo();
private JTextArea _sqlEntry = new JTextArea();
private JButton _saveBtn;
- ViewSessionScriptsPanel(SessionScriptPlugin plugin, IApplication app)
+ ViewSessionScriptsPanel(SessionScriptPlugin plugin)
{
- super();
if (plugin == null)
{
throw new IllegalArgumentException("SessionScriptPlugin == null");
}
- if (app == null)
- {
- throw new IllegalArgumentException("IApplication == null");
- }
_plugin = plugin;
- _app = app;
createUserInterface();
refreshScript();
@@ -86,7 +83,7 @@ private void createUserInterface()
{
setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
- _aliasesCmb.load(_app);
+ _aliasesCmb.load(_plugin.getScriptsCache());
_aliasesCmb.addActionListener(new AliasesComboListener(this));
_sqlEntry.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
diff --git a/sql12/plugins/sqlbookmark/doc/readme.html b/sql12/plugins/sqlbookmark/doc/readme.html
index 23625ab81..cb0bce817 100644
--- a/sql12/plugins/sqlbookmark/doc/readme.html
+++ b/sql12/plugins/sqlbookmark/doc/readme.html
@@ -9,7 +9,7 @@
-SQLBookmark 1.0 - Joe Mocker, Gerd Wagner
+SQLBookmark 2.0.1 - Joe Mocker, Gerd Wagner
SQLBookmark allows you to "bookmark" commonly used SQL
code for easy point and click reuse. Whatever you type in the SQL
editor can be easily bookmarked by opening SQuirreL's tools popup via
@@ -99,5 +99,16 @@
The Global Preferences window can be opened using the “Edit
Bookmarks” toolbar button of a Session window.
+
+
+
+Executing Bookmarks scriptlike:
+Bookmarks can be called from within the SQL editor using the following syntax:
+
+
+ @runbookmark <bookmarkNameInSingleQuotes>
+
+
+