use of org.jkiss.dbeaver.ui.editors.sql.handlers.SQLNavigatorContext in project dbeaver by serge-rider.
the class ViewSQLDialog method buttonPressed.
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OPEN_ID) {
String title = getTitle();
String text = getText();
UIUtils.asyncExec(() -> {
SQLEditorHandlerOpenEditor.openSQLConsole(UIUtils.getActiveWorkbenchWindow(), new SQLNavigatorContext(contextProvider.getExecutionContext()), title, text);
});
close();
} else if (buttonId == IDialogConstants.PROCEED_ID) {
setReturnCode(IDialogConstants.PROCEED_ID);
close();
} else {
super.buttonPressed(buttonId);
}
}
use of org.jkiss.dbeaver.ui.editors.sql.handlers.SQLNavigatorContext in project dbeaver by dbeaver.
the class SQLEditor method setDataSourceContainer.
@Override
public boolean setDataSourceContainer(@Nullable DBPDataSourceContainer container) {
if (container == dataSourceContainer) {
return true;
}
// Release ds container
releaseContainer();
closeAllJobs();
dataSourceContainer = container;
if (dataSourceContainer != null) {
dataSourceContainer.getPreferenceStore().addPropertyChangeListener(this);
dataSourceContainer.getRegistry().addDataSourceListener(this);
}
IEditorInput input = getEditorInput();
if (input != null) {
DBPDataSourceContainer savedContainer = EditorUtils.getInputDataSource(input);
if (savedContainer != container) {
EditorUtils.setInputDataSource(input, new SQLNavigatorContext(container, getExecutionContext()));
}
IFile file = EditorUtils.getFileFromInput(input);
if (file != null) {
DBNUtils.refreshNavigatorResource(file, container);
} else {
// FIXME: this is a hack. We can't fire event on resource change so editor's state won't be updated in UI.
// FIXME: To update main toolbar and other controls we hade and show this editor
IWorkbenchPage page = getSite().getPage();
for (IEditorReference er : page.getEditorReferences()) {
if (er.getEditor(false) == this) {
page.hideEditor(er);
page.showEditor(er);
break;
}
}
// page.activate(this);
}
}
checkConnected(false, status -> UIUtils.asyncExec(() -> {
if (!status.isOK()) {
DBWorkbench.getPlatformUI().showError("Can't connect to database", "Error connecting to datasource", status);
}
setFocus();
}));
setPartName(getEditorName());
fireDataSourceChange();
if (dataSourceContainer != null) {
dataSourceContainer.acquire(this);
}
if (SQLEditorBase.isWriteEmbeddedBinding()) {
// Patch connection reference
UIUtils.syncExec(this::embedDataSourceAssociation);
}
return true;
}
use of org.jkiss.dbeaver.ui.editors.sql.handlers.SQLNavigatorContext in project dbeaver by dbeaver.
the class SQLEditor method onDataSourceChange.
private void onDataSourceChange() {
if (resultsSash == null || resultsSash.isDisposed()) {
reloadSyntaxRules();
return;
}
DatabaseEditorUtils.setPartBackground(this, resultTabs);
if (getSourceViewerConfiguration() instanceof SQLEditorSourceViewerConfiguration) {
((SQLEditorSourceViewerConfiguration) getSourceViewerConfiguration()).onDataSourceChange();
}
DBCExecutionContext executionContext = getExecutionContext();
if (executionContext != null) {
EditorUtils.setInputDataSource(getEditorInput(), new SQLNavigatorContext(executionContext));
}
refreshActions();
if (syntaxLoaded && lastExecutionContext == executionContext) {
return;
}
if (curResultsContainer != null) {
ResultSetViewer rsv = curResultsContainer.getResultSetController();
if (rsv != null) {
if (executionContext == null) {
rsv.setStatus(ModelMessages.error_not_connected_to_database);
} else {
// $NON-NLS-2$
rsv.setStatus(SQLEditorMessages.editors_sql_staus_connected_to + executionContext.getDataSource().getContainer().getName() + "'");
}
}
}
if (lastExecutionContext == null || executionContext == null || lastExecutionContext.getDataSource() != executionContext.getDataSource()) {
// Update command states
SQLEditorPropertyTester.firePropertyChange(SQLEditorPropertyTester.PROP_CAN_EXECUTE);
SQLEditorPropertyTester.firePropertyChange(SQLEditorPropertyTester.PROP_CAN_EXPLAIN);
reloadSyntaxRules();
}
if (getDataSourceContainer() == null) {
resultsSash.setMaximizedControl(sqlEditorPanel);
} else {
resultsSash.setMaximizedControl(null);
}
lastExecutionContext = executionContext;
syntaxLoaded = true;
loadActivePreferenceSettings();
}
use of org.jkiss.dbeaver.ui.editors.sql.handlers.SQLNavigatorContext in project dbeaver by dbeaver.
the class ViewSQLDialog method buttonPressed.
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OPEN_ID) {
String title = getTitle();
String text = getText();
UIUtils.asyncExec(() -> {
SQLEditorHandlerOpenEditor.openSQLConsole(UIUtils.getActiveWorkbenchWindow(), new SQLNavigatorContext(contextProvider.getExecutionContext()), title, text);
});
close();
} else if (buttonId == IDialogConstants.PROCEED_ID) {
setReturnCode(IDialogConstants.PROCEED_ID);
close();
} else {
super.buttonPressed(buttonId);
}
}
Aggregations