- use annotations instead of layer.xml release701
authorchrislovsund@netbeans.org
Mon, 13 Feb 2012 21:41:10 +0100
branchrelease701
changeset 1641adaff0cc2f4
parent 163 ed464a4179e1
child 165 3a2a9a082157
- use annotations instead of layer.xml
- general cleanup
PLSQL/Execution/nbproject/project.properties
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/CopyAsJavaStringAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/CreateTestBlockAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/DescribeAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PasteAsSqlCommandAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlCommitAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutableObject.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecuteAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutionHistoryAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutionHistoryNextAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutionHistoryPreviousAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExplainPlanAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlMultipleExecuteAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlRollbackAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlSaveCommandAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/ViewDataAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/actions/DeploySelectedCodeAction.java
PLSQL/Execution/src/org/netbeans/modules/plsql/execution/layer.xml
Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/ui/SQLExecutionAction.java
nbproject/genfiles.properties
     1.1 --- a/PLSQL/Execution/nbproject/project.properties	Mon Feb 13 18:37:52 2012 +0100
     1.2 +++ b/PLSQL/Execution/nbproject/project.properties	Mon Feb 13 21:41:10 2012 +0100
     1.3 @@ -1,2 +1,9 @@
     1.4 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
     1.5 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
     1.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
     1.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
     1.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
     1.9 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
    1.10 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
    1.11  javac.source=1.6
    1.12  javac.compilerargs=-Xlint -Xlint:-serial
     2.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/CopyAsJavaStringAction.java	Mon Feb 13 18:37:52 2012 +0100
     2.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/CopyAsJavaStringAction.java	Mon Feb 13 21:41:10 2012 +0100
     2.3 @@ -46,6 +46,9 @@
     2.4  import javax.swing.JEditorPane;
     2.5  import javax.swing.text.BadLocationException;
     2.6  import javax.swing.text.Document;
     2.7 +import org.openide.awt.ActionID;
     2.8 +import org.openide.awt.ActionReference;
     2.9 +import org.openide.awt.ActionRegistration;
    2.10  import org.openide.cookies.EditorCookie;
    2.11  import org.openide.loaders.DataObject;
    2.12  import org.openide.nodes.Node;
    2.13 @@ -56,6 +59,9 @@
    2.14  import org.openide.util.actions.CookieAction;
    2.15  import org.openide.util.datatransfer.ExClipboard;
    2.16  
    2.17 +@ActionID(id = "org.netbeans.modules.plsql.execution.CopyAsJavaStringAction", category = "PLSQL")
    2.18 +@ActionRegistration(displayName = "#CTL_CopyAsJavaStringAction")
    2.19 +@ActionReference(path = "Editors/text/x-plsql/Popup", position = 285)
    2.20  public class CopyAsJavaStringAction extends CookieAction {
    2.21  
    2.22      @Override
     3.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/CreateTestBlockAction.java	Mon Feb 13 18:37:52 2012 +0100
     3.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/CreateTestBlockAction.java	Mon Feb 13 21:41:10 2012 +0100
     3.3 @@ -66,6 +66,10 @@
     3.4  import org.netbeans.api.lexer.TokenSequence;
     3.5  import org.netbeans.api.project.FileOwnerQuery;
     3.6  import org.netbeans.api.project.Project;
     3.7 +import org.openide.awt.ActionID;
     3.8 +import org.openide.awt.ActionReference;
     3.9 +import org.openide.awt.ActionReferences;
    3.10 +import org.openide.awt.ActionRegistration;
    3.11  import org.openide.cookies.EditorCookie;
    3.12  import org.openide.loaders.DataObject;
    3.13  import org.openide.nodes.Node;
    3.14 @@ -76,6 +80,11 @@
    3.15  import org.openide.util.actions.CookieAction;
    3.16  import org.openide.windows.WindowManager;
    3.17  
    3.18 +@ActionID(id = "org.netbeans.modules.plsql.execution.CreateTestBlockAction", category = "PLSQL")
    3.19 +@ActionRegistration(displayName = "#CTL_CreateTestBlockAction")
    3.20 +@ActionReferences(value = {
    3.21 +   @ActionReference(path = "Shortcuts", name = "AS-B"),
    3.22 +   @ActionReference(path = "Editors/text/x-plsql/Popup", position = 281)})
    3.23  public final class CreateTestBlockAction extends CookieAction {
    3.24  
    3.25      private static final PlsqlFileValidatorService validator = Lookup.getDefault().lookup(PlsqlFileValidatorService.class);
     4.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/DescribeAction.java	Mon Feb 13 18:37:52 2012 +0100
     4.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/DescribeAction.java	Mon Feb 13 21:41:10 2012 +0100
     4.3 @@ -47,8 +47,9 @@
     4.4  import java.util.List;
     4.5  import javax.swing.text.Document;
     4.6  import org.netbeans.api.db.explorer.DatabaseConnection;
     4.7 -import org.netbeans.api.project.FileOwnerQuery;
     4.8 -import org.netbeans.api.project.Project;
     4.9 +import org.openide.awt.ActionID;
    4.10 +import org.openide.awt.ActionReference;
    4.11 +import org.openide.awt.ActionRegistration;
    4.12  import org.openide.cookies.EditorCookie;
    4.13  import org.openide.loaders.DataObject;
    4.14  import org.openide.nodes.Node;
    4.15 @@ -61,6 +62,9 @@
    4.16   *
    4.17   * @author YADHLK
    4.18   */
    4.19 +@ActionID(id = "org.netbeans.modules.plsql.execution.DescribeAction", category = "PLSQL")
    4.20 +@ActionRegistration(displayName = "#CTL_DescribeAction")
    4.21 +@ActionReference(path = "Editors/text/x-plsql/Popup", position = 283)
    4.22  public class DescribeAction extends CookieAction {
    4.23  
    4.24     private String viewName = null;
    4.25 @@ -78,7 +82,6 @@
    4.26     @Override
    4.27     protected void performAction(Node[] activatedNodes) {
    4.28        DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
    4.29 -      Project project = FileOwnerQuery.getOwner(dataObject.getPrimaryFile());
    4.30        EditorCookie ec = dataObject.getCookie(EditorCookie.class);
    4.31        final Document doc = ec.getDocument();
    4.32        final DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
    4.33 @@ -117,10 +120,10 @@
    4.34        return HelpCtx.DEFAULT_HELP;
    4.35     }
    4.36  
    4.37 +   @Override
    4.38     protected boolean enable(Node[] activatedNodes) {
    4.39        viewName = null;
    4.40  
    4.41 -      Project project = null;
    4.42        if (!super.enable(activatedNodes)) {
    4.43           return false;
    4.44        }
     5.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PasteAsSqlCommandAction.java	Mon Feb 13 18:37:52 2012 +0100
     5.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PasteAsSqlCommandAction.java	Mon Feb 13 21:41:10 2012 +0100
     5.3 @@ -45,9 +45,6 @@
     5.4  import java.awt.datatransfer.DataFlavor;
     5.5  import java.awt.datatransfer.Transferable;
     5.6  import java.awt.datatransfer.UnsupportedFlavorException;
     5.7 -import java.io.IOException;
     5.8 -import java.util.regex.Matcher;
     5.9 -import java.util.regex.Pattern;
    5.10  import javax.swing.JEditorPane;
    5.11  import javax.swing.text.BadLocationException;
    5.12  import javax.swing.text.Caret;
    5.13 @@ -55,6 +52,9 @@
    5.14  import javax.swing.text.JTextComponent;
    5.15  import org.netbeans.lib.editor.codetemplates.api.CodeTemplate;
    5.16  import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager;
    5.17 +import org.openide.awt.ActionID;
    5.18 +import org.openide.awt.ActionReference;
    5.19 +import org.openide.awt.ActionRegistration;
    5.20  import org.openide.cookies.EditorCookie;
    5.21  import org.openide.loaders.DataObject;
    5.22  import org.openide.nodes.Node;
    5.23 @@ -65,6 +65,9 @@
    5.24  import org.openide.util.actions.CookieAction;
    5.25  import org.openide.util.datatransfer.ExClipboard;
    5.26  
    5.27 +@ActionID(id = "org.netbeans.modules.plsql.execution.PasteAsSqlCommandAction", category = "PLSQL")
    5.28 +@ActionRegistration(displayName = "#CTL_PasteAsSqlCommandAction")
    5.29 +@ActionReference(path = "Editors/text/x-plsql/Popup", position = 286)
    5.30  public class PasteAsSqlCommandAction extends CookieAction {
    5.31  
    5.32      @Override
     6.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlCommitAction.java	Mon Feb 13 18:37:52 2012 +0100
     6.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlCommitAction.java	Mon Feb 13 21:41:10 2012 +0100
     6.3 @@ -41,7 +41,6 @@
     6.4   */
     6.5  package org.netbeans.modules.plsql.execution;
     6.6  
     6.7 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
     6.8  import java.awt.Component;
     6.9  import java.awt.event.ActionEvent;
    6.10  import java.awt.image.BufferedImage;
    6.11 @@ -49,15 +48,20 @@
    6.12  import java.util.Arrays;
    6.13  import java.util.List;
    6.14  import java.util.Locale;
    6.15 +
    6.16  import javax.swing.AbstractAction;
    6.17  import javax.swing.Action;
    6.18  import javax.swing.ImageIcon;
    6.19  import javax.swing.JButton;
    6.20  import javax.swing.text.Document;
    6.21 +
    6.22  import org.netbeans.api.db.explorer.DatabaseConnection;
    6.23  import org.netbeans.api.progress.ProgressHandle;
    6.24  import org.netbeans.api.progress.ProgressHandleFactory;
    6.25 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
    6.26  import org.netbeans.modules.plsqlsupport.options.OptionsUtilities;
    6.27 +import org.openide.awt.ActionID;
    6.28 +import org.openide.awt.ActionRegistration;
    6.29  import org.openide.awt.DropDownButtonFactory;
    6.30  import org.openide.cookies.EditorCookie;
    6.31  import org.openide.cookies.SaveCookie;
    6.32 @@ -71,6 +75,9 @@
    6.33  import org.openide.util.actions.Presenter;
    6.34  import org.openide.windows.IOProvider;
    6.35  import org.openide.windows.InputOutput;
    6.36 +
    6.37 +@ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlCommitAction", category = "PLSQL")
    6.38 +@ActionRegistration(displayName = "#CTL_PlsqlCommit")
    6.39  public class PlsqlCommitAction extends AbstractAction implements ContextAwareAction, Presenter.Toolbar {
    6.40  
    6.41      private static final List<String> EXTENSIONS = Arrays.asList(new String[]{"tdb"});
    6.42 @@ -82,7 +89,6 @@
    6.43  
    6.44      public PlsqlCommitAction() {
    6.45          this(Utilities.actionsGlobalContext());
    6.46 -
    6.47      }
    6.48  
    6.49      public PlsqlCommitAction(Lookup context) {
    6.50 @@ -112,9 +118,9 @@
    6.51          } else {
    6.52              setEnabled(false);
    6.53          }
    6.54 -
    6.55      }
    6.56  
    6.57 +    @Override
    6.58      public Action createContextAwareInstance(Lookup context) {
    6.59          return new PlsqlCommitAction(context);
    6.60  
    6.61 @@ -125,17 +131,20 @@
    6.62              connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
    6.63          }
    6.64  
    6.65 -         connection = dataObject.getLookup().lookup(DatabaseConnection.class);
    6.66 +        connection = dataObject.getLookup().lookup(DatabaseConnection.class);
    6.67      }
    6.68  
    6.69 +    @Override
    6.70      public void actionPerformed(ActionEvent event) {
    6.71  
    6.72          prepareConnection();
    6.73 -        if (connectionProvider == null || connection == null)
    6.74 +        if (connectionProvider == null || connection == null) {
    6.75              return;
    6.76 +        }
    6.77  
    6.78 -        if(!connectionProvider.hasDataToCommit(connection))
    6.79 +        if (!connectionProvider.hasDataToCommit(connection)) {
    6.80              return;
    6.81 +        }
    6.82  
    6.83          EditorCookie edCookie = dataObject.getLookup().lookup(EditorCookie.class);
    6.84          Document document = edCookie.getDocument();
    6.85 @@ -148,20 +157,23 @@
    6.86  
    6.87          try {
    6.88              io = IOProvider.getDefault().getIO(obj.getPrimaryFile().getNameExt(), false);
    6.89 -            if(!io.isClosed())
    6.90 +            if (!io.isClosed()) {
    6.91                  io.getOut().println((new StringBuilder()).append("> Commit Statement successfully"));
    6.92 +            }
    6.93  
    6.94 -                if(connection.getJDBCConnection()!=null)
    6.95 -                  connectionProvider.commitRollbackTransactions(connection, true);
    6.96 +            if (connection.getJDBCConnection() != null) {
    6.97 +                connectionProvider.commitRollbackTransactions(connection, true);
    6.98 +            }
    6.99  
   6.100          } catch (Exception ex) {
   6.101 -           io.getOut().println((new StringBuilder()).append(">!!! Error Commit Statement"));
   6.102 -           Exceptions.printStackTrace(ex);
   6.103 +            io.getOut().println((new StringBuilder()).append(">!!! Error Commit Statement"));
   6.104 +            Exceptions.printStackTrace(ex);
   6.105          } finally {
   6.106              handle.finish();
   6.107          }
   6.108      }
   6.109  
   6.110 +    @Override
   6.111      public Component getToolbarPresenter() {
   6.112          if (!isEnabled()) {
   6.113              return null;
   6.114 @@ -175,10 +187,6 @@
   6.115          return button;
   6.116      }
   6.117  
   6.118 -    private void updateButton() {
   6.119 -          button.setEnabled(true);
   6.120 -    }
   6.121 -
   6.122      private void saveIfModified(DataObject dataObj) {
   6.123          try {
   6.124              SaveCookie saveCookie = dataObj.getCookie(SaveCookie.class);
     7.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutableObject.java	Mon Feb 13 18:37:52 2012 +0100
     7.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutableObject.java	Mon Feb 13 21:41:10 2012 +0100
     7.3 @@ -45,65 +45,61 @@
     7.4  
     7.5  public class PlsqlExecutableObject {
     7.6  
     7.7 -   public PlsqlExecutableObject() {
     7.8 -   }
     7.9 +    public PlsqlExecutableObject(int startLineNo, String plsqlString, String name,
    7.10 +            PlsqlExecutableObjectType type, int startOffset, int endOffset) {
    7.11 +        this.startLineNo = startLineNo;
    7.12 +        this.plsqlString = plsqlString;
    7.13 +        this.executableObjName = name;
    7.14 +        this.type = type;
    7.15 +        this.startOffset = startOffset;
    7.16 +        this.endoffset = endOffset;
    7.17 +    }
    7.18  
    7.19 -   public PlsqlExecutableObject(int startLineNo, String plsqlString, String name, 
    7.20 -           PlsqlExecutableObjectType type, int startOffset, int endOffset) {
    7.21 -      this.startLineNo = startLineNo;
    7.22 -      this.plsqlString = plsqlString;
    7.23 -      this.executableObjName = name;
    7.24 -      this.type = type;
    7.25 -      this.startOffset = startOffset;
    7.26 -      this.endoffset = endOffset;
    7.27 -   }
    7.28 +    public String getPlsqlString() {
    7.29 +        return plsqlString;
    7.30 +    }
    7.31  
    7.32 -   public String getPlsqlString() {
    7.33 -      return plsqlString;
    7.34 -   }
    7.35 +    public int getStartLineNo() {
    7.36 +        return startLineNo;
    7.37 +    }
    7.38  
    7.39 -   public int getStartLineNo() {
    7.40 -      return startLineNo;
    7.41 -   }
    7.42 +    public PlsqlExecutableObjectType getType() {
    7.43 +        return type;
    7.44 +    }
    7.45  
    7.46 -   public PlsqlExecutableObjectType getType() {
    7.47 -      return type;
    7.48 -   }
    7.49 +    public String getExecutableObjName() {
    7.50 +        return executableObjName;
    7.51 +    }
    7.52  
    7.53 -   public String getExecutableObjName() {
    7.54 -      return executableObjName;
    7.55 -   }
    7.56 +    public List getDocLinesArray() {
    7.57 +        return docLinesArray;
    7.58 +    }
    7.59  
    7.60 -   public List getDocLinesArray() {
    7.61 -      return docLinesArray;
    7.62 -   }
    7.63 +    public void setDocLinesArray(List docLinesArray) {
    7.64 +        this.docLinesArray = docLinesArray;
    7.65 +    }
    7.66  
    7.67 -   public void setDocLinesArray(List docLinesArray) {
    7.68 -      this.docLinesArray = docLinesArray;
    7.69 -   }
    7.70 +    public void setOriginalFileName(String originalFileName) {
    7.71 +        this.originalFileName = originalFileName;
    7.72 +    }
    7.73  
    7.74 -   public void setOriginalFileName(String originalFileName) {
    7.75 -      this.originalFileName = originalFileName;
    7.76 -   }
    7.77 +    public String getOriginalFileName() {
    7.78 +        return originalFileName;
    7.79 +    }
    7.80  
    7.81 -   public String getOriginalFileName() {
    7.82 -      return originalFileName;
    7.83 -   }
    7.84 -   
    7.85 -   public int getStartOffset() {
    7.86 -      return startOffset;
    7.87 -   }
    7.88 -   
    7.89 -   public int getEndOffset() {
    7.90 -      return endoffset;
    7.91 -   }
    7.92 -   
    7.93 -   private String plsqlString;
    7.94 -   private int startLineNo;
    7.95 -   private int startOffset;
    7.96 -   private int endoffset;
    7.97 -   private PlsqlExecutableObjectType type;
    7.98 -   private String executableObjName;
    7.99 -   private List docLinesArray;
   7.100 -   private String originalFileName;
   7.101 +    public int getStartOffset() {
   7.102 +        return startOffset;
   7.103 +    }
   7.104 +
   7.105 +    public int getEndOffset() {
   7.106 +        return endoffset;
   7.107 +    }
   7.108 +    private String plsqlString;
   7.109 +    private int startLineNo;
   7.110 +    private int startOffset;
   7.111 +    private int endoffset;
   7.112 +    private PlsqlExecutableObjectType type;
   7.113 +    private String executableObjName;
   7.114 +    private List docLinesArray;
   7.115 +    private String originalFileName;
   7.116  }
     8.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecuteAction.java	Mon Feb 13 18:37:52 2012 +0100
     8.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecuteAction.java	Mon Feb 13 21:41:10 2012 +0100
     8.3 @@ -41,9 +41,6 @@
     8.4   */
     8.5  package org.netbeans.modules.plsql.execution;
     8.6  
     8.7 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
     8.8 -import org.netbeans.modules.plsql.filetype.PlsqlDataObject;
     8.9 -import org.netbeans.modules.plsql.utilities.PlsqlFileValidatorService;
    8.10  import java.awt.Component;
    8.11  import java.awt.event.ActionEvent;
    8.12  import java.awt.event.ActionListener;
    8.13 @@ -58,6 +55,7 @@
    8.14  import java.util.ArrayList;
    8.15  import java.util.List;
    8.16  import java.util.Locale;
    8.17 +
    8.18  import javax.swing.AbstractAction;
    8.19  import javax.swing.Action;
    8.20  import javax.swing.ImageIcon;
    8.21 @@ -69,10 +67,17 @@
    8.22  import javax.swing.event.PopupMenuEvent;
    8.23  import javax.swing.event.PopupMenuListener;
    8.24  import javax.swing.text.Document;
    8.25 +
    8.26  import org.netbeans.api.db.explorer.DatabaseConnection;
    8.27  import org.netbeans.api.progress.ProgressHandle;
    8.28  import org.netbeans.api.progress.ProgressHandleFactory;
    8.29 +import org.netbeans.modules.plsql.filetype.PlsqlDataObject;
    8.30 +import org.netbeans.modules.plsql.utilities.PlsqlFileValidatorService;
    8.31 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
    8.32  import org.netbeans.modules.plsqlsupport.options.OptionsUtilities;
    8.33 +import org.openide.awt.ActionID;
    8.34 +import org.openide.awt.ActionReference;
    8.35 +import org.openide.awt.ActionRegistration;
    8.36  import org.openide.awt.DropDownButtonFactory;
    8.37  import org.openide.cookies.EditorCookie;
    8.38  import org.openide.cookies.SaveCookie;
    8.39 @@ -88,336 +93,339 @@
    8.40  import org.openide.util.Utilities;
    8.41  import org.openide.util.actions.Presenter;
    8.42  
    8.43 +@ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlExecuteAction", category = "PLSQL")
    8.44 +@ActionRegistration(displayName = "#CTL_fileExecution")
    8.45 +@ActionReference(path = "Shortcuts", name = "AS-E")
    8.46  public class PlsqlExecuteAction extends AbstractAction implements ContextAwareAction, Presenter.Toolbar {
    8.47  
    8.48 -    private static final PlsqlFileValidatorService validator = Lookup.getDefault().lookup(PlsqlFileValidatorService.class);
    8.49 -    private static final String DATABASE_CONNECTION_KEY = "databaseConnection";
    8.50 -    private static final String TEST_BLOCK_NAME_PREFIX = "TestBlock:";
    8.51 -    private DataObject dataObject;
    8.52 -    private PlsqlDataObject plsqlDataobject;
    8.53 -    private DatabaseConnectionManager connectionProvider;
    8.54 -    private DatabaseConnection connection;
    8.55 -    private PopupMenuPopulator popupMenuPopulator = null;
    8.56 -    private JPopupMenu popup;
    8.57 -    private JButton button;
    8.58 -    private ActionListener buttonListener = new ButtonListener();
    8.59 -    private boolean autoCommit = true;
    8.60 +   private static final PlsqlFileValidatorService validator = Lookup.getDefault().lookup(PlsqlFileValidatorService.class);
    8.61 +   private static final String DATABASE_CONNECTION_KEY = "databaseConnection";
    8.62 +   private static final String TEST_BLOCK_NAME_PREFIX = "TestBlock:";
    8.63 +   private DataObject dataObject;
    8.64 +   private PlsqlDataObject plsqlDataobject;
    8.65 +   private DatabaseConnectionManager connectionProvider;
    8.66 +   private DatabaseConnection connection;
    8.67 +   private PopupMenuPopulator popupMenuPopulator = null;
    8.68 +   private JPopupMenu popup;
    8.69 +   private JButton button;
    8.70 +   private ActionListener buttonListener = new ButtonListener();
    8.71 +   private boolean autoCommit = true;
    8.72  
    8.73 -    public PlsqlExecuteAction() {
    8.74 -        this(Utilities.actionsGlobalContext());
    8.75 -    }
    8.76 +   public PlsqlExecuteAction() {
    8.77 +      this(Utilities.actionsGlobalContext());
    8.78 +   }
    8.79  
    8.80 -    public PlsqlExecuteAction(Lookup context) {
    8.81 -        putValue(NAME, NbBundle.getMessage(PlsqlExecuteAction.class, "CTL_fileExecution"));
    8.82 -        putValue(SHORT_DESCRIPTION, NbBundle.getMessage(PlsqlExecuteAction.class, "CTL_fileExecution"));
    8.83 -        putValue(SMALL_ICON, new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/plsql/execution/execute.png")));
    8.84 +   public PlsqlExecuteAction(Lookup context) {
    8.85 +      putValue(NAME, NbBundle.getMessage(PlsqlExecuteAction.class, "CTL_fileExecution"));
    8.86 +      putValue(SHORT_DESCRIPTION, NbBundle.getMessage(PlsqlExecuteAction.class, "CTL_fileExecution"));
    8.87 +      putValue(SMALL_ICON, new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/plsql/execution/execute.png")));
    8.88  
    8.89 -        dataObject = context.lookup(DataObject.class);
    8.90 +      dataObject = context.lookup(DataObject.class);
    8.91  
    8.92 -        //Enable execution for .spec .body files in workspace (copied using 'Copy to Workspace Folder')
    8.93 -        if (dataObject != null && (validator.isValidPackageDefault(dataObject)
    8.94 -                || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("db"))) {
    8.95 -            if (!dataObject.getPrimaryFile().canWrite()) {
    8.96 -                dataObject = null;
    8.97 +      //Enable execution for .spec .body files in workspace (copied using 'Copy to Workspace Folder')
    8.98 +      if (dataObject != null && (validator.isValidPackageDefault(dataObject)
    8.99 +              || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("db"))) {
   8.100 +         if (!dataObject.getPrimaryFile().canWrite()) {
   8.101 +            dataObject = null;
   8.102 +         }
   8.103 +      }
   8.104 +
   8.105 +      if (dataObject != null && dataObject.getLookup().lookup(EditorCookie.class) == null) {
   8.106 +         dataObject = null;
   8.107 +      }
   8.108 +
   8.109 +      setEnabled(dataObject != null);
   8.110 +      if (validator.isValidTDB(dataObject)) {
   8.111 +         autoCommit = OptionsUtilities.isCommandWindowAutoCommitEnabled();
   8.112 +      }
   8.113 +   }
   8.114 +
   8.115 +   @Override
   8.116 +   public Action createContextAwareInstance(Lookup context) {
   8.117 +      return new PlsqlExecuteAction(context);
   8.118 +   }
   8.119 +
   8.120 +   private void prepareConnection() {
   8.121 +      if (dataObject != null) {
   8.122 +         connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
   8.123 +         if (connectionProvider != null) {
   8.124 +            if (popupMenuPopulator == null) {
   8.125 +               popupMenuPopulator = new PopupMenuPopulator();
   8.126 +               connectionProvider.addPropertyChangeListener(popupMenuPopulator);
   8.127              }
   8.128 -        }
   8.129 +         }
   8.130 +      }
   8.131 +   }
   8.132  
   8.133 -        if (dataObject != null && dataObject.getLookup().lookup(EditorCookie.class) == null) {
   8.134 -            dataObject = null;
   8.135 -        }
   8.136 +   @Override
   8.137 +   public void actionPerformed(ActionEvent event) {
   8.138 +      if (connectionProvider == null) {
   8.139 +         prepareConnection();
   8.140 +      }
   8.141 +      if (connectionProvider == null) {
   8.142 +         return;
   8.143 +      }
   8.144  
   8.145 -        setEnabled(dataObject != null);
   8.146 -        if (validator.isValidTDB(dataObject)) {
   8.147 -            autoCommit = OptionsUtilities.isCommandWindowAutoCommitEnabled();
   8.148 -        }
   8.149 -    }
   8.150 +      // If autocommit OFF - take the connection from data object.
   8.151 +      if (!autoCommit) {
   8.152 +         connection = dataObject.getLookup().lookup(DatabaseConnection.class);
   8.153 +      }
   8.154  
   8.155 -    @Override
   8.156 -    public Action createContextAwareInstance(Lookup context) {
   8.157 -        return new PlsqlExecuteAction(context);
   8.158 -    }
   8.159 +      if (connection == null) {
   8.160 +         connection = connectionProvider.getTemplateConnection();
   8.161 +      }
   8.162  
   8.163 -    private void prepareConnection() {
   8.164 -        if (dataObject != null) {
   8.165 -            connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
   8.166 -            if (connectionProvider != null) {
   8.167 -                if (popupMenuPopulator == null) {
   8.168 -                    popupMenuPopulator = new PopupMenuPopulator();
   8.169 -                    connectionProvider.addPropertyChangeListener(popupMenuPopulator);
   8.170 -                }
   8.171 +      if (connection == null) {
   8.172 +         return;
   8.173 +      }
   8.174 +      saveAndExecute();
   8.175 +   }
   8.176 +
   8.177 +   @Override
   8.178 +   public Component getToolbarPresenter() {
   8.179 +      if (!isEnabled()) {
   8.180 +         return null;
   8.181 +      }
   8.182 +
   8.183 +      popup = new JPopupMenu();
   8.184 +      if (connectionProvider == null) {
   8.185 +         prepareConnection();
   8.186 +      }
   8.187 +
   8.188 +      if (connectionProvider != null) {
   8.189 +         populatePopupMenu();
   8.190 +      }
   8.191 +
   8.192 +      button = DropDownButtonFactory.createDropDownButton(
   8.193 +              new ImageIcon(new BufferedImage(32, 32, BufferedImage.TYPE_BYTE_GRAY)), popup);
   8.194 +      button.setAction(this);
   8.195 +      button.addItemListener(new ItemListener() {
   8.196 +
   8.197 +         @Override
   8.198 +         public void itemStateChanged(ItemEvent e) {
   8.199 +            if (e.getStateChange() == ItemEvent.SELECTED) {
   8.200 +               popup.show(button, 0, button.getHeight());
   8.201              }
   8.202 -        }
   8.203 -    }
   8.204 +         }
   8.205 +      });
   8.206  
   8.207 -    @Override
   8.208 -    public void actionPerformed(ActionEvent event) {
   8.209 -        if (connectionProvider == null) {
   8.210 -            prepareConnection();
   8.211 -        }
   8.212 -        if (connectionProvider == null) {
   8.213 -            return;
   8.214 -        }
   8.215 +      popup.addPopupMenuListener(new PopupMenuListener() {
   8.216  
   8.217 -        // If autocommit OFF - take the connection from data object.
   8.218 -        if (!autoCommit) {
   8.219 -            connection = dataObject.getLookup().lookup(DatabaseConnection.class);
   8.220 -        }
   8.221 +         @Override
   8.222 +         public void popupMenuCanceled(PopupMenuEvent e) {
   8.223 +            button.setSelected(false);
   8.224 +         }
   8.225  
   8.226 -        if (connection == null) {
   8.227 -            connection = connectionProvider.getTemplateConnection();
   8.228 -        }
   8.229 +         @Override
   8.230 +         public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
   8.231 +            button.setSelected(false);
   8.232 +         }
   8.233  
   8.234 -        if (connection == null) {
   8.235 -            return;
   8.236 -        }
   8.237 -        saveAndExecute();
   8.238 -    }
   8.239 +         @Override
   8.240 +         public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
   8.241 +         }
   8.242 +      });
   8.243  
   8.244 -    @Override
   8.245 -    public Component getToolbarPresenter() {
   8.246 -        if (!isEnabled()) {
   8.247 -            return null;
   8.248 -        }
   8.249 +      return button;
   8.250 +   }
   8.251  
   8.252 -        popup = new JPopupMenu();
   8.253 -        if (connectionProvider == null) {
   8.254 -            prepareConnection();
   8.255 -        }
   8.256 +   private void populatePopupMenu() {
   8.257 +      popup.removeAll();
   8.258 +      if (autoCommit) {
   8.259 +         for (DatabaseConnection c : connectionProvider.getDatabaseConnections()) {
   8.260 +            String url = c.getDatabaseURL();
   8.261 +            String schema = c.getUser();
   8.262 +            int pos = url.indexOf("@") + 1;
   8.263 +            if (pos > 0) {
   8.264 +               url = url.substring(pos);
   8.265 +            }
   8.266 +            url = schema + "@" + url;
   8.267 +            String alias = c.getDisplayName();
   8.268 +            if (alias != null && !alias.equals(c.getName())) {
   8.269 +               url = alias + " [" + url + "]";
   8.270 +            }
   8.271 +            JMenuItem item = new JMenuItem(url);
   8.272 +            item.putClientProperty(DATABASE_CONNECTION_KEY, c);
   8.273 +            item.addActionListener(buttonListener);
   8.274 +            popup.add(item);
   8.275 +         }
   8.276 +      }
   8.277 +   }
   8.278  
   8.279 -        if (connectionProvider != null) {
   8.280 -            populatePopupMenu();
   8.281 -        }
   8.282 +   public void saveAndExecute() {
   8.283 +      if (connectionProvider == null) {
   8.284 +         prepareConnection();
   8.285 +      }
   8.286  
   8.287 -        button = DropDownButtonFactory.createDropDownButton(
   8.288 -                new ImageIcon(new BufferedImage(32, 32, BufferedImage.TYPE_BYTE_GRAY)), popup);
   8.289 -        button.setAction(this);
   8.290 -        button.addItemListener(new ItemListener() {
   8.291 +      EditorCookie edCookie = dataObject.getLookup().lookup(EditorCookie.class);
   8.292 +      Document document = edCookie.getDocument();
   8.293 +      saveIfModified(dataObject);
   8.294 +      List<PlsqlExecutableObject> blocks = null;
   8.295  
   8.296 -            @Override
   8.297 -            public void itemStateChanged(ItemEvent e) {
   8.298 -                if (e.getStateChange() == ItemEvent.SELECTED) {
   8.299 -                    popup.show(button, 0, button.getHeight());
   8.300 -                }
   8.301 +      DataObject obj = FileExecutionUtil.getDataObject(document);
   8.302 +      FileObject file = obj.getPrimaryFile();
   8.303 +      if (file == null) {
   8.304 +         return;
   8.305 +      }
   8.306 +
   8.307 +      if (autoCommit && !connectionProvider.isDefaultDatabase(connection)) {
   8.308 +         if (!OptionsUtilities.isDeployNoPromptEnabled()) {
   8.309 +            String msg = "You are now connecting to a secondary database.";
   8.310 +            String title = "Connecting to a Secondary Database!";
   8.311 +            if (JOptionPane.showOptionDialog(null,
   8.312 +                    msg,
   8.313 +                    title,
   8.314 +                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
   8.315 +                    null, null, null) == JOptionPane.NO_OPTION) {
   8.316 +               return;
   8.317              }
   8.318 -        });
   8.319 +            connectionProvider.connect(connection);
   8.320 +            try {
   8.321 +               Connection jdbcConnection = connection.getJDBCConnection();
   8.322 +               if (jdbcConnection == null || !jdbcConnection.isValid(1000)) {
   8.323 +                  return;
   8.324 +               }
   8.325 +            } catch (SQLException ex) {
   8.326 +               return;
   8.327 +            }
   8.328 +         }
   8.329 +      } else {
   8.330 +         //to reconnect if the connection is gone. 
   8.331 +         if (connection.getJDBCConnection() == null) {
   8.332 +            connectionProvider.connect(connection);
   8.333 +         }
   8.334 +      }
   8.335  
   8.336 -        popup.addPopupMenuListener(new PopupMenuListener() {
   8.337 +      //if the user has selected any text in the window, create exec block using selected text only
   8.338 +      if (validator.isValidTDB(dataObject)) {
   8.339 +         JEditorPane[] panes = edCookie.getOpenedPanes();
   8.340 +         if ((panes != null) && (panes.length > 0)) {
   8.341 +            String selectedSql = panes[0].getSelectedText();
   8.342 +            if (selectedSql != null && !selectedSql.trim().equals("")) { //some text has been selected
   8.343 +               //create executable block with selected sql
   8.344 +               blocks = new ArrayList<PlsqlExecutableObject>();
   8.345 +               blocks.add(new PlsqlExecutableObject(0, selectedSql, "SQL", PlsqlExecutableObjectType.STATEMENT, 0, selectedSql.length() - 1));
   8.346 +            }
   8.347 +         }
   8.348 +      }
   8.349  
   8.350 -            @Override
   8.351 -            public void popupMenuCanceled(PopupMenuEvent e) {
   8.352 -                button.setSelected(false);
   8.353 +      //if blocks were not created using selected text, use entire document to create exec blocks
   8.354 +      if (blocks == null) {
   8.355 +         PlsqlExecutableBlocksMaker blockMaker = new PlsqlExecutableBlocksMaker(document);
   8.356 +         blocks = blockMaker.makeExceutableObjects();
   8.357 +      }
   8.358 +      String extension = file.getExt();
   8.359 +      if (blocks.size() > 0 && "tdb".equalsIgnoreCase(extension) && (dataObject.getNodeDelegate().getDisplayName() == null || !dataObject.getNodeDelegate().getDisplayName().contains(TEST_BLOCK_NAME_PREFIX))) {
   8.360 +         String str = blocks.get(0).getPlsqlString().replaceAll("\n", " ");
   8.361 +         dataObject.getNodeDelegate().setDisplayName(str.length() > 30 ? str.substring(0, 30) + "..." : str);
   8.362 +      }
   8.363 +      RequestProcessor processor = RequestProcessor.getDefault();
   8.364 +      processor.post(new ExecutionHandler(connectionProvider, connection, blocks, document));
   8.365 +
   8.366 +   }
   8.367 +
   8.368 +   private void saveIfModified(DataObject dataObj) {
   8.369 +      try {
   8.370 +         SaveCookie saveCookie = dataObj.getCookie(SaveCookie.class);
   8.371 +         if (saveCookie != null) {
   8.372 +            saveCookie.save();
   8.373 +         }
   8.374 +      } catch (IOException ex) {
   8.375 +         Exceptions.printStackTrace(ex);
   8.376 +      }
   8.377 +   }
   8.378 +
   8.379 +   private class ExecutionHandler implements Runnable, Cancellable {
   8.380 +
   8.381 +      private DatabaseConnectionManager connectionProvider;
   8.382 +      private DatabaseConnection connection;
   8.383 +      private List<PlsqlExecutableObject> blocks;
   8.384 +      private Document document;
   8.385 +      private PlsqlFileExecutor executor;
   8.386 +
   8.387 +      public ExecutionHandler(DatabaseConnectionManager connectionProvider, DatabaseConnection connection,
   8.388 +              List<PlsqlExecutableObject> blocks, Document doc) {
   8.389 +         this.connectionProvider = connectionProvider;
   8.390 +         this.connection = connection;
   8.391 +         this.blocks = blocks;
   8.392 +         this.document = doc;
   8.393 +      }
   8.394 +
   8.395 +      @Override
   8.396 +      public void run() {
   8.397 +         ProgressHandle handle = ProgressHandleFactory.createHandle("Executing database file...", this);
   8.398 +         DataObject obj = null;
   8.399 +         try {
   8.400 +            handle.start();
   8.401 +            if (connection == connectionProvider.getTemplateConnection()) {
   8.402 +               connection = connectionProvider.getPooledDatabaseConnection(false, true);
   8.403 +               if (connection == null) {
   8.404 +                  return;
   8.405 +               }
   8.406              }
   8.407  
   8.408 -            @Override
   8.409 -            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
   8.410 -                button.setSelected(false);
   8.411 +            obj = FileExecutionUtil.getDataObject(document);
   8.412 +            FileObject file = obj.getPrimaryFile();
   8.413 +            if (file == null) {
   8.414 +               return;
   8.415              }
   8.416  
   8.417 -            @Override
   8.418 -            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
   8.419 +            executor = new PlsqlFileExecutor(connectionProvider, connection);
   8.420 +            executor.executePLSQL(blocks, document, false, autoCommit);
   8.421 +
   8.422 +         } finally {
   8.423 +            if (autoCommit) {
   8.424 +               connectionProvider.releaseDatabaseConnection(connection);
   8.425 +            } else {
   8.426 +               //set connection to the lookup when autocommit is OFF
   8.427 +               modifyConnection();
   8.428              }
   8.429 -        });
   8.430 +            handle.finish();
   8.431 +         }
   8.432 +      }
   8.433  
   8.434 -        return button;
   8.435 -    }
   8.436 +      @Override
   8.437 +      public boolean cancel() {
   8.438 +         if (executor != null) {
   8.439 +            executor.cancel();
   8.440 +         }
   8.441 +         return true;
   8.442 +      }
   8.443  
   8.444 -    private void populatePopupMenu() {
   8.445 -        popup.removeAll();
   8.446 -        if (autoCommit) {
   8.447 -            for (DatabaseConnection c : connectionProvider.getDatabaseConnections()) {
   8.448 -                String url = c.getDatabaseURL();
   8.449 -                String schema = c.getUser();
   8.450 -                int pos = url.indexOf("@") + 1;
   8.451 -                if (pos > 0) {
   8.452 -                    url = url.substring(pos);
   8.453 -                }
   8.454 -                url = schema + "@" + url;
   8.455 -                String alias = c.getDisplayName();
   8.456 -                if (alias != null && !alias.equals(c.getName())) {
   8.457 -                    url = alias + " [" + url + "]";
   8.458 -                }
   8.459 -                JMenuItem item = new JMenuItem(url);
   8.460 -                item.putClientProperty(DATABASE_CONNECTION_KEY, c);
   8.461 -                item.addActionListener(buttonListener);
   8.462 -                popup.add(item);
   8.463 -            }
   8.464 -        }
   8.465 -    }
   8.466 +      private void modifyConnection() {
   8.467  
   8.468 -    public void saveAndExecute() {
   8.469 -        if (connectionProvider == null) {
   8.470 +         plsqlDataobject = (PlsqlDataObject) dataObject;
   8.471 +         plsqlDataobject.modifyLookupDatabaseConnection(connection);
   8.472 +         dataObject = plsqlDataobject;
   8.473 +      }
   8.474 +   }
   8.475 +
   8.476 +   private class ButtonListener implements ActionListener {
   8.477 +
   8.478 +      public ButtonListener() {
   8.479 +      }
   8.480 +
   8.481 +      @Override
   8.482 +      public void actionPerformed(ActionEvent e) {
   8.483 +
   8.484 +         JMenuItem item = (JMenuItem) e.getSource();
   8.485 +         connection = (DatabaseConnection) item.getClientProperty(DATABASE_CONNECTION_KEY);
   8.486 +         saveAndExecute();
   8.487 +
   8.488 +      }
   8.489 +   };
   8.490 +
   8.491 +   private class PopupMenuPopulator implements PropertyChangeListener {
   8.492 +
   8.493 +      public PopupMenuPopulator() {
   8.494 +      }
   8.495 +
   8.496 +      @Override
   8.497 +      public void propertyChange(PropertyChangeEvent event) {
   8.498 +         if (popup != null) {
   8.499              prepareConnection();
   8.500 -        }
   8.501 -
   8.502 -        EditorCookie edCookie = dataObject.getLookup().lookup(EditorCookie.class);
   8.503 -        Document document = edCookie.getDocument();
   8.504 -        saveIfModified(dataObject);
   8.505 -        List<PlsqlExecutableObject> blocks = null;
   8.506 -
   8.507 -        DataObject obj = FileExecutionUtil.getDataObject(document);
   8.508 -        FileObject file = obj.getPrimaryFile();
   8.509 -        if (file == null) {
   8.510 -            return;
   8.511 -        }
   8.512 -
   8.513 -        if (autoCommit && !connectionProvider.isDefaultDatabase(connection)) {
   8.514 -            if (!OptionsUtilities.isDeployNoPromptEnabled()) {
   8.515 -                String msg = "You are now connecting to a secondary database.";
   8.516 -                String title = "Connecting to a Secondary Database!";
   8.517 -                if (JOptionPane.showOptionDialog(null,
   8.518 -                        msg,
   8.519 -                        title,
   8.520 -                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
   8.521 -                        null, null, null) == JOptionPane.NO_OPTION) {
   8.522 -                    return;
   8.523 -                }
   8.524 -                connectionProvider.connect(connection);
   8.525 -                try {
   8.526 -                    Connection jdbcConnection = connection.getJDBCConnection();
   8.527 -                    if (jdbcConnection == null || !jdbcConnection.isValid(1000)) {
   8.528 -                        return;
   8.529 -                    }
   8.530 -                } catch (SQLException ex) {
   8.531 -                    return;
   8.532 -                }
   8.533 -            }
   8.534 -        } else {
   8.535 -            //to reconnect if the connection is gone. 
   8.536 -            if (connection.getJDBCConnection() == null) {
   8.537 -                connectionProvider.connect(connection);
   8.538 -            }
   8.539 -        }
   8.540 -
   8.541 -        //if the user has selected any text in the window, create exec block using selected text only
   8.542 -        if (validator.isValidTDB(dataObject)) {
   8.543 -            JEditorPane[] panes = edCookie.getOpenedPanes();
   8.544 -            if ((panes != null) && (panes.length > 0)) {
   8.545 -                String selectedSql = panes[0].getSelectedText();
   8.546 -                if (selectedSql != null && !selectedSql.trim().equals("")) { //some text has been selected
   8.547 -                    //create executable block with selected sql
   8.548 -                    blocks = new ArrayList<PlsqlExecutableObject>();
   8.549 -                    blocks.add(new PlsqlExecutableObject(0, selectedSql, "SQL", PlsqlExecutableObjectType.STATEMENT, 0, selectedSql.length() - 1));
   8.550 -                }
   8.551 -            }
   8.552 -        }
   8.553 -
   8.554 -        //if blocks were not created using selected text, use entire document to create exec blocks
   8.555 -        if (blocks == null) {
   8.556 -            PlsqlExecutableBlocksMaker blockMaker = new PlsqlExecutableBlocksMaker(document);
   8.557 -            blocks = blockMaker.makeExceutableObjects();
   8.558 -        }
   8.559 -        String extension = file.getExt();
   8.560 -        if (blocks.size() > 0 && "tdb".equalsIgnoreCase(extension) && (dataObject.getNodeDelegate().getDisplayName() == null || !dataObject.getNodeDelegate().getDisplayName().contains(TEST_BLOCK_NAME_PREFIX))) {
   8.561 -            String str = blocks.get(0).getPlsqlString().replaceAll("\n", " ");
   8.562 -            dataObject.getNodeDelegate().setDisplayName(str.length() > 30 ? str.substring(0, 30) + "..." : str);
   8.563 -        }
   8.564 -        RequestProcessor processor = RequestProcessor.getDefault();
   8.565 -        processor.post(new ExecutionHandler(connectionProvider, connection, blocks, document));
   8.566 -
   8.567 -    }
   8.568 -
   8.569 -    private void saveIfModified(DataObject dataObj) {
   8.570 -        try {
   8.571 -            SaveCookie saveCookie = dataObj.getCookie(SaveCookie.class);
   8.572 -            if (saveCookie != null) {
   8.573 -                saveCookie.save();
   8.574 -            }
   8.575 -        } catch (IOException ex) {
   8.576 -            Exceptions.printStackTrace(ex);
   8.577 -        }
   8.578 -    }
   8.579 -
   8.580 -    private class ExecutionHandler implements Runnable, Cancellable {
   8.581 -
   8.582 -        private DatabaseConnectionManager connectionProvider;
   8.583 -        private DatabaseConnection connection;
   8.584 -        private List<PlsqlExecutableObject> blocks;
   8.585 -        private Document document;
   8.586 -        private PlsqlFileExecutor executor;
   8.587 -
   8.588 -        public ExecutionHandler(DatabaseConnectionManager connectionProvider, DatabaseConnection connection,
   8.589 -                List<PlsqlExecutableObject> blocks, Document doc) {
   8.590 -            this.connectionProvider = connectionProvider;
   8.591 -            this.connection = connection;
   8.592 -            this.blocks = blocks;
   8.593 -            this.document = doc;
   8.594 -        }
   8.595 -
   8.596 -        @Override
   8.597 -        public void run() {
   8.598 -            ProgressHandle handle = ProgressHandleFactory.createHandle("Executing database file...", this);
   8.599 -            DataObject obj = null;
   8.600 -            try {
   8.601 -                handle.start();
   8.602 -                if (connection == connectionProvider.getTemplateConnection()) {
   8.603 -                    connection = connectionProvider.getPooledDatabaseConnection(false, true);
   8.604 -                    if (connection == null) {
   8.605 -                        return;
   8.606 -                    }
   8.607 -                }
   8.608 -
   8.609 -                obj = FileExecutionUtil.getDataObject(document);
   8.610 -                FileObject file = obj.getPrimaryFile();
   8.611 -                if (file == null) {
   8.612 -                    return;
   8.613 -                }
   8.614 -
   8.615 -                executor = new PlsqlFileExecutor(connectionProvider, connection);
   8.616 -                executor.executePLSQL(blocks, document, false, autoCommit);
   8.617 -
   8.618 -            } finally {
   8.619 -                if (autoCommit) {
   8.620 -                    connectionProvider.releaseDatabaseConnection(connection);
   8.621 -                } else {
   8.622 -                    //set connection to the lookup when autocommit is OFF
   8.623 -                    modifyConnection();
   8.624 -                }
   8.625 -                handle.finish();
   8.626 -            }
   8.627 -        }
   8.628 -
   8.629 -        @Override
   8.630 -        public boolean cancel() {
   8.631 -            if (executor != null) {
   8.632 -                executor.cancel();
   8.633 -            }
   8.634 -            return true;
   8.635 -        }
   8.636 -
   8.637 -        private void modifyConnection() {
   8.638 -
   8.639 -            plsqlDataobject = (PlsqlDataObject) dataObject;
   8.640 -            plsqlDataobject.modifyLookupDatabaseConnection(connection);
   8.641 -            dataObject = plsqlDataobject;
   8.642 -        }
   8.643 -    }
   8.644 -
   8.645 -    private class ButtonListener implements ActionListener {
   8.646 -
   8.647 -        public ButtonListener() {
   8.648 -        }
   8.649 -
   8.650 -        @Override
   8.651 -        public void actionPerformed(ActionEvent e) {
   8.652 -
   8.653 -            JMenuItem item = (JMenuItem) e.getSource();
   8.654 -            connection = (DatabaseConnection) item.getClientProperty(DATABASE_CONNECTION_KEY);
   8.655 -            saveAndExecute();
   8.656 -
   8.657 -        }
   8.658 -    };
   8.659 -
   8.660 -    private class PopupMenuPopulator implements PropertyChangeListener {
   8.661 -
   8.662 -        public PopupMenuPopulator() {
   8.663 -        }
   8.664 -
   8.665 -        @Override
   8.666 -        public void propertyChange(PropertyChangeEvent event) {
   8.667 -            if (popup != null) {
   8.668 -                prepareConnection();
   8.669 -                populatePopupMenu();
   8.670 -            }
   8.671 -        }
   8.672 -    }
   8.673 +            populatePopupMenu();
   8.674 +         }
   8.675 +      }
   8.676 +   }
   8.677  }
     9.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutionHistoryAction.java	Mon Feb 13 18:37:52 2012 +0100
     9.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutionHistoryAction.java	Mon Feb 13 21:41:10 2012 +0100
     9.3 @@ -41,8 +41,6 @@
     9.4   */
     9.5  package org.netbeans.modules.plsql.execution;
     9.6  
     9.7 -import org.netbeans.modules.plsql.filetype.StatementExecutionHistory;
     9.8 -import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
     9.9  import java.awt.Component;
    9.10  import java.awt.event.ActionEvent;
    9.11  import java.awt.event.ActionListener;
    9.12 @@ -51,6 +49,7 @@
    9.13  import java.awt.image.BufferedImage;
    9.14  import java.util.ArrayList;
    9.15  import java.util.List;
    9.16 +
    9.17  import javax.swing.AbstractAction;
    9.18  import javax.swing.Action;
    9.19  import javax.swing.ImageIcon;
    9.20 @@ -60,6 +59,11 @@
    9.21  import javax.swing.event.PopupMenuEvent;
    9.22  import javax.swing.text.BadLocationException;
    9.23  import javax.swing.text.StyledDocument;
    9.24 +
    9.25 +import org.netbeans.modules.plsql.filetype.StatementExecutionHistory;
    9.26 +import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
    9.27 +import org.openide.awt.ActionID;
    9.28 +import org.openide.awt.ActionRegistration;
    9.29  import org.openide.awt.DropDownButtonFactory;
    9.30  import org.openide.cookies.EditorCookie;
    9.31  import org.openide.loaders.DataObject;
    9.32 @@ -75,6 +79,8 @@
    9.33  import org.openide.windows.InputOutput;
    9.34  import org.openide.windows.OutputWriter;
    9.35  
    9.36 +@ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlExecutionHistoryAction", category = "PLSQL")
    9.37 +@ActionRegistration(displayName = "#CTL_PlsqlExecutionHistoryAction")
    9.38  public final class PlsqlExecutionHistoryAction extends AbstractAction implements ContextAwareAction, Presenter.Toolbar {
    9.39  
    9.40      private JPopupMenu popup;
    9.41 @@ -95,6 +101,7 @@
    9.42          setEnabled(dataObject != null && dataObject.getPrimaryFile().getNameExt().startsWith(SQLCommandWindow.SQL_EXECUTION_FILE_PREFIX));
    9.43      }
    9.44  
    9.45 +    @Override
    9.46      public Action createContextAwareInstance(Lookup context) {
    9.47          return new PlsqlExecutionHistoryAction(context);
    9.48      }
    9.49 @@ -113,9 +120,10 @@
    9.50  
    9.51      @Override
    9.52      public Component getToolbarPresenter() {
    9.53 -        if (!isEnabled())
    9.54 +        if (!isEnabled()) {
    9.55              return null;
    9.56 -        
    9.57 +        }
    9.58 +
    9.59          popup = new JPopupMenu();
    9.60          populatePopupMenu();
    9.61  
    9.62 @@ -124,6 +132,7 @@
    9.63          button.setAction(this);
    9.64          button.addItemListener(new ItemListener() {
    9.65  
    9.66 +            @Override
    9.67              public void itemStateChanged(ItemEvent e) {
    9.68                  if (e.getStateChange() == ItemEvent.SELECTED) {
    9.69                      popup.show(button, 0, button.getHeight());
    9.70 @@ -133,14 +142,17 @@
    9.71  
    9.72          popup.addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
    9.73  
    9.74 +            @Override
    9.75              public void popupMenuCanceled(PopupMenuEvent e) {
    9.76                  button.setSelected(false);
    9.77              }
    9.78  
    9.79 +            @Override
    9.80              public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
    9.81                  button.setSelected(false);
    9.82              }
    9.83  
    9.84 +            @Override
    9.85              public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    9.86                  populatePopupMenu();
    9.87              }
    9.88 @@ -169,6 +181,7 @@
    9.89          }
    9.90      }
    9.91  
    9.92 +    @Override
    9.93      public void actionPerformed(ActionEvent e) {
    9.94          StatementExecutionHistory history = dataObject.getLookup().lookup(StatementExecutionHistory.class);
    9.95          List<String> statements = history != null ? history.getStatementHistory() : new ArrayList<String>();
    9.96 @@ -186,9 +199,7 @@
    9.97  
    9.98      private class ButtonListener implements ActionListener {
    9.99  
   9.100 -        public ButtonListener() {
   9.101 -        }
   9.102 -
   9.103 +        @Override
   9.104          public void actionPerformed(ActionEvent e) {
   9.105              JMenuItem item = (JMenuItem) e.getSource();
   9.106              String statement = (String) item.getClientProperty("STATEMENT");
    10.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutionHistoryNextAction.java	Mon Feb 13 18:37:52 2012 +0100
    10.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutionHistoryNextAction.java	Mon Feb 13 21:41:10 2012 +0100
    10.3 @@ -41,13 +41,18 @@
    10.4   */
    10.5  package org.netbeans.modules.plsql.execution;
    10.6  
    10.7 -import org.netbeans.modules.plsql.filetype.StatementExecutionHistory;
    10.8 -import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
    10.9  import java.awt.event.ActionEvent;
   10.10 +
   10.11  import javax.swing.AbstractAction;
   10.12  import javax.swing.Action;
   10.13  import javax.swing.text.BadLocationException;
   10.14  import javax.swing.text.StyledDocument;
   10.15 +
   10.16 +import org.netbeans.modules.plsql.filetype.StatementExecutionHistory;
   10.17 +import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
   10.18 +import org.openide.awt.ActionID;
   10.19 +import org.openide.awt.ActionReference;
   10.20 +import org.openide.awt.ActionRegistration;
   10.21  import org.openide.cookies.EditorCookie;
   10.22  import org.openide.loaders.DataObject;
   10.23  import org.openide.util.ContextAwareAction;
   10.24 @@ -57,44 +62,51 @@
   10.25  import org.openide.util.NbBundle;
   10.26  import org.openide.util.Utilities;
   10.27  
   10.28 +@ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlExecutionHistoryNextAction", category = "PLSQL")
   10.29 +@ActionRegistration(displayName = "#CTL_PlsqlExecutionHistoryNextAction")
   10.30 +@ActionReference(path = "Shortcuts", name = "AS-N")
   10.31  public final class PlsqlExecutionHistoryNextAction extends AbstractAction implements ContextAwareAction {
   10.32 -   private DataObject dataObject;
   10.33  
   10.34 -   public PlsqlExecutionHistoryNextAction() {
   10.35 -      this(Utilities.actionsGlobalContext());
   10.36 -   }
   10.37 +    private DataObject dataObject;
   10.38  
   10.39 -   public PlsqlExecutionHistoryNextAction(Lookup context) {
   10.40 -      putValue(NAME,getName());
   10.41 -      putValue(SHORT_DESCRIPTION, getName());
   10.42 -      dataObject = context.lookup(DataObject.class);
   10.43 -      setEnabled(dataObject != null && dataObject.getPrimaryFile().getNameExt().startsWith(SQLCommandWindow.SQL_EXECUTION_FILE_PREFIX));
   10.44 -   }
   10.45 +    public PlsqlExecutionHistoryNextAction() {
   10.46 +        this(Utilities.actionsGlobalContext());
   10.47 +    }
   10.48  
   10.49 -   public Action createContextAwareInstance(Lookup context) {
   10.50 -      return new PlsqlExecutionHistoryNextAction(context);
   10.51 -   }
   10.52 +    public PlsqlExecutionHistoryNextAction(Lookup context) {
   10.53 +        putValue(NAME, getName());
   10.54 +        putValue(SHORT_DESCRIPTION, getName());
   10.55 +        dataObject = context.lookup(DataObject.class);
   10.56 +        setEnabled(dataObject != null && dataObject.getPrimaryFile().getNameExt().startsWith(SQLCommandWindow.SQL_EXECUTION_FILE_PREFIX));
   10.57 +    }
   10.58  
   10.59 -   private String getName() {
   10.60 -      return NbBundle.getMessage(PlsqlExecutionHistoryNextAction.class, "CTL_PlsqlExecutionHistoryNextAction");
   10.61 -   }
   10.62 +    @Override
   10.63 +    public Action createContextAwareInstance(Lookup context) {
   10.64 +        return new PlsqlExecutionHistoryNextAction(context);
   10.65 +    }
   10.66  
   10.67 -   public HelpCtx getHelpCtx() {
   10.68 -      return HelpCtx.DEFAULT_HELP;
   10.69 -   }
   10.70 +    private String getName() {
   10.71 +        return NbBundle.getMessage(PlsqlExecutionHistoryNextAction.class, "CTL_PlsqlExecutionHistoryNextAction");
   10.72 +    }
   10.73  
   10.74 -   public void actionPerformed(ActionEvent e) {
   10.75 -      StatementExecutionHistory history = dataObject.getLookup().lookup(StatementExecutionHistory.class);
   10.76 -      if(history!=null) {
   10.77 -         boolean moveOk = history.moveNext();
   10.78 -         StyledDocument document = dataObject.getLookup().lookup(EditorCookie.class).getDocument();
   10.79 -         try {
   10.80 -            document.remove(0, document.getLength());
   10.81 -            if(moveOk)
   10.82 -               document.insertString(0, history.getSelectedEntry(), null);
   10.83 -         } catch (BadLocationException ex) {
   10.84 -            Exceptions.printStackTrace(ex);
   10.85 -         }
   10.86 -      }
   10.87 -   }
   10.88 +    public HelpCtx getHelpCtx() {
   10.89 +        return HelpCtx.DEFAULT_HELP;
   10.90 +    }
   10.91 +
   10.92 +    @Override
   10.93 +    public void actionPerformed(ActionEvent e) {
   10.94 +        StatementExecutionHistory history = dataObject.getLookup().lookup(StatementExecutionHistory.class);
   10.95 +        if (history != null) {
   10.96 +            boolean moveOk = history.moveNext();
   10.97 +            StyledDocument document = dataObject.getLookup().lookup(EditorCookie.class).getDocument();
   10.98 +            try {
   10.99 +                document.remove(0, document.getLength());
  10.100 +                if (moveOk) {
  10.101 +                    document.insertString(0, history.getSelectedEntry(), null);
  10.102 +                }
  10.103 +            } catch (BadLocationException ex) {
  10.104 +                Exceptions.printStackTrace(ex);
  10.105 +            }
  10.106 +        }
  10.107 +    }
  10.108  }
    11.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutionHistoryPreviousAction.java	Mon Feb 13 18:37:52 2012 +0100
    11.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExecutionHistoryPreviousAction.java	Mon Feb 13 21:41:10 2012 +0100
    11.3 @@ -41,13 +41,18 @@
    11.4   */
    11.5  package org.netbeans.modules.plsql.execution;
    11.6  
    11.7 -import org.netbeans.modules.plsql.filetype.StatementExecutionHistory;
    11.8 -import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
    11.9  import java.awt.event.ActionEvent;
   11.10 +
   11.11  import javax.swing.AbstractAction;
   11.12  import javax.swing.Action;
   11.13  import javax.swing.text.BadLocationException;
   11.14  import javax.swing.text.StyledDocument;
   11.15 +
   11.16 +import org.netbeans.modules.plsql.filetype.StatementExecutionHistory;
   11.17 +import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
   11.18 +import org.openide.awt.ActionID;
   11.19 +import org.openide.awt.ActionReference;
   11.20 +import org.openide.awt.ActionRegistration;
   11.21  import org.openide.cookies.EditorCookie;
   11.22  import org.openide.loaders.DataObject;
   11.23  import org.openide.util.ContextAwareAction;
   11.24 @@ -57,45 +62,51 @@
   11.25  import org.openide.util.NbBundle;
   11.26  import org.openide.util.Utilities;
   11.27  
   11.28 +@ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlExecutionHistoryPreviousAction", category = "PLSQL")
   11.29 +@ActionRegistration(displayName = "#CTL_PlsqlExecutionHistoryPreviousAction")
   11.30 +@ActionReference(path = "Shortcuts", name = "AS-P")
   11.31  public final class PlsqlExecutionHistoryPreviousAction extends AbstractAction implements ContextAwareAction {
   11.32 -   private DataObject dataObject;
   11.33  
   11.34 -   public PlsqlExecutionHistoryPreviousAction() {
   11.35 -      this(Utilities.actionsGlobalContext());
   11.36 -   }
   11.37 +    private DataObject dataObject;
   11.38  
   11.39 -   public PlsqlExecutionHistoryPreviousAction(Lookup context) {
   11.40 -      putValue(NAME, getName());
   11.41 -      putValue(SHORT_DESCRIPTION, getName());
   11.42 -      dataObject = context.lookup(DataObject.class);
   11.43 -      setEnabled(dataObject != null && dataObject.getPrimaryFile().getNameExt().startsWith(SQLCommandWindow.SQL_EXECUTION_FILE_PREFIX));
   11.44 -   }
   11.45 +    public PlsqlExecutionHistoryPreviousAction() {
   11.46 +        this(Utilities.actionsGlobalContext());
   11.47 +    }
   11.48  
   11.49 -   public Action createContextAwareInstance(Lookup context) {
   11.50 -      return new PlsqlExecutionHistoryPreviousAction(context);
   11.51 -   }
   11.52 +    public PlsqlExecutionHistoryPreviousAction(Lookup context) {
   11.53 +        putValue(NAME, getName());
   11.54 +        putValue(SHORT_DESCRIPTION, getName());
   11.55 +        dataObject = context.lookup(DataObject.class);
   11.56 +        setEnabled(dataObject != null && dataObject.getPrimaryFile().getNameExt().startsWith(SQLCommandWindow.SQL_EXECUTION_FILE_PREFIX));
   11.57 +    }
   11.58  
   11.59 -   private String getName() {
   11.60 -      return NbBundle.getMessage(PlsqlExecutionHistoryPreviousAction.class, "CTL_PlsqlExecutionHistoryPreviousAction");
   11.61 -   }
   11.62 +    @Override
   11.63 +    public Action createContextAwareInstance(Lookup context) {
   11.64 +        return new PlsqlExecutionHistoryPreviousAction(context);
   11.65 +    }
   11.66  
   11.67 -   public HelpCtx getHelpCtx() {
   11.68 -      return HelpCtx.DEFAULT_HELP;
   11.69 -   }
   11.70 +    private String getName() {
   11.71 +        return NbBundle.getMessage(PlsqlExecutionHistoryPreviousAction.class, "CTL_PlsqlExecutionHistoryPreviousAction");
   11.72 +    }
   11.73  
   11.74 -   public void actionPerformed(ActionEvent e) {
   11.75 -      StatementExecutionHistory history = dataObject.getLookup().lookup(StatementExecutionHistory.class);
   11.76 -      if(history!=null && history.getSize() > 0) {
   11.77 -         boolean moveOk = history.movePrevious();
   11.78 -         StyledDocument document = dataObject.getLookup().lookup(EditorCookie.class).getDocument();
   11.79 -         try {
   11.80 -            if(moveOk) {
   11.81 -               document.remove(0, document.getLength());
   11.82 -               document.insertString(0, history.getSelectedEntry(), null);
   11.83 +    public HelpCtx getHelpCtx() {
   11.84 +        return HelpCtx.DEFAULT_HELP;
   11.85 +    }
   11.86 +
   11.87 +    @Override
   11.88 +    public void actionPerformed(ActionEvent e) {
   11.89 +        StatementExecutionHistory history = dataObject.getLookup().lookup(StatementExecutionHistory.class);
   11.90 +        if (history != null && history.getSize() > 0) {
   11.91 +            boolean moveOk = history.movePrevious();
   11.92 +            StyledDocument document = dataObject.getLookup().lookup(EditorCookie.class).getDocument();
   11.93 +            try {
   11.94 +                if (moveOk) {
   11.95 +                    document.remove(0, document.getLength());
   11.96 +                    document.insertString(0, history.getSelectedEntry(), null);
   11.97 +                }
   11.98 +            } catch (BadLocationException ex) {
   11.99 +                Exceptions.printStackTrace(ex);
  11.100              }
  11.101 -         } catch (BadLocationException ex) {
  11.102 -            Exceptions.printStackTrace(ex);
  11.103 -         }
  11.104 -      }
  11.105 -   }
  11.106 +        }
  11.107 +    }
  11.108  }
    12.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExplainPlanAction.java	Mon Feb 13 18:37:52 2012 +0100
    12.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlExplainPlanAction.java	Mon Feb 13 21:41:10 2012 +0100
    12.3 @@ -41,22 +41,24 @@
    12.4   */
    12.5  package org.netbeans.modules.plsql.execution;
    12.6  
    12.7 -import org.netbeans.modules.plsqlsupport.db.ui.SQLExecutionAction;
    12.8 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
    12.9 -import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
   12.10  import java.sql.Connection;
   12.11  import java.sql.ResultSet;
   12.12  import java.sql.SQLException;
   12.13  import java.sql.Statement;
   12.14 +
   12.15  import javax.swing.JOptionPane;
   12.16  import javax.swing.text.BadLocationException;
   12.17  import javax.swing.text.Document;
   12.18 +
   12.19  import org.netbeans.api.db.explorer.DatabaseConnection;
   12.20 -import org.netbeans.api.project.FileOwnerQuery;
   12.21 -import org.netbeans.api.project.Project;
   12.22 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
   12.23 +import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
   12.24 +import org.openide.awt.ActionID;
   12.25 +import org.openide.awt.ActionRegistration;
   12.26  import org.openide.cookies.EditorCookie;
   12.27  import org.openide.loaders.DataObject;
   12.28  import org.openide.nodes.Node;
   12.29 +import org.openide.util.Exceptions;
   12.30  import org.openide.util.HelpCtx;
   12.31  import org.openide.util.NbBundle;
   12.32  import org.openide.util.actions.CookieAction;
   12.33 @@ -64,8 +66,11 @@
   12.34  import org.openide.windows.InputOutput;
   12.35  import org.openide.windows.OutputWriter;
   12.36  
   12.37 +@ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlExplainPlanAction", category = "PLSQL")
   12.38 +@ActionRegistration(displayName = "#CTL_PlsqlExplainPlanAction")
   12.39  public final class PlsqlExplainPlanAction extends CookieAction {
   12.40  
   12.41 +    @Override
   12.42     protected void performAction(Node[] activatedNodes) {
   12.43        EditorCookie editorCookie = activatedNodes[0].getLookup().lookup(EditorCookie.class);
   12.44        DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
   12.45 @@ -87,19 +92,22 @@
   12.46                 dbConnectionManager.releaseDatabaseConnection(dbConnection);
   12.47              }
   12.48           } catch (BadLocationException ex) {
   12.49 -            ex.printStackTrace();
   12.50 +            Exceptions.printStackTrace(ex);
   12.51           }
   12.52        }
   12.53     }
   12.54  
   12.55 +    @Override
   12.56     protected int mode() {
   12.57        return CookieAction.MODE_EXACTLY_ONE;
   12.58     }
   12.59  
   12.60 +    @Override
   12.61     public String getName() {
   12.62        return NbBundle.getMessage(PlsqlExplainPlanAction.class, "CTL_PlsqlExplainPlanAction");
   12.63     }
   12.64  
   12.65 +    @Override
   12.66     protected Class[] cookieClasses() {
   12.67        return new Class[]{DataObject.class};
   12.68     }
   12.69 @@ -109,6 +117,7 @@
   12.70        return "org/netbeans/modules/plsql/execution/explain.png";
   12.71     }
   12.72  
   12.73 +    @Override
   12.74     public HelpCtx getHelpCtx() {
   12.75        return HelpCtx.DEFAULT_HELP;
   12.76     }
    13.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlMultipleExecuteAction.java	Mon Feb 13 18:37:52 2012 +0100
    13.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlMultipleExecuteAction.java	Mon Feb 13 21:41:10 2012 +0100
    13.3 @@ -41,25 +41,30 @@
    13.4   */
    13.5  package org.netbeans.modules.plsql.execution;
    13.6  
    13.7 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
    13.8 -import org.netbeans.modules.plsql.utilities.PlsqlExecutorService;
    13.9  import java.awt.event.ActionEvent;
   13.10  import java.awt.event.ActionListener;
   13.11  import java.io.IOException;
   13.12  import java.util.Arrays;
   13.13  import java.util.List;
   13.14  import java.util.Locale;
   13.15 +
   13.16  import javax.swing.JMenu;
   13.17  import javax.swing.JMenuItem;
   13.18  import javax.swing.JOptionPane;
   13.19  import javax.swing.JSeparator;
   13.20  import javax.swing.text.Document;
   13.21 +
   13.22  import org.netbeans.api.db.explorer.DatabaseConnection;
   13.23  import org.netbeans.api.progress.ProgressHandle;
   13.24  import org.netbeans.api.progress.ProgressHandleFactory;
   13.25  import org.netbeans.api.project.FileOwnerQuery;
   13.26  import org.netbeans.api.project.Project;
   13.27 +import org.netbeans.modules.plsql.utilities.PlsqlExecutorService;
   13.28 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
   13.29  import org.netbeans.modules.plsqlsupport.options.OptionsUtilities;
   13.30 +import org.openide.awt.ActionID;
   13.31 +import org.openide.awt.ActionReference;
   13.32 +import org.openide.awt.ActionRegistration;
   13.33  import org.openide.cookies.EditorCookie;
   13.34  import org.openide.cookies.SaveCookie;
   13.35  import org.openide.loaders.DataObject;
   13.36 @@ -77,298 +82,298 @@
   13.37  import org.openide.windows.OutputEvent;
   13.38  import org.openide.windows.OutputListener;
   13.39  
   13.40 +@ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlMultipleExecuteAction", category = "PLSQL")
   13.41 +@ActionRegistration(displayName = "#CTL_PlsqlMultipleExecuteAction")
   13.42 +@ActionReference(path = "Loaders/text/x-plsql/Actions", position = 250)
   13.43  public final class PlsqlMultipleExecuteAction extends CookieAction {
   13.44  
   13.45 -   private static final List<String> INVALID_EXTENSIONS = Arrays.asList(new String[]{"dbl"});
   13.46 -   private static final String DATABASE_CONNECTION_KEY = "databaseConnection";
   13.47 -   private static final PlsqlExecutorService executorService = Lookup.getDefault().lookup(PlsqlExecutorService.class);
   13.48 -   private DatabaseConnection connection;
   13.49 -   private Node[] activatedNodes;
   13.50 -   private Project project;
   13.51 -   private DataObject dataObject;
   13.52 +    private static final List<String> INVALID_EXTENSIONS = Arrays.asList(new String[]{"dbl"});
   13.53 +    private static final String DATABASE_CONNECTION_KEY = "databaseConnection";
   13.54 +    private static final PlsqlExecutorService executorService = Lookup.getDefault().lookup(PlsqlExecutorService.class);
   13.55 +    private DatabaseConnection connection;
   13.56 +    private Node[] activatedNodes;
   13.57 +    private Project project;
   13.58 +    private DataObject dataObject;
   13.59  
   13.60 -   public PlsqlMultipleExecuteAction() {
   13.61 -   }
   13.62 +    @Override
   13.63 +    protected boolean enable(Node[] activatedNodes) {
   13.64 +        this.activatedNodes = activatedNodes;
   13.65 +        if (!super.enable(activatedNodes)) {
   13.66 +            return false;
   13.67 +        }
   13.68  
   13.69 -   @Override
   13.70 -   protected boolean enable(Node[] activatedNodes) {
   13.71 -      this.activatedNodes = activatedNodes;
   13.72 -      if (!super.enable(activatedNodes)) {
   13.73 -         return false;
   13.74 -      }
   13.75 +        for (Node node : activatedNodes) {
   13.76 +            if (INVALID_EXTENSIONS.contains(node.getLookup().lookup(DataObject.class).getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH))) {
   13.77 +                return false;
   13.78 +            }
   13.79 +        }
   13.80  
   13.81 -      for (Node node : activatedNodes) {
   13.82 -         if (INVALID_EXTENSIONS.contains(node.getLookup().lookup(DataObject.class).getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH))) {
   13.83 +        project = FileOwnerQuery.getOwner(activatedNodes[0].getLookup().lookup(DataObject.class).getPrimaryFile());
   13.84 +        dataObject = project == null && activatedNodes.length == 1 ? activatedNodes[0].getLookup().lookup(DataObject.class) : null;
   13.85 +        if (project == null && activatedNodes.length > 1) {
   13.86              return false;
   13.87 -         }
   13.88 -      }
   13.89 +        }
   13.90 +        if (project != null && project.getLookup().lookup(DatabaseConnectionManager.class) == null) {
   13.91 +            return false;
   13.92 +        }
   13.93 +        for (int i = 1; i < activatedNodes.length; i++) {
   13.94 +            Project p = FileOwnerQuery.getOwner(activatedNodes[i].getLookup().lookup(DataObject.class).getPrimaryFile());
   13.95 +            if (p != project) {
   13.96 +                return false;
   13.97 +            }
   13.98 +        }
   13.99  
  13.100 -      project = FileOwnerQuery.getOwner(activatedNodes[0].getLookup().lookup(DataObject.class).getPrimaryFile());
  13.101 -      dataObject = project == null && activatedNodes.length == 1 ? activatedNodes[0].getLookup().lookup(DataObject.class) : null;
  13.102 -      if (project == null && activatedNodes.length > 1) {
  13.103 -         return false;
  13.104 -      }
  13.105 -      if (project != null && project.getLookup().lookup(DatabaseConnectionManager.class) == null) {
  13.106 -         return false;
  13.107 -      }
  13.108 -      for (int i = 1; i < activatedNodes.length; i++) {
  13.109 -         Project p = FileOwnerQuery.getOwner(activatedNodes[i].getLookup().lookup(DataObject.class).getPrimaryFile());
  13.110 -         if (p != project) {
  13.111 -            return false;
  13.112 -         }
  13.113 -      }
  13.114 +        return true;
  13.115 +    }
  13.116  
  13.117 -      return true;
  13.118 -   }
  13.119 +    private void execute() {
  13.120 +        DatabaseConnectionManager connectionProvider = project != null
  13.121 +                ? DatabaseConnectionManager.getInstance(project)
  13.122 +                : DatabaseConnectionManager.getInstance(dataObject);
  13.123 +        connectionProvider.connect(connection);
  13.124 +        if (connection.getJDBCConnection() == null) {
  13.125 +            return;
  13.126 +        }
  13.127  
  13.128 -   private void execute() {
  13.129 -      DatabaseConnectionManager connectionProvider = project != null
  13.130 -              ? DatabaseConnectionManager.getInstance(project)
  13.131 -              : DatabaseConnectionManager.getInstance(dataObject);
  13.132 -      connectionProvider.connect(connection);
  13.133 -      if (connection.getJDBCConnection() == null) {
  13.134 -         return;
  13.135 -      }
  13.136 +        RequestProcessor processor = RequestProcessor.getDefault();
  13.137 +        processor.post(new ExecutionHandler(connectionProvider, connection, activatedNodes));
  13.138 +    }
  13.139  
  13.140 -      RequestProcessor processor = RequestProcessor.getDefault();
  13.141 -      processor.post(new ExecutionHandler(connectionProvider, connection, activatedNodes));
  13.142 -   }
  13.143 +    @Override
  13.144 +    protected void performAction(Node[] activatedNodes) {
  13.145 +        execute();
  13.146 +    }
  13.147  
  13.148 -   @Override
  13.149 -   protected void performAction(Node[] activatedNodes) {
  13.150 -      execute();
  13.151 -   }
  13.152 +    @Override
  13.153 +    protected int mode() {
  13.154 +        return CookieAction.MODE_ALL;
  13.155 +    }
  13.156  
  13.157 -   @Override
  13.158 -   protected int mode() {
  13.159 -      return CookieAction.MODE_ALL;
  13.160 -   }
  13.161 +    @Override
  13.162 +    public String getName() {
  13.163 +        return NbBundle.getMessage(PlsqlMultipleExecuteAction.class, "CTL_PlsqlMultipleExecuteAction");
  13.164 +    }
  13.165  
  13.166 -   @Override
  13.167 -   public String getName() {
  13.168 -      return NbBundle.getMessage(PlsqlMultipleExecuteAction.class, "CTL_PlsqlMultipleExecuteAction");
  13.169 -   }
  13.170 +    @Override
  13.171 +    protected Class[] cookieClasses() {
  13.172 +        return new Class[]{DataObject.class};
  13.173 +    }
  13.174  
  13.175 -   @Override
  13.176 -   protected Class[] cookieClasses() {
  13.177 -      return new Class[]{DataObject.class};
  13.178 -   }
  13.179 +    @Override
  13.180 +    protected void initialize() {
  13.181 +        super.initialize();
  13.182 +        putValue("noIconInMenu", Boolean.TRUE);
  13.183 +    }
  13.184  
  13.185 -   @Override
  13.186 -   protected void initialize() {
  13.187 -      super.initialize();
  13.188 -      putValue("noIconInMenu", Boolean.TRUE);
  13.189 -   }
  13.190 +    @Override
  13.191 +    public HelpCtx getHelpCtx() {
  13.192 +        return HelpCtx.DEFAULT_HELP;
  13.193 +    }
  13.194  
  13.195 -   @Override
  13.196 -   public HelpCtx getHelpCtx() {
  13.197 -      return HelpCtx.DEFAULT_HELP;
  13.198 -   }
  13.199 +    private String formatDbConnectionName(DatabaseConnection connection) {
  13.200 +        if (connection != null) {
  13.201 +            String url = connection.getDatabaseURL();
  13.202 +            String schema = connection.getUser();
  13.203 +            int pos = url.indexOf("@") + 1;
  13.204 +            if (pos > 0) {
  13.205 +                url = url.substring(pos);
  13.206 +            }
  13.207 +            url = schema + "@" + url;
  13.208 +            String alias = connection.getDisplayName();
  13.209 +            if (alias != null && !alias.equals(connection.getName())) {
  13.210 +                url = alias + " [" + url + "]";
  13.211 +            }
  13.212 +            return url;
  13.213 +        }
  13.214 +        return "Unknown database";
  13.215 +    }
  13.216  
  13.217 -   private String formatDbConnectionName(DatabaseConnection connection) {
  13.218 -      if (connection != null) {
  13.219 -         String url = connection.getDatabaseURL();
  13.220 -         String schema = connection.getUser();
  13.221 -         int pos = url.indexOf("@") + 1;
  13.222 -         if (pos > 0) {
  13.223 -            url = url.substring(pos);
  13.224 -         }
  13.225 -         url = schema + "@" + url;
  13.226 -         String alias = connection.getDisplayName();
  13.227 -         if (alias != null && !alias.equals(connection.getName())) {
  13.228 -            url = alias + " [" + url + "]";
  13.229 -         }
  13.230 -         return url;
  13.231 -      }
  13.232 -      return "Unknown database";
  13.233 -   }
  13.234 +    @Override
  13.235 +    public JMenuItem getPopupPresenter() {
  13.236 +        if (project == null) {
  13.237 +            return super.getPopupPresenter(); //NOPMD
  13.238 +        }
  13.239  
  13.240 -   @Override
  13.241 -   public JMenuItem getPopupPresenter() {
  13.242 -      if (project == null) {
  13.243 -         return super.getPopupPresenter(); //NOPMD
  13.244 -      }
  13.245 +        DatabaseConnectionManager connectionProvider = project.getLookup().lookup(DatabaseConnectionManager.class);
  13.246  
  13.247 -      DatabaseConnectionManager connectionProvider = project.getLookup().lookup(DatabaseConnectionManager.class);
  13.248 +        JMenu menu = new JMenu(getName());
  13.249 +        ActionListener buttonListener = new ButtonListener();
  13.250 +        DatabaseConnection[] databaseConnections = connectionProvider.getDatabaseConnections();
  13.251 +        for (int i = 0; i < databaseConnections.length; i++) {
  13.252 +            JMenuItem item = new JMenuItem(formatDbConnectionName(databaseConnections[i]));
  13.253 +            item.putClientProperty(DATABASE_CONNECTION_KEY, databaseConnections[i]);
  13.254 +            item.addActionListener(buttonListener);
  13.255 +            menu.add(item);
  13.256 +            if (i == 0 && databaseConnections.length > 1) {
  13.257 +                menu.add(new JSeparator());
  13.258 +            }
  13.259 +        }
  13.260 +        return menu;
  13.261 +    }
  13.262  
  13.263 -      JMenu menu = new JMenu(getName());
  13.264 -      ActionListener buttonListener = new ButtonListener();
  13.265 -      DatabaseConnection[] databaseConnections = connectionProvider.getDatabaseConnections();
  13.266 -      for (int i = 0; i < databaseConnections.length; i++) {
  13.267 -         JMenuItem item = new JMenuItem(formatDbConnectionName(databaseConnections[i]));
  13.268 -         item.putClientProperty(DATABASE_CONNECTION_KEY, databaseConnections[i]);
  13.269 -         item.addActionListener(buttonListener);
  13.270 -         menu.add(item);
  13.271 -         if (i == 0 && databaseConnections.length > 1) {
  13.272 -            menu.add(new JSeparator());
  13.273 -         }
  13.274 -      }
  13.275 -      return menu;
  13.276 -   }
  13.277 +    @Override
  13.278 +    protected boolean asynchronous() {
  13.279 +        return false;
  13.280 +    }
  13.281  
  13.282 -   @Override
  13.283 -   protected boolean asynchronous() {
  13.284 -      return false;
  13.285 -   }
  13.286 +    private class DeploymentError implements OutputListener {
  13.287  
  13.288 -   private class DeploymentError implements OutputListener {
  13.289 +        private InputOutput errorTab;
  13.290  
  13.291 -      private InputOutput errorTab;
  13.292 +        public DeploymentError(InputOutput errorTab) {
  13.293 +            this.errorTab = errorTab;
  13.294 +        }
  13.295  
  13.296 -      public DeploymentError(InputOutput errorTab) {
  13.297 -         this.errorTab = errorTab;
  13.298 -      }
  13.299 +        @Override
  13.300 +        public void outputLineSelected(OutputEvent arg0) {
  13.301 +            //do nothing
  13.302 +        }
  13.303  
  13.304 -      @Override
  13.305 -      public void outputLineSelected(OutputEvent arg0) {
  13.306 -         //do nothing
  13.307 -      }
  13.308 +        @Override
  13.309 +        public void outputLineAction(OutputEvent arg0) {
  13.310 +            if (errorTab != null && !errorTab.isClosed()) {
  13.311 +                errorTab.select();
  13.312 +            }
  13.313 +        }
  13.314  
  13.315 -      @Override
  13.316 -      public void outputLineAction(OutputEvent arg0) {
  13.317 -         if (errorTab != null && !errorTab.isClosed()) {
  13.318 -            errorTab.select();
  13.319 -         }
  13.320 -      }
  13.321 +        @Override
  13.322 +        public void outputLineCleared(OutputEvent arg0) {
  13.323 +            //do nothing
  13.324 +        }
  13.325 +    }
  13.326  
  13.327 -      @Override
  13.328 -      public void outputLineCleared(OutputEvent arg0) {
  13.329 -         //do nothing
  13.330 -      }
  13.331 -   }
  13.332 +    private class ExecutionHandler implements Runnable, Cancellable {
  13.333  
  13.334 -   private class ExecutionHandler implements Runnable, Cancellable {
  13.335 +        private DatabaseConnectionManager connectionProvider;
  13.336 +        private DatabaseConnection connection;
  13.337 +        private Node[] activatedNodes;
  13.338 +        private PlsqlFileExecutor executor;
  13.339 +        private boolean cancelDeployment = false;
  13.340  
  13.341 -      private DatabaseConnectionManager connectionProvider;
  13.342 -      private DatabaseConnection connection;
  13.343 -      private Node[] activatedNodes;
  13.344 -      private PlsqlFileExecutor executor;
  13.345 -      private boolean cancelDeployment = false;
  13.346 +        public ExecutionHandler(DatabaseConnectionManager connectionProvider, DatabaseConnection connection, Node[] activatedNodes) {
  13.347 +            this.connectionProvider = connectionProvider;
  13.348 +            this.connection = connection;
  13.349 +            this.activatedNodes = activatedNodes;
  13.350 +        }
  13.351  
  13.352 -      public ExecutionHandler(DatabaseConnectionManager connectionProvider, DatabaseConnection connection, Node[] activatedNodes) {
  13.353 -         this.connectionProvider = connectionProvider;
  13.354 -         this.connection = connection;
  13.355 -         this.activatedNodes = activatedNodes;
  13.356 -      }
  13.357 +        @Override
  13.358 +        public void run() {
  13.359 +            List<String> executionOrder = executorService.getExecutionOrder();
  13.360 +            ProgressHandle handle = ProgressHandleFactory.createHandle("Deploying files to database...", (Cancellable) this);
  13.361 +            cancelDeployment = false;
  13.362 +            try {
  13.363 +                if (connectionProvider != null && connectionProvider.isDefaultDatabase(connection)) { //only use pooled connections for the "main" database.
  13.364 +                    connection = connectionProvider.getPooledDatabaseConnection(false);
  13.365 +                } else {
  13.366 +                    if (!OptionsUtilities.isDeployNoPromptEnabled()) {
  13.367 +                        String msg = "You are now connecting to a secondary database.";
  13.368 +                        String title = "Connecting to a Secondary Database!";
  13.369 +                        if (JOptionPane.showOptionDialog(null,
  13.370 +                                msg,
  13.371 +                                title,
  13.372 +                                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
  13.373 +                                null, null, null) == JOptionPane.NO_OPTION) {
  13.374 +                            cancelDeployment = true;
  13.375 +                        }
  13.376 +                    }
  13.377 +                }
  13.378  
  13.379 -      @Override
  13.380 -      public void run() {
  13.381 -         List<String> executionOrder = executorService.getExecutionOrder();
  13.382 -         ProgressHandle handle = ProgressHandleFactory.createHandle("Deploying files to database...", (Cancellable) this);
  13.383 -         cancelDeployment = false;
  13.384 -         try {
  13.385 -            if (connectionProvider != null && connectionProvider.isDefaultDatabase(connection)) { //only use pooled connections for the "main" database.
  13.386 -               connection = connectionProvider.getPooledDatabaseConnection(false);
  13.387 -            } else {
  13.388 -               if (!OptionsUtilities.isDeployNoPromptEnabled()) {
  13.389 -                  String msg = "You are now connecting to a secondary database.";
  13.390 -                  String title = "Connecting to a Secondary Database!";
  13.391 -                  if (JOptionPane.showOptionDialog(null,
  13.392 -                          msg,
  13.393 -                          title,
  13.394 -                          JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
  13.395 -                          null, null, null) == JOptionPane.NO_OPTION) {
  13.396 -                     cancelDeployment = true;
  13.397 -                  }
  13.398 -               }
  13.399 +                handle.start();
  13.400 +                int count = 0;
  13.401 +                InputOutput io = IOProvider.getDefault().getIO("File deployment summary", false);
  13.402 +                io.getOut().reset();
  13.403 +                if (cancelDeployment) {
  13.404 +                    io.getOut().println("Canceled deploying database files");
  13.405 +                } else {
  13.406 +                    io.getOut().println("Deploying " + activatedNodes.length + " database files");
  13.407 +                    executor = new PlsqlFileExecutor(connectionProvider, connection);
  13.408 +                }
  13.409 +                for (int typeIndex = 0; !cancelDeployment && typeIndex < executionOrder.size(); typeIndex++) {
  13.410 +                    for (int i = 0; !cancelDeployment && i < activatedNodes.length; i++) {
  13.411 +                        DataObject obj = activatedNodes[i].getLookup().lookup(DataObject.class);
  13.412 +                        if (obj != null) {
  13.413 +                            String fileName = obj.getPrimaryFile().getNameExt();
  13.414 +                            if (fileName.toLowerCase(Locale.ENGLISH).endsWith(executionOrder.get(typeIndex))) {
  13.415 +                                //Load the editor cookier and allow parsing
  13.416 +                                EditorCookie ec = obj.getCookie(EditorCookie.class);
  13.417 +                                Document doc = null;
  13.418 +                                try {
  13.419 +                                    doc = ec.openDocument();
  13.420 +                                } catch (UserQuestionException uqe) {
  13.421 +                                    uqe.confirmed();
  13.422 +                                    doc = ec.openDocument();
  13.423 +                                }
  13.424 +                                saveIfModified(obj);
  13.425 +                                PlsqlExecutableBlocksMaker blockMaker = new PlsqlExecutableBlocksMaker(doc);
  13.426 +                                final List exeBlocks = blockMaker.makeExceutableObjects();
  13.427 +                                io.getOut().print("> Deploying " + fileName + "...");
  13.428 +                                handle.setDisplayName("Deploying files to database (" + (++count) + "/" + activatedNodes.length + ")");
  13.429 +                                InputOutput errorTab = executor.executePLSQL(exeBlocks, doc, true, true);
  13.430 +                                if (errorTab == null) {
  13.431 +                                    io.getOut().println("Ok");
  13.432 +                                } else {
  13.433 +                                    io.getOut().println("Failed");
  13.434 +                                    try {
  13.435 +                                        io.getErr().println("!!!Error deploying file " + fileName, new DeploymentError(errorTab));
  13.436 +                                    } catch (IOException ex) {
  13.437 +                                        Exceptions.printStackTrace(ex);
  13.438 +                                    }
  13.439 +                                    cancelDeployment = true;
  13.440 +                                }
  13.441 +                            }
  13.442 +                        }
  13.443 +                    }
  13.444 +                }
  13.445 +                io.getOut().close();
  13.446 +                io.getErr().close();
  13.447 +                io.select();
  13.448 +            } catch (IOException ex) {
  13.449 +                Exceptions.printStackTrace(ex);
  13.450 +            } finally {
  13.451 +                handle.finish();
  13.452 +                if (connectionProvider != null) {
  13.453 +                    connectionProvider.releaseDatabaseConnection(connection);
  13.454 +                }
  13.455              }
  13.456 +        }
  13.457  
  13.458 -            handle.start();
  13.459 -            int count = 0;
  13.460 -            InputOutput io = IOProvider.getDefault().getIO("File deployment summary", false);
  13.461 -            io.getOut().reset();
  13.462 -            if (cancelDeployment) {
  13.463 -               io.getOut().println("Canceled deploying database files");
  13.464 -            } else {
  13.465 -               io.getOut().println("Deploying " + activatedNodes.length + " database files");
  13.466 -               executor = new PlsqlFileExecutor(connectionProvider, connection);
  13.467 +        /**
  13.468 +         * Check whether this data object is modified if so save the object
  13.469 +         * @param dataObj
  13.470 +         */
  13.471 +        private void saveIfModified(DataObject dataObj) {
  13.472 +            if (dataObj instanceof DataObject) {
  13.473 +                try {
  13.474 +                    SaveCookie saveCookie = dataObj.getCookie(SaveCookie.class);
  13.475 +                    if (saveCookie != null) {
  13.476 +                        saveCookie.save();
  13.477 +                    }
  13.478 +                } catch (IOException ex) {
  13.479 +                    Exceptions.printStackTrace(ex);
  13.480 +                }
  13.481              }
  13.482 -            for (int typeIndex = 0; !cancelDeployment && typeIndex < executionOrder.size(); typeIndex++) {
  13.483 -               for (int i = 0; !cancelDeployment && i < activatedNodes.length; i++) {
  13.484 -                  DataObject obj = activatedNodes[i].getLookup().lookup(DataObject.class);
  13.485 -                  if (obj != null) {
  13.486 -                     String fileName = obj.getPrimaryFile().getNameExt();
  13.487 -                     if (fileName.toLowerCase(Locale.ENGLISH).endsWith(executionOrder.get(typeIndex))) {
  13.488 -                        //Load the editor cookier and allow parsing
  13.489 -                        EditorCookie ec = obj.getCookie(EditorCookie.class);
  13.490 -                        Document doc = null;
  13.491 -                        try {
  13.492 -                           doc = ec.openDocument();
  13.493 -                        } catch (UserQuestionException uqe) {
  13.494 -                           uqe.confirmed();
  13.495 -                           doc = ec.openDocument();
  13.496 -                        }
  13.497 -                        saveIfModified(obj);
  13.498 -                        PlsqlExecutableBlocksMaker blockMaker = new PlsqlExecutableBlocksMaker(doc);
  13.499 -                        final List exeBlocks = blockMaker.makeExceutableObjects();
  13.500 -                        io.getOut().print("> Deploying " + fileName + "...");
  13.501 -                        handle.setDisplayName("Deploying files to database (" + (++count) + "/" + activatedNodes.length + ")");
  13.502 -                        InputOutput errorTab = executor.executePLSQL(exeBlocks, doc, true, true);
  13.503 -                        if (errorTab == null) {
  13.504 -                           io.getOut().println("Ok");
  13.505 -                        } else {
  13.506 -                           io.getOut().println("Failed");
  13.507 -                           try {
  13.508 -                              io.getErr().println("!!!Error deploying file " + fileName, new DeploymentError(errorTab));
  13.509 -                           } catch (IOException ex) {
  13.510 -                              Exceptions.printStackTrace(ex);
  13.511 -                           }
  13.512 -                           cancelDeployment = true;
  13.513 -                        }
  13.514 -                     }
  13.515 -                  }
  13.516 -               }
  13.517 +        }
  13.518 +
  13.519 +        @Override
  13.520 +        public boolean cancel() {
  13.521 +            if (executor != null) {
  13.522 +                executor.cancel();
  13.523 +                cancelDeployment = true;
  13.524              }
  13.525 -            io.getOut().close();
  13.526 -            io.getErr().close();
  13.527 -            io.select();
  13.528 -         } catch (IOException ex) {
  13.529 -            Exceptions.printStackTrace(ex);
  13.530 -         } finally {
  13.531 -            handle.finish();
  13.532 -            if (connectionProvider != null) {
  13.533 -               connectionProvider.releaseDatabaseConnection(connection);
  13.534 -            }
  13.535 -         }
  13.536 -      }
  13.537 +            return true;
  13.538 +        }
  13.539 +    }
  13.540  
  13.541 -      /**
  13.542 -       * Check whether this data object is modified if so save the object
  13.543 -       * @param dataObj
  13.544 -       */
  13.545 -      private void saveIfModified(DataObject dataObj) {
  13.546 -         if (dataObj instanceof DataObject) {
  13.547 -            try {
  13.548 -               SaveCookie saveCookie = dataObj.getCookie(SaveCookie.class);
  13.549 -               if (saveCookie != null) {
  13.550 -                  saveCookie.save();
  13.551 -               }
  13.552 -            } catch (IOException ex) {
  13.553 -               Exceptions.printStackTrace(ex);
  13.554 -            }
  13.555 -         }
  13.556 -      }
  13.557 +    private class ButtonListener implements ActionListener {
  13.558  
  13.559 -      @Override
  13.560 -      public boolean cancel() {
  13.561 -         if (executor != null) {
  13.562 -            executor.cancel();
  13.563 -            cancelDeployment = true;
  13.564 -         }
  13.565 -         return true;
  13.566 -      }
  13.567 -   }
  13.568 +        public ButtonListener() {
  13.569 +        }
  13.570  
  13.571 -   private class ButtonListener implements ActionListener {
  13.572 -
  13.573 -      public ButtonListener() {
  13.574 -      }
  13.575 -
  13.576 -      @Override
  13.577 -      public void actionPerformed(ActionEvent e) {
  13.578 -         JMenuItem item = (JMenuItem) e.getSource();
  13.579 -         connection = (DatabaseConnection) item.getClientProperty(DATABASE_CONNECTION_KEY);
  13.580 -         execute();
  13.581 -      }
  13.582 -   }
  13.583 +        @Override
  13.584 +        public void actionPerformed(ActionEvent e) {
  13.585 +            JMenuItem item = (JMenuItem) e.getSource();
  13.586 +            connection = (DatabaseConnection) item.getClientProperty(DATABASE_CONNECTION_KEY);
  13.587 +            execute();
  13.588 +        }
  13.589 +    }
  13.590  }
    14.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlRollbackAction.java	Mon Feb 13 18:37:52 2012 +0100
    14.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlRollbackAction.java	Mon Feb 13 21:41:10 2012 +0100
    14.3 @@ -41,7 +41,6 @@
    14.4   */
    14.5  package org.netbeans.modules.plsql.execution;
    14.6  
    14.7 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
    14.8  import java.awt.Component;
    14.9  import java.awt.event.ActionEvent;
   14.10  import java.awt.image.BufferedImage;
   14.11 @@ -49,15 +48,20 @@
   14.12  import java.util.Arrays;
   14.13  import java.util.List;
   14.14  import java.util.Locale;
   14.15 +
   14.16  import javax.swing.AbstractAction;
   14.17  import javax.swing.Action;
   14.18  import javax.swing.ImageIcon;
   14.19  import javax.swing.JButton;
   14.20  import javax.swing.text.Document;
   14.21 +
   14.22  import org.netbeans.api.db.explorer.DatabaseConnection;
   14.23  import org.netbeans.api.progress.ProgressHandle;
   14.24  import org.netbeans.api.progress.ProgressHandleFactory;
   14.25 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
   14.26  import org.netbeans.modules.plsqlsupport.options.OptionsUtilities;
   14.27 +import org.openide.awt.ActionID;
   14.28 +import org.openide.awt.ActionRegistration;
   14.29  import org.openide.awt.DropDownButtonFactory;
   14.30  import org.openide.cookies.EditorCookie;
   14.31  import org.openide.cookies.SaveCookie;
   14.32 @@ -72,54 +76,56 @@
   14.33  import org.openide.windows.IOProvider;
   14.34  import org.openide.windows.InputOutput;
   14.35  
   14.36 -
   14.37 +@ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlRollbackAction", category = "PLSQL")
   14.38 +@ActionRegistration(displayName = "#CTL_PlsqlRollback")
   14.39  public class PlsqlRollbackAction extends AbstractAction implements ContextAwareAction, Presenter.Toolbar {
   14.40  
   14.41 -   private static final List<String> EXTENSIONS = Arrays.asList(new String[]{"tdb"});
   14.42 -   private DataObject dataObject;
   14.43 -   private DatabaseConnectionManager connectionProvider;
   14.44 -   private JButton button;
   14.45 -   public boolean autoCommit = true;
   14.46 -   private DatabaseConnection connection;
   14.47 +    private static final List<String> EXTENSIONS = Arrays.asList(new String[]{"tdb"});
   14.48 +    private DataObject dataObject;
   14.49 +    private DatabaseConnectionManager connectionProvider;
   14.50 +    private JButton button;
   14.51 +    public boolean autoCommit = true;
   14.52 +    private DatabaseConnection connection;
   14.53  
   14.54 -   public PlsqlRollbackAction() {
   14.55 -      this(Utilities.actionsGlobalContext());
   14.56 +    public PlsqlRollbackAction() {
   14.57 +        this(Utilities.actionsGlobalContext());
   14.58  
   14.59 -   }
   14.60 +    }
   14.61  
   14.62 -   public PlsqlRollbackAction(Lookup context) {
   14.63 -      putValue(SHORT_DESCRIPTION, NbBundle.getMessage(PlsqlRollbackAction.class, "CTL_PlsqlRollback"));
   14.64 -      putValue(SMALL_ICON, new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/plsql/execution/database_rollback.png")));
   14.65 +    public PlsqlRollbackAction(Lookup context) {
   14.66 +        putValue(SHORT_DESCRIPTION, NbBundle.getMessage(PlsqlRollbackAction.class, "CTL_PlsqlRollback"));
   14.67 +        putValue(SMALL_ICON, new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/plsql/execution/database_rollback.png")));
   14.68  
   14.69 -     dataObject = context.lookup(DataObject.class);
   14.70 +        dataObject = context.lookup(DataObject.class);
   14.71  
   14.72 -      //Enable execution for .spec .body files in workspace (copied using 'Copy to Workspace Folder')
   14.73 -      if (dataObject != null && (dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("spec")
   14.74 -              || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("body")
   14.75 -              || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("db"))) {
   14.76 -         if (!dataObject.getPrimaryFile().canWrite()) {
   14.77 +        //Enable execution for .spec .body files in workspace (copied using 'Copy to Workspace Folder')
   14.78 +        if (dataObject != null && (dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("spec")
   14.79 +                || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("body")
   14.80 +                || dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH).equals("db"))) {
   14.81 +            if (!dataObject.getPrimaryFile().canWrite()) {
   14.82 +                dataObject = null;
   14.83 +            }
   14.84 +        } else if (dataObject != null && !EXTENSIONS.contains(dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH))) {
   14.85              dataObject = null;
   14.86 -         }
   14.87 -      } else if (dataObject != null && !EXTENSIONS.contains(dataObject.getPrimaryFile().getExt().toLowerCase(Locale.ENGLISH))) {
   14.88 -         dataObject = null;
   14.89 -      }
   14.90 +        }
   14.91  
   14.92 -      if (dataObject != null && dataObject.getLookup().lookup(EditorCookie.class) == null) {
   14.93 -         dataObject = null;
   14.94 -      }
   14.95 +        if (dataObject != null && dataObject.getLookup().lookup(EditorCookie.class) == null) {
   14.96 +            dataObject = null;
   14.97 +        }
   14.98  
   14.99 -      if (dataObject != null) {
  14.100 -         setEnabled(true);
  14.101 -         autoCommit = OptionsUtilities.isCommandWindowAutoCommitEnabled();
  14.102 -      } else {
  14.103 -         setEnabled(false);
  14.104 -      }
  14.105 -   }
  14.106 +        if (dataObject != null) {
  14.107 +            setEnabled(true);
  14.108 +            autoCommit = OptionsUtilities.isCommandWindowAutoCommitEnabled();
  14.109 +        } else {
  14.110 +            setEnabled(false);
  14.111 +        }
  14.112 +    }
  14.113  
  14.114 -   public Action createContextAwareInstance(Lookup context) {
  14.115 -      return new PlsqlRollbackAction(context);
  14.116 +    @Override
  14.117 +    public Action createContextAwareInstance(Lookup context) {
  14.118 +        return new PlsqlRollbackAction(context);
  14.119  
  14.120 -   }
  14.121 +    }
  14.122  
  14.123      private void prepareConnection() {
  14.124          if (dataObject != null) {
  14.125 @@ -128,14 +134,17 @@
  14.126          connection = dataObject.getLookup().lookup(DatabaseConnection.class);
  14.127      }
  14.128  
  14.129 +    @Override
  14.130      public void actionPerformed(ActionEvent event) {
  14.131  
  14.132          prepareConnection();
  14.133 -        if (connectionProvider == null || connection == null)
  14.134 +        if (connectionProvider == null || connection == null) {
  14.135              return;
  14.136 +        }
  14.137  
  14.138 -        if (!connectionProvider.hasDataToCommit(connection))
  14.139 +        if (!connectionProvider.hasDataToCommit(connection)) {
  14.140              return;
  14.141 +        }
  14.142  
  14.143          EditorCookie edCookie = dataObject.getLookup().lookup(EditorCookie.class);
  14.144          Document document = edCookie.getDocument();
  14.145 @@ -164,6 +173,7 @@
  14.146          }
  14.147      }
  14.148  
  14.149 +    @Override
  14.150      public Component getToolbarPresenter() {
  14.151          if (!isEnabled()) {
  14.152              return null;
  14.153 @@ -177,14 +187,14 @@
  14.154          return button;
  14.155      }
  14.156  
  14.157 -   private void saveIfModified(DataObject dataObj) {
  14.158 -      try {
  14.159 -         SaveCookie saveCookie = dataObj.getCookie(SaveCookie.class);
  14.160 -         if (saveCookie != null) {
  14.161 -            saveCookie.save();
  14.162 -         }
  14.163 -      } catch (IOException ex) {
  14.164 -         Exceptions.printStackTrace(ex);
  14.165 -      }
  14.166 -   }
  14.167 +    private void saveIfModified(DataObject dataObj) {
  14.168 +        try {
  14.169 +            SaveCookie saveCookie = dataObj.getCookie(SaveCookie.class);
  14.170 +            if (saveCookie != null) {
  14.171 +                saveCookie.save();
  14.172 +            }
  14.173 +        } catch (IOException ex) {
  14.174 +            Exceptions.printStackTrace(ex);
  14.175 +        }
  14.176 +    }
  14.177  }
    15.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlSaveCommandAction.java	Mon Feb 13 18:37:52 2012 +0100
    15.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlSaveCommandAction.java	Mon Feb 13 21:41:10 2012 +0100
    15.3 @@ -49,6 +49,8 @@
    15.4  import javax.swing.JFileChooser;
    15.5  import javax.swing.text.BadLocationException;
    15.6  import javax.swing.text.Document;
    15.7 +import org.openide.awt.ActionID;
    15.8 +import org.openide.awt.ActionRegistration;
    15.9  import org.openide.filesystems.FileObject;
   15.10  import org.openide.filesystems.FileUtil;
   15.11  import org.openide.loaders.DataObject;
   15.12 @@ -58,84 +60,90 @@
   15.13  import org.openide.util.NbBundle;
   15.14  import org.openide.util.actions.CookieAction;
   15.15  
   15.16 +@ActionID(id = "org.netbeans.modules.plsql.execution.PlsqlSaveCommandAction", category = "PLSQL")
   15.17 +@ActionRegistration(displayName = "#CTL_PlsqlSaveAsAction")
   15.18  public final class PlsqlSaveCommandAction extends CookieAction {
   15.19  
   15.20 -   protected void performAction(Node[] activatedNodes) {
   15.21 -      try {
   15.22 -         DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
   15.23 -         if (dataObject == null) {
   15.24 -            return;
   15.25 -         }
   15.26 +    @Override
   15.27 +    protected void performAction(Node[] activatedNodes) {
   15.28 +        try {
   15.29 +            DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
   15.30 +            if (dataObject == null) {
   15.31 +                return;
   15.32 +            }
   15.33  
   15.34 -         PlsqlEditorSupport editorSupport = dataObject.getCookie(PlsqlEditorSupport.class);
   15.35 -         if (editorSupport == null) {
   15.36 -            return;
   15.37 -         }
   15.38 +            PlsqlEditorSupport editorSupport = dataObject.getCookie(PlsqlEditorSupport.class);
   15.39 +            if (editorSupport == null) {
   15.40 +                return;
   15.41 +            }
   15.42  
   15.43 -         //Select folder
   15.44 -         JFileChooser fc = new JFileChooser();
   15.45 -         fc.setMultiSelectionEnabled(false);
   15.46 -         fc.setDialogTitle(NbBundle.getMessage(PlsqlSaveCommandAction.class, "CTL_PlsqlSaveAsAction"));
   15.47 -         fc.setApproveButtonText("Save");
   15.48 -         fc.setSelectedFile(new File("Command.sql"));
   15.49 -         File selected = null;
   15.50 -         int returnVal = fc.showOpenDialog(null);
   15.51 +            //Select folder
   15.52 +            JFileChooser fc = new JFileChooser();
   15.53 +            fc.setMultiSelectionEnabled(false);
   15.54 +            fc.setDialogTitle(NbBundle.getMessage(PlsqlSaveCommandAction.class, "CTL_PlsqlSaveAsAction"));
   15.55 +            fc.setApproveButtonText("Save");
   15.56 +            fc.setSelectedFile(new File("Command.sql"));
   15.57 +            File selected = null;
   15.58 +            int returnVal = fc.showOpenDialog(null);
   15.59  
   15.60 -         if (returnVal == JFileChooser.APPROVE_OPTION) {
   15.61 -            selected = fc.getSelectedFile();
   15.62 -         } else {
   15.63 -            return;
   15.64 -         }
   15.65 +            if (returnVal == JFileChooser.APPROVE_OPTION) {
   15.66 +                selected = fc.getSelectedFile();
   15.67 +            } else {
   15.68 +                return;
   15.69 +            }
   15.70  
   15.71 -         //Write the contents to the new file
   15.72 -         FileObject newFile = FileUtil.createData(selected);
   15.73 -         Document doc = editorSupport.getDocument();
   15.74 -         String txt = doc.getText(doc.getStartPosition().getOffset(), doc.getLength());
   15.75 -         OutputStream output = newFile.getOutputStream();
   15.76 -         OutputStreamWriter osWriter = new OutputStreamWriter(output);
   15.77 -         osWriter.write(txt, 0, txt.length());
   15.78 -         osWriter.flush();
   15.79 -         osWriter.close();
   15.80 -         output.close();
   15.81 -      } catch (BadLocationException ex) {
   15.82 -         Exceptions.printStackTrace(ex);
   15.83 -      } catch (IOException ex) {
   15.84 -         Exceptions.printStackTrace(ex);
   15.85 -      }
   15.86 -   }
   15.87 +            //Write the contents to the new file
   15.88 +            FileObject newFile = FileUtil.createData(selected);
   15.89 +            Document doc = editorSupport.getDocument();
   15.90 +            String txt = doc.getText(doc.getStartPosition().getOffset(), doc.getLength());
   15.91 +            OutputStream output = newFile.getOutputStream();
   15.92 +            OutputStreamWriter osWriter = new OutputStreamWriter(output);
   15.93 +            osWriter.write(txt, 0, txt.length());
   15.94 +            osWriter.flush();
   15.95 +            osWriter.close();
   15.96 +            output.close();
   15.97 +        } catch (BadLocationException ex) {
   15.98 +            Exceptions.printStackTrace(ex);
   15.99 +        } catch (IOException ex) {
  15.100 +            Exceptions.printStackTrace(ex);
  15.101 +        }
  15.102 +    }
  15.103  
  15.104 -   protected int mode() {
  15.105 -      return CookieAction.MODE_EXACTLY_ONE;
  15.106 -   }
  15.107 +    @Override
  15.108 +    protected int mode() {
  15.109 +        return CookieAction.MODE_EXACTLY_ONE;
  15.110 +    }
  15.111  
  15.112 -   public String getName() {
  15.113 -      return NbBundle.getMessage(PlsqlSaveCommandAction.class, "CTL_PlsqlSaveAsAction");
  15.114 -   }
  15.115 +    @Override
  15.116 +    public String getName() {
  15.117 +        return NbBundle.getMessage(PlsqlSaveCommandAction.class, "CTL_PlsqlSaveAsAction");
  15.118 +    }
  15.119  
  15.120 -   protected Class[] cookieClasses() {
  15.121 -      return new Class[]{DataObject.class};
  15.122 -   }
  15.123 +    @Override
  15.124 +    protected Class[] cookieClasses() {
  15.125 +        return new Class[]{DataObject.class};
  15.126 +    }
  15.127  
  15.128 -   @Override
  15.129 -   protected String iconResource() {
  15.130 -      return "org/netbeans/modules/plsql/execution/saveAs.png";
  15.131 -   }
  15.132 +    @Override
  15.133 +    protected String iconResource() {
  15.134 +        return "org/netbeans/modules/plsql/execution/saveAs.png";
  15.135 +    }
  15.136  
  15.137 -   public HelpCtx getHelpCtx() {
  15.138 -      return HelpCtx.DEFAULT_HELP;
  15.139 -   }
  15.140 +    @Override
  15.141 +    public HelpCtx getHelpCtx() {
  15.142 +        return HelpCtx.DEFAULT_HELP;
  15.143 +    }
  15.144  
  15.145 -   @Override
  15.146 -   protected boolean asynchronous() {
  15.147 -      return false;
  15.148 -   }
  15.149 +    @Override
  15.150 +    protected boolean asynchronous() {
  15.151 +        return false;
  15.152 +    }
  15.153  
  15.154 -   @Override
  15.155 -   protected boolean enable(Node[] activatedNodes) {
  15.156 -      if (!super.enable(activatedNodes)) {
  15.157 -         return false;
  15.158 -      }
  15.159 -      return activatedNodes[0].getLookup().lookup(DataObject.class).getPrimaryFile().getNameExt().endsWith(".tdb");  //Temp database file
  15.160 -   }
  15.161 +    @Override
  15.162 +    protected boolean enable(Node[] activatedNodes) {
  15.163 +        if (!super.enable(activatedNodes)) {
  15.164 +            return false;
  15.165 +        }
  15.166 +        return activatedNodes[0].getLookup().lookup(DataObject.class).getPrimaryFile().getNameExt().endsWith(".tdb");  //Temp database file
  15.167 +    }
  15.168  }
  15.169 -
    16.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/ViewDataAction.java	Mon Feb 13 18:37:52 2012 +0100
    16.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/ViewDataAction.java	Mon Feb 13 21:41:10 2012 +0100
    16.3 @@ -41,13 +41,16 @@
    16.4   */
    16.5  package org.netbeans.modules.plsql.execution;
    16.6  
    16.7 +
    16.8 +import javax.swing.JEditorPane;
    16.9 +
   16.10 +import org.netbeans.api.db.explorer.DatabaseConnection;
   16.11  import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
   16.12  import org.netbeans.modules.plsqlsupport.db.DatabaseContentManager;
   16.13  import org.netbeans.modules.plsqlsupport.db.ui.SQLCommandWindow;
   16.14 -import javax.swing.JEditorPane;
   16.15 -import org.netbeans.api.db.explorer.DatabaseConnection;
   16.16 -import org.netbeans.api.project.FileOwnerQuery;
   16.17 -import org.netbeans.api.project.Project;
   16.18 +import org.openide.awt.ActionID;
   16.19 +import org.openide.awt.ActionReference;
   16.20 +import org.openide.awt.ActionRegistration;
   16.21  import org.openide.cookies.EditorCookie;
   16.22  import org.openide.loaders.DataObject;
   16.23  import org.openide.nodes.Node;
   16.24 @@ -55,25 +58,32 @@
   16.25  import org.openide.util.NbBundle;
   16.26  import org.openide.util.actions.CookieAction;
   16.27  
   16.28 +@ActionID(id = "org.netbeans.modules.plsql.execution.ViewDataAction", category = "PLSQL")
   16.29 +@ActionRegistration(displayName = "#CTL_ViewDataAction")
   16.30 +@ActionReference(path = "Editors/text/x-plsql/Popup", position = 282)
   16.31  public final class ViewDataAction extends CookieAction {
   16.32  
   16.33      /**
   16.34       * Create a sql execution window for the selected methoad
   16.35       * @param activatedNodes
   16.36       */
   16.37 +    @Override
   16.38      protected void performAction(Node[] activatedNodes) {
   16.39          String selectStatement = "SELECT ${*} FROM " + getSelectedViewOrTable(activatedNodes) + ";\n${cursor}";
   16.40          SQLCommandWindow.createSQLCommandWindow(activatedNodes, selectStatement, null);
   16.41      }
   16.42  
   16.43 +    @Override
   16.44      protected int mode() {
   16.45          return CookieAction.MODE_EXACTLY_ONE;
   16.46      }
   16.47  
   16.48 +    @Override
   16.49      public String getName() {
   16.50          return NbBundle.getMessage(ViewDataAction.class, "CTL_ViewDataAction");
   16.51      }
   16.52  
   16.53 +    @Override
   16.54      protected Class[] cookieClasses() {
   16.55          return new Class[]{DataObject.class, EditorCookie.class};
   16.56      }
   16.57 @@ -85,6 +95,7 @@
   16.58          putValue("noIconInMenu", Boolean.TRUE);
   16.59      }
   16.60  
   16.61 +    @Override
   16.62      public HelpCtx getHelpCtx() {
   16.63          return HelpCtx.DEFAULT_HELP;
   16.64      }
   16.65 @@ -101,7 +112,6 @@
   16.66       */
   16.67      @Override
   16.68      protected boolean enable(Node[] activatedNodes) {
   16.69 -        Project project = null;
   16.70          if (!super.enable(activatedNodes)) {
   16.71              return false;
   16.72          }
    17.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/actions/DeploySelectedCodeAction.java	Mon Feb 13 18:37:52 2012 +0100
    17.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/actions/DeploySelectedCodeAction.java	Mon Feb 13 21:41:10 2012 +0100
    17.3 @@ -41,13 +41,12 @@
    17.4   */
    17.5  package org.netbeans.modules.plsql.execution.actions;
    17.6  
    17.7 -import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
    17.8 -import org.netbeans.modules.plsql.lexer.PlsqlBlockFactory;
    17.9  import java.awt.event.ActionEvent;
   17.10  import java.awt.event.ActionListener;
   17.11  import java.io.File;
   17.12  import java.io.FileWriter;
   17.13  import java.io.IOException;
   17.14 +
   17.15  import javax.swing.JEditorPane;
   17.16  import javax.swing.JMenu;
   17.17  import javax.swing.JMenuItem;
   17.18 @@ -55,10 +54,16 @@
   17.19  import javax.swing.text.BadLocationException;
   17.20  import javax.swing.text.Caret;
   17.21  import javax.swing.text.Document;
   17.22 +
   17.23  import org.netbeans.api.db.explorer.DatabaseConnection;
   17.24  import org.netbeans.api.project.FileOwnerQuery;
   17.25  import org.netbeans.api.project.Project;
   17.26 +import org.netbeans.modules.plsql.lexer.PlsqlBlockFactory;
   17.27 +import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
   17.28  import org.netbeans.spi.project.CacheDirectoryProvider;
   17.29 +import org.openide.awt.ActionID;
   17.30 +import org.openide.awt.ActionReference;
   17.31 +import org.openide.awt.ActionRegistration;
   17.32  import org.openide.cookies.EditorCookie;
   17.33  import org.openide.filesystems.FileUtil;
   17.34  import org.openide.loaders.DataObject;
   17.35 @@ -68,203 +73,208 @@
   17.36  import org.openide.util.NbBundle;
   17.37  import org.openide.util.actions.CookieAction;
   17.38  
   17.39 +@ActionID(id = "org.netbeans.modules.plsql.execution.actions.DeploySelectedCodeAction", category = "PLSQL")
   17.40 +@ActionRegistration(displayName = "#CTL_DeploySelectedCodeAction")
   17.41 +@ActionReference(path = "Editors/text/x-plsql/Popup", name = "org-netbeans-modules-plsql-execution-action-DeploySelectedCodeAction", position = 280)
   17.42  public final class DeploySelectedCodeAction extends CookieAction {
   17.43  
   17.44 -   private Node[] activatedNodes;
   17.45 -   private DataObject dataObject = null;
   17.46 -   private Project project = null;
   17.47 -   private DatabaseConnection connection = null;
   17.48 -   private static final String DATABASE_CONNECTION_KEY = "databaseConnection";
   17.49 -   private final String TEMP_SQL_FILE_PREFIX = "Tempory";
   17.50 +    private Node[] activatedNodes;
   17.51 +    private DataObject dataObject = null;
   17.52 +    private Project project = null;
   17.53 +    private DatabaseConnection connection = null;
   17.54 +    private static final String DATABASE_CONNECTION_KEY = "databaseConnection";
   17.55 +    private final String TEMP_SQL_FILE_PREFIX = "Tempory";
   17.56  
   17.57 -   /**
   17.58 -    * Create a sql execution window for the selected methoad
   17.59 -    * @param activatedNodes
   17.60 -    */
   17.61 -   protected void performAction(Node[] activatedNodes) {
   17.62 -   }
   17.63 +    /**
   17.64 +     * Create a sql execution window for the selected methoad
   17.65 +     * @param activatedNodes
   17.66 +     */
   17.67 +    @Override
   17.68 +    protected void performAction(Node[] activatedNodes) {
   17.69 +    }
   17.70  
   17.71 -   protected int mode() {
   17.72 -      return CookieAction.MODE_EXACTLY_ONE;
   17.73 -   }
   17.74 +    @Override
   17.75 +    protected int mode() {
   17.76 +        return CookieAction.MODE_EXACTLY_ONE;
   17.77 +    }
   17.78  
   17.79 -   public String getName() {
   17.80 -      return NbBundle.getMessage(DeploySelectedCodeAction.class, "CTL_DeploySelectedCodeAction");
   17.81 -   }
   17.82 +    @Override
   17.83 +    public String getName() {
   17.84 +        return NbBundle.getMessage(DeploySelectedCodeAction.class, "CTL_DeploySelectedCodeAction");
   17.85 +    }
   17.86  
   17.87 -   protected Class[] cookieClasses() {
   17.88 -      return new Class[]{DataObject.class, EditorCookie.class};
   17.89 -   }
   17.90 +    @Override
   17.91 +    protected Class[] cookieClasses() {
   17.92 +        return new Class[]{DataObject.class, EditorCookie.class};
   17.93 +    }
   17.94  
   17.95 -   @Override
   17.96 -   protected void initialize() {
   17.97 -      super.initialize();
   17.98 -      // see org.openide.util.actions.SystemAction.iconResource() Javadoc for more details
   17.99 -      putValue("noIconInMenu", Boolean.TRUE);
  17.100 -   }
  17.101 +    @Override
  17.102 +    protected void initialize() {
  17.103 +        super.initialize();
  17.104 +        // see org.openide.util.actions.SystemAction.iconResource() Javadoc for more details
  17.105 +        putValue("noIconInMenu", Boolean.TRUE);
  17.106 +    }
  17.107  
  17.108 -   public HelpCtx getHelpCtx() {
  17.109 -      return HelpCtx.DEFAULT_HELP;
  17.110 -   }
  17.111 +    @Override
  17.112 +    public HelpCtx getHelpCtx() {
  17.113 +        return HelpCtx.DEFAULT_HELP;
  17.114 +    }
  17.115  
  17.116 -   @Override
  17.117 -   protected boolean asynchronous() {
  17.118 -      return false;
  17.119 -   }
  17.120 +    @Override
  17.121 +    protected boolean asynchronous() {
  17.122 +        return false;
  17.123 +    }
  17.124  
  17.125 -   /**
  17.126 -    * Enable this action when right clicked on procedures or functions
  17.127 -    * @param arg0
  17.128 -    * @return
  17.129 -    */
  17.130 -   @Override
  17.131 -   protected boolean enable(Node[] activatedNodes) {
  17.132 -      this.activatedNodes = activatedNodes;
  17.133 -      if (!super.enable(activatedNodes)) {
  17.134 -         return false;
  17.135 -      }
  17.136 +    /**
  17.137 +     * Enable this action when right clicked on procedures or functions
  17.138 +     * @param arg0
  17.139 +     * @return
  17.140 +     */
  17.141 +    @Override
  17.142 +    protected boolean enable(Node[] activatedNodes) {
  17.143 +        this.activatedNodes = activatedNodes;
  17.144 +        if (!super.enable(activatedNodes)) {
  17.145 +            return false;
  17.146 +        }
  17.147  
  17.148 -      EditorCookie editorCookie = activatedNodes[0].getLookup().lookup(EditorCookie.class);
  17.149 -      if (editorCookie == null) {
  17.150 -         return false;
  17.151 -      }
  17.152 +        EditorCookie editorCookie = activatedNodes[0].getLookup().lookup(EditorCookie.class);
  17.153 +        if (editorCookie == null) {
  17.154 +            return false;
  17.155 +        }
  17.156  
  17.157 -      int offset = -1;
  17.158 -      int start = -1;
  17.159 -      int end = -1;
  17.160 +        int offset = -1;
  17.161 +        int start = -1;
  17.162 +        int end = -1;
  17.163  
  17.164 -      JEditorPane[] panes = editorCookie.getOpenedPanes();
  17.165 -      if ((panes != null) && (panes.length != 0)) {
  17.166 -         Caret caret = panes[0].getCaret();
  17.167 -         offset = caret.getDot();
  17.168 -         start = Math.min(caret.getDot(), caret.getMark());
  17.169 -         end = Math.max(caret.getDot(), caret.getMark());
  17.170 -      }
  17.171 +        JEditorPane[] panes = editorCookie.getOpenedPanes();
  17.172 +        if ((panes != null) && (panes.length != 0)) {
  17.173 +            Caret caret = panes[0].getCaret();
  17.174 +            offset = caret.getDot();
  17.175 +            start = Math.min(caret.getDot(), caret.getMark());
  17.176 +            end = Math.max(caret.getDot(), caret.getMark());
  17.177 +        }
  17.178  
  17.179 -      //If we are able to take the selected position get data object and get the block factory
  17.180 -      if (offset != -1) {
  17.181 -         dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
  17.182 -         if (dataObject != null) {
  17.183 -            project = FileOwnerQuery.getOwner(dataObject.getPrimaryFile());
  17.184 -            if (project == null || DatabaseConnectionManager.getInstance(project) == null) {
  17.185 -               return false;
  17.186 +        //If we are able to take the selected position get data object and get the block factory
  17.187 +        if (offset != -1) {
  17.188 +            dataObject = activatedNodes[0].getLookup().lookup(DataObject.class);
  17.189 +            if (dataObject != null) {
  17.190 +                project = FileOwnerQuery.getOwner(dataObject.getPrimaryFile());
  17.191 +                if (project == null || DatabaseConnectionManager.getInstance(project) == null) {
  17.192 +                    return false;
  17.193 +                }
  17.194 +                if ((end - start) > 0) {
  17.195 +                    return true;
  17.196 +                }
  17.197              }
  17.198 -            if ((end - start) > 0) {
  17.199 -               return true;
  17.200 +        }
  17.201 +        return false;
  17.202 +    }
  17.203 +
  17.204 +    @Override
  17.205 +    public JMenuItem getPopupPresenter() {
  17.206 +        if (project == null) {
  17.207 +            return super.getPopupPresenter();
  17.208 +        }
  17.209 +
  17.210 +        DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
  17.211 +
  17.212 +        JMenu menu = new JMenu(getName());
  17.213 +        ActionListener buttonListener = new ButtonListener();
  17.214 +        DatabaseConnection[] databaseConnections = connectionProvider.getDatabaseConnections();
  17.215 +        for (int i = 0; i < databaseConnections.length; i++) {
  17.216 +            JMenuItem item = new JMenuItem(databaseConnections[i].getName());
  17.217 +            item.putClientProperty(DATABASE_CONNECTION_KEY, databaseConnections[i]);
  17.218 +            item.addActionListener(buttonListener);
  17.219 +            menu.add(item);
  17.220 +            if (i == 0 && databaseConnections.length > 1) {
  17.221 +                menu.add(new JSeparator());
  17.222              }
  17.223 -         }
  17.224 -      }
  17.225 -      return false;
  17.226 -   }
  17.227 +        }
  17.228 +        return menu;
  17.229 +    }
  17.230  
  17.231 -   @Override
  17.232 -   public JMenuItem getPopupPresenter() {
  17.233 -      if (project == null) {
  17.234 -         return super.getPopupPresenter();
  17.235 -      }
  17.236 +    private class ButtonListener implements ActionListener {
  17.237  
  17.238 -      DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(dataObject);
  17.239 +        @Override
  17.240 +        public void actionPerformed(ActionEvent e) {
  17.241 +            JMenuItem item = (JMenuItem) e.getSource();
  17.242 +            String output = "";
  17.243 +            connection = (DatabaseConnection) item.getClientProperty(DATABASE_CONNECTION_KEY);
  17.244 +            DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(project);
  17.245 +            EditorCookie editorCookie = activatedNodes[0].getLookup().lookup(EditorCookie.class);
  17.246 +            try {
  17.247 +                output = replaceAliases(getSelection(editorCookie), dataObject.getLookup().lookup(PlsqlBlockFactory.class), '&');
  17.248 +            } catch (BadLocationException ex) {
  17.249 +                Exceptions.printStackTrace(ex);
  17.250 +            }
  17.251 +            File tmpFile = null;
  17.252 +            try {
  17.253 +                tmpFile = File.createTempFile(TEMP_SQL_FILE_PREFIX, ".sql",
  17.254 +                        FileUtil.toFile(project.getLookup().lookup(CacheDirectoryProvider.class).getCacheDirectory()));
  17.255 +                tmpFile.deleteOnExit();
  17.256 +                FileWriter writer = new FileWriter(tmpFile);
  17.257 +                writer.write(output);
  17.258 +                writer.close();
  17.259 +            } catch (IOException ex) {
  17.260 +                Exceptions.printStackTrace(ex);
  17.261 +            }
  17.262 +            File[] files = {tmpFile};
  17.263 +            try {
  17.264 +                DeployFilesAction.execute(connection, connectionProvider, files, true);
  17.265 +            } catch (IOException ex) {
  17.266 +                Exceptions.printStackTrace(ex);
  17.267 +            }
  17.268 +        }
  17.269  
  17.270 -      JMenu menu = new JMenu(getName());
  17.271 -      ActionListener buttonListener = new ButtonListener();
  17.272 -      DatabaseConnection[] databaseConnections = connectionProvider.getDatabaseConnections();
  17.273 -      for (int i = 0; i < databaseConnections.length; i++) {
  17.274 -         JMenuItem item = new JMenuItem(databaseConnections[i].getName());
  17.275 -         item.putClientProperty(DATABASE_CONNECTION_KEY, databaseConnections[i]);
  17.276 -         item.addActionListener(buttonListener);
  17.277 -         menu.add(item);
  17.278 -         if (i == 0 && databaseConnections.length > 1) {
  17.279 -            menu.add(new JSeparator());
  17.280 -         }
  17.281 -      }
  17.282 -      return menu;
  17.283 -   }
  17.284 +        private String getSelection(EditorCookie editorCookie) throws BadLocationException {
  17.285 +            JEditorPane[] panes = editorCookie.getOpenedPanes();
  17.286 +            Document document = editorCookie.getDocument();
  17.287 +            String selection = "";
  17.288 +            if ((panes != null) && (panes.length != 0)) {
  17.289 +                Caret caret = panes[0].getCaret();
  17.290 +                int start = Math.min(caret.getDot(), caret.getMark());
  17.291 +                int end = Math.max(caret.getDot(), caret.getMark());
  17.292 +                selection = document.getText(start, (end - start));
  17.293 +            }
  17.294 +            return selection;
  17.295 +        }
  17.296  
  17.297 -   private class ButtonListener implements ActionListener {
  17.298 +        private String replaceAliases(String plsqlString, PlsqlBlockFactory blockFac, char define) {
  17.299 +            if (plsqlString.indexOf(define) < 0) {
  17.300 +                return plsqlString;
  17.301 +            }
  17.302  
  17.303 -      public ButtonListener() {
  17.304 -      }
  17.305 -
  17.306 -      public void actionPerformed(ActionEvent e) {
  17.307 -         JMenuItem item = (JMenuItem) e.getSource();
  17.308 -         String output = "";
  17.309 -         connection = (DatabaseConnection) item.getClientProperty(DATABASE_CONNECTION_KEY);
  17.310 -         DatabaseConnectionManager connectionProvider = DatabaseConnectionManager.getInstance(project);
  17.311 -         EditorCookie editorCookie = activatedNodes[0].getLookup().lookup(EditorCookie.class);
  17.312 -         try {
  17.313 -            output = replaceAliases(getSelection(editorCookie), dataObject.getLookup().lookup(PlsqlBlockFactory.class), '&');
  17.314 -         } catch (BadLocationException ex) {
  17.315 -            Exceptions.printStackTrace(ex);
  17.316 -         }
  17.317 -         File tmpFile = null;
  17.318 -         try {
  17.319 -            tmpFile = File.createTempFile(TEMP_SQL_FILE_PREFIX, ".sql",
  17.320 -                    FileUtil.toFile(project.getLookup().lookup(CacheDirectoryProvider.class).getCacheDirectory()));
  17.321 -            tmpFile.deleteOnExit();
  17.322 -            FileWriter writer = new FileWriter(tmpFile);
  17.323 -            writer.write(output);
  17.324 -            writer.close();            
  17.325 -         } catch (IOException ex) {
  17.326 -            Exceptions.printStackTrace(ex);
  17.327 -         }
  17.328 -         File[] files = {tmpFile};
  17.329 -         try {
  17.330 -            DeployFilesAction.execute(connection, connectionProvider, files, true);
  17.331 -         } catch (IOException ex) {
  17.332 -            Exceptions.printStackTrace(ex);
  17.333 -         }         
  17.334 -      }
  17.335 -
  17.336 -      private String getSelection(EditorCookie editorCookie) throws BadLocationException {
  17.337 -         JEditorPane[] panes = editorCookie.getOpenedPanes();
  17.338 -         Document document = editorCookie.getDocument();
  17.339 -         String selection = "";
  17.340 -         if ((panes != null) && (panes.length != 0)) {
  17.341 -            Caret caret = panes[0].getCaret();
  17.342 -            int start = Math.min(caret.getDot(), caret.getMark());
  17.343 -            int end = Math.max(caret.getDot(), caret.getMark());
  17.344 -            selection = document.getText(start, (end - start));
  17.345 -         }
  17.346 -         return selection;
  17.347 -      }
  17.348 -
  17.349 -      private String replaceAliases(String plsqlString, PlsqlBlockFactory blockFac, char define) {
  17.350 -      if (plsqlString.indexOf(define) < 0) {
  17.351 -         return plsqlString;
  17.352 -      }
  17.353 -
  17.354 -      StringBuilder newString = new StringBuilder();
  17.355 -      for (int i = 0; i < plsqlString.length(); i++) {
  17.356 -         char c = plsqlString.charAt(i);
  17.357 -         if (c == define) {
  17.358 -            for (int j = i + 1; j < plsqlString.length(); j++) {
  17.359 -               char nextChar = plsqlString.charAt(j);
  17.360 -               if (Character.isJavaIdentifierPart(nextChar) && j == plsqlString.length() - 1) { //we have reached the end of the text
  17.361 -                  nextChar = '.'; //this will make sure that the correct sustitution is made below by emulating an additional character
  17.362 -                  j = j + 1;
  17.363 -               }
  17.364 -               if (!Character.isJavaIdentifierPart(nextChar)) { //potential end of substitutionvariable
  17.365 -                  if (j > i + 1) { //substituion variable found
  17.366 -                     String name = plsqlString.substring(i, j);
  17.367 -                     String value = blockFac.getDefine(name);
  17.368 -                     newString.append(value);
  17.369 -                     if (nextChar == '.') {
  17.370 -                        i = j;
  17.371 -                     } else {
  17.372 -                        i = j - 1;
  17.373 -                     }
  17.374 -                  } else {
  17.375 -                     newString.append(c);
  17.376 -                  }
  17.377 -                  break;
  17.378 -               }
  17.379 +            StringBuilder newString = new StringBuilder();
  17.380 +            for (int i = 0; i < plsqlString.length(); i++) {
  17.381 +                char c = plsqlString.charAt(i);
  17.382 +                if (c == define) {
  17.383 +                    for (int j = i + 1; j < plsqlString.length(); j++) {
  17.384 +                        char nextChar = plsqlString.charAt(j);
  17.385 +                        if (Character.isJavaIdentifierPart(nextChar) && j == plsqlString.length() - 1) { //we have reached the end of the text
  17.386 +                            nextChar = '.'; //this will make sure that the correct sustitution is made below by emulating an additional character
  17.387 +                            j = j + 1;
  17.388 +                        }
  17.389 +                        if (!Character.isJavaIdentifierPart(nextChar)) { //potential end of substitutionvariable
  17.390 +                            if (j > i + 1) { //substituion variable found
  17.391 +                                String name = plsqlString.substring(i, j);
  17.392 +                                String value = blockFac.getDefine(name);
  17.393 +                                newString.append(value);
  17.394 +                                if (nextChar == '.') {
  17.395 +                                    i = j;
  17.396 +                                } else {
  17.397 +                                    i = j - 1;
  17.398 +                                }
  17.399 +                            } else {
  17.400 +                                newString.append(c);
  17.401 +                            }
  17.402 +                            break;
  17.403 +                        }
  17.404 +                    }
  17.405 +                } else {
  17.406 +                    newString.append(c);
  17.407 +                }
  17.408              }
  17.409 -         } else {
  17.410 -            newString.append(c);
  17.411 -         }
  17.412 -      }
  17.413 -      return newString.toString();
  17.414 -   }
  17.415 -   }
  17.416 +            return newString.toString();
  17.417 +        }
  17.418 +    }
  17.419  }
  17.420 -
    18.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/layer.xml	Mon Feb 13 18:37:52 2012 +0100
    18.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/layer.xml	Mon Feb 13 21:41:10 2012 +0100
    18.3 @@ -1,32 +1,6 @@
    18.4  <?xml version="1.0" encoding="UTF-8"?>
    18.5  <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
    18.6  <filesystem>
    18.7 -    <folder name="Actions">
    18.8 -        <folder name="PLSQL">
    18.9 -            <file name="org-netbeans-modules-plsql-execution-ViewDataAction.instance"/>
   18.10 -            <file name="org-netbeans-modules-plsql-execution-DescribeAction.instance"/>
   18.11 -            <file name="org-netbeans-modules-plsql-execution-CreateTestBlockAction.instance"/>
   18.12 -            <file name="org-netbeans-modules-plsql-execution-CopyAsJavaStringAction.instance"/>
   18.13 -            <file name="org-netbeans-modules-plsql-execution-PasteAsSqlCommandAction.instance"/>
   18.14 -            <file name="org-netbeans-modules-plsql-execution-PlsqlExecuteAction.instance">
   18.15 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.plsql.execution.PlsqlExecuteAction"/>
   18.16 -            </file>
   18.17 -            <file name="org-netbeans-modules-plsql-execution-PlsqlCommitAction.instance">
   18.18 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.plsql.execution.PlsqlCommitAction"/>
   18.19 -            </file>
   18.20 -            <file name="org-netbeans-modules-plsql-execution-PlsqlRollbackAction.instance">
   18.21 -                <attr name="instanceClass" stringvalue="org.netbeans.modules.plsql.execution.PlsqlRollbackAction"/>
   18.22 -            </file>
   18.23 -            <file name="org-netbeans-modules-plsql-execution-PlsqlExecutionHistoryAction.instance"/>
   18.24 -            <file name="org-netbeans-modules-plsql-execution-PlsqlExecutionHistoryNextAction.instance"/>
   18.25 -            <file name="org-netbeans-modules-plsql-execution-PlsqlExecutionHistoryPreviousAction.instance"/>
   18.26 -            <file name="org-netbeans-modules-plsql-execution-PlsqlExplainPlanAction.instance"/>
   18.27 -            <file name="org-netbeans-modules-plsql-execution-PlsqlMultipleExecuteAction.instance"/>
   18.28 -            <file name="org-netbeans-modules-plsql-execution-SQLExecutionAction.instance"/>
   18.29 -            <file name="org-netbeans-modules-plsql-execution-actions-DeploySelectedCodeAction.instance"/>
   18.30 -            <file name="org-netbeans-modules-plsql-execution-PlsqlSaveCommandAction.instance"/>
   18.31 -        </folder>
   18.32 -    </folder>
   18.33      <folder name="Databases">
   18.34          <folder name="Nodes">
   18.35              <folder name="Oracle">
   18.36 @@ -44,32 +18,10 @@
   18.37                          <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
   18.38                          <attr name="position" intvalue="225"/>
   18.39                      </file>
   18.40 -                    <file name="org-netbeans-modules-plsql-execution-PlsqlMultipleExecuteAction.shadow">
   18.41 -                        <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-execution-PlsqlMultipleExecuteAction.instance"/>
   18.42 -                        <attr name="position" intvalue="250"/>
   18.43 -                    </file>
   18.44                  </folder>
   18.45              </folder>
   18.46          </folder>
   18.47      </folder>
   18.48 -    <folder name="Shortcuts">
   18.49 -        <file name="AS-B.shadow">
   18.50 -            <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-execution-CreateTestBlockAction.instance"/>
   18.51 -          <!--  <attr name="instanceClass" stringvalue="org.netbeans.modules.plsql.execution.CreateTestBlockAction"/> -->
   18.52 -        </file>
   18.53 -        <file name="AS-N.shadow">
   18.54 -            <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-execution-PlsqlExecutionHistoryNextAction.instance"/>
   18.55 -          <!--  <attr name="instanceClass" stringvalue="org.netbeans.modules.plsql.execution.PlsqlExecutionHistoryNextAction"/> -->
   18.56 -        </file>
   18.57 -        <file name="AS-P.shadow">
   18.58 -            <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-execution-PlsqlExecutionHistoryPreviousAction.instance"/>
   18.59 -         <!--   <attr name="instanceClass" stringvalue="org.netbeans.modules.plsql.execution.PlsqlExecutionHistoryPreviousAction"/> -->
   18.60 -        </file>
   18.61 -      <file name="AS-E.shadow">
   18.62 -          <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-execution-PlsqlExecuteAction.instance"/>
   18.63 -      <!--   <attr name="instanceClass" stringvalue="org.netbeans.modules.plsql.execution.PlsqlExecuteAction"/> -->
   18.64 -      </file>
   18.65 -    </folder>
   18.66      <folder name="Editors">
   18.67          <folder name="text">
   18.68              <folder name="x-plsql">
   18.69 @@ -78,34 +30,12 @@
   18.70                          <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
   18.71                          <attr name="position" intvalue="273"/>
   18.72                      </file>     
   18.73 -                    <file name="org-netbeans-modules-plsql-execution-action-DeploySelectedCodeAction.shadow">
   18.74 -                        <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-execution-actions-DeploySelectedCodeAction.instance"/>
   18.75 -                        <attr name="position" intvalue="280"/>
   18.76 -                    </file>
   18.77 -                    <file name="org-netbeans-modules-plsql-execution-CreateTestBlockAction.shadow">
   18.78 -                        <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-execution-CreateTestBlockAction.instance"/>
   18.79 -                        <attr name="position" intvalue="281"/>
   18.80 -                    </file>
   18.81 -                    <file name="org-netbeans-modules-plsql-execution-ViewDataAction.shadow">
   18.82 -                        <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-execution-ViewDataAction.instance"/>
   18.83 -                        <attr name="position" intvalue="282"/>
   18.84 -                    </file>
   18.85 -                    <file name="org-netbeans-modules-plsql-execution-DescribeAction.shadow">
   18.86 -                        <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-execution-DescribeAction.instance"/>
   18.87 -                        <attr name="position" intvalue="283"/>
   18.88 -                    </file>  
   18.89 +                      
   18.90                      <file name="org-netbeans-modules-plsql-execution-separatorBefore.instance">
   18.91                          <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
   18.92                          <attr name="position" intvalue="284"/>
   18.93 -                    </file>
   18.94 -                    <file name="org-netbeans-modules-plsql-execution-CopyAsJavaStringAction.shadow">
   18.95 -                        <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-execution-CopyAsJavaStringAction.instance"/>
   18.96 -                        <attr name="position" intvalue="285"/>
   18.97                      </file>  
   18.98 -                    <file name="org-netbeans-modules-plsql-execution-PasteAsSqlCommandAction.shadow">
   18.99 -                        <attr name="originalFile" stringvalue="Actions/PLSQL/org-netbeans-modules-plsql-execution-PasteAsSqlCommandAction.instance"/>
  18.100 -                        <attr name="position" intvalue="286"/>
  18.101 -                    </file>  
  18.102 +                      
  18.103                      <file name="org-netbeans-modules-plsql-execution-separatorAfter.instance">
  18.104                          <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
  18.105                          <attr name="position" intvalue="290"/>
    19.1 --- a/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/ui/SQLExecutionAction.java	Mon Feb 13 18:37:52 2012 +0100
    19.2 +++ b/Utilities/Oracle/src/org/netbeans/modules/plsqlsupport/db/ui/SQLExecutionAction.java	Mon Feb 13 21:41:10 2012 +0100
    19.3 @@ -50,10 +50,12 @@
    19.4  
    19.5  public final class SQLExecutionAction extends CookieAction {
    19.6  
    19.7 +   @Override
    19.8      protected void performAction(Node[] activatedNodes) {
    19.9          SQLCommandWindow.createSQLCommandWindow(activatedNodes, null, null);
   19.10      }
   19.11  
   19.12 +   @Override
   19.13      public String getName() {
   19.14          return NbBundle.getMessage(SQLExecutionAction.class, "CTL_SQLExecutionAction");
   19.15      }
   19.16 @@ -65,6 +67,7 @@
   19.17          putValue("noIconInMenu", Boolean.TRUE);
   19.18      }
   19.19  
   19.20 +   @Override
   19.21      public HelpCtx getHelpCtx() {
   19.22          return HelpCtx.DEFAULT_HELP;
   19.23      }
    20.1 --- a/nbproject/genfiles.properties	Mon Feb 13 18:37:52 2012 +0100
    20.2 +++ b/nbproject/genfiles.properties	Mon Feb 13 21:41:10 2012 +0100
    20.3 @@ -6,3 +6,6 @@
    20.4  nbproject/build-impl.xml.data.CRC32=fd65edd3
    20.5  nbproject/build-impl.xml.script.CRC32=0393aba7
    20.6  nbproject/build-impl.xml.stylesheet.CRC32=196c7090
    20.7 +nbproject/platform.xml.data.CRC32=fd65edd3
    20.8 +nbproject/platform.xml.script.CRC32=db9e1f43
    20.9 +nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.47.1