1 19 20 package org.netbeans.modules.db.explorer.actions; 21 22 import org.netbeans.api.db.explorer.ConnectionManager; 23 import org.netbeans.modules.db.explorer.DatabaseConnection; 24 import org.netbeans.modules.db.explorer.infos.ConnectionNodeInfo; 25 import org.netbeans.modules.db.explorer.infos.DatabaseNodeInfo; 26 import org.netbeans.modules.db.explorer.sql.editor.SQLEditorSupport; 27 import org.openide.nodes.Node; 28 29 public class ExecuteCommandAction extends DatabaseAction { 30 31 protected boolean enable(Node[] activatedNodes) { 32 Node node; 33 if (activatedNodes != null && activatedNodes.length == 1) 34 node = activatedNodes[0]; 35 else 36 return false; 37 38 ConnectionNodeInfo info = (ConnectionNodeInfo)node.getCookie(ConnectionNodeInfo.class); 39 if (info != null) 40 return (info.getConnection() != null); 41 42 return true; 43 } 44 45 public void performAction (Node[] activatedNodes) { 46 if (activatedNodes != null && activatedNodes.length > 0) { 47 Node node = activatedNodes[0]; 48 DatabaseNodeInfo info = (DatabaseNodeInfo)node.getCookie(DatabaseNodeInfo.class); 49 String name = ((DatabaseConnection)info.getDatabaseConnection()).getName(); 50 SQLEditorSupport.openSQLEditor(ConnectionManager.getDefault().getConnection(name), "", false); } 52 } 53 } 54 | Popular Tags |