This is an automated email from the ASF dual-hosted git repository.

matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 1867e8a  [NETBEANS-3909] SQL Execution should reuse Output Window if 
possible
     new 71a1de5  Merge pull request #1962 from matthiasblaesing/netbeans-3909
1867e8a is described below

commit 1867e8ada9b3587e2f2d103116ca0d9e91c1bc4f
Author: Matthias Bläsing <mblaes...@doppel-helix.eu>
AuthorDate: Sat Feb 22 17:32:32 2020 +0100

    [NETBEANS-3909] SQL Execution should reuse Output Window if possible
    
    When executing an SQL statement, each time a new exection is started by
    the user a new output windows is created. This quickly clutters the
    output window pane. Instead of this it would be better to reuse the
    existings output window.
---
 .../modules/db/sql/loader/SQLEditorSupport.java    | 22 ++++++++++++----------
 .../db/sql/loader/SQLExecutionLoggerImpl.java      |  3 ++-
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git 
a/ide/db.core/src/org/netbeans/modules/db/sql/loader/SQLEditorSupport.java 
b/ide/db.core/src/org/netbeans/modules/db/sql/loader/SQLEditorSupport.java
index c7e245c..7e293b1 100644
--- a/ide/db.core/src/org/netbeans/modules/db/sql/loader/SQLEditorSupport.java
+++ b/ide/db.core/src/org/netbeans/modules/db/sql/loader/SQLEditorSupport.java
@@ -465,18 +465,19 @@ public class SQLEditorSupport extends DataEditorSupport
         ConnectionManager.getDefault().refreshConnectionInExplorer(dbconn);
     }
     
-    private SQLExecutionLoggerImpl createLogger() {
+    private SQLExecutionLoggerImpl getOrCreateLogger() {
         synchronized (loggerLock) {
-            closeLogger();
-
-            String loggerDisplayName;
-            if (isConsole()) {
-                loggerDisplayName = getDataObject().getName();
-            } else {
-                loggerDisplayName = 
getDataObject().getNodeDelegate().getDisplayName();
+            if (logger == null) {
+                String loggerDisplayName;
+                if (isConsole()) {
+                    loggerDisplayName = getDataObject().getName();
+                } else {
+                    loggerDisplayName = 
getDataObject().getNodeDelegate().getDisplayName();
+                }
+                logger = new SQLExecutionLoggerImpl(loggerDisplayName, this);
             }
 
-            return new SQLExecutionLoggerImpl(loggerDisplayName, this);
+            return logger;
         }
     }
     
@@ -484,6 +485,7 @@ public class SQLEditorSupport extends DataEditorSupport
         synchronized (loggerLock) {
             if (logger != null) {
                 logger.close();
+                logger = null;
             }
         }
     }
@@ -586,7 +588,7 @@ public class SQLEditorSupport extends DataEditorSupport
                     }
                     parent.closeExecutionResult();
 
-                    SQLExecutionLoggerImpl logger = parent.createLogger();
+                    SQLExecutionLoggerImpl logger = parent.getOrCreateLogger();
                     SQLExecutionResults executionResults = 
SQLExecuteHelper.execute(
                             sql, startOffset, endOffset, dbconn, logger, 
pageSize);
                     handleExecutionResults(executionResults, logger);
diff --git 
a/ide/db.core/src/org/netbeans/modules/db/sql/loader/SQLExecutionLoggerImpl.java
 
b/ide/db.core/src/org/netbeans/modules/db/sql/loader/SQLExecutionLoggerImpl.java
index 3869c70..6c65fc5 100644
--- 
a/ide/db.core/src/org/netbeans/modules/db/sql/loader/SQLExecutionLoggerImpl.java
+++ 
b/ide/db.core/src/org/netbeans/modules/db/sql/loader/SQLExecutionLoggerImpl.java
@@ -47,7 +47,7 @@ public class SQLExecutionLoggerImpl implements 
SQLExecutionLogger {
     private int errorCount;
 
     @NbBundle.Messages({
-        "# {0} - the name of the executed SQL file", 
+        "# {0} - the name of the executed SQL file",
         "LBL_SQLFileExecution={0} execution"})
     public SQLExecutionLoggerImpl(String displayName, LineCookie lineCookie) {
         this.lineCookie = lineCookie;
@@ -81,6 +81,7 @@ public class SQLExecutionLoggerImpl implements 
SQLExecutionLogger {
             writer.println(LBL_ExecutionFinished(
                     executionTime / 1000d,
                     errorCount));
+            writer.println("");
         }
         inputOutput.select();
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to