Lines 359-365
Link Here
|
359 |
Logger.getLogger("global").log(Level.INFO, null, e); |
359 |
Logger.getLogger("global").log(Level.INFO, null, e); |
360 |
sql = ""; // NOI18N |
360 |
sql = ""; // NOI18N |
361 |
} |
361 |
} |
362 |
execute(sql, 0, sql.length()); |
362 |
execute(sql, 0, sql.length(), null); |
363 |
} |
363 |
} |
364 |
|
364 |
|
365 |
@Override |
365 |
@Override |
Lines 394-400
Link Here
|
394 |
* @param sql the SQL string to execute. If it contains multiple lines they |
394 |
* @param sql the SQL string to execute. If it contains multiple lines they |
395 |
* have to be delimited by \n. |
395 |
* have to be delimited by \n. |
396 |
*/ |
396 |
*/ |
397 |
void execute(String sql, int startOffset, int endOffset) { |
397 |
void execute(String sql, int startOffset, int endOffset, SQLCloneableEditor editor) { |
398 |
DatabaseConnection conn; |
398 |
DatabaseConnection conn; |
399 |
synchronized (this) { |
399 |
synchronized (this) { |
400 |
conn = this.dbconn; |
400 |
conn = this.dbconn; |
Lines 402-408
Link Here
|
402 |
if (conn == null) { |
402 |
if (conn == null) { |
403 |
return; |
403 |
return; |
404 |
} |
404 |
} |
405 |
SQLExecutor executor = new SQLExecutor(this, conn, sql, startOffset, endOffset); |
405 |
SQLExecutor executor = new SQLExecutor(this, conn, sql, startOffset, endOffset, editor); |
406 |
final RequestProcessor.Task task = rp.create(executor); |
406 |
final RequestProcessor.Task task = rp.create(executor); |
407 |
executor.setTask(task); |
407 |
executor.setTask(task); |
408 |
task.schedule(0); |
408 |
task.schedule(0); |
Lines 426-432
Link Here
|
426 |
sqlPropChangeSupport.firePropertyChange(SQLExecution.PROP_EXECUTING, null, null); |
426 |
sqlPropChangeSupport.firePropertyChange(SQLExecution.PROP_EXECUTING, null, null); |
427 |
} |
427 |
} |
428 |
|
428 |
|
429 |
private void setResultsToEditors(final SQLExecutionResults results) { |
429 |
private void setResultsToEditors(final SQLExecutionResults results, final SQLCloneableEditor editor) { |
430 |
Mutex.EVENT.writeAccess(new Runnable() { |
430 |
Mutex.EVENT.writeAccess(new Runnable() { |
431 |
@Override |
431 |
@Override |
432 |
public void run() { |
432 |
public void run() { |
Lines 442-447
Link Here
|
442 |
} |
442 |
} |
443 |
} |
443 |
} |
444 |
|
444 |
|
|
|
445 |
if (editor != null) { |
446 |
editor.setResults(components); |
447 |
} else { |
445 |
Enumeration editors = allEditors.getComponents(); |
448 |
Enumeration editors = allEditors.getComponents(); |
446 |
while (editors.hasMoreElements()) { |
449 |
while (editors.hasMoreElements()) { |
447 |
CloneableTopComponent editor = (CloneableTopComponent) editors.nextElement(); |
450 |
CloneableTopComponent editor = (CloneableTopComponent) editors.nextElement(); |
Lines 451-456
Link Here
|
451 |
} |
454 |
} |
452 |
} |
455 |
} |
453 |
} |
456 |
} |
|
|
457 |
} |
454 |
}); |
458 |
}); |
455 |
} |
459 |
} |
456 |
|
460 |
|
Lines 459-465
Link Here
|
459 |
} |
463 |
} |
460 |
|
464 |
|
461 |
private void closeExecutionResult() { |
465 |
private void closeExecutionResult() { |
462 |
setResultsToEditors(null); |
466 |
setResultsToEditors(null, null); |
463 |
|
467 |
|
464 |
Runnable run = new Runnable() { |
468 |
Runnable run = new Runnable() { |
465 |
@Override |
469 |
@Override |
Lines 513-519
Link Here
|
513 |
} |
517 |
} |
514 |
|
518 |
|
515 |
private final static class SQLExecutor implements Runnable, Cancellable { |
519 |
private final static class SQLExecutor implements Runnable, Cancellable { |
516 |
|
520 |
private final SQLCloneableEditor editor; |
517 |
private final SQLEditorSupport parent; |
521 |
private final SQLEditorSupport parent; |
518 |
|
522 |
|
519 |
// the connections which the statements are executed against |
523 |
// the connections which the statements are executed against |
Lines 527-533
Link Here
|
527 |
// the task representing the execution of statements |
531 |
// the task representing the execution of statements |
528 |
private RequestProcessor.Task task; |
532 |
private RequestProcessor.Task task; |
529 |
|
533 |
|
530 |
public SQLExecutor(SQLEditorSupport parent, DatabaseConnection dbconn, String sql, int startOffset, int endOffset) { |
534 |
public SQLExecutor(SQLEditorSupport parent, DatabaseConnection dbconn, String sql, int startOffset, int endOffset, SQLCloneableEditor editor) { |
531 |
assert parent != null; |
535 |
assert parent != null; |
532 |
assert dbconn != null; |
536 |
assert dbconn != null; |
533 |
assert sql != null; |
537 |
assert sql != null; |
Lines 537-542
Link Here
|
537 |
this.sql = sql; |
541 |
this.sql = sql; |
538 |
this.startOffset = startOffset; |
542 |
this.startOffset = startOffset; |
539 |
this.endOffset = endOffset; |
543 |
this.endOffset = endOffset; |
|
|
544 |
this.editor = editor; |
540 |
} |
545 |
} |
541 |
|
546 |
|
542 |
public void setTask(RequestProcessor.Task task) { |
547 |
public void setTask(RequestProcessor.Task task) { |
Lines 638-644
Link Here
|
638 |
return; |
643 |
return; |
639 |
} |
644 |
} |
640 |
|
645 |
|
641 |
parent.setResultsToEditors(executionResults); |
646 |
parent.setResultsToEditors(executionResults, editor); |
642 |
|
647 |
|
643 |
if (executionResults.hasExceptions()) { |
648 |
if (executionResults.hasExceptions()) { |
644 |
// there was at least one exception |
649 |
// there was at least one exception |