# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/matthias/NetBeansProjects/core-main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: db/src/org/netbeans/modules/db/explorer/action/ExecuteCommandAction.java --- db/src/org/netbeans/modules/db/explorer/action/ExecuteCommandAction.java +++ db/src/org/netbeans/modules/db/explorer/action/ExecuteCommandAction.java @@ -42,6 +42,8 @@ package org.netbeans.modules.db.explorer.action; +import java.util.HashSet; +import java.util.Set; import org.netbeans.modules.db.explorer.DatabaseConnection; import org.netbeans.modules.db.explorer.sql.editor.SQLEditorSupport; import org.openide.nodes.Node; @@ -49,30 +51,34 @@ import org.openide.util.NbBundle; /** + * Open an sql editor as an sql console. * * @author Rob Englander */ public class ExecuteCommandAction extends BaseAction { - + @Override protected boolean enable(Node[] activatedNodes) { - if (activatedNodes == null || activatedNodes.length != 1) { - return false; + return true; // This action is always enabled } - boolean enabled = false; - DatabaseConnection dbconn = activatedNodes[0].getLookup().lookup(DatabaseConnection.class); - - if (dbconn != null) { - enabled = DatabaseConnection.isVitalConnection(dbconn.getConnection(), dbconn); + @Override + public void performAction (Node[] activatedNodes) { + // If exactly one DatabaseConnection can be detected via the activated + // nodes, that database connection is set as the default connection + Set dbconnSet = new HashSet<>(); + if (activatedNodes != null) { + for (Node node : activatedNodes) { + DatabaseConnection dbconn = node.getLookup().lookup(DatabaseConnection.class); + if(dbconn != null) { + dbconnSet.add(dbconn); } - - return enabled; } - - public void performAction (Node[] activatedNodes) { - if (activatedNodes != null && activatedNodes.length == 1) { - DatabaseConnection dbconn = activatedNodes[0].getLookup().lookup(DatabaseConnection.class); + } + if(dbconnSet.size() == 1) { + DatabaseConnection dbconn = dbconnSet.iterator().next(); SQLEditorSupport.openSQLEditor(dbconn.getDatabaseConnection(), "", false); // NOI18N + } else { + SQLEditorSupport.openSQLEditor(null, "", false); // NOI18N } } Index: db/src/org/netbeans/modules/db/resources/mf-layer.xml --- db/src/org/netbeans/modules/db/resources/mf-layer.xml +++ db/src/org/netbeans/modules/db/resources/mf-layer.xml @@ -45,7 +45,20 @@ --> + + + + + + + + + + + + + @@ -134,7 +147,8 @@ - + + @@ -231,7 +245,8 @@ - + + @@ -252,7 +267,8 @@ - + + @@ -286,7 +302,8 @@ - + + @@ -339,7 +356,8 @@ - + + @@ -363,7 +381,8 @@ - + + @@ -389,7 +408,8 @@ - + + @@ -420,7 +440,8 @@ - + + @@ -441,7 +462,8 @@ - + + @@ -466,7 +488,8 @@ - + + @@ -484,7 +507,8 @@ - + + @@ -517,7 +541,8 @@ - + + @@ -534,7 +559,8 @@ - + + @@ -553,7 +579,8 @@ - + + @@ -574,7 +601,8 @@ - + + @@ -587,7 +615,8 @@ - + +