1.1 --- a/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlFileExecutor.java Thu Aug 16 14:44:55 2012 +0530
1.2 +++ b/PLSQL/Execution/src/org/netbeans/modules/plsql/execution/PlsqlFileExecutor.java Mon Aug 20 09:29:11 2012 +0530
1.3 @@ -42,6 +42,7 @@
1.4 package org.netbeans.modules.plsql.execution;
1.5
1.6 import java.awt.Component;
1.7 +import java.io.File;
1.8 import java.io.IOException;
1.9 import java.lang.reflect.InvocationTargetException;
1.10 import java.sql.*;
1.11 @@ -63,12 +64,12 @@
1.12 import org.netbeans.modules.db.sql.execute.SQLExecutionResult;
1.13 import org.netbeans.modules.db.sql.execute.SQLExecutionResults;
1.14 import org.netbeans.modules.db.sql.execute.StatementInfo;
1.15 -import org.netbeans.modules.db.sql.history.SQLHistory;
1.16 import org.netbeans.modules.db.sql.history.SQLHistoryEntry;
1.17 import org.netbeans.modules.db.sql.history.SQLHistoryManager;
1.18 import org.netbeans.modules.plsql.filetype.PlsqlEditor;
1.19 import org.netbeans.modules.plsql.filetype.StatementExecutionHistory;
1.20 import org.netbeans.modules.plsql.lexer.PlsqlTokenId;
1.21 +import org.netbeans.modules.plsql.utilities.PlsqlFileUtil;
1.22 import org.netbeans.modules.plsql.utilities.PlsqlFileValidatorService;
1.23 import org.netbeans.modules.plsqlsupport.db.DatabaseConnectionManager;
1.24 import org.netbeans.modules.plsqlsupport.db.DatabaseContentManager;
1.25 @@ -78,6 +79,7 @@
1.26 import org.openide.filesystems.FileObject;
1.27 import org.openide.filesystems.FileUtil;
1.28 import org.openide.loaders.DataObject;
1.29 +import org.openide.loaders.DataObjectNotFoundException;
1.30 import org.openide.util.Cancellable;
1.31 import org.openide.util.Exceptions;
1.32 import org.openide.util.Lookup;
1.33 @@ -383,7 +385,7 @@
1.34 Object object = doc.getProperty(Document.StreamDescriptionProperty);
1.35 if (object instanceof DataObject) {
1.36 FileObject fo = ((DataObject) object).getPrimaryFile();
1.37 - project = FileOwnerQuery.getOwner(fo);
1.38 + project = FileOwnerQuery.getOwner(fo);
1.39 }
1.40
1.41 //store in object history if this is an SQL Command window (*.tdb)
1.42 @@ -682,6 +684,10 @@
1.43 } else {
1.44 firstWord = plsqlText;
1.45 }
1.46 + if(firstWord.startsWith("@")||firstWord.startsWith("@@") ||firstWord.equalsIgnoreCase("START")){
1.47 + executeSqlPlusStart(plsqlText,firstWord,doc,io);
1.48 + continue;
1.49 + }
1.50 if (firstWord.equalsIgnoreCase("SELECT")) {
1.51 //this should really never happen... Unless there are multiple parts of a file and some sections are select statements
1.52 if (plsqlEditor != null) {
1.53 @@ -1336,6 +1342,41 @@
1.54 return null;
1.55 }
1.56
1.57 + private void executeSqlPlusStart(String plsqlText, String firstWord, Document doc, InputOutput io) {
1.58 + try {
1.59 + String fileName = null;
1.60 + if (firstWord.equalsIgnoreCase("START")) {
1.61 + fileName = plsqlText.substring(5).trim();
1.62 + } else if (firstWord.startsWith("@@")) {
1.63 + Object object = doc.getProperty(Document.StreamDescriptionProperty);
1.64 + if (object instanceof DataObject) {
1.65 + FileObject fo = ((DataObject) object).getPrimaryFile();
1.66 + fileName = fo.getPath().substring(0, fo.getPath().lastIndexOf("/")) + "/" + plsqlText.substring(2);
1.67 + }
1.68 + } else {
1.69 + fileName = plsqlText.substring(1).trim();
1.70 + }
1.71 + File file = new File(fileName);
1.72 + if (file.exists()) {
1.73 +
1.74 + DataObject obj = DataObject.find(FileUtil.toFileObject(file));
1.75 +
1.76 + if (obj != null) {
1.77 + //Load the editor cookier and allow parsing
1.78 + Document document = PlsqlFileUtil.getDocument(obj);
1.79 + PlsqlExecutableBlocksMaker blockMaker = new PlsqlExecutableBlocksMaker(document);
1.80 + final List exeBlocks = blockMaker.makeExceutableObjects();
1.81 + executePLSQL(exeBlocks, document, true, true);
1.82 +
1.83 + }
1.84 + } else {
1.85 + io.getOut().println("!!!Error opening " + fileName);
1.86 + }
1.87 + } catch (DataObjectNotFoundException ex) {
1.88 + Exceptions.printStackTrace(ex);
1.89 + }
1.90 + }
1.91 +
1.92 private final class SQLExecutor implements Runnable, Cancellable {
1.93
1.94 private static final int DEFAULT_PAGE_SIZE = 100;
2.1 --- a/PLSQL/Formatter/src/org/netbeans/modules/plsql/format/Bundle.properties Thu Aug 16 14:44:55 2012 +0530
2.2 +++ b/PLSQL/Formatter/src/org/netbeans/modules/plsql/format/Bundle.properties Mon Aug 20 09:29:11 2012 +0530
2.3 @@ -15,7 +15,7 @@
2.4 expand-child-folds=Expand child folds of this fold
2.5 collapse-child-folds=Collapse child folds of this fold
2.6
2.7 -LIST_SQLPLUS=DEFINE,DEF,DEFI,DEFIN,UNDEFINE,UNDEF,PROMPT,SHOW,EXECUTE,EXEC,SET,\
2.8 +LIST_SQLPLUS=DEFINE,DEF,DEFI,DEFIN,UNDEFINE,UNDEF,PROMPT,SHOW,EXECUTE,EXEC,SET,@,@@,\
2.9
2.10 #Plsql list of reserved and non-reserved keywords
2.11 LIST_PLSQLKeywords=%FOUND,READ,OUT,%ROWTYPE,\
2.12 @@ -61,5 +61,5 @@
2.13 EXCEPTION_INIT,FALSE,FETCH,FOR,FORM,GENERIC,GOTO,IF,INTERFACE,LIMITED,LOOP,NEXTVAL,\
2.14 PRAGMA,RAISE,RECORD,RELEASE,ROWTYPE,SIGNTYPE,SPACE,SQL,STATEMENT,SUBTYPE,TASK,\
2.15 TERMINATE,TRUE,VIEWS,WHILE,ASCENDING,OTHERS,DESCENDING,NOCOPY,NATURAL,\
2.16 - JAVA,SOURCE,NAMED,BULK,COLLECT,$IF,$ELSE,$THEN,$ELSIF,$END,$ERROR,\
2.17 + JAVA,SOURCE,NAMED,BULK,COLLECT,$IF,$ELSE,$THEN,$ELSIF,$END,$ERROR,@,@@,\
2.18
3.1 --- a/PLSQL/Lexer/src/org/netbeans/modules/plsql/lexer/Bundle.properties Thu Aug 16 14:44:55 2012 +0530
3.2 +++ b/PLSQL/Lexer/src/org/netbeans/modules/plsql/lexer/Bundle.properties Mon Aug 20 09:29:11 2012 +0530
3.3 @@ -25,7 +25,7 @@
3.4 invalid-comment-end=Invalid Comment End
3.5 ignore-marker=Ignore Marker
3.6
3.7 -LIST_SQLPLUS=DEFINE,DEF,DEFI,DEFIN,UNDEFINE,UNDEF,PROMPT,SHOW,EXECUTE,EXEC,SET,\
3.8 +LIST_SQLPLUS=DEFINE,DEF,DEFI,DEFIN,UNDEFINE,UNDEF,PROMPT,SHOW,EXECUTE,EXEC,SET,@@,@\
3.9
3.10 #Plsql list of reserved and non-reserved keywords
3.11 LIST_PLSQLKeywords=%FOUND,READ,OUT,%ROWTYPE,\
3.12 @@ -71,4 +71,4 @@
3.13 EXCEPTION_INIT,FALSE,FETCH,FOR,FORM,GENERIC,GOTO,IF,INTERFACE,LIMITED,LOOP,NEXTVAL,\
3.14 PRAGMA,RAISE,RECORD,RELEASE,ROWTYPE,SIGNTYPE,SPACE,SQL,STATEMENT,SUBTYPE,TASK,\
3.15 TERMINATE,TRUE,VIEWS,WHILE,ASCENDING,OTHERS,DESCENDING,NOCOPY,NATURAL,\
3.16 - JAVA,SOURCE,NAMED,BULK,COLLECT,$IF,$ELSE,$THEN,$ELSIF,$END,$ERROR,\
3.17 + JAVA,SOURCE,NAMED,BULK,COLLECT,$IF,$ELSE,$THEN,$ELSIF,$END,$ERROR,@,@@\
4.1 --- a/PLSQL/Lexer/src/org/netbeans/modules/plsql/lexer/PlsqlLexer.java Thu Aug 16 14:44:55 2012 +0530
4.2 +++ b/PLSQL/Lexer/src/org/netbeans/modules/plsql/lexer/PlsqlLexer.java Mon Aug 20 09:29:11 2012 +0530
4.3 @@ -143,7 +143,7 @@
4.4 case '|':
4.5 case ',':
4.6 case ';':
4.7 - case '%':
4.8 + case '%':
4.9 return token(PlsqlTokenId.OPERATOR);
4.10
4.11 case '*':
4.12 @@ -172,6 +172,7 @@
4.13 input.backup(1);
4.14 return token(PlsqlTokenId.OPERATOR);
4.15 }
4.16 + case '@':
4.17 case '$':
4.18 case 'a':
4.19 case 'b':