提交 7a12d6d8 编写于 作者: S serge-rider

Smart combo fix.

SQL editor datasource listener register/unregister fix


Former-commit-id: 0d3f8fb4
上级 48545ee0
......@@ -198,6 +198,10 @@ public class CSmartCombo<ITEM_TYPE> extends Composite {
public void setBackground(Color background)
{
if (background == null) {
if (defBackground == null) {
// Not yet initialized
return;
}
background = defBackground;
}
super.setBackground(background);
......
......@@ -214,6 +214,7 @@ public class SQLEditor extends SQLEditorBase implements
onDataSourceChange();
return true;
}
// Release ds container
releaseContainer();
closeAllJobs();
......@@ -221,6 +222,7 @@ public class SQLEditor extends SQLEditorBase implements
dataSourceContainer = container;
if (dataSourceContainer != null) {
dataSourceContainer.getPreferenceStore().addPropertyChangeListener(this);
dataSourceContainer.getRegistry().addDataSourceListener(this);
}
IEditorInput input = getEditorInput();
if (input != null) {
......@@ -311,8 +313,10 @@ public class SQLEditor extends SQLEditorBase implements
private void releaseContainer() {
releaseExecutionContext();
if (dataSourceContainer != null) {
dataSourceContainer.getPreferenceStore().removePropertyChangeListener(this);
dataSourceContainer.getRegistry().removeDataSourceListener(this);
dataSourceContainer.release(this);
dataSourceContainer = null;
}
......@@ -678,11 +682,6 @@ public class SQLEditor extends SQLEditorBase implements
throws PartInitException
{
super.init(site, editorInput);
final DBPDataSourceContainer dsContainer = EditorUtils.getInputDataSource(editorInput);
if (dsContainer != null) {
dsContainer.getRegistry().addDataSourceListener(this);
}
}
@Override
......@@ -1124,11 +1123,6 @@ public class SQLEditor extends SQLEditorBase implements
final IEditorInput editorInput = getEditorInput();
IFile sqlFile = EditorUtils.getFileFromInput(editorInput);
final DBPDataSourceContainer dsContainer = EditorUtils.getInputDataSource(editorInput);
if (dsContainer != null) {
dsContainer.getRegistry().removeDataSourceListener(this);
}
logViewer = null;
outputViewer = null;
......
......@@ -880,7 +880,9 @@ public class DataSourceManagementToolbar implements DBPRegistryListener, DBPEven
if (element == null) {
return DBeaverIcons.getImage(DBIcon.TREE_DATABASE);
}
final DBNDatabaseNode node = DBeaverCore.getInstance().getNavigatorModel().findNode((DBPDataSourceContainer) element);
DBNModel nm = DBeaverCore.getInstance().getNavigatorModel();
nm.ensureProjectLoaded(((DBPDataSourceContainer) element).getRegistry().getProject());
final DBNDatabaseNode node = nm.findNode((DBPDataSourceContainer) element);
return node == null ? null : DBeaverIcons.getImage(node.getNodeIcon());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册