Revision: 6579
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6579&view=rev
Author: gerdwagner
Date: 2012-02-15 21:23:22 +0000 (Wed, 15 Feb 2012)
Log Message:
-----------
Fixed Swing access outside event dispatch thread
Modified Paths:
--------------
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecutionInfo.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/mainpanel/SQLExecutionHandler.java
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/mainpanel/SQLResultExecuterPanel.java
trunk/sql12/plugins/swingViolations/src/main/java/net/sourceforge/squirrel_sql/plugins/swingviolations/EDTViolationRepaintManager.java
Added Paths:
-----------
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecutionInfoFinishedListener.java
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecutionInfo.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecutionInfo.java 2012-02-15 19:54:16 UTC (rev 6578)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecutionInfo.java 2012-02-15 21:23:22 UTC (rev 6579)
@@ -46,6 +46,7 @@
/** Number of rows query limited to. */
private final int _maxRows;
private Integer _numberResultRowsRead;
+ private SQLExecutionInfoFinishedListener _sqlExecutionInfoFinishedListener;
/**
* Default ctor. Defaults SQL execution start time to the current time.
@@ -124,6 +125,11 @@
public void resultsProcessingComplete()
{
_resultsProcessingEnd = Calendar.getInstance().getTime();
+
+ if(null != _sqlExecutionInfoFinishedListener)
+ {
+ _sqlExecutionInfoFinishedListener.allProcessingComplete(this);
+ }
}
/**
@@ -232,4 +238,9 @@
{
return _numberResultRowsRead;
}
+
+ public void setFinishedListener(SQLExecutionInfoFinishedListener sqlExecutionInfoFinishedListener)
+ {
+ _sqlExecutionInfoFinishedListener = sqlExecutionInfoFinishedListener;
+ }
}
Added: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecutionInfoFinishedListener.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecutionInfoFinishedListener.java (rev 0)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/SQLExecutionInfoFinishedListener.java 2012-02-15 21:23:22 UTC (rev 6579)
@@ -0,0 +1,6 @@
+package net.sourceforge.squirrel_sql.client.session;
+
+public interface SQLExecutionInfoFinishedListener
+{
+ void allProcessingComplete(SQLExecutionInfo sqlExecutionInfo);
+}
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/mainpanel/SQLExecutionHandler.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/mainpanel/SQLExecutionHandler.java 2012-02-15 19:54:16 UTC (rev 6578)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/mainpanel/SQLExecutionHandler.java 2012-02-15 21:23:22 UTC (rev 6579)
@@ -1,10 +1,7 @@
package net.sourceforge.squirrel_sql.client.session.mainpanel;
import net.sourceforge.squirrel_sql.client.preferences.SquirrelPreferences;
-import net.sourceforge.squirrel_sql.client.session.ISQLExecuterHandler;
-import net.sourceforge.squirrel_sql.client.session.ISession;
-import net.sourceforge.squirrel_sql.client.session.SQLExecuterTask;
-import net.sourceforge.squirrel_sql.client.session.SQLExecutionInfo;
+import net.sourceforge.squirrel_sql.client.session.*;
import net.sourceforge.squirrel_sql.client.session.event.ISQLExecutionListener;
import net.sourceforge.squirrel_sql.client.session.properties.SessionProperties;
import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetException;
@@ -220,17 +217,18 @@
* this method will track the total time when executing a large script,
* otherwise for small scripts it puts out a message for every statemselect * from employeeent.
*/
- public void sqlExecutionComplete(SQLExecutionInfo exInfo,
- int processedStatementCount,
- int statementCount)
+ public void sqlExecutionComplete(final SQLExecutionInfo exInfo,
+ final int processedStatementCount,
+ final int statementCount)
{
- double executionLength = ((double) exInfo.getSQLExecutionElapsedMillis()) / 1000;
- double outputLength = ((double) exInfo.getResultsProcessingElapsedMillis()) / 1000;
- double totalLength = executionLength + outputLength;
- Integer numberResultRowsRead = exInfo.getNumberResultRowsRead();
+ final Integer numberResultRowsRead = exInfo.getNumberResultRowsRead();
if (_largeScript)
{
+ double executionLength = ((double) exInfo.getSQLExecutionElapsedMillis()) / 1000;
+ double outputLength = ((double) exInfo.getResultsProcessingElapsedMillis()) / 1000;
+ double totalLength = executionLength + outputLength;
+
// Track the time in aggregate for the script.
_scriptQueryTime += executionLength;
_scriptOutptutTime += outputLength;
@@ -248,16 +246,42 @@
}
else
{
- printStatementExecTime(
- processedStatementCount,
- statementCount,
- numberResultRowsRead,
- executionLength,
- outputLength,
- totalLength);
+ exInfo.setFinishedListener(new SQLExecutionInfoFinishedListener()
+ {
+ @Override
+ public void allProcessingComplete(SQLExecutionInfo exInfo)
+ {
+ onAllProcessingComplete(exInfo, processedStatementCount, statementCount, numberResultRowsRead);
+ }
+ });
}
}
+ private void onAllProcessingComplete(SQLExecutionInfo exInfo, int processedStatementCount, int statementCount, Integer numberResultRowsRead)
+ {
+ double executionLength = ((double) exInfo.getSQLExecutionElapsedMillis()) / 1000;
+ double outputLength = ((double) exInfo.getResultsProcessingElapsedMillis()) / 1000;
+ double totalLength = executionLength + outputLength;
+
+ final NumberFormat nbrFmt = NumberFormat.getNumberInstance();
+
+ Object[] args = new Object[]{
+ Integer.valueOf(processedStatementCount),
+ Integer.valueOf(statementCount),
+ numberResultRowsRead == null ? 0 : numberResultRowsRead,
+ nbrFmt.format(totalLength),
+ nbrFmt.format(executionLength),
+ nbrFmt.format(outputLength)
+ };
+
+ //i18n[SQLResultExecuterPanel.queryStatistics=Query {0} of {1}
+ //elapsed time (seconds) - Total: {2}, SQL query: {3},
+ //Building output: {4}]
+ String stats = s_stringMgr.getString("SQLResultExecuterPanel.queryStatistics", args);
+
+ _session.showMessage(stats);
+ }
+
private void printScriptExecDetails(int statementCount,
double executionLength,
double outputLength,
@@ -292,33 +316,6 @@
_session.showMessage(stats);
}
- private void printStatementExecTime(
- int processedStatementCount,
- int statementCount,
- Integer numberResultRowsRead,
- double executionLength,
- double outputLength,
- double totalLength)
- {
- final NumberFormat nbrFmt = NumberFormat.getNumberInstance();
-
- Object[] args = new Object[]{
- Integer.valueOf(processedStatementCount),
- Integer.valueOf(statementCount),
- numberResultRowsRead == null ? 0 : numberResultRowsRead,
- nbrFmt.format(totalLength),
- nbrFmt.format(executionLength),
- nbrFmt.format(outputLength)
- };
-
- //i18n[SQLResultExecuterPanel.queryStatistics=Query {0} of {1}
- //elapsed time (seconds) - Total: {2}, SQL query: {3},
- //Building output: {4}]
- String stats = s_stringMgr.getString("SQLResultExecuterPanel.queryStatistics", args);
-
- _session.showMessage(stats);
- }
-
public void sqlExecutionCancelled()
{
if (rsds != null)
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/mainpanel/SQLResultExecuterPanel.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/mainpanel/SQLResultExecuterPanel.java 2012-02-15 19:54:16 UTC (rev 6578)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/mainpanel/SQLResultExecuterPanel.java 2012-02-15 21:23:22 UTC (rev 6579)
@@ -673,25 +673,22 @@
final IDataSetUpdateableTableModel creator,
final IResultTab resultTabToReplace)
{
- try
- {
-
- // Creating the resultTab must not be asynchronous. Otherwise, the Execution Info would be wrong
- final ResultTab tab = _resultTabFactory.createResultTab(exInfo, creator, rsds, mdds);
-
SwingUtilities.invokeLater(new Runnable()
{
- public void run()
- {
- addResultsTab(tab, resultTabToReplace);
- _tabbedExecutionsPanel.setSelectedComponent(tab);
- }
- });
- }catch (Throwable t)
- {
- _session.showErrorMessage(t);
- }
-
+ public void run()
+ {
+ try
+ {
+ ResultTab tab = _resultTabFactory.createResultTab(exInfo, creator, rsds, mdds);
+ addResultsTab(tab, resultTabToReplace);
+ _tabbedExecutionsPanel.setSelectedComponent(tab);
+ }
+ catch (Throwable t)
+ {
+ _session.showErrorMessage(t);
+ }
+ }
+ });
}
private void onRemoveCancelPanel(final CancelPanelCtrl cancelPanelCtrl, final IResultTab resultTabToReplace)
Modified: trunk/sql12/plugins/swingViolations/src/main/java/net/sourceforge/squirrel_sql/plugins/swingviolations/EDTViolationRepaintManager.java
===================================================================
--- trunk/sql12/plugins/swingViolations/src/main/java/net/sourceforge/squirrel_sql/plugins/swingviolations/EDTViolationRepaintManager.java 2012-02-15 19:54:16 UTC (rev 6578)
+++ trunk/sql12/plugins/swingViolations/src/main/java/net/sourceforge/squirrel_sql/plugins/swingviolations/EDTViolationRepaintManager.java 2012-02-15 21:23:22 UTC (rev 6579)
@@ -279,12 +279,9 @@
}
protected void violationFound(JComponent c, StackTraceElement[] stackTrace) {
- log.error("EDT violation detected!");
- log.error(c);
- for (StackTraceElement st : stackTrace) {
- log.error("\tat " + st);
- }
- app.getMessageHandler().showErrorMessage("EDT violation detected!");
+ String message = "EDT violation detected in " + c;
+ log.error(message, new RuntimeException(message));
+ app.getMessageHandler().showErrorMessage("EDT violation detected!");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|