Skip to content

Commit

Permalink
dbeaver#7822 "Open separate connection" listener in SQL editor
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-rider committed Feb 11, 2020
1 parent 5e3b612 commit f204281
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1985,18 +1985,6 @@ public boolean transformQueryWithParameters(SQLQuery query) {
return createScriptContext().fillQueryParameters(query, false);
}

// Called on OPEN_SEPARATE_CONNECTION optio nchange
public void updateExecutionContextState() {
// Save current datasource (we want to keep it here)
DBPDataSource dataSource = curDataSource;
releaseExecutionContext();
// Restore cur data source (as it is reset in releaseExecutionContext)
curDataSource = dataSource;
if (dataSource != null && SQLEditorUtils.isOpenSeparateConnection(dataSource.getContainer())) {
initSeparateConnection(dataSource, null);
}
}

private boolean checkSession(DBRProgressListener onFinish)
throws DBException
{
Expand Down Expand Up @@ -2383,6 +2371,17 @@ public void preferenceChange(PreferenceChangeEvent event) {
case SQLPreferenceConstants.RESULT_SET_ORIENTATION:
updateResultSetOrientation();
break;
case SQLPreferenceConstants.EDITOR_SEPARATE_CONNECTION: {
// Save current datasource (we want to keep it here)
DBPDataSource dataSource = curDataSource;
releaseExecutionContext();
// Restore cur data source (as it is reset in releaseExecutionContext)
curDataSource = dataSource;
if (dataSource != null && SQLEditorUtils.isOpenSeparateConnection(dataSource.getContainer())) {
initSeparateConnection(dataSource, null);
}
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.menus.UIElement;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.actions.AbstractDataSourceHandler;
import org.jkiss.dbeaver.ui.editors.sql.SQLEditor;
import org.jkiss.dbeaver.ui.editors.sql.SQLPreferenceConstants;
import org.jkiss.dbeaver.ui.editors.sql.internal.SQLEditorMessages;

Expand All @@ -53,11 +51,6 @@ public Object execute(ExecutionEvent event) throws ExecutionException
throw new ExecutionException("Error saving configuration", e);
}

IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof SQLEditor) {
((SQLEditor) editor).updateExecutionContextState();
}

return null;
}

Expand Down

0 comments on commit f204281

Please sign in to comment.